balancer / dune-spellbook

SQL views for Dune Analytics
Other
7 stars 12 forks source link

Convert spells from table to incremental #81

Closed viniabussafi closed 3 weeks ago

viniabussafi commented 1 month ago

I had some issues with incremental runs of a few spells on the past, such as protocol fees (see this and this). I will try to address this issue again by tackling multiple spells at once (liquidity, bpt prices, bpt supply and protocol fees).

With that, spells would be refreshed hourly, instead of daily

viniabussafi commented 1 month ago

Working on a PR

viniabussafi commented 1 month ago

Status update on this: We're unsure whether to move on with this PR or not. It passes the tests, but the results may be different from what's expected:

hey, @jeff-dude!

Tests should pass now, but I'm still a bit unsure regarding the implementation of incremental models and how it would affect spells that rely on rolling sums of token balances, which is the case of the liquidity spell. In a gross demonstration, considering a specific pool and an incremental refresh interval of 3 days

what should happen: spell merged today day 1 - 100k in - tvl = 100k day 2 - 50k out - tvl = 50k day 3 - 50k in - tvl = 100k day 4 - 100k in - tvl = 200k

what I'm afraid will happen: spell runs incrementally tomorrow day 2 - 50k out - tvl = -50k day 3 - 50k in - tvl = 0k day 4 - 100k in - tvl = 100k day 5 - 50k out - tvl = 50k

Am I correct in my assumption? If so, how are incremental runs of balances spells dealt with at the moment?

Going to put this on hold while we have some extra thought on that matter

viniabussafi commented 1 month ago

👀 for reference: https://github.com/duneanalytics/spellbook/pull/5980#discussion_r1619402803

viniabussafi commented 4 weeks ago

If that's the case: https://github.com/duneanalytics/spellbook/discussions/6037#discussion-6753023, making this change won't be useful

Moving forward, all spells outside of the main sub-projects will run on a daily cadence. No changes need to be made to materialization type, rather the orchestration logic will change to make it work.

viniabussafi commented 3 weeks ago

Will close this one and maybe reopen in the future, based on the comment above