From f8775a2b20b0502b208ae22b32ae8ea827d68fa4 Mon Sep 17 00:00:00 2001 From: Samster91 Date: Fri, 29 Nov 2024 18:11:41 +0100 Subject: [PATCH] NEW: IdleDAO Bastion Vault --- projects/idle/index.js | 53 +++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/projects/idle/index.js b/projects/idle/index.js index e15ae60c793e..1b0c925d00f4 100644 --- a/projects/idle/index.js +++ b/projects/idle/index.js @@ -58,6 +58,11 @@ const contracts = { }, optimism: { + }, + arbitrum: { + cdos: [ + "0x3919396Cd445b03E6Bb62995A7a4CB2AC544245D" // Bastion Credit Vault + ] } } @@ -119,32 +124,32 @@ async function tvl(api) { fromBlock, }) cdos.push(...logs.map(i => i.proxy)) - - const [strategyToken, token, aatrances, bbtrances, aaprices, bbprices] = await Promise.all(['address:strategyToken', "address:token", "address:AATranche", "address:BBTranche", "uint256:priceAA", "uint256:priceBB"].map(abi => api.multiCall({ abi, calls: cdos }))) - blacklistedTokens.push(...cdos) - blacklistedTokens.push(...aatrances) - blacklistedTokens.push(...bbtrances) - - // Get CDOs contract values - const contractValue = await api.multiCall({ abi: 'uint256:getContractValue', calls: cdos }) - cdos.forEach((cdo, i) => { - const tokenDecimals = tokensDecimals[token[i]] || 18 - trancheTokensMapping[aatrances[i]] = { - token: token[i], - decimals: tokenDecimals, - price: BigNumber(aaprices[i]).div(`1e${tokenDecimals}`).toFixed() - } - trancheTokensMapping[bbtrances[i]] = { - token: token[i], - decimals: tokenDecimals, - price: BigNumber(bbprices[i]).div(`1e${tokenDecimals}`).toFixed() - } - - // Get CDOs underlying tokens balances - sdk.util.sumSingleBalance(balances, token[i], contractValue[i], api.chain) - }) } + const [cdoToken, aatrances, bbtrances, aaprices, bbprices] = await Promise.all(["address:token", "address:AATranche", "address:BBTranche", "uint256:priceAA", "uint256:priceBB"].map(abi => api.multiCall({ abi, calls: cdos }))) + blacklistedTokens.push(...cdos) + blacklistedTokens.push(...aatrances) + blacklistedTokens.push(...bbtrances) + + // Get CDOs contract values + const contractValue = await api.multiCall({ abi: 'uint256:getContractValue', calls: cdos }) + cdos.forEach((cdo, i) => { + const tokenDecimals = tokensDecimals[cdoToken[i]] || 18 + trancheTokensMapping[aatrances[i]] = { + token: cdoToken[i], + decimals: tokenDecimals, + price: BigNumber(aaprices[i]).div(`1e${tokenDecimals}`).toFixed() + } + trancheTokensMapping[bbtrances[i]] = { + token: cdoToken[i], + decimals: tokenDecimals, + price: BigNumber(bbprices[i]).div(`1e${tokenDecimals}`).toFixed() + } + + // Get CDOs underlying tokens balances + sdk.util.sumSingleBalance(balances, cdoToken[i], contractValue[i], api.chain) + }) + const trancheTokensBalancesCalls = [] allTokens.forEach((tokens, i) => {