Skip to content

Commit

Permalink
Merge pull request #1766 from dementedgames/master
Browse files Browse the repository at this point in the history
Add demented-games to fees dashboard
  • Loading branch information
dtmkeng committed Aug 19, 2024
2 parents 0dbc0aa + 62bf03c commit c836a89
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
16 changes: 16 additions & 0 deletions fees/demented-games/abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const commonAbi = [
{
constant: true,
inputs: [],
name: 'accumulatedFees',
outputs: [
{
name: '',
type: 'uint256',
},
],
payable: false,
stateMutability: 'view',
type: 'function',
},
];
59 changes: 59 additions & 0 deletions fees/demented-games/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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 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 = {
version: 2,
adapter: {
[CHAIN.FUSE]: {
fetch,
runAtCurrTime: true,
start: 1720396800,
meta: {
methodology: {
Fees: 'Sum of all fees from each game on the Demented Games platform.',
},
},
},
},
};

export default adapter;

0 comments on commit c836a89

Please sign in to comment.