Skip to content

Commit 26923a9

Browse files
authored
feat: add few new tokens and chain for fetching
1 parent 698b9cc commit 26923a9

File tree

1 file changed

+50
-8
lines changed

1 file changed

+50
-8
lines changed

projects/liveart/index.js

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,29 @@ async function computeMarketCap(api, assets, token) {
44
const priceFeedAbi = 'function latestRoundData() view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)'
55
const assetList = Array.isArray(assets) ? assets : [assets]
66

7-
await Promise.all(assetList.map(async (asset) => {
8-
const { answer: price } = await api.call({ abi: priceFeedAbi, target: asset.priceFeed })
9-
const totalSupply = await api.call({ abi: 'erc20:totalSupply', target: asset.assetId })
10-
const assetDecimals = asset.decimals ?? 18
11-
const priceDecimals = asset.priceDecimals ?? 8
12-
const marketCap = (Number(totalSupply) / 10 ** assetDecimals) * (Number(price) / 10 ** priceDecimals)
7+
const priceCalls = []
8+
const supplyCalls = []
9+
for (const asset of assetList) {
10+
priceCalls.push({ target: asset.priceFeed })
11+
supplyCalls.push({ target: asset.assetId })
12+
}
13+
14+
const prices = await api.multiCall({
15+
abi: priceFeedAbi,
16+
calls: priceCalls,
17+
})
18+
19+
const supplies = await api.multiCall({
20+
abi: 'erc20:totalSupply',
21+
calls: supplyCalls,
22+
})
23+
24+
for (let i = 0; i < assetList.length; i++) {
25+
const { answer: price } = prices[i]
26+
const totalSupply = supplies[i]
27+
const marketCap = (Number(totalSupply) / 1e18) * (Number(price) / 1e8)
1328
sdk.util.sumSingleBalance(api.getBalances(), token, marketCap)
14-
}))
29+
}
1530

1631
return api.getBalances()
1732
}
@@ -24,6 +39,12 @@ module.exports = {
2439
}, {
2540
assetId: '0x25a0e808A7Ed833EA9e9C0B643Eb8B6832af3749', // MURFLO Token
2641
priceFeed: '0x6913A66f54DAe935fD489f34728D20aeEB43A6bB',
42+
}, {
43+
assetId: '0x1bb8da2A094078DdD91A1425afb29B0F5381b990', // BANGIR Token
44+
priceFeed: '0x5FD035D057f27fA6872E0D83F3F9C31665019b7A',
45+
}, {
46+
assetId: '0xf3b70e15743a9d94FE679891a4BfdA61183FD9f5', // KUSPUM Token
47+
priceFeed: '0x488Cd7e0D3CAE1fe5f52895DC0D255e9185F0f39',
2748
}], 'coingecko:usd-coin'),
2849
},
2950
bsc: {
@@ -33,12 +54,33 @@ module.exports = {
3354
}, {
3455
assetId: '0x2024739806E4DEb480481150C45340fB800cB8fe', // MURFLO Token
3556
priceFeed: '0x102a2a121F6d54cCc137978642c6294a73c971d7',
36-
}], 'coingecko:tether')
57+
}, {
58+
assetId: '0xafE03Cf0833401c83C639566448fC4d754a52829', // HARPLA Token
59+
priceFeed: '0xAd49a5C7D8d8241588Da87821a51c83198cC3cd5',
60+
}, {
61+
assetId: '0x1bb8da2A094078DdD91A1425afb29B0F5381b990', // BANGIR Token
62+
priceFeed: '0x8eB682CdC4E7F913414274a54db1ca35bcC0c4bC',
63+
}, {
64+
assetId: '0xf3b70e15743a9d94FE679891a4BfdA61183FD9f5', // KUSPUM Token
65+
priceFeed: '0x8eB682CdC4E7F913414274a54db1ca35bcC0c4bC',
66+
},], 'coingecko:tether')
3767
},
3868
berachain: {
3969
tvl: async (api) => computeMarketCap(api, [{
4070
assetId: '0x25a0e808A7Ed833EA9e9C0B643Eb8B6832af3749', // MURFLO Token
4171
priceFeed: '0x0C0ccB0d5de18E0a208225585f0de4288D8dD2ff',
72+
}, {
73+
assetId: '0x1bb8da2A094078DdD91A1425afb29B0F5381b990', // BANGIR Token
74+
priceFeed: '0x638c575b1a374c84f0D11DaCeD349B2cC78E2f48',
75+
}, {
76+
assetId: '0xf3b70e15743a9d94FE679891a4BfdA61183FD9f5', // KUSPUM Token
77+
priceFeed: '0x638c575b1a374c84f0D11DaCeD349B2cC78E2f48',
4278
}], 'coingecko:tether')
4379
},
80+
linea: {
81+
tvl: async (api) => computeMarketCap(api, [{
82+
assetId: '0xf3b70e15743a9d94FE679891a4BfdA61183FD9f5', // KUSPUM Token
83+
priceFeed: '0xFB64a717319EBbB64f2dfC93d8E4316723eB8417',
84+
}], 'coingecko:usd-coin')
85+
},
4486
};

0 commit comments

Comments
 (0)