From 62bf03c58f00fa5d5a24190a8e3741366e9be0ac Mon Sep 17 00:00:00 2001 From: dementedgames Date: Wed, 14 Aug 2024 14:57:33 -0300 Subject: [PATCH] Add dailyFees --- fees/demented-games/index.ts | 45 ++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/fees/demented-games/index.ts b/fees/demented-games/index.ts index a3458ffb03..ad0d412bfc 100644 --- a/fees/demented-games/index.ts +++ b/fees/demented-games/index.ts @@ -1,4 +1,5 @@ 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'; @@ -6,23 +7,37 @@ 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 = {