Skip to content

Commit

Permalink
added openxswap balances
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason4276 committed Jan 18, 2025
1 parent 2a3baeb commit 22d3f2c
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ models:
description: "Tracks OP token balances in Aave pools on Optimism."
meta:
blockchain: optimism
sector: DEX
sector: Leding
project: aave
contributors: jason
config:
Expand Down
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
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
1 change: 1 addition & 0 deletions sources/_sector/dex/trades/optimism/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ sources:
- name: openxswap_optimism
tables:
- name: Aggregator_evt_Swap
- name: UniswapV2Factory_evt_PairCreated
- name: openocean_v2_optimism
tables:
- name: OpenOceanExchangeProxy_evt_Swapped
Expand Down

0 comments on commit 22d3f2c

Please sign in to comment.