forked from duneanalytics/spellbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimism: uniswap pools balances (duneanalytics#7434)
* added optimism: uniswap pools dex balances * update sql file * Update _schema.yml * update files * Resolved merge conflicts in _schema.yml * updated sql file * updated sql file * updated sql file * updated sql file * updated sql file * updated sql file * updated sql file * updated sql file * updated sql file * updated sql file * updated sql file * updated sql file * updated sql file * Update uniswap_pools_optimism_balances.sql * updated sql file * updated sql file * updated sql file * updated sql file
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
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','pools'] | ||
data_tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- pool_address | ||
- snapshot_day |
47 changes: 47 additions & 0 deletions
47
...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,47 @@ | ||
{{ | ||
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_addresses as ( | ||
select | ||
pool as address, | ||
token0, | ||
token1, | ||
0x4200000000000000000000000000000000000042 as token_address, | ||
fee as fee_tier, | ||
creation_block_time as creation_time | ||
from | ||
{{ source('uniswap_v3_optimism', 'pools') }} | ||
where | ||
token0 = 0x4200000000000000000000000000000000000042 | ||
or token1 = 0x4200000000000000000000000000000000000042 | ||
), | ||
|
||
filtered_balances as ( | ||
{{ balances_incremental_subset_daily( | ||
blockchain='optimism', | ||
start_date='2021-11-11', | ||
address_token_list = 'op_addresses' | ||
) }} | ||
) | ||
|
||
select | ||
p.address as pool_address, | ||
p.token0 as token0, | ||
p.token1 as token1, | ||
p.fee_tier, | ||
p.creation_time, | ||
coalesce(b.balance, 0) as op_balance, | ||
coalesce(b.day, current_date) as snapshot_day | ||
from | ||
filtered_balances b | ||
left join | ||
op_addresses p on b.address = p.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