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

Aave v2/v3 lending.supply macro fix - add WrappedTokenGateway lookup #7365

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ 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 *
from {{ source(project_decoded_as ~ '_' ~ blockchain, 'LendingPool_evt_LiquidationCall') }}
Expand All @@ -167,18 +177,30 @@ base_supply as (
union all
select
'withdraw' as transaction_type,
reserve as token_address,
user as depositor,
cast(null as varbinary) as on_behalf_of,
to as withdrawn_to,
w.reserve as token_address,
w.user as depositor,
{% 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(amount as double) as amount,
contract_address,
evt_tx_hash,
evt_index,
evt_block_time,
evt_block_number
from src_LendingPool_evt_Withdraw
-1 * cast(w.amount as double) as amount,
w.contract_address,
w.evt_tx_hash,
w.evt_index,
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 @@ -225,7 +247,8 @@ from base_supply
project,
version,
project_decoded_as = 'aave_v3',
decoded_contract_name = 'Pool'
decoded_contract_name = 'Pool',
decoded_wrapped_token_gateway_name = 'WrappedTokenGatewayV3'
)
%}

Expand All @@ -247,6 +270,16 @@ 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 *
from {{ source(project_decoded_as ~ '_' ~ blockchain, decoded_contract_name ~ '_evt_Repay') }}
Expand Down Expand Up @@ -282,18 +315,30 @@ base_supply as (
union all
select
'withdraw' as transaction_type,
reserve as token_address,
user as depositor,
cast(null as varbinary) as on_behalf_of,
to as withdrawn_to,
w.reserve as token_address,
w.user as depositor,
{% 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(amount as double) as amount,
contract_address,
evt_tx_hash,
evt_index,
evt_block_time,
evt_block_number
from src_LendingPool_evt_Withdraw
-1 * cast(w.amount as double) as amount,
w.contract_address,
w.evt_tx_hash,
w.evt_index,
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
blockchain = 'ethereum',
project = 'aave_lido',
version = '3',
decoded_contract_name = 'LidoPool'
decoded_contract_name = 'LidoPool',
decoded_wrapped_token_gateway_name = 'LidoWrappedTokenGatewayV3'
)
}}
1 change: 1 addition & 0 deletions sources/_sector/lending/supply/arbitrum/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sources:
tables:
- name: L2Pool_evt_Supply
- name: L2Pool_evt_Withdraw
- name: WrappedTokenGatewayV3_call_withdrawETH

- name: compound_v3_arbitrum
tables:
Expand Down
2 changes: 2 additions & 0 deletions sources/_sector/lending/supply/avalanche_c/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ sources:
- name: LendingPool_evt_Deposit
- name: LendingPool_evt_Withdraw
- name: LendingPool_evt_RedeemUnderlying
- name: WrappedTokenGatewayV2_call_withdrawETH

- name: aave_v3_avalanche_c
tables:
- name: Pool_evt_Supply
- name: Pool_evt_Withdraw
- name: Pool_evt_RedeemUnderlying
- name: WrappedTokenGatewayV3_call_withdrawETH

- name: benqi_finance_avalanche_c
tables:
Expand Down
1 change: 1 addition & 0 deletions sources/_sector/lending/supply/base/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ sources:
- name: L2Pool_evt_Supply
- name: L2Pool_evt_Withdraw
- name: L2Pool_evt_RedeemUnderlying
- name: WrappedTokenGatewayV3_call_withdrawETH

- name: compound_v3_base
tables:
Expand Down
1 change: 1 addition & 0 deletions sources/_sector/lending/supply/bnb/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sources:
tables:
- name: Pool_evt_Supply
- name: Pool_evt_Withdraw
- name: WrappedTokenGatewayV3_call_withdrawETH

- name: the_granary_bnb
tables:
Expand Down
4 changes: 4 additions & 0 deletions sources/_sector/lending/supply/ethereum/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ sources:
tables:
- name: LendingPool_evt_Deposit
- name: LendingPool_evt_Withdraw
- name: WrappedTokenGatewayV2_call_withdrawETH

- name: aave_v3_ethereum
tables:
- name: Pool_evt_Supply
- name: Pool_evt_Withdraw
- name: Pool_evt_ReserveDataUpdated
- name: WrappedTokenGatewayV3_call_withdrawETH
- name: LidoPool_evt_Supply
- name: LidoPool_evt_Withdraw
- name: LidoPool_evt_ReserveDataUpdated
- name: LidoWrappedTokenGatewayV3_call_withdrawETH

- name: aave_v3_etherfi_ethereum
tables:
- name: PoolInstance_evt_Supply
- name: PoolInstance_evt_Withdraw
- name: PoolInstance_evt_ReserveDataUpdated
- name: WrappedTokenGatewayV3_call_withdrawETH

- name: compound_v2_ethereum
tables:
Expand Down
1 change: 1 addition & 0 deletions sources/_sector/lending/supply/fantom/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ sources:
- name: Pool_evt_Supply
- name: Pool_evt_Withdraw
- name: Pool_evt_RedeemUnderlying
- name: WrappedTokenGatewayV3_call_withdrawETH

- name: the_granary_fantom
tables:
Expand Down
1 change: 1 addition & 0 deletions sources/_sector/lending/supply/gnosis/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sources:
tables:
- name: Pool_evt_Supply
- name: Pool_evt_Withdraw
- name: WrappedTokenGatewayV3_call_withdrawETH

- name: real_rmm_v1_gnosis
tables:
Expand Down
1 change: 1 addition & 0 deletions sources/_sector/lending/supply/optimism/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ sources:
- name: Pool_evt_Supply
- name: Pool_evt_Withdraw
- name: Pool_evt_RedeemUnderlying
- name: WrappedTokenGatewayV3_call_withdrawETH

- name: sonne_finance_optimism
tables:
Expand Down
2 changes: 2 additions & 0 deletions sources/_sector/lending/supply/polygon/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ sources:
- name: LendingPool_evt_Deposit
- name: LendingPool_evt_Withdraw
- name: LendingPool_evt_RedeemUnderlying
- name: WrappedTokenGatewayV2_call_withdrawETH

- name: aave_v3_polygon
tables:
- name: Pool_evt_Supply
- name: Pool_evt_Withdraw
- name: Pool_evt_RedeemUnderlying
- name: WrappedTokenGatewayV3_call_withdrawETH

- name: compound_v3_polygon
tables:
Expand Down
1 change: 1 addition & 0 deletions sources/_sector/lending/supply/scroll/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sources:
tables:
- name: L2Pool_evt_Supply
- name: L2Pool_evt_Withdraw
- name: WrappedTokenGatewayV3_call_withdrawETH

- name: layer_bank_scroll
tables:
Expand Down
Loading