-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[SPELL DESIGN] <something>.tvl #5666
Comments
catching up here - in this case, for a given uniswap pair it would have two rows in uniswap.tvl_base? also balances is already forward filled so no need to ffill again on downstream models? |
Correct, the base model would have a row for each address and token combo. Other models can be build on top that aggregate the balances based on address, project, version,..
balances is only forward filled in |
heys guys, very interesting discussion! did you have any progress on it in the past weeks? one suggestion I have for the schema name is
I also agree |
thanks, added your suggestion to the list! |
Current State of Balances:
We currently employ two models for managing balances:
tokens.balances
: This table is fully materialized and contains a balance record for each timestamp where a balance update was detected. However, due to the sparse nature of the data, it can be challenging to work with effectively.tokens.balances_daily
: This model enhances the sparse raw data intokens.balances
by forward-filling, providing a balance for each day, even when the balance hasn't changed. Additionally, both models have views that enrich the data with token metadata (which will be disregarded for the current discussion).However, these models are not optimal for complex queries, such as aggregating balances of known Uniswap pools or calculating the average balance over time of a defi lending project.
Goal:
The aim of
<something>.TVL
(name to be determined) is to create a fully materialized, dense balances table for a specific subset of address <> token pairs. This subset will allow for more flexible querying, as the compute-intensive forward-fill logic won't need to be rerun for each query.Schema:
The proposed schema aligns with the main balances schema, with the primary axis being
day
. It includes aggregation level columns(category, project, version)
and the primary balance columns(address, token, balance)
.Spellbook Setup:
The setup involves:
<address, token>
pair list for each project of interest, preferably through querying decoded contracts or deployment events. Manual curation is an option if automated methods are not feasible.tvl_base
macro to execute the forward-fill logic incrementally, taking inputs from the base daily balances table and the address <> token pair list.For a visual representation of the proposed setup, refer to the schema image below:
Usage:
get current uniswap TVL:
compare historical bridge balances
Naming:
We'll need to think a bit more about naming and purpose. Suggestions welcome.
Some options:
projects.tvl
dex.liquidity
projects.balances
protocols.tvl
considerations:
Each option has its implications, and careful consideration should be given to aligning the chosen name with the intended purpose and broader context of the project. I think my current preference would got to
projects.balances
, theprojects
schema can be expanded upon in the future with spells for daily active users, volume, retention, ...The text was updated successfully, but these errors were encountered: