Skip to content

Commit bece63b

Browse files
authored
Merge pull request #1 from LimeChain/feat/hashport-project
feat: hashport project is added
2 parents 4383499 + 140bc3f commit bece63b

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

projects/hashport/index.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 hederaTokens = {}
23+
24+
const hederaTVL = async (address, paginationPath = '') => {
25+
try {
26+
let path = `/api/v1/accounts/${address}/tokens?limit=100&order=desc`
27+
if (paginationPath) {
28+
path = paginationPath
29+
}
30+
const { tokens, links } = await get(`${HEDERA_MIRROR_NODE_URL}${path}`)
31+
tokens.forEach(token => {
32+
hederaTokens[`hedera:${token.token_id}`] = String(token.balance)
33+
})
34+
if (links?.next) {
35+
return hederaTVL(address, links.next)
36+
}
37+
} catch (error) {
38+
log(error)
39+
}
40+
return hederaTokens
41+
}
42+
43+
const evmTVL = async (api, token, useCoValent = true) => {
44+
const totalBalances = await sumTokens2({ api, owner: token, fetchCoValentTokens: useCoValent })
45+
return totalBalances
46+
}
47+
48+
Object.entries(CONFIG).forEach(([chain, address]) => {
49+
module.exports[chain] = {
50+
tvl: async (api) => {
51+
if (chain === 'hedera') {
52+
return hederaTVL(address)
53+
}
54+
if (chain == 'cronos' || chain == 'aurora') return evmTVL(api, address, false)
55+
return evmTVL(api, address);
56+
}
57+
};
58+
});

projects/helper/token.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const ankrChainMapping = {
7070
rollux: 'rollux',
7171
scroll: 'scroll',
7272
syscoin: 'syscoin',
73+
moonbeam: 'moonbeam'
7374
}
7475

7576
async function ankrGetTokens(address, { onlyWhitelisted = true, skipCacheRead = false } = {}) {

0 commit comments

Comments
 (0)