-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add aave v2, v3 helper and Avalon Finance adapter #2713
base: master
Are you sure you want to change the base?
Conversation
The avalon.ts adapter exports:
|
The avalon.ts adapter exports:
|
The avalon.ts adapter exports:
|
params: [event.reserve], | ||
skipCache: true, | ||
permitFailure: false, | ||
block: event.blockNumber - 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is why the block parameter you set here are ignored: https://github.com/DefiLlama/defillama-sdk/blob/master/src/ChainApi.ts#L48
so, instead of options.api, you need to use the vannila sdk.api2.call like here:
https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/contango/index.js#L21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but, approx how many of these events are emitted per day? if it is a lot, one rpc call per event is not exactly scalable
helpers/aave/index.ts
Outdated
// get reserves configs, mainly reserveFactor values | ||
const reserveConfigs = await options.api.multiCall({ | ||
abi: AaveAbis.getReserveConfiguration, | ||
calls: reservesList.map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the map here, you can move the target to the top level and do calls: reservesList,
helpers/aave/index.ts
Outdated
const totalDailySupplySideRevenue = options.createBalances() | ||
|
||
for (const pool of pools) { | ||
const { dailyFees, dailyRevenue } = await getPoolFees(pool, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not pass dailyFees & dailyRevenue as third arg, this way, you dont have add everything up later
helpers/aave/index.ts
Outdated
totalDailyHoldersRevenue.addBalances(dailyRevenue) | ||
|
||
Object.entries(dailyRevenue.getBalances()).forEach(([token, balance]) => { | ||
totalDailySupplySideRevenue.addTokenVannila(token, Number(balance) * -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can simplify this by cloning the dailyFees object (.clone()
) and then subtracting daily revenue object (https://github.com/DefiLlama/defillama-sdk/blob/master/src/Balances.ts#L153)
The avalon.ts adapter exports:
|
The avalon.ts adapter exports:
|
@@ -76,7 +68,7 @@ async function getPoolFees(pool: AaveLendingPoolConfig, options: FetchOptions): | |||
.flat() | |||
|
|||
for (const event of events) { | |||
const reserveData = await options.api.call({ | |||
const reserveData = await sdk.api2.abi.call({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to pass chain parameter here, else it will run against ethereum (the default chain)
The avalon.ts adapter exports:
|
The avalon.ts adapter exports:
|
This pull request support the Aave fees and revenue helper. It supports version 2 and version 3. Forks can use this helper with given configs.
This pull request also contains a case study of Avalon Finance is using Aave helper.