-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
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
17 changes: 17 additions & 0 deletions
17
dbt_subprojects/daily_spellbook/models/_sector/dex/pools/optimism/openxswap/_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: openxswap_pools_optimism_balances | ||
description: "Tracks OP token balances in openxswap pools on Optimism." | ||
meta: | ||
blockchain: optimism | ||
sector: DEX | ||
project: openxswap | ||
contributors: jason | ||
config: | ||
tags: ['optimism', 'op_token', 'balances', 'openxswap'] | ||
data_tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- pool_address | ||
- snapshot_day |
46 changes: 46 additions & 0 deletions
46
...ellbook/models/_sector/dex/pools/optimism/openxswap/openxswap_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,46 @@ | ||
{{ | ||
config( | ||
schema = 'openxswap_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 | ||
pair as address, | ||
token0, | ||
token1, | ||
0x4200000000000000000000000000000000000042 as token_address, | ||
evt_block_date as creation_time | ||
from | ||
{{ source('openxswap_optimism', 'UniswapV2Factory_evt_PairCreated') }} | ||
where | ||
token0 = 0x4200000000000000000000000000000000000042 | ||
or token1 = 0x4200000000000000000000000000000000000042 | ||
), | ||
|
||
filtered_balances as ( | ||
{{ balances_incremental_subset_daily( | ||
blockchain='optimism', | ||
start_date='2022-09-14', | ||
address_token_list = 'op_addresses' | ||
) }} | ||
) | ||
|
||
select | ||
p.address as pool_address, | ||
'openxswap' AS protocol_name, | ||
p.token0 as token0, | ||
p.token1 as token1, | ||
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