Skip to content

Commit a2ae6f1

Browse files
Add Superform TVL calculation (DefiLlama#9711)
* chore: add superform tvl * refactor to use multicall --------- Co-authored-by: sujithsomraaj <[email protected]>
1 parent 6732cb6 commit a2ae6f1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

projects/superform/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const superform_chains = ["ethereum", "polygon", "bsc", "avax", "arbitrum", "optimism", "base"];
2+
const factory_contract = "0xD85ec15A9F814D6173bF1a89273bFB3964aAdaEC";
3+
4+
async function tvl(api) {
5+
const forms = await api.fetchList({ lengthAbi: 'getSuperformCount', itemAbi: "function superforms(uint256) external view returns(uint256)", target: factory_contract })
6+
const getSuperformRes = await api.multiCall({ abi: "function getSuperform(uint256) external view returns(address, uint32, uint64)", calls: forms, target: factory_contract })
7+
const super4626 = getSuperformRes.map(v => v[0])
8+
const vaults = await api.multiCall({ abi: 'address:vault', calls: super4626 })
9+
const assets = await api.multiCall({ abi: 'address:asset', calls: super4626 })
10+
const vBals = await api.multiCall({ abi: "erc20:balanceOf", calls: vaults.map((v, i) => ({ target: v, params: super4626[i] })) })
11+
const bals = await api.multiCall({ abi: "function previewRedeemFrom(uint256) external view returns(uint256)", calls: super4626.map((v, i) => ({ target: v, params: vBals[i] })), permitFailure: true })
12+
bals.forEach((bal, i) => {
13+
if (bal) api.add(assets[i], bal)
14+
})
15+
}
16+
17+
module.exports = {
18+
methodology: "counts the TVL of each superform across all the supported networks",
19+
};
20+
21+
superform_chains.forEach(chain => module.exports[chain] = { tvl })

0 commit comments

Comments
 (0)