Skip to content
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: aave pools balances #7482

Closed
wants to merge 12 commits into from
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 3

models:
- name: aave_pools_optimism_balances
description: "Tracks OP token balances in Aave pools on Optimism."
meta:
blockchain: optimism
sector: Leding
project: aave
contributors: jason
config:
tags: ['optimism', 'op_token', 'balances', 'aave']
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,37 @@
{{
config(
schema = 'aave_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')]
)
}}

-- Aave address that holds OP tokens
WITH aave_op_reserve AS (
SELECT
0x513c7E3a9c69cA3e22550eF58AC1C0088e918FFf AS address,
0x4200000000000000000000000000000000000042 AS token_address
),

filtered_balances AS (
{{ balances_incremental_subset_daily(
blockchain='optimism',
start_date='2021-11-11',
address_token_list = 'aave_op_reserve'
) }}
)

SELECT
p.address AS pool_address,
'aave' AS protocol_name,
'v3' AS protocol_version,
COALESCE(b.day, CURRENT_DATE) AS snapshot_day,
COALESCE(b.balance, 0) AS op_balance
FROM
filtered_balances b
left join
aave_op_reserve p on b.address = p.address
2 changes: 1 addition & 1 deletion sources/_sector/dex/trades/optimism/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ sources:
- name: SwapFlashLoan_evt_TokenSwap
- name: bridgers_optimism
tables:
- name: Bridgers_evt_Swap
- name: Bridgers_evt_Swap dbt
Loading