Skip to content

Commit 2497aac

Browse files
authored
feat: add LiveArt adapter
1 parent 2dd4d0d commit 2497aac

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

projects/liveart/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const sdk = require('@defillama/sdk')
2+
3+
async function computeMarketCap(api, asset) {
4+
const abi = 'function latestRoundData() view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)'
5+
const { answer: price } = await api.call({ abi, target: asset.priceFeed })
6+
const totalSupply = await api.call({ abi: 'erc20:totalSupply', target: asset.assetId })
7+
const marketCap = (Number(totalSupply) / 10 ** 18) * (Number(price) / 10 ** 8)
8+
sdk.util.sumSingleBalance(api.getBalances(), 'coingecko:usd-coin', marketCap)
9+
return api.getBalances()
10+
}
11+
12+
module.exports = {
13+
base: {
14+
tvl: async (api) => computeMarketCap(api, {
15+
assetId: '0xcCa6848034d327fAc4D60126Ac6ee26708BDfe9d', // KOODOG Token
16+
priceFeed: '0x7B4dc9df689afbf5dDe58d474C229c3d2fb4cd85',
17+
})
18+
},
19+
bsc: {
20+
tvl: async (api) => computeMarketCap(api, {
21+
assetId: '0x8c3b6Bf5078bE53B7462353218853129B642943C', // HOCPOOL Token
22+
priceFeed: '0x8eB682CdC4E7F913414274a54db1ca35bcC0c4bC',
23+
})
24+
},
25+
};

0 commit comments

Comments
 (0)