Skip to content

Commit

Permalink
NEW: IdleDAO Bastion Vault
Browse files Browse the repository at this point in the history
  • Loading branch information
Samster91 committed Nov 29, 2024
1 parent 7b457cd commit f8775a2
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions projects/idle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ const contracts = {
},
optimism: {

},
arbitrum: {
cdos: [
"0x3919396Cd445b03E6Bb62995A7a4CB2AC544245D" // Bastion Credit Vault
]
}
}

Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit f8775a2

Please sign in to comment.