Skip to content

Commit 58377a7

Browse files
committed
update apexdefi
1 parent 427f390 commit 58377a7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

projects/apexdefi/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const { staking } = require('../helper/staking')
22
const ADDRESSES = require('../helper/coreAssets.json');
33

44
const config = {
5-
avax: { factory: "0x3D193de151F8e4e3cE1C4CB2977F806663106A87", },
6-
base: { factory: "0x4ccf7aa5736c5e8b6da5234d1014b5019f50cb56", },
5+
avax: { factory: "0x3D193de151F8e4e3cE1C4CB2977F806663106A87", wrapperFactory: '0x39aB4aabAd7656f94E32ebD90547C3c4a183f4B4' },
6+
base: { factory: "0x4ccf7aa5736c5e8b6da5234d1014b5019f50cb56", wrapperFactory: '0xc9fbf1e865eeababe92d47ddb11d580f37ce4e00' },
77
ethereum: { factory: "0x820c889D5749847217599B43ab86FcC91781019f", },
88
}
99

@@ -15,11 +15,20 @@ async function _staking(api) {
1515
}
1616

1717
module.exports.methodology = "The Apex DeFi factory contract address is used to obtain the balances held in each token contract as liquidity and the staking contract is used to get the staked APEX balance.";
18+
module.exports.misrepresentedTokens = true
1819

1920
Object.keys(config).forEach(chain => {
20-
const { factory, } = config[chain]
21+
const { factory,wrapperFactory, } = config[chain]
2122
module.exports[chain] = {
2223
tvl: async (api) => {
24+
// count the value of erc20 wrapped and deposited in the pools
25+
if (wrapperFactory) {
26+
const wrapperPools = await api.fetchList({ lengthAbi: 'allWrappersLength', itemAbi: 'allWrappers', target: wrapperFactory })
27+
const erc314Tokens = await api.multiCall({ abi: 'address:wrappedToken', calls: wrapperPools})
28+
// this is a hack, summing value of gas tokens in the contract and assuming it matches the value of wrapped tokens in the pools
29+
await api.sumTokens({ owners:erc314Tokens, tokens: [ADDRESSES.null] })
30+
}
31+
2332
const tokens = await api.call({ abi: 'address[]:getAllTokens', target: factory })
2433
return api.sumTokens({ owners: tokens, tokens: [ADDRESSES.null] })
2534
}

0 commit comments

Comments
 (0)