|
| 1 | +const ADDRESSES = require('../helper/coreAssets.json'); |
| 2 | +const poolABI = { |
| 3 | + type: "function", |
| 4 | + name: "poolTokenAmounts", |
| 5 | + inputs: [{name: "", type: "address", internalType: "address"}], |
| 6 | + outputs: [{name: "", type: "uint256", internalType: "uint256"}], |
| 7 | + stateMutability: "view" |
| 8 | +}; |
| 9 | +const poolAddresses = { |
| 10 | + hela: { |
| 11 | + pool: "0x850034064016D9105D8719b3E06c30789e5E87Fc", |
| 12 | + token: ADDRESSES.null |
| 13 | + }, |
| 14 | + bsc: { |
| 15 | + pool: "0x528d46B5780879E28Cf410C0b86D991A38Fe64Aa", |
| 16 | + tokens: [ADDRESSES.bsc.USDT, ADDRESSES.bsc.USDC] |
| 17 | + }, |
| 18 | + polygon: { |
| 19 | + pool: "0x109d3042a3c682f94107b3818e93b3ade2a47544", |
| 20 | + tokens: [ADDRESSES.polygon.USDC_CIRCLE, ADDRESSES.polygon.USDT] |
| 21 | + }, |
| 22 | + ethereum: { |
| 23 | + pool: "0x109D3042a3c682F94107b3818e93b3aDE2A47544", |
| 24 | + tokens: [ADDRESSES.ethereum.USDC, ADDRESSES.ethereum.USDT] |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +async function tvl(api, chain) { |
| 29 | + if (chain === 'hela') { |
| 30 | + const tvl = await api.call({ abi: poolABI, target: poolAddresses[chain].pool, params: poolAddresses[chain].token, chain}) |
| 31 | + api.add(poolAddresses[chain].token, tvl) |
| 32 | + } |
| 33 | + if (chain === 'bsc' || chain === 'polygon' || chain === 'ethereum') { |
| 34 | + const tvls = await api.multiCall({ abi: poolABI, calls: poolAddresses[chain].tokens.map((t) => ({ target: poolAddresses[chain].pool, params: t })), chain }) |
| 35 | + tvls.forEach((tvl, i) => api.add(poolAddresses[chain].tokens[i], tvl)) |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +module.exports = { |
| 40 | + hela: { |
| 41 | + tvl: async (api) => { |
| 42 | + await tvl(api, 'hela', api.chain) |
| 43 | + } |
| 44 | + }, |
| 45 | + bsc: { |
| 46 | + tvl: async (api) => { |
| 47 | + await tvl(api, 'bsc', api.chain) |
| 48 | + } |
| 49 | + }, |
| 50 | + polygon: { |
| 51 | + tvl: async (api) => { |
| 52 | + await tvl(api, 'polygon', api.chain) |
| 53 | + } |
| 54 | + }, |
| 55 | + ethereum: { |
| 56 | + tvl: async (api) => { |
| 57 | + await tvl(api, 'ethereum', api.chain) |
| 58 | + } |
| 59 | + } |
| 60 | +} |
0 commit comments