-
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.
Add: avalon finance cedefi market ethereum
- Loading branch information
1 parent
e3f4d73
commit 41b65b8
Showing
4 changed files
with
75 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,12 @@ | ||
const avalonCeDefi = { | ||
ethereum: "0x02feDCff97942fe28e8936Cdc3D7A480fdD248f0" | ||
}; | ||
|
||
const lfbtc = { | ||
ethereum: "0x3119a1AD5B63A000aB9CA3F2470611eB997B93B9" | ||
} | ||
|
||
module.exports = { | ||
avalonCeDefi, | ||
lfbtc, | ||
} |
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,42 @@ | ||
// Defillama Adapter for Avalon Finance CeDeFi Market | ||
const { fetchMarketData } = require('./markets'); | ||
const { avalonCeDefi, lfbtc } = require("./addresses"); | ||
const coreAssets = 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; | ||
|
||
api.add(lfbtcAddress, balanceOfCollateral); | ||
if (borrowed) { | ||
api.add(usdtAddress, balanceOfDebt); | ||
} | ||
} catch (error) { | ||
console.error("Error in getMetrics:", error); | ||
throw error; | ||
} | ||
}; | ||
|
||
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); | ||
} | ||
}; | ||
|
||
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 |
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,15 @@ | ||
const abi = require("../helper/abis/avalon.json"); | ||
|
||
// @dev fetchMarketsData: call to get the reserve information for all markets. Call getPoolManagerReserveInformation for one market. | ||
async function fetchMarketData(poolAddress, api) { | ||
const poolReserveInfo = await api.call({ | ||
abi: abi.avalonCeDefi.getPoolManagerReserveInformation, | ||
target: poolAddress, | ||
}); | ||
|
||
return poolReserveInfo; | ||
} | ||
|
||
module.exports = { | ||
fetchMarketData | ||
} |
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,6 @@ | ||
{ | ||
"avalonCeDefi": { | ||
"getPoolManagerReserveInformation": "function getPoolManagerReserveInformation() view returns (tuple(uint256 userAmount, uint256 collateral, uint256 debt, uint256 claimableUSDT, uint256 claimableBTC) poolManagerReserveInfor)" | ||
} | ||
} | ||
|