|
| 1 | +const { sumTokens2 } = require("../helper/unwrapLPs"); |
| 2 | +const { get } = require('../helper/http'); |
| 3 | +const { log } = require("@defillama/sdk"); |
| 4 | + |
| 5 | +const HEDERA_MIRROR_NODE_URL = 'https://mainnet-public.mirrornode.hedera.com' |
| 6 | + |
| 7 | +const CONFIG = { |
| 8 | + ethereum: "0x367e59b559283C8506207d75B0c5D8C66c4Cd4B7", |
| 9 | + polygon: "0xf4C0153A8bdB3dfe8D135cE3bE0D45e14e5Ce53D", |
| 10 | + bsc: "0x9021926Be887355B76e60F4148eBB6b3f1fFAfCc", |
| 11 | + avax: "0xd8df34A071179fe8CEF910Ae0B43cdE49D611B49", |
| 12 | + optimism: "0x6Da4e99b62B8D910e1688E34121CD8D50B7c0C3e", |
| 13 | + arbitrum: "0x984BB007b41a865bd8a9Db9CA919000FBab5893a", |
| 14 | + fantom: "0x475B21ADe54B9494D8201e0330cA7994081f4E0F", |
| 15 | + moonbeam: "0x617D29b4bae43b3AA3D63b7f61177600036d2F6b", |
| 16 | + base: "0x0f3414b61B902513e04E76cA4d1a7B003D09F54b", |
| 17 | + cronos: "0x36DAaFd7C305677905A643CF1a0c74a281c6413c", |
| 18 | + aurora: "0x3b32202A662353DCb4DbB983aDBdF2AB49181506", |
| 19 | + hedera: '0.0.540219', |
| 20 | +} |
| 21 | + |
| 22 | +const hederaTVL = async (address) => { |
| 23 | + const totalBalances = {} |
| 24 | + try { |
| 25 | + const { balance } = await get(`${HEDERA_MIRROR_NODE_URL}/api/v1/accounts/${address}?limit=100&order=asc&transactiontype=cryptotransfer&transactions=true`) |
| 26 | + balance?.tokens.forEach(token => { |
| 27 | + // Note: We are filtering this token because its an old version of DOVE |
| 28 | + if(token.token_id === '0.0.624505') return |
| 29 | + totalBalances[`hedera:${token.token_id}`] = String(token.balance) |
| 30 | + }) |
| 31 | + } catch (error) { |
| 32 | + log(error) |
| 33 | + } |
| 34 | + return totalBalances |
| 35 | +} |
| 36 | + |
| 37 | +const evmTVL = async (api, token, useCoValent = true) => { |
| 38 | + const totalBalances = await sumTokens2({ api, owner: token, fetchCoValentTokens: useCoValent }) |
| 39 | + return totalBalances |
| 40 | +} |
| 41 | + |
| 42 | +Object.entries(CONFIG).forEach(([chain, address]) => { |
| 43 | + module.exports[chain] = { |
| 44 | + tvl: async (api) => { |
| 45 | + if (chain === 'hedera') { |
| 46 | + return hederaTVL(address) |
| 47 | + } |
| 48 | + if (chain == 'cronos' || chain == 'aurora') return evmTVL(api, address, false) |
| 49 | + return evmTVL(api, address); |
| 50 | + } |
| 51 | + }; |
| 52 | +}); |
0 commit comments