Skip to content

Commit

Permalink
fix broken adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed May 11, 2024
1 parent 0c99801 commit 8d601a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion projects/puffer/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const PUF_ETH = '0xD9A442856C234a39a81a089C06451EBAa4306a72';

async function tvl(api) {
return api.erc4626Sum({ calls: [PUF_ETH], isOG4626: true })
return api.erc4626Sum({ calls: [PUF_ETH], isOG4626: true, permitFailure: true, })
}

module.exports = {
Expand Down
10 changes: 7 additions & 3 deletions projects/xWinFinance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Object.keys(config).forEach(chain => {
const { portfolioURL, strategyUrl, privateKey, } = config[chain]
module.exports[chain] = {
tvl: async (api) => {
const vaults = (await getConfig('xWinFinance/vaults/' + api.chain, strategyUrl)).map(i => i.contractaddress)
let vaults = (await getConfig('xWinFinance/vaults/' + api.chain, strategyUrl)).map(i => i.contractaddress)
const privateVaults = await getConfig('xWinFinance/privateVaults', PrivateURL)

vaults.push(...privateVaults[privateKey])
Expand All @@ -34,14 +34,18 @@ Object.keys(config).forEach(chain => {
vaults.push(...portfolioVaults.map(i => i.contractaddress))
}

const bals = await api.multiCall({ abi: 'uint256:getVaultValues', calls: vaults })

const isValidVault = await api.multiCall({ abi: 'uint256:getVaultValues', calls: vaults, permitFailure: true })
vaults = vaults.filter((_, i) => isValidVault[i])

const bals = await api.multiCall({ abi: 'uint256:getVaultValues', calls: vaults, permitFailure: true })
const tokens = await api.multiCall({ abi: 'address:baseToken', calls: vaults })
const decimals = await api.multiCall({ abi: 'erc20:decimals', calls: tokens })


//Get Vault Values returns 18 decimals even if the base token is not
//For loop that removes the extra zeros if the base token is not 18 decimals.
bals.forEach((bal, i) => bals[i] = bal / 10 ** (18 - decimals[i]))
bals.forEach((bal, i) => bals[i] = (bal ?? 0) / 10 ** (18 - decimals[i]))

api.addTokens(tokens, bals)
}
Expand Down

0 comments on commit 8d601a8

Please sign in to comment.