Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AERA Finance - support special tokens that behave like ERC4626s but dont comply to the standard #11299

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions projects/aera/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const config = {
address: "0xa1c908cf7371047649dfca9ece01327dc6db3094",
fromBlock: 48024333
}
]
],
specialTokens: []
},
ethereum: {
aavePool: '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2',
Expand Down Expand Up @@ -70,7 +71,8 @@ const config = {
address: "0x38896b4ac8420b8A2B768001Da44d11109F1797D",
fromBlock: 18737324
}
]
],
specialTokens: ['0x971e5b5D4baa5607863f3748FeBf287C7bf82618']
},
arbitrum: {
aavePool: '0x794a61358D6845594F94dc1DB02A252b5b4814aD',
Expand All @@ -91,7 +93,8 @@ const config = {
address: "0xaF2762E1F75DeCdb8d240576e7A2CEc1A365cD46",
fromBlock: 203397910
}
]
],
specialTokens: []
},
base: {
aavePool: '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5',
Expand All @@ -116,7 +119,8 @@ const config = {
address: "0x5CD0Cb0DcDEF98a8d07a8D44054a13F2c35C53E1",
fromBlock: 13582859
}
]
],
specialTokens: []
},
}

Expand All @@ -131,6 +135,7 @@ Object.keys(config).forEach(chain => {
const COMETS = config[chain].comets
const COMET_REWARD = config[chain].cometReward
const vaultFactories = config[chain].vaultFactories
const specialTokens = config[chain].specialTokens

const vaultCreateds = []
for (const { address, fromBlock} of vaultFactories) {
Expand Down Expand Up @@ -180,10 +185,21 @@ Object.keys(config).forEach(chain => {
}
}

const [underlyingTokens, vaultErc4626Balances, tokenNames,] = await Promise.all([
const specialTokensCalls = []
for (const tokenAndOwner of tokensAndOwners) {
const specialToken = specialTokens.find(x => x.toLowerCase() === tokenAndOwner[0].toLowerCase())

if (specialToken) {
specialTokensCalls.push([specialToken, tokenAndOwner[1]])
}
}

const [underlyingTokens, vaultErc4626Balances, tokenNames, specialTokensAssets, specialTokensBalances] = await Promise.all([
api.multiCall({ abi: 'address:asset', calls: Object.keys(erc4626UnderylingMap) }),
api.multiCall({ abi: 'erc20:balanceOf', calls: erc4626sAndOwners.map(x => ({ target: x[0], params: x[1] })) }),
api.multiCall({ abi: 'string:name', calls: positions.map(x => x[0]), permitFailure: true }),
api.multiCall({ abi: 'address:asset', calls: specialTokensCalls.map(x => x[0])}),
api.multiCall({ abi: 'erc20:balanceOf', calls: specialTokensCalls.map(x => ({ target: x[0], params: x[1] })) })
])
await processLendingTvls(positions, tokenNames, api, AAVE_POOL, AAVE_POOL_DATA_PROVIDER, COMETS, vaults, COMET_REWARD)

Expand All @@ -196,6 +212,10 @@ Object.keys(config).forEach(chain => {
api.add(underlyingToken, vaultConvertToAssets[i])
})

specialTokensAssets.forEach((asset, i) => {
api.add(asset, specialTokensBalances[i])
})

return sumTokens2({ api, tokensAndOwners })
}
}
Expand Down
Loading