Skip to content

Commit 9449da9

Browse files
g1nt0kiCapChuyan
andauthored
Update zoo finance and refactor code structure (DefiLlama#13459)
Co-authored-by: chuyan <[email protected]>
1 parent ca074bb commit 9449da9

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

projects/treasury/zoofi-io.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const { treasuryExports } = require("../helper/treasury");
1+
const zooProtocol = '0xc0fA386aE92f18A783476d09121291A1972C30Dc'
2+
const treasury = "0x54C56e149F6D655Aa784678057D1f96612b0Cf1a"
23

3-
const treasury = "0x54C56e149F6D655Aa784678057D1f96612b0Cf1a";
4+
async function tvl(api) {
5+
const tokens = await api.call({ abi: 'address[]:assetTokens', target: zooProtocol })
6+
return api.sumTokens({ tokens, owner: treasury })
7+
}
48

5-
module.exports = treasuryExports({
9+
module.exports = {
610
berachain: {
7-
tokens: [
8-
"0xF961a8f6d8c69E7321e78d254ecAfBcc3A637621"
9-
],
10-
owners: [treasury],
11-
ownTokens: [],
12-
},
13-
})
11+
tvl,
12+
}
13+
}

projects/zoofi-io/index.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
1+
12
async function tvl(api) {
23
const zooProtocol = '0xc0fA386aE92f18A783476d09121291A1972C30Dc'
34
const assets = await api.call({ abi: 'address[]:assetTokens', target: zooProtocol })
5+
6+
// Normally, assets are routed to other vaults like Infrared, Yeet, etc
47
const vaults = (await api.multiCall({ abi: 'function getVaultAddresses(address) view returns (address[])', calls: assets, target: zooProtocol })).flat()
5-
const bals = await api.multiCall({ abi: 'uint256:assetBalance', calls: vaults })
6-
const tokens = await api.multiCall({ abi: 'address:assetToken', calls: vaults })
7-
api.add(tokens, bals)
8+
const assetBals = await api.multiCall({ abi: 'uint256:assetBalance', calls: vaults })
9+
api.add(assets, assetBals)
10+
11+
// On vault close, assets are withdrawn from underlying vaults and held by the vault itself
12+
const tokensAndOwners = vaults.map((vault, i) => [assets[i], vault])
13+
14+
15+
// On every epoch close, a portion of assets are withdrawn from underlying vaults, and deposited to the redeem pool contract
16+
const epochInfoAbi = 'function epochInfoById(uint256 epochId) public view returns (uint256 epochId, uint256 startTime, uint256 duration, address redeemPool, address stakingBribesPool, address adhocBribesPool)'
17+
const epochInfos = await api.fetchList({ lengthAbi: 'epochIdCount', itemAbi: epochInfoAbi, targets: vaults, startFromOne: true, groupedByInput: true })
18+
19+
epochInfos.forEach((infos, i) => {
20+
const asset = assets[i]
21+
infos.forEach(({ redeemPool }) => {
22+
tokensAndOwners.push([asset, redeemPool])
23+
})
24+
})
25+
26+
return api.sumTokens({ tokensAndOwners })
827
}
928

1029
module.exports = {

0 commit comments

Comments
 (0)