forked from DefiLlama/DefiLlama-Adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Avalon CeDeFi of Avalon Finance (DefiLlama#11301)
Co-authored-by: g1nt0ki <[email protected]>
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const ADDRESSES = require('../helper/coreAssets.json') | ||
const sdk = require('@defillama/sdk'); | ||
const { sumTokensExport } = require('../helper/sumTokens'); | ||
|
||
const abi = { | ||
"getPoolManagerReserveInformation": "function getPoolManagerReserveInformation() view returns (tuple(uint256 userAmount, uint256 collateral, uint256 debt, uint256 claimableUSDT, uint256 claimableBTC) poolManagerReserveInfor)" | ||
} | ||
|
||
const config = { | ||
ethereum: { poolAddress: "0x02feDCff97942fe28e8936Cdc3D7A480fdD248f0", lfbtcAddress: "0x3119a1AD5B63A000aB9CA3F2470611eB997B93B9", usdtAddress: ADDRESSES.ethereum.USDT, }, | ||
} | ||
|
||
// @dev btcOwnersOfCedefi: Bitcoin owners of the Avalon CeDefi pool contract. | ||
const btcOwnersOfCedefi = [ | ||
'32DgQPVHSV6FSxLnw68nggvchp3ZNKquxA', | ||
'bc1qr5nz7n8ulcdz0w3s6fska80fawxhvqlh273qypm3rkjequ9wpmhs65ppw7', | ||
'bc1qhu98nf6ddz6ja73rn72encdr8ezsyhexwpdzap0vcs7lg2wpmrnq5ygfsl', | ||
'bc1qg6asmzjr7nr5f5upg3xqyrdxl2tq8ef58hha7t0s82mzzx6zjxesyccp4h', | ||
'bc1qxe3md4lehg8gmrlx3e8xqju5mytt266l4hcy8khl6tm5mahghmeqtxlgqq', | ||
'bc1qy48h0kuv0r3e330wjfs6r74sk49pkzumnm907t5mhqjxml22r3ss2ucuxc', | ||
] | ||
|
||
// @dev getMetrics: call to get the collateral and debt of the Avalon CeDefi pool contract. | ||
const getMetrics = async (api, borrowed) => { | ||
const { poolAddress, lfbtcAddress, usdtAddress } = config[api.chain] | ||
const marketData = await api.call({ abi: abi.getPoolManagerReserveInformation, target: poolAddress, }); | ||
// @note: no more count collateral on Ethereum, count collateral on Bitcoin instead | ||
// const balanceOfCollateral = marketData.collateral; | ||
const balanceOfDebt = marketData.debt; | ||
|
||
if (borrowed) | ||
api.add(usdtAddress, balanceOfDebt); | ||
// else | ||
// api.add(lfbtcAddress, balanceOfCollateral); | ||
} | ||
|
||
module.exports = { | ||
methodology: `lfbtc collateral, USDT debt of Avalon CeDefi pool contract and Bitcoin owners of the Avalon CeDefi pool contract`, | ||
doublecounted: false, | ||
ethereum: { | ||
tvl: (api) => getMetrics(api, false), | ||
borrowed: (api) => getMetrics(api, true), | ||
}, | ||
bitcoin: { | ||
tvl: sdk.util.sumChainTvls([ | ||
sumTokensExport({ owners: btcOwnersOfCedefi }), | ||
]), | ||
}, | ||
} |