-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
26 additions
and
70 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,42 +1,31 @@ | ||
// Defillama Adapter for Avalon Finance CeDeFi Market | ||
const { fetchMarketData } = require('./markets'); | ||
const { avalonCeDefi, lfbtc } = require("./addresses"); | ||
const coreAssets = require('../helper/coreAssets.json'); | ||
const ADDRESSES = require('../helper/coreAssets.json') | ||
|
||
// @dev getMetrics: call to get the collateral and debt of the Avalon CeDefi pool contract. | ||
const getMetrics = async (poolAddress, lfbtcAddress, usdtAddress, api, borrowed) => { | ||
try { | ||
const marketData = await fetchMarketData(poolAddress, api); | ||
const balanceOfCollateral = marketData.collateral; | ||
const balanceOfDebt = marketData.debt; | ||
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, }, | ||
} | ||
|
||
api.add(lfbtcAddress, balanceOfCollateral); | ||
if (borrowed) { | ||
api.add(usdtAddress, balanceOfDebt); | ||
} | ||
} catch (error) { | ||
console.error("Error in getMetrics:", error); | ||
throw error; | ||
} | ||
}; | ||
// @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, }); | ||
const balanceOfCollateral = marketData.collateral; | ||
const balanceOfDebt = marketData.debt; | ||
|
||
const ethereum = function (borrowed) { | ||
const poolAddress = avalonCeDefi.ethereum | ||
const lfbtcAddress = lfbtc.ethereum | ||
const usdtAddress = coreAssets.ethereum.USDT | ||
return async (api) => { | ||
return getMetrics(poolAddress, lfbtcAddress, usdtAddress, api, borrowed); | ||
} | ||
}; | ||
if (borrowed) | ||
api.add(usdtAddress, balanceOfDebt); | ||
else | ||
api.add(lfbtcAddress, balanceOfCollateral); | ||
} | ||
|
||
module.exports = { | ||
methodology: `lfbtc collateral and USDT debt of Avalon CeDefi pool contract`, | ||
doublecounted: false, | ||
ethereum: { | ||
tvl: ethereum(false), | ||
borrowed: ethereum(true), | ||
} | ||
}; | ||
|
||
// export LLAMA_DEBUG_MODE="true" | ||
// node test.js projects/avalon-finance-cedefi/index.js | ||
methodology: `lfbtc collateral and USDT debt of Avalon CeDefi pool contract`, | ||
doublecounted: false, | ||
ethereum: { | ||
tvl: (api) => getMetrics(api), | ||
borrowed: (api) => getMetrics(api, true), | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.