From 24a8b8f085b9b6fd17d3cf72e6c7741cd3781eef Mon Sep 17 00:00:00 2001 From: Alan Ghobadi Date: Thu, 4 Jul 2024 21:24:04 +0200 Subject: [PATCH] Add block_date to oneinch ar --- .../oneinch/AR/oneinch_ar_handle_generic.sql | 3 ++- .../oneinch/AR/oneinch_ar_handle_unoswap.sql | 3 ++- .../_project/oneinch/AR/oneinch_ar_macro.sql | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/dex/macros/models/_project/oneinch/AR/oneinch_ar_handle_generic.sql b/dex/macros/models/_project/oneinch/AR/oneinch_ar_handle_generic.sql index 8cf618d4a08..fcd37745c4f 100644 --- a/dex/macros/models/_project/oneinch/AR/oneinch_ar_handle_generic.sql +++ b/dex/macros/models/_project/oneinch/AR/oneinch_ar_handle_generic.sql @@ -1,4 +1,4 @@ -{% macro +{% macro oneinch_ar_handle_generic( contract, contract_data, @@ -15,6 +15,7 @@ select call_block_number as block_number , call_block_time as block_time + , date(date_trunc('day', call_block_time)) as block_date , call_tx_hash as tx_hash , '{{ contract }}' as contract_name , '{{ contract_data.version }}' as protocol_version diff --git a/dex/macros/models/_project/oneinch/AR/oneinch_ar_handle_unoswap.sql b/dex/macros/models/_project/oneinch/AR/oneinch_ar_handle_unoswap.sql index 788018404eb..2db17a592dd 100644 --- a/dex/macros/models/_project/oneinch/AR/oneinch_ar_handle_unoswap.sql +++ b/dex/macros/models/_project/oneinch/AR/oneinch_ar_handle_unoswap.sql @@ -1,4 +1,4 @@ -{% macro +{% macro oneinch_ar_handle_unoswap( contract, contract_data, @@ -16,6 +16,7 @@ select block_number , block_time + , date(date_trunc('day', call_block_time)) as block_date , tx_hash , '{{ contract }}' as contract_name , '{{ contract_data.version }}' as protocol_version diff --git a/dex/macros/models/_project/oneinch/AR/oneinch_ar_macro.sql b/dex/macros/models/_project/oneinch/AR/oneinch_ar_macro.sql index 244c05a8c6e..b0e6f2f5f9b 100644 --- a/dex/macros/models/_project/oneinch/AR/oneinch_ar_macro.sql +++ b/dex/macros/models/_project/oneinch/AR/oneinch_ar_macro.sql @@ -1,7 +1,7 @@ -{% macro +{% macro oneinch_ar_macro( blockchain - ) + ) %} @@ -9,14 +9,14 @@ {% set native = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' %} -with +with -- pools tokens for unoswap lineage tokens parsing pools_list as ( select pool as pool_address , tokens from {{ ref('dex_raw_pools') }} - where + where type in ('uniswap_compatible', 'curve_compatible') and blockchain = '{{ blockchain }}' group by 1, 2 @@ -25,7 +25,7 @@ pools_list as ( , calls as ( {% for contract, contract_data in oneinch_ar_cfg_contracts_macro().items() if blockchain in contract_data.blockchains %} - + select * from ( with traces_cte as ( select @@ -51,10 +51,10 @@ pools_list as ( {% endif %} ) - + {% for method, method_data in contract_data.methods.items() if blockchain in method_data.get('blockchains', contract_data.blockchains) %} -- method-level blockchains override contract-level blockchains {% if method_data.router_type in ['generic', 'clipper'] %} - {{ + {{ oneinch_ar_handle_generic( contract=contract, contract_data=contract_data, @@ -63,8 +63,8 @@ pools_list as ( blockchain=blockchain, traces_cte=traces_cte, start_date=contract_data['start'], - ) - }} + ) + }} {% elif method_data.router_type in ['unoswap'] %} {{ oneinch_ar_handle_unoswap( @@ -90,6 +90,7 @@ select blockchain , block_number , block_time + , block_date , tx_hash , tx_from , tx_to