subgraphs icon indicating copy to clipboard operation
subgraphs copied to clipboard

Aave Treasury Data

Open defispartan opened this issue 3 years ago • 7 comments

Each Aave market has a treasury contract, which collects a portion of protocol interest in the form of aTokens. Treasury data is not included in the Aave protocol subgraph, so it needs to be added to the mapping. The treasury logic works a bit differently in V2 and V3.

V2: aTokens are automatically transferred to the collector contracts, so summing the aToken balances will give the entire balance.

V2 Collectors: Eth Mainnet V2/AMM/ARC: 0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c (shared contract) Polygon V2: 0x7734280A4337F37Fbf4651073Db7c28C80B339e9 Avalanche V2: 0x467b92aF281d14cB6809913AD016a607b5ba8A36

V3: aTokens must be pulled into the treasury contract by calling the mintToTreasury function on the Pool contract. There's a field on each reserve called accruedToTreasury which tracks the unminted amounts (not currently on the subgraph but I'll update this issue once it's added). So the treasury total is the aToken balances of the contracts below + accruedToTreasury for each reserve.

V3 Collectors: Optimism V3: 0xA77E4A084d7d4f064E326C0F6c0aCefd47A5Cb21 Arbitrum V3: 0xC3301b30f4EcBfd59dE0d74e89690C1a70C6f21B Polygon V3: 0x73D435AFc15e35A9aC63B2a81B5AA54f974eadFe Harmony V3: 0xeaC16519923774Fd7723d3D5E442a1e2E46BA962 (not supported by TheGraph yet) Fantom V3: 0xc0F0cFBbd0382BcE3B93234E4BFb31b2aaBE36aD Avalanche V3: 0xaCbE7d574EF8dC39435577eb638167Aca74F79f0

defispartan avatar May 10 '22 04:05 defispartan

Thanks @defispartan! We will revisit this when we get to the v3 subgraph.

this-username-is-taken avatar May 10 '22 04:05 this-username-is-taken

Since this is different from reserves I think this should be an add on field for aave v2 and v3.

melotik avatar Nov 14 '22 16:11 melotik

@dmelotik are these fields in the 3.0.0 schema? We are going to table this then till AAVE is upgraded to 3.0.0

bye43 avatar Dec 14 '22 16:12 bye43

No, it would be an addon field there as well. It really wouldn't make a difference if we added to the current schema as an additional field. But depends on priority

melotik avatar Dec 14 '22 18:12 melotik

If we decide to go down this route of grabbing treasury data. I think we would set ourselves up much better long term to create a small schema for treasury metrics and make separate subgraphs for that. Rather than adding it onto existing subgraphs and waiting to sync.

melotik avatar Feb 21 '23 21:02 melotik

@dmelotik, (and maybe @defispartan), I appreciate your guidance on a few things related to the treasury addition. Since we already track protocol side revenue, so this new field/entity will just track the actual treasury balance? Any preference between using an (optional) field of the market entity (seems making most sense to me as the balance is collected in aToken), vs a separate entity? Any other information besides balance, e.g. source, amountUSD? I suppose it/they needs to be added to daily/hourly snapshot? thx!

tnkrxyz avatar Apr 15 '23 23:04 tnkrxyz

If/when we go down the route of treasury tracking with subgraphs I think the plan will be to make it it's own schema/subgraph. Open to other opinions though

melotik avatar Apr 20 '23 20:04 melotik