Skip to content

Commit

Permalink
Merge pull request #281 from dappradar/OPEN-integration
Browse files Browse the repository at this point in the history
OPEN integration
  • Loading branch information
mantasfam authored Jun 19, 2024
2 parents 4c472f9 + 9473b68 commit 9cf718d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/factory/providers/ethereum/open/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import util from '../../../../util/blockchainUtil';
import formatter from '../../../../util/formatter';
import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl';

const START_BLOCK = 19483155;
const STAKING_CONTRACT = '0x686e8500B6bE8812EB198aAbbbFA14C95c03fC88';
const OPN_TOKEN = '0xc28eb2250d1ae32c7e74cfb6d6b86afc9beb6509';

async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> {
const { block, chain, provider, web3 } = params;
if (block < START_BLOCK) {
return {};
}

const tokenBalances = await util.getTokenBalances(
STAKING_CONTRACT,
[OPN_TOKEN],
block,
chain,
web3,
);

const balances = {};
formatter.sumMultiBalanceOf(balances, tokenBalances, chain, provider);
formatter.convertBalancesToFixed(balances);
return { balances };
}

export { tvl };
29 changes: 29 additions & 0 deletions src/factory/providers/polygon/open/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import util from '../../../../util/blockchainUtil';
import formatter from '../../../../util/formatter';
import { ITvlParams, ITvlReturn } from '../../../../interfaces/ITvl';

const START_BLOCK = 54913762;
const STAKING_CONTRACT = '0x686e8500B6bE8812EB198aAbbbFA14C95c03fC88';
const OPN_TOKEN = '0x7844F79FC841E4F92d974C417031c76F8578c2D5';

async function tvl(params: ITvlParams): Promise<Partial<ITvlReturn>> {
const { block, chain, provider, web3 } = params;
if (block < START_BLOCK) {
return {};
}

const tokenBalances = await util.getTokenBalances(
STAKING_CONTRACT,
[OPN_TOKEN],
block,
chain,
web3,
);

const balances = {};
formatter.sumMultiBalanceOf(balances, tokenBalances, chain, provider);
formatter.convertBalancesToFixed(balances);
return { balances };
}

export { tvl };

0 comments on commit 9cf718d

Please sign in to comment.