Skip to content

Commit 82637bb

Browse files
g1nt0kibshyong
andauthored
* add Anzen TVL * Refactor TVL and add borrowed function --------- Co-authored-by: Ben Shyong <[email protected]>
1 parent 0acd4e4 commit 82637bb

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

projects/anzen/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const tokens = [
2+
'0xEf5AAcB3c38a5Be7785a361008e27fb0328a62B5', // secured private credit token
3+
// '0xE16f2eC94E8a0819EB93022c45E05D582f4E5c15', // private credit token
4+
];
5+
6+
async function tvl(_, _1, _2, { api }) {
7+
const uTokens = await api.multiCall({ abi: 'address:usdc', calls: tokens })
8+
return api.sumTokens({ tokensAndOwners2: [uTokens, tokens,] })
9+
}
10+
async function borrowed(_, _1, _2, { api }) {
11+
const uTokens = await api.multiCall({ abi: 'address:usdc', calls: tokens })
12+
const bals = (await api.multiCall({ abi: 'uint256:totalPooledUSD', calls: tokens })).map(i => i / 1e12)
13+
const inContracts = (await api.multiCall({ abi: 'address:reserveUSD', calls: tokens })).map(i => i * -1)
14+
api.add(uTokens, bals)
15+
api.add(uTokens, inContracts)
16+
return api.getBalances()
17+
}
18+
19+
module.exports = {
20+
methodology: "Sums the locked collateral amounts and depositor token balances.",
21+
ethereum: {
22+
tvl, borrowed,
23+
},
24+
};

0 commit comments

Comments
 (0)