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

Add aave v2, v3 helper and Avalon Finance adapter #2713

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

noateden
Copy link
Contributor

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.

@llamabutler
Copy link

The avalon.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees avalon.ts

🦙 Running AVALON.TS adapter 🦙
---------------------------------------------------
Start Date:	Tue, 25 Mar 2025 17:32:53 GMT
End Date:	Wed, 26 Mar 2025 17:32:53 GMT
---------------------------------------------------

[Error: Llama RPC error! method: undefined 
- host: https://bsc-dataseed.binance.org error: missing trie node
- host: https://binance.nodereal.io error: missing trie node
- host: https://endpoints.omniatech.io/v1/bsc/mainnet/public error: empty reader set
- host: https://bsc-dataseed1.defibit.io error: missing trie node
- host: https://0.48.club error: empty reader set
- host: https://bsc-pokt.nodies.app error: empty reader set
- host: https://bsc-dataseed.bnbchain.org error: missing trie node] {
  _underlyingError: '[object Object]',
  _isCustomError: true,
  chain: 'bsc'
}

@llamabutler
Copy link

The avalon.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees avalon.ts

🦙 Running AVALON.TS adapter 🦙
---------------------------------------------------
Start Date:	Tue, 25 Mar 2025 17:39:40 GMT
End Date:	Wed, 26 Mar 2025 17:39:40 GMT
---------------------------------------------------

[Error: Llama RPC error! method: undefined 
- host: https://bsc-dataseed.binance.org error: missing trie node
- host: https://bsc-dataseed2.defibit.io error: missing trie node
- host: https://bsc-dataseed1.ninicoin.io error: missing trie node
- host: https://bsc-dataseed.bnbchain.org error: missing trie node
- host: https://bsc-dataseed2.ninicoin.io error: missing trie node
- host: https://bsc-dataseed2.bnbchain.org error: missing trie node
- host: https://bsc.meowrpc.com error: empty reader set] {
  _underlyingError: '[object Object]',
  _isCustomError: true,
  chain: 'bsc'
}

@g1nt0ki g1nt0ki self-assigned this Mar 26, 2025
@llamabutler
Copy link

The avalon.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees avalon.ts

🦙 Running AVALON.TS adapter 🦙
---------------------------------------------------
Start Date:	Tue, 25 Mar 2025 20:50:19 GMT
End Date:	Wed, 26 Mar 2025 20:50:19 GMT
---------------------------------------------------

[Error: Llama RPC error! method: undefined 
- host: https://bsc-dataseed.binance.org error: missing trie node
- host: https://0.48.club error: empty reader set
- host: https://bsc-dataseed3.defibit.io error: missing trie node
- host: https://bsc-dataseed4.bnbchain.org error: missing trie node
- host: https://bsc-dataseed1.defibit.io error: missing trie node
- host: https://bsc-dataseed1.ninicoin.io error: missing trie node
- host: https://bsc-dataseed1.bnbchain.org error: missing trie node] {
  _underlyingError: '[object Object]',
  _isCustomError: true,
  chain: 'bsc'
}

params: [event.reserve],
skipCache: true,
permitFailure: false,
block: event.blockNumber - 1,
Copy link
Member

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

Copy link
Member

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

