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

Aave V3 Fee Issue (potentially large deviations from the real value) #1322

Open
melotik opened this issue Mar 18, 2024 · 3 comments
Open

Aave V3 Fee Issue (potentially large deviations from the real value) #1322

melotik opened this issue Mar 18, 2024 · 3 comments

Comments

@melotik
Copy link

melotik commented Mar 18, 2024

Hey defillama team,

I am over at messari and noticed a bug in how you are calculating the fees for aave v3 (likely other aave protocols and forks).

const dailyFee = feeBreakdown.depositorInterestUSD + feeBreakdown.outstandingTreasuryIncomeUSD + feeBreakdown.treasuryIncomeUSD

What is "outstanding treasury income"?
This is the accruedToTreasury field in the aave subgraph you use. And that coincides with accruedToTreasury in aave smart contracts.

What is accruedToTreasury?
"//the current treasury balance, scaled" - per comment in contracts

How does this field behave?
This is essentially a counter for reserve accrued interest, and once it is large enough a MintToTreasury event is emitted and the counter is reset to 0, and the value (in aTokens) is minted to the treasury.

Why is this wrong?

  1. This is not a strictly increasing field. So it is reset to 0, and when you subtract current value by yesterday's value it is possible to get negative values. Doesn't seem to be handled in the open source code, so I am guessing you do something internally to hide these values.
  2. This value is really just lifetimeReserveFactorAccrued or treasuryIncomeUSD (in the adapters). So it is double counting fees generated to the protocol from user interest sent to the treasury.

What are the effects?
There are pretty massive $1mm+ spikes, that don't coincide with the actual revenue.

Screenshot 2024-03-18 at 5 38 29 PM Source: https://defillama.com/protocol/aave-v3
@dtmkeng
Copy link
Contributor

dtmkeng commented May 2, 2024

fixed bd3d3b3

@melotik
Copy link
Author

melotik commented May 29, 2024

The data looks the same, does this require a backfill?

@dtmkeng
Copy link
Contributor

dtmkeng commented May 30, 2024

The data looks the same, does this require a backfill?

which day ?

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

No branches or pull requests

2 participants