Skip to content

Commit 0ff68fb

Browse files
committed
track multichainz DefiLlama#13432
1 parent f68b72c commit 0ff68fb

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

projects/multichainz/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const abi = {
2+
"getTokensForBorrowingArray": "function getTokensForBorrowingArray() view returns ((address tokenAddress, uint256 LTV, uint256 stableRate, string name, uint256 liquidationThreshold)[])",
3+
"getTokensForLendingArray": "function getTokensForLendingArray() view returns ((address tokenAddress, uint256 LTV, uint256 stableRate, string name, uint256 liquidationThreshold)[])",
4+
"getTotalTokenBorrowed": "function getTotalTokenBorrowed(address tokenAddress) view returns (uint256)",
5+
}
6+
7+
const config = {
8+
plume: { pool: '0x8bd47bC14f38840820d1DC7eD5Eb57b85d2c7808', },
9+
}
10+
11+
Object.keys(config).forEach(chain => {
12+
const { pool } = config[chain]
13+
module.exports[chain] = {
14+
tvl: async (api) => {
15+
const tokens = await getTokens(api)
16+
return api.sumTokens({ owner: pool, tokens })
17+
},
18+
borrowed: async (api) => {
19+
const tokens = await getTokens(api)
20+
const bals = await api.multiCall({ abi: abi.getTotalTokenBorrowed, calls: tokens, target: pool })
21+
api.add(tokens, bals)
22+
}
23+
}
24+
25+
async function getTokens(api) {
26+
const tokenBorrowed = await api.call({ abi: abi.getTokensForBorrowingArray, target: pool })
27+
const tokenLending = await api.call({ abi: abi.getTokensForBorrowingArray, target: pool })
28+
return [...new Set(tokenLending.concat(tokenBorrowed).map(log => log.tokenAddress))]
29+
}
30+
})

0 commit comments

Comments
 (0)