Skip to content
Draft
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 @@ -28,36 +28,36 @@ from
*
from
swapExactAmountIn
union
union all
select
*
from
swapExactAmountInOnUniswapV2
union
union all
select
*
from
swapExactAmountInOnUniswapV3
union
union all
select
*
from
swapExactAmountInOnCurveV1
union
union all
select
*
from
swapExactAmountInOnCurveV2
union
union all
select
*
from
swapExactAmountInOnBalancerV2
-- TODO: should be possible to improve this conditional code
{% if contract_details['version'] == '6.2' %}
union select * from swapOnAugustusRFQTryBatchFill
union all select * from swapOnAugustusRFQTryBatchFill
{% if blockchain not in exclude_maker_psm %}
union select * from swapExactAmountInOutOnMakerPSM
union all select * from swapExactAmountInOutOnMakerPSM
{% endif %}
{% endif %}
)
Expand All @@ -77,17 +77,17 @@ from
*
from
swapExactAmountOut
union
union all
select
*
from
swapExactAmountOutOnUniswapV2
union
union all
select
*
from
swapExactAmountOutOnUniswapV3
union
union all
select
*
from
Expand All @@ -102,7 +102,7 @@ from
*
from
sell_trades
union
union all
select
*
from
Expand All @@ -119,7 +119,7 @@ select
call_block_number as blockNumber,
call_tx_hash as call_tx_hash,
project_contract_address as projectContractAddress,
call_trace_address as call_trace_address,
call_trace_address,
srcToken,
destToken,
fromAmount,
Expand Down Expand Up @@ -169,10 +169,26 @@ select
"AugustusV6_2": {"version": "6.2"}
} %}
{% endif %}
{% for contract_name, contract_details in contracts.items() %}
select * from ({{ paraswap_v6_trades_by_contract(blockchain, project, contract_name, contract_details) }})
{% if not loop.last %}
union all
{% endif %}
{% endfor %}
{% endmacro %}

with v6_trades as (
{% for contract_name, contract_details in contracts.items() %}
select * from (
{{ paraswap_v6_trades_by_contract(blockchain, project, contract_name, contract_details) }}
)
{% if not loop.last %} union all {% endif %}
{% endfor %}
)
select
*,
ROW_NUMBER() OVER (
PARTITION BY
call_tx_hash
ORDER BY
side,
method,
toAmount DESC,
fromAmount DESC,
COALESCE(beneficiary,'')
) - 1 AS evt_index
from v6_trades
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
file_format = 'delta',
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'method', 'trace_address'],
unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'method', 'trace_address', 'evt_index'],
post_hook='{{ expose_spells(\'["ethereum"]\',
"project",
"paraswap_v6",
Expand Down Expand Up @@ -40,7 +40,7 @@ with dexs AS (
projectContractAddress as project_contract_address,
call_tx_hash as tx_hash,
call_trace_address AS trace_address,
CAST(-1 as integer) AS evt_index
evt_index
FROM {{ ref('paraswap_v6_ethereum_trades_decoded') }}
{% if is_incremental() %}
WHERE {{ incremental_predicate('blockTime') }}
Expand Down