Skip to content

Commit 49595fc

Browse files
committed
track tren-finance DefiLlama#12843
1 parent b557dac commit 49595fc

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

projects/tren-finance/index.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const SSL = ['0xDC4a311f0D852934d9b51C0eAc7c7e13EA1DF11b', '0xDFF4a68044eb68c60354810E9316B2B6DB88B3eb']
2+
3+
async function tvl(api) {
4+
const stables = await api.multiCall({ abi: 'address:stable', calls: SSL })
5+
await api.sumTokens({ tokensAndOwners2: [stables, SSL] })
6+
const hyperPools = ['0xDC4a311f0D852934d9b51C0eAc7c7e13EA1DF11b']
7+
8+
const vaults = await api.multiCall({ abi: 'address:vault', calls: hyperPools })
9+
const vaultBalances = await api.multiCall({ abi: 'erc20:balanceOf', calls: vaults.map((v, i) => ({ target: v, params: hyperPools[i] })) })
10+
const vaultSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: vaults })
11+
const vToken0s = await api.multiCall({ abi: 'address:token0', calls: vaults })
12+
const vToken1s = await api.multiCall({ abi: 'address:token1', calls: vaults })
13+
const vTokenAmounts = await api.multiCall({ abi: 'function getTotalAmounts() view returns (uint256 total0, uint256 total1)', calls: vaults })
14+
15+
vaults.forEach((_vault, i) => {
16+
const token0 = vToken0s[i]
17+
const token1 = vToken1s[i]
18+
const { total0, total1, } = vTokenAmounts[i]
19+
const ratio = vaultBalances[i] / vaultSupplies[i]
20+
api.add(token0, total0 * ratio)
21+
api.add(token1, total1 * ratio)
22+
})
23+
24+
const curvePoolVaults = ['0xDFF4a68044eb68c60354810E9316B2B6DB88B3eb']
25+
const curvePools = await api.multiCall({ abi: 'address:curvePool', calls: curvePoolVaults })
26+
const cBalances = await api.multiCall({ abi: 'erc20:balanceOf', calls: curvePools.map((v, i) => ({ target: v, params: curvePoolVaults[i] })) })
27+
const cSupplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: curvePools })
28+
29+
30+
for (const cPool of curvePools) {
31+
const i = curvePools.indexOf(cPool)
32+
const cTokens = await api.fetchList({ lengthAbi: 'N_COINS', itemAbi: 'coins', target: cPool })
33+
const ratio = cBalances[i] / cSupplies[i]
34+
const bals = await api.multiCall({ abi: 'erc20:balanceOf', calls: cTokens.map((v) => ({ target: v, params: cPool })) })
35+
for (let j=0; j<cTokens.length; j++)
36+
api.add(cTokens[j], bals[j] * ratio)
37+
}
38+
39+
api.removeTokenBalance('0xd4fe6e1e37dfcf35e9eeb54d4cca149d1c10239f')
40+
}
41+
42+
module.exports = {
43+
arbitrum: { tvl },
44+
};

0 commit comments

Comments
 (0)