// get reserves configs, mainly reserveFactor values
const reserveConfigs = await options.api.multiCall({
abi: AaveAbis.getReserveConfiguration,
calls: reservesList.map(
Copy link
Member

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,

const totalDailySupplySideRevenue = options.createBalances()

for (const pool of pools) {
const { dailyFees, dailyRevenue } = await getPoolFees(pool, options)
Copy link
Member

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

totalDailyHoldersRevenue.addBalances(dailyRevenue)

Object.entries(dailyRevenue.getBalances()).forEach(([token, balance]) => {
totalDailySupplySideRevenue.addTokenVannila(token, Number(balance) * -1)
Copy link
Member

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)

@llamabutler
Copy link

The avalon.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees avalon.ts

🦙 Running AVALON.TS adapter 🦙
---------------------------------------------------
Start Date:	Wed, 26 Mar 2025 03:31:35 GMT
End Date:	Thu, 27 Mar 2025 03:31:35 GMT
---------------------------------------------------

[Error: Llama RPC error! method: undefined 
- host: https://bsc-dataseed.binance.org error: missing trie node
- host: https://bsc-dataseed1.ninicoin.io error: missing trie node
- host: https://bsc-dataseed3.ninicoin.io error: missing trie node
- host: https://bsc-dataseed2.defibit.io error: missing trie node
- host: https://bsc-dataseed1.defibit.io error: missing trie node
- host: https://bsc.rpc.blxrbdn.com error: empty reader set
- host: https://0.48.club error: empty reader set] {
  _underlyingError: '[object Object]',
  _isCustomError: true,
  chain: 'bsc'
}

@llamabutler
Copy link

The avalon.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees avalon.ts

🦙 Running AVALON.TS adapter 🦙
---------------------------------------------------
Start Date:	Wed, 26 Mar 2025 03:53:55 GMT
End Date:	Thu, 27 Mar 2025 03:53:55 GMT
---------------------------------------------------

[Error: Llama RPC error! method: undefined 
- host: https://bsc-dataseed.binance.org error: missing trie node
- host: https://bsc-dataseed1.ninicoin.io error: missing trie node
- host: https://bsc-dataseed4.defibit.io error: missing trie node
- host: https://bsc.meowrpc.com error: empty reader set
- host: https://bsc-dataseed3.ninicoin.io error: missing trie node
- host: https://bsc.rpc.blxrbdn.com error: empty reader set
- host: https://api.zan.top/bsc-mainnet error: Request failed with status code 429] {
  _underlyingError: '[object Object]',
  _isCustomError: true,
  chain: 'bsc'
}

@@ -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({
Copy link
Member

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)

@llamabutler
Copy link

The avalon.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees avalon.ts

🦙 Running AVALON.TS adapter 🦙
---------------------------------------------------
Start Date:	Wed, 26 Mar 2025 08:28:40 GMT
End Date:	Thu, 27 Mar 2025 08:28:40 GMT
---------------------------------------------------

[Error: Llama RPC error! method: undefined 
- host: https://bsc-dataseed.binance.org error: missing trie node
- host: https://bsc-dataseed3.defibit.io error: missing trie node
- host: https://endpoints.omniatech.io/v1/bsc/mainnet/public error: empty reader set
- host: https://api.zan.top/bsc-mainnet error: Request failed with status code 429
- host: https://bsc-dataseed1.bnbchain.org error: missing trie node
- host: https://binance.nodereal.io error: missing trie node
- host: https://rpc-bsc.48.club error: empty reader set] {
  _underlyingError: '[object Object]',
  _isCustomError: true,
  chain: 'bsc'
}

@llamabutler
Copy link

The avalon.ts adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees avalon.ts

🦙 Running AVALON.TS adapter 🦙
---------------------------------------------------
Start Date:	Wed, 26 Mar 2025 09:17:47 GMT
End Date:	Thu, 27 Mar 2025 09:17:47 GMT
---------------------------------------------------

[Error: Llama RPC error! method: undefined 
- host: https://bsc-dataseed.binance.org error: missing trie node
- host: https://bsc-dataseed3.ninicoin.io error: missing trie node
- host: https://bsc-dataseed3.defibit.io error: missing trie node
- host: https://bsc-dataseed4.bnbchain.org error: missing trie node
- host: https://bsc.rpc.blxrbdn.com error: empty reader set
- host: https://bsc-dataseed1.ninicoin.io error: missing trie node
- host: https://bsc-dataseed1.defibit.io error: missing trie node] {
  _underlyingError: '[object Object]',
  _isCustomError: true,
  chain: 'bsc'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants