Skip to content

Commit 46d7bea

Browse files
jpgpng342g1nt0ki
andauthored
Add: Avalon CeDeFi of Avalon Finance (DefiLlama#11301)
Co-authored-by: g1nt0ki <[email protected]>
1 parent 3db7770 commit 46d7bea

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const ADDRESSES = require('../helper/coreAssets.json')
2+
const sdk = require('@defillama/sdk');
3+
const { sumTokensExport } = require('../helper/sumTokens');
4+
5+
const abi = {
6+
"getPoolManagerReserveInformation": "function getPoolManagerReserveInformation() view returns (tuple(uint256 userAmount, uint256 collateral, uint256 debt, uint256 claimableUSDT, uint256 claimableBTC) poolManagerReserveInfor)"
7+
}
8+
9+
const config = {
10+
ethereum: { poolAddress: "0x02feDCff97942fe28e8936Cdc3D7A480fdD248f0", lfbtcAddress: "0x3119a1AD5B63A000aB9CA3F2470611eB997B93B9", usdtAddress: ADDRESSES.ethereum.USDT, },
11+
}
12+
13+
// @dev btcOwnersOfCedefi: Bitcoin owners of the Avalon CeDefi pool contract.
14+
const btcOwnersOfCedefi = [
15+
'32DgQPVHSV6FSxLnw68nggvchp3ZNKquxA',
16+
'bc1qr5nz7n8ulcdz0w3s6fska80fawxhvqlh273qypm3rkjequ9wpmhs65ppw7',
17+
'bc1qhu98nf6ddz6ja73rn72encdr8ezsyhexwpdzap0vcs7lg2wpmrnq5ygfsl',
18+
'bc1qg6asmzjr7nr5f5upg3xqyrdxl2tq8ef58hha7t0s82mzzx6zjxesyccp4h',
19+
'bc1qxe3md4lehg8gmrlx3e8xqju5mytt266l4hcy8khl6tm5mahghmeqtxlgqq',
20+
'bc1qy48h0kuv0r3e330wjfs6r74sk49pkzumnm907t5mhqjxml22r3ss2ucuxc',
21+
]
22+
23+
// @dev getMetrics: call to get the collateral and debt of the Avalon CeDefi pool contract.
24+
const getMetrics = async (api, borrowed) => {
25+
const { poolAddress, lfbtcAddress, usdtAddress } = config[api.chain]
26+
const marketData = await api.call({ abi: abi.getPoolManagerReserveInformation, target: poolAddress, });
27+
// @note: no more count collateral on Ethereum, count collateral on Bitcoin instead
28+
// const balanceOfCollateral = marketData.collateral;
29+
const balanceOfDebt = marketData.debt;
30+
31+
if (borrowed)
32+
api.add(usdtAddress, balanceOfDebt);
33+
// else
34+
// api.add(lfbtcAddress, balanceOfCollateral);
35+
}
36+
37+
module.exports = {
38+
methodology: `lfbtc collateral, USDT debt of Avalon CeDefi pool contract and Bitcoin owners of the Avalon CeDefi pool contract`,
39+
doublecounted: false,
40+
ethereum: {
41+
tvl: (api) => getMetrics(api, false),
42+
borrowed: (api) => getMetrics(api, true),
43+
},
44+
bitcoin: {
45+
tvl: sdk.util.sumChainTvls([
46+
sumTokensExport({ owners: btcOwnersOfCedefi }),
47+
]),
48+
},
49+
}

0 commit comments

Comments
 (0)