Skip to content

Commit

Permalink
introduce incremental aave models
Browse files Browse the repository at this point in the history
  • Loading branch information
viniabussafi committed Nov 26, 2024
1 parent 9f42022 commit 129ebf7
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{ config(
schema = 'balancer',
alias = 'aave_static_token_mapping',
post_hook='{{ expose_spells(blockchains = \'["ethereum", "gnosis"]\',
spell_type = "project",
spell_name = "balancer",
contributors = \'["viniabussafi"]\') }}'
)
}}

{% set balancer_models = [
ref('balancer_v3_ethereum_aave_static_tokens_mapping'),
ref('balancer_v3_gnosis_aave_static_tokens_mapping')
] %}

SELECT *
FROM (
{% for model in balancer_models %}
SELECT
blockchain,
aToken,
atoken_symbol,
static_atoken,
static_atoken_name,
static_atoken_symbol,
underlying_token,
underlying_token_symbol,
underlying_token_decimals
FROM {{ model }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{ config(
schema = 'balancer',
alias = 'aave_static_token_prices',
post_hook='{{ expose_spells(blockchains = \'["ethereum", "gnosis"]\',
spell_type = "project",
spell_name = "balancer",
contributors = \'["viniabussafi"]\') }}'
)
}}

{% set balancer_models = [
ref('balancer_v3_ethereum_aave_static_tokens_prices'),
ref('balancer_v3_gnosis_aave_static_tokens_prices')
] %}

SELECT *
FROM (
{% for model in balancer_models %}
SELECT
minute,
blockchain,
wrapped_token,
underlying_token,
static_atoken_symbol,
underlying_token_symbol,
decimals,
median_price,
next_change
FROM {{ model }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{{ config(
schema = 'balancer_v3_ethereum',
alias = 'aave_static_token_prices',
materialized = 'table',
file_format = 'delta'
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['minute', 'wrapped_token'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.minute')]
)
}}

Expand All @@ -13,6 +16,9 @@ WITH wrap_unwrap AS(
wrappedToken,
CAST(mintedShares AS DOUBLE) / CAST(depositedUnderlying AS DOUBLE) AS ratio
FROM {{ source('balancer_v3_ethereum', 'Vault_evt_Wrap') }}
{% if is_incremental() %}
AND {{ incremental_predicate('evt_block_time') }}
{% endif %}

UNION ALL

Expand All @@ -22,6 +28,9 @@ WITH wrap_unwrap AS(
wrappedToken,
CAST(burnedShares AS DOUBLE) / CAST(withdrawnUnderlying AS DOUBLE) AS ratio
FROM {{ source('balancer_v3_ethereum', 'Vault_evt_Unwrap') }}
{% if is_incremental() %}
AND {{ incremental_predicate('evt_block_time') }}
{% endif %}
),


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{{ config(
schema = 'balancer_v3_gnosis',
alias = 'aave_static_token_prices',
materialized = 'table',
file_format = 'delta'
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['minute', 'wrapped_token'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.minute')]
)
}}

Expand All @@ -13,6 +16,9 @@ WITH wrap_unwrap AS(
wrappedToken,
CAST(mintedShares AS DOUBLE) / CAST(depositedUnderlying AS DOUBLE) AS ratio
FROM {{ source('balancer_v3_gnosis', 'Vault_evt_Wrap') }}
{% if is_incremental() %}
AND {{ incremental_predicate('evt_block_time') }}
{% endif %}

UNION ALL

Expand All @@ -22,6 +28,9 @@ WITH wrap_unwrap AS(
wrappedToken,
CAST(burnedShares AS DOUBLE) / CAST(withdrawnUnderlying AS DOUBLE) AS ratio
FROM {{ source('balancer_v3_gnosis', 'Vault_evt_Unwrap') }}
{% if is_incremental() %}
AND {{ incremental_predicate('evt_block_time') }}
{% endif %}
),


Expand Down

0 comments on commit 129ebf7

Please sign in to comment.