Skip to content

Commit

Permalink
Add dailyFees
Browse files Browse the repository at this point in the history
  • Loading branch information
dementedgames committed Aug 14, 2024
1 parent 9676ad9 commit 62bf03c
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions fees/demented-games/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
import { ETHER_ADDRESS } from '@defillama/sdk/build/general';
import BigNumber from 'bignumber.js';
import { Adapter, FetchOptions } from '../../adapters/types';
import { CHAIN } from '../../helpers/chains';
import { commonAbi } from './abi';

const ROULETTE_ADDRESS = '0x94ba26ee118ef6c407c75dbb23385b1ad71a4547';
const PUMP_OR_REKT_ADDRESS = '0xcbc003cb76c5d218cba2dfb3a2b2f101950ed7e7';

const startDate = new Date('2024-07-26T00:00:00.000Z').getTime();
const currentDate = new Date().getTime();
const differenceInTime = currentDate - startDate;
const totalDays = Math.floor(differenceInTime / (1000 * 60 * 60 * 24));

async function fetch({ createBalances, api }: FetchOptions) {
const totalFees = createBalances();

const pumpOrRektFees = await api.call({
abi: commonAbi[0],
target: ROULETTE_ADDRESS,
});

const roulletteFees = await api.call({
abi: commonAbi[0],
target: PUMP_OR_REKT_ADDRESS,
});

totalFees.add(ETHER_ADDRESS, pumpOrRektFees);
totalFees.add(ETHER_ADDRESS, roulletteFees);

return { totalFees };
const dailyFees = createBalances();

const pumpOrRektFees = BigNumber(
await api.call({
abi: commonAbi[0],
target: ROULETTE_ADDRESS,
})
);
const roulletteFees = BigNumber(
await api.call({
abi: commonAbi[0],
target: PUMP_OR_REKT_ADDRESS,
})
);

const total = pumpOrRektFees.plus(roulletteFees);

totalFees.add(ETHER_ADDRESS, total);
dailyFees.add(ETHER_ADDRESS, total.dividedToIntegerBy(totalDays));

return {
totalFees,
dailyFees,
};
}

const adapter: Adapter = {
Expand Down

0 comments on commit 62bf03c

Please sign in to comment.