duneanalytics / spellbook

SQL views for Dune
Other
1.18k stars 1.12k forks source link

[Spell Design] Missing Context on Aave Macro #5504

Open lgingerich opened 8 months ago

lgingerich commented 8 months ago

The current macro for Aave V3 has a single column for the user on borrows. aave_v3_ethereum.Pool_evt_Borrow has two columns that relate to the user: user and onBehalfOf. From a quick look, this also affects Aave V2, but I didn't check beyond that.

By omitting data in onBehalfOf, there is missing context in lending.borrow. It's not possible to calculate net borrow/lend since we don't know who's account funds were borrowed from.

So we need to add this onBehalfOf column back in somehow. I'm imagining we want to have both columns and not just swap these out. I wasn't part of the creation of the Aave model or any borrow/lend stuff, so I wanted to open an issue and get input from those that did work on it.

cc: @Hosuke @tomfutago @jeff-dude

tomfutago commented 8 months ago

Hi @lgingerich - I used existing spells at the time of adding this macro (one of my early on Spellbook projects). Adding onBehalfOf sounds like a valid point - will have a look at adding it in. Any preference for the column name? I'd go with on_behalf_of to keep snake case convention as for other column names, but open to suggestions.

lgingerich commented 8 months ago

on_behalf_of makes sense to me. The main reason I opened an issue for this is that it will of course effect the overall lending table schema. Before officially going with that name, I want to investigate if Compound and others have anything else we need to handle on this.