Skip to content

Commit

Permalink
Add adapter for Untangled Finance
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-untangled committed May 13, 2024
1 parent 0dc3e8f commit a51eb23
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions projects/untangled/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const {BigNumber} = require("bignumber.js");

const Contracts = {
SecuritizationManager: "0x4DCC7a839CE7e952Cd90d03d65C70B9CCD6BA4C2",
USDC: "0xcebA9300f2b948710d2653dD7B07f33A8B32118C",
};

async function tvl(api) {
const poolLength = await api.call({ abi: 'function getPoolsLength() view returns (uint256)', target: Contracts.SecuritizationManager })
const poolsTVL = []
let tvl = BigNumber(0)
for (let i = 0; i < poolLength; i++) {
const poolAddress = await api.call({ abi: 'function pools(uint256 i) view returns (address)', target: Contracts.SecuritizationManager, params: [i]})
const reserves = await api.call({abi : 'function getReserves() external view returns (uint256, uint256)', target: poolAddress})
const poolTVL = BigNumber(reserves[0]).plus(BigNumber(reserves[1]))
tvl = tvl.plus(poolTVL)
}
return {
'celo:0xcebA9300f2b948710d2653dD7B07f33A8B32118C': Number(tvl),
}
}

module.exports = {
celo: {
tvl,
},
};

0 comments on commit a51eb23

Please sign in to comment.