-
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
optimism: uniswap pools dex balances #7271
Draft
Jason4276
wants to merge
20
commits into
duneanalytics:main
Choose a base branch
from
LamprosLabsDAO:op-token
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2064ab8
uniswap dex balances
Jason4276 c6431f9
Merge branch 'main' into op-token
Jason4276 e194cd5
updated sql file
Jason4276 80eae5d
Update op_token_balances.sql
Jason4276 e504d22
updated sql file
Jason4276 f46df27
Merge branch 'op-token' of https://github.com/LamprosLabsDAO/spellboo…
Jason4276 678785b
updated files
Jason4276 cb646db
updated sources file
Jason4276 eaf15c1
Upadate source
Jason4276 e63af4b
Update _sources.yml
Jason4276 c15e263
Upadate source
Jason4276 e5bec48
Merge remote-tracking branch 'origin/op-token' into op-token
Jason4276 8583f36
Merge branch 'main' into op-token
Jason4276 955aa94
Upadate source
Jason4276 44169d6
Merge remote-tracking branch 'origin/op-token' into op-token
Jason4276 d6902fe
Upadate sql file
Jason4276 5ac9413
Upadate sql file
Jason4276 3bcaf18
Merge branch 'main' into op-token
Jason4276 47b3005
Upadate sql file
Jason4276 7f5c0fe
Upadate sql file
Jason4276 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
dbt_subprojects/daily_spellbook/models/_sector/dex/pools/optimism/uniswap/_schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: uniswap_pools_optimism_balances | ||
description: "Tracks OP token balances in Uniswap pools on Optimism." | ||
meta: | ||
blockchain: optimism | ||
sector: DEX | ||
project: uniswap | ||
contributors: jason | ||
config: | ||
tags: ['optimism', 'op_token', 'balances', 'uniswap'] | ||
data_tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- pool_address | ||
- snapshot_day |
53 changes: 53 additions & 0 deletions
53
...y_spellbook/models/_sector/dex/pools/optimism/uniswap/uniswap_pools_optimism_balances.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{{ | ||
config( | ||
schema = 'uniswap_pools_optimism', | ||
alias = 'balances', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['pool_address', 'snapshot_day'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.snapshot_day')] | ||
) | ||
}} | ||
|
||
WITH op_pools AS ( | ||
SELECT | ||
pool AS pool_address, | ||
token0, | ||
token1, | ||
|
||
fee AS fee_tier, | ||
evt_block_time AS creation_time | ||
FROM | ||
{{ source('uniswap_v3_optimism', 'UniswapV3Factory_evt_PoolCreated') }} | ||
WHERE | ||
(token0 = 0x4200000000000000000000000000000000000042 | ||
OR token1 = 0x4200000000000000000000000000000000000042) | ||
), | ||
filtered_balances AS ( | ||
SELECT | ||
address AS pool_address, | ||
balance AS op_balance, | ||
day AS snapshot_day | ||
FROM | ||
{{ source('tokens_optimism', 'balances_daily') }} | ||
WHERE | ||
token_address = 0x4200000000000000000000000000000000000042 | ||
{% if is_incremental() %} | ||
and {{ incremental_predicate('day') }} | ||
{% else %} | ||
and day >= date '2021-11-11' --first pool initiated | ||
{% endif %} | ||
) | ||
SELECT | ||
p.pool_address, | ||
p.token0, | ||
p.token1, | ||
p.fee_tier, | ||
p.creation_time, | ||
COALESCE(b.op_balance, 0) AS op_balance, | ||
COALESCE(b.snapshot_day, CURRENT_DATE) AS snapshot_day | ||
FROM | ||
op_pools p | ||
LEFT JOIN | ||
filtered_balances b ON p.pool_address = b.pool_address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm second guessing myself a bit now, after seeing this moved here. since
uniswap_v3_optimism
schema is called out but no tables specifically, i think it already accounts for all tables under that schema automatically. i'm afraid if we add this table specifically, it could break other models that relied on the auto assignment of all tables under that schema.last check, can you remove this table completely (i.e. lines 5 & 6), and just let it run with only the schema there? would like to see if CI is able to run fine in that setup.
also do help me confirm if you are sticking with this decoded table vs. switching to the other spell of pools mentioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your guidance! I’ve decided to switch to using the uniswap_optimism_pools spell instead of the decoded table. This approach aligns better with the existing structure and ensures consistency across models.
I also ran CI without adding the table explicitly under sources, relying only on the schema, but an error occurred. Could you advise on what steps I should take next? Should I re-add the table explicitly, or is there another setup I should consider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm a bit confused. you mention moving to
uniswap_optimism_pools
spell as a source, but still see the old decoded table in the PR now?you will need to list spell as a source here:
https://github.com/duneanalytics/spellbook/blob/main/sources/_subprojects_outputs/dex/_sources.yml
then update your model to read from
source('uniswap_optimism,' 'pools')