Skip to content

Commit

Permalink
fix get daily data
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Aug 19, 2024
1 parent c836a89 commit 9c6e753
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions fees/demented-games/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,34 @@ 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) {
async function fetch({ createBalances, api, fromApi, toApi }: FetchOptions) {
const totalFees = createBalances();
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));
const pumpOrRektFeesFrom = await fromApi.call({
abi: commonAbi[0],
target: PUMP_OR_REKT_ADDRESS,
});
const pumpOrRektFeesTo = await toApi.call({
abi: commonAbi[0],
target: PUMP_OR_REKT_ADDRESS,
});

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

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

const dailypumpOrRektFees = Number(pumpOrRektFeesTo) - Number(pumpOrRektFeesFrom);
const dailyroulletteFees = Number(roulletteFeesTo) - Number(roulletteFeesFrom);
const tottal = Number(pumpOrRektFeesTo) + Number(roulletteFeesTo);
const dailyTotal = dailypumpOrRektFees + dailyroulletteFees;
totalFees.add(ETHER_ADDRESS, tottal);
dailyFees.add(ETHER_ADDRESS, dailyTotal);

return {
totalFees,
Expand Down

0 comments on commit 9c6e753

Please sign in to comment.