Skip to content

Commit 698b9cc

Browse files
authored
feat: add MURFLO Token value fetching
1 parent 7456468 commit 698b9cc

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

projects/liveart/index.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,44 @@
11
const sdk = require('@defillama/sdk')
22

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)
3+
async function computeMarketCap(api, assets, token) {
4+
const priceFeedAbi = 'function latestRoundData() view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)'
5+
const assetList = Array.isArray(assets) ? assets : [assets]
6+
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)
13+
sdk.util.sumSingleBalance(api.getBalances(), token, marketCap)
14+
}))
15+
916
return api.getBalances()
1017
}
1118

1219
module.exports = {
1320
base: {
14-
tvl: async (api) => computeMarketCap(api, {
21+
tvl: async (api) => computeMarketCap(api, [{
1522
assetId: '0xcCa6848034d327fAc4D60126Ac6ee26708BDfe9d', // KOODOG Token
1623
priceFeed: '0x7B4dc9df689afbf5dDe58d474C229c3d2fb4cd85',
17-
})
24+
}, {
25+
assetId: '0x25a0e808A7Ed833EA9e9C0B643Eb8B6832af3749', // MURFLO Token
26+
priceFeed: '0x6913A66f54DAe935fD489f34728D20aeEB43A6bB',
27+
}], 'coingecko:usd-coin'),
1828
},
1929
bsc: {
20-
tvl: async (api) => computeMarketCap(api, {
30+
tvl: async (api) => computeMarketCap(api, [{
2131
assetId: '0x8c3b6Bf5078bE53B7462353218853129B642943C', // HOCPOOL Token
2232
priceFeed: '0x8eB682CdC4E7F913414274a54db1ca35bcC0c4bC',
23-
})
33+
}, {
34+
assetId: '0x2024739806E4DEb480481150C45340fB800cB8fe', // MURFLO Token
35+
priceFeed: '0x102a2a121F6d54cCc137978642c6294a73c971d7',
36+
}], 'coingecko:tether')
37+
},
38+
berachain: {
39+
tvl: async (api) => computeMarketCap(api, [{
40+
assetId: '0x25a0e808A7Ed833EA9e9C0B643Eb8B6832af3749', // MURFLO Token
41+
priceFeed: '0x0C0ccB0d5de18E0a208225585f0de4288D8dD2ff',
42+
}], 'coingecko:tether')
2443
},
2544
};

0 commit comments

Comments
 (0)