Skip to content

Commit

Permalink
fix: apply only to aave
Browse files Browse the repository at this point in the history
  • Loading branch information
tomfutago committed Dec 22, 2024
1 parent 98470f3 commit 47778cc
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ src_LendingPool_evt_Withdraw as (
{% endif %}
),

{% if 'aave' in project %}
src_WrappedTokenGatewayV2_call_withdrawETH as (
select *
from {{ source(project_decoded_as ~ '_' ~ blockchain, 'WrappedTokenGatewayV2_call_withdrawETH') }}
{% if is_incremental() %}
where {{ incremental_predicate('call_block_time') }}
{% endif %}
),
{% endif %}

src_LendingPool_evt_LiquidationCall as (
select *
Expand Down Expand Up @@ -177,7 +179,11 @@ base_supply as (
'withdraw' as transaction_type,
w.reserve as token_address,
w.user as depositor,
cast(wrap.to as varbinary) as on_behalf_of,
{% if 'aave' in project %}
cast(wrap.to as varbinary)
{% else %}
cast(null as varbinary)
{% endif %} as on_behalf_of,
w.to as withdrawn_to,
cast(null as varbinary) as liquidator,
-1 * cast(w.amount as double) as amount,
Expand All @@ -187,12 +193,14 @@ base_supply as (
w.evt_block_time,
w.evt_block_number
from src_LendingPool_evt_Withdraw w
{% if 'aave' in project %}
left join src_WrappedTokenGatewayV2_call_withdrawETH wrap
on w.evt_block_number = wrap.call_block_number
and w.evt_tx_hash = wrap.call_tx_hash
and w.to = wrap.contract_address
and w.amount = wrap.amount
and wrap.call_success
{% endif %}
union all
select
'deposit_liquidation' as transaction_type,
Expand Down Expand Up @@ -262,13 +270,15 @@ src_LendingPool_evt_Withdraw as (
{% endif %}
),

{% if 'aave' in project %}
src_WrappedTokenGatewayV3_call_withdrawETH as (
select *
from {{ source(project_decoded_as ~ '_' ~ blockchain, decoded_wrapped_token_gateway_name ~ '_call_withdrawETH') }}
{% if is_incremental() %}
where {{ incremental_predicate('call_block_time') }}
{% endif %}
),
{% endif %}

src_LendingPool_evt_Repay as (
select *
Expand Down Expand Up @@ -307,7 +317,11 @@ base_supply as (
'withdraw' as transaction_type,
w.reserve as token_address,
w.user as depositor,
cast(wrap.to as varbinary) as on_behalf_of,
{% if 'aave' in project %}
cast(wrap.to as varbinary)
{% else %}
cast(null as varbinary)
{% endif %} as on_behalf_of,
w.to as withdrawn_to,
cast(null as varbinary) as liquidator,
-1 * cast(w.amount as double) as amount,
Expand All @@ -317,12 +331,14 @@ base_supply as (
w.evt_block_time,
w.evt_block_number
from src_LendingPool_evt_Withdraw w
{% if 'aave' in project %}
left join src_WrappedTokenGatewayV3_call_withdrawETH wrap
on w.evt_block_number = wrap.call_block_number
and w.evt_tx_hash = wrap.call_tx_hash
and w.to = wrap.contract_address
and w.amount = wrap.amount
and wrap.call_success
{% endif %}
union all
select
'repay_with_atokens' as transaction_type,
Expand Down

0 comments on commit 47778cc

Please sign in to comment.