diff --git a/dbt_macros/dune/expose_spells.sql b/dbt_macros/dune/config_trino_properties.sql similarity index 70% rename from dbt_macros/dune/expose_spells.sql rename to dbt_macros/dune/config_trino_properties.sql index 7420e9403fd..1b8592496a5 100644 --- a/dbt_macros/dune/expose_spells.sql +++ b/dbt_macros/dune/config_trino_properties.sql @@ -1,3 +1,12 @@ +{%- macro trino_properties(properties) -%} + map_from_entries(ARRAY[ + {%- for key, value in properties.items() %} + ROW('{{ key }}', '{{ value }}') + {%- if not loop.last -%},{%- endif -%} + {%- endfor %} + ]) +{%- endmacro -%} + {% macro expose_spells(blockchains, spell_type, spell_name, contributors) %} {%- set validated_contributors = tojson(fromjson(contributors | as_text)) -%} {%- if ("%s" % validated_contributors) == "null" -%} @@ -24,11 +33,20 @@ {%- endif -%} {%- endmacro -%} -{%- macro trino_properties(properties) -%} - map_from_entries(ARRAY[ - {%- for key, value in properties.items() %} - ROW('{{ key }}', '{{ value }}') - {%- if not loop.last -%},{%- endif -%} - {%- endfor %} - ]) -{%- endmacro -%} +{% macro hide_spells() %} + {%- if target.name == 'prod' -%} + {%- set properties = { + 'dune.public': 'false', + 'dune.data_explorer.category': 'abstraction', + 'dune.vacuum': '{"enabled":true}' + } -%} + {%- if model.config.materialized == "view" -%} + CALL {{ model.database }}._internal.alter_view_properties('{{ model.schema }}', '{{ model.alias }}', + {{ trino_properties(properties) }} + ) + {%- else -%} + ALTER TABLE {{ this }} + SET PROPERTIES extra_properties = {{ trino_properties(properties) }} + {%- endif -%} + {%- endif -%} +{%- endmacro -%} \ No newline at end of file diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/map_internal_to_dex.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/map_internal_to_dex.sql index 28e9d9a6014..962cc8b4e2d 100644 --- a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/map_internal_to_dex.sql +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/map_internal_to_dex.sql @@ -34,13 +34,42 @@ select COALESCE(evt_index, 0) as evt_index, -- TMP: after joining envents in swapSettle can remove it order_index, method + {% if version == 'v2' %} + ,from_hex(regexp_replace( + try_cast( + TRY_CAST( + BITWISE_RIGHT_SHIFT(partnerAndFee, 96) AS VARBINARY + ) as VARCHAR + ), + '0x(00){12}' + )) AS partnerAddress + ,computed_order_hash + ,evt_order_hash + ,bridgeMultiCallHandler + ,bridgeOutputToken + ,bridgeMaxRelayerFee + ,bridgeDestinationChainId + ,bridge + ,"order" + ,"owner" + ,ordersCount + ,call_block_number as block_number + ,raw_tx_gas_used + ,raw_tx_gas_price + ,{{from_alias}}.gas_fee_usd + ,wnt_price_usd + ,executor + ,evt_return_amount -- uint256 + ,evt_protocol_fee -- uint256 + ,evt_partner_fee -- uint256 + {% endif %} from {{from_alias}} LEFT JOIN {{ source('tokens', 'erc20') }} t_src_token ON t_src_token.blockchain = '{{blockchain}}' - AND t_src_token.contract_address = src_token + AND t_src_token.contract_address = src_token_for_joining LEFT JOIN {{ source('tokens', 'erc20') }} t_dest_token ON t_dest_token.blockchain = '{{blockchain}}' - AND t_dest_token.contract_address = dest_token + AND t_dest_token.contract_address = dest_token_for_joining {% endmacro %} diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/safe_settle_batch_swap.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/methods/safe_settle_batch_swap.sql similarity index 100% rename from dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/safe_settle_batch_swap.sql rename to dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/methods/safe_settle_batch_swap.sql diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/settle_swap.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/methods/settle_swap.sql similarity index 100% rename from dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/settle_swap.sql rename to dbt_subprojects/dex/macros/models/_project/paraswap/delta/v1/methods/settle_swap.sql diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/compute_order_hash.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/compute_order_hash.sql new file mode 100644 index 00000000000..261c9f4ea00 --- /dev/null +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/compute_order_hash.sql @@ -0,0 +1,67 @@ +{% macro compute_order_hash(blockchain) %} + +{% set network_to_chain_id = { + 'ethereum': 1, + 'optimism': 10, + 'base': 8453, +} %} + +-- SELECT + keccak( + concat( + X'1901', + + -- domain separator + keccak( + concat( + keccak(to_utf8('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')), + keccak(to_utf8('Portikus')), + keccak(to_utf8('2.0.0')), + lpad(cast(cast({{ network_to_chain_id[blockchain]}} AS uint256) AS varbinary), 32, X'00'), + lpad(from_hex('0000000000bbf5c5fd284e657f01bd000933c96d'), 32, X'00') + ) + ), + + -- struct hash + keccak( + concat( + keccak(to_utf8('Order(address owner,address beneficiary,address srcToken,address destToken,uint256 srcAmount,uint256 destAmount,uint256 expectedDestAmount,uint256 deadline,uint256 nonce,uint256 partnerAndFee,bytes permit)')), + -- lpad(from_hex('12924049e2d21664e35387c69429c98e9891a820'), 32, X'00'), -- owner + lpad(owner, 32, X'00'), + -- lpad(from_hex('12924049e2d21664e35387c69429c98e9891a820'), 32, X'00'), -- beneficiary + lpad(beneficiary, 32, X'00'), -- beneficiary + -- lpad(from_hex('04c154b66cb340f3ae24111cc767e0184ed00cc6'), 32, X'00'), -- srcToken + lpad(srcToken, 32, X'00'), -- srcToken + -- lpad(from_hex('eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'), 32, X'00'), -- destToken + lpad(destToken, 32, X'00'), -- destToken + -- lpad(cast(cast('1202939820354578' AS uint256) AS varbinary), 32, X'00'), -- srcAmount + lpad(cast(srcAmount AS varbinary), 32, X'00'), -- srcAmount + -- lpad(cast(cast('868930905657826' AS uint256) AS varbinary), 32, X'00'), -- destAmount + lpad(cast(destAmount AS varbinary), 32, X'00'), -- destAmount + -- lpad(cast(cast('873297392620931' AS uint256) AS varbinary), 32, X'00'), -- expectedDestAmount + lpad(cast(expectedDestAmount AS varbinary), 32, X'00'), -- expectedDestAmount + -- lpad(cast(cast('1740790593' AS uint256) AS varbinary), 32, X'00'), -- deadline + lpad(cast(deadline AS varbinary), 32, X'00'), -- deadline + -- lpad(cast(cast('1740787014424' AS uint256) AS varbinary), 32, X'00'), -- nonce + lpad(cast(nonce AS varbinary), 32, X'00'), -- nonce + -- lpad(cast(cast('90631063861114836560958097440945986548822432573276877133894239693005947666432' AS uint256) AS varbinary), 32, X'00'), -- partnerAndFee + lpad(cast(partnerAndFee AS varbinary), 32, X'00'), -- partnerAndFee + -- permit: + -- lpad( + -- keccak(from_hex( + -- '00000000000000000000000012924049e2d21664e35387c69429c98e9891a8200000000000000000000000000000000000bbf5c5fd284e657f01bd000933c96d0000000000000000000000000000000000000000000000000004461140adac120000000000000000000000000000000000000000000000000000000067c641b2000000000000000000000000000000000000000000000000000000000000001bae25978476dcaf13eb21c5140c058bc49fd4d087f0f0d23b1ccede8f9288bb33450886d34539305ede3448c44206e89074d91afcdc8e07cabbe23cf45c67dd7c' + -- )), + -- 32, X'00' + -- ) + lpad( + keccak(permit), + 32, X'00' + ) + ) + ) + ) + ) + -- ) AS eip712_final_hash + + +{% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/compute_order_hash_with_bridge.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/compute_order_hash_with_bridge.sql new file mode 100644 index 00000000000..f0507f5f8e6 --- /dev/null +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/compute_order_hash_with_bridge.sql @@ -0,0 +1,76 @@ +{% macro compute_order_hash_with_bridge(blockchain) %} + +{% set network_to_chain_id = { + 'ethereum': 1, + 'optimism': 10, + 'base': 8453, +} %} + +-- SELECT + keccak( + concat( + X'1901', + + -- domain separator + keccak( + concat( + keccak(to_utf8('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')), + keccak(to_utf8('Portikus')), + keccak(to_utf8('2.0.0')), + lpad(cast(cast({{ network_to_chain_id[blockchain]}} AS uint256) AS varbinary), 32, X'00'), + lpad(from_hex('0000000000bbf5c5fd284e657f01bd000933c96d'), 32, X'00') + ) + ), + + -- Order struct hash + keccak( + concat( + keccak(to_utf8( + 'Order(address owner,address beneficiary,address srcToken,address destToken,uint256 srcAmount,uint256 destAmount,uint256 expectedDestAmount,uint256 deadline,uint256 nonce,uint256 partnerAndFee,bytes permit,Bridge bridge)Bridge(uint256 maxRelayerFee,uint256 destinationChainId,address outputToken,address multiCallHandler)' + )), + + -- lpad(from_hex('6d383975c64eebe1251e50c3ab0e53537342bde9'), 32, X'00'), -- owner + lpad(owner, 32, X'00'), + -- lpad(from_hex('6d383975c64eebe1251e50c3ab0e53537342bde9'), 32, X'00'), -- beneficiary + lpad(beneficiary, 32, X'00'), -- beneficiary + -- lpad(from_hex('f469fbd2abcd6b9de8e169d128226c0fc90a012e'), 32, X'00'), -- srcToken + lpad(srcToken, 32, X'00'), -- srcToken + -- lpad(from_hex('eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'), 32, X'00'), -- destToken + lpad(destToken, 32, X'00'), -- destToken + -- lpad(cast(cast('422561' as uint256) AS varbinary), 32, X'00'), + lpad(cast(srcAmount AS varbinary), 32, X'00'), -- srcAmount + -- lpad(cast(cast('168106215780811752' as uint256) AS varbinary), 32, X'00'), + lpad(cast(destAmount AS varbinary), 32, X'00'), -- destAmount + -- lpad(cast(cast('168950970633981661' as uint256) AS varbinary), 32, X'00'), + lpad(cast(expectedDestAmount AS varbinary), 32, X'00'), -- expectedDestAmount + -- lpad(cast(cast('1747024424' as uint256) AS varbinary), 32, X'00'), + lpad(cast(deadline AS varbinary), 32, X'00'), -- deadline + -- lpad(cast(cast('1747020844040' as uint256) AS varbinary), 32, X'00'), + lpad(cast(nonce AS varbinary), 32, X'00'), -- nonce + -- lpad(cast(cast('90631063861114836560958097440945986548822432573276877133894239693005947666447' as uint256) AS varbinary), 32, X'00'), + lpad(cast(partnerAndFee AS varbinary), 32, X'00'), -- partnerAndFee + + -- Permit (empty: 0x, not 0x00) + -- lpad(keccak(from_hex('')), 32, X'00'), + lpad( + keccak(permit), + 32, X'00' + ), + -- Bridge struct hash (inlined) + keccak( + concat( + keccak(to_utf8('Bridge(uint256 maxRelayerFee,uint256 destinationChainId,address outputToken,address multiCallHandler)')), + lpad(cast(cast(bridgeMaxRelayerFee as uint256) AS varbinary), 32, X'00'), + lpad(cast(cast(bridgeDestinationChainId as uint256) AS varbinary), 32, X'00'), + lpad(bridgeOutputToken, 32, X'00'), + lpad(bridgeMultiCallHandler, 32, X'00') + ) + ) + ) + ) + ) + ) + -- ) AS eip712_body_hash; + + +{% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/executor_fee_amount.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/executor_fee_amount.sql index 67a808b6a63..a79dc5349c6 100644 --- a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/executor_fee_amount.sql +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/executor_fee_amount.sql @@ -16,7 +16,8 @@ -- } CASE WHEN executor = 0x6bb000067005450704003100632eb93ea00c0000 THEN varbinary_to_uint256(varbinary_substring(executorData, 161, 32)) - -- WHEN executor = 0x0500b5050c40e06ed700005dd7cb0ef0b0d0a000 THEN "TODO: join augustus executor contract call and return the output" + -- WHEN executor = 0x10100dcac00088044067a00d520a0f7900000770 THEN "TODO: join augustus executor contract call and return the output" + -- 0x0500b5050c40e06ed700005dd7cb0ef0b0d0a000 - staging one ELSE 0 END as "executorFeeAmount" {% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/executor_fee_amount_usd.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/executor_fee_amount_usd.sql index 2616713e31a..a6d6bcbc279 100644 --- a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/executor_fee_amount_usd.sql +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/executor_fee_amount_usd.sql @@ -1,8 +1,13 @@ {% macro gas_fee_usd() %} - COALESCE( - d.price * w.executorFeeAmount / POWER(10, d.decimals), -- compute directly (dest token is gas fee compensation if it's augustus axecutor) - s.price * w.srcAmount / POWER(10, s.decimals) * CAST (w.executorFeeAmount AS DECIMAL) / (CAST (w.destAmount AS DECIMAL)), -- compute pro-rata based on src token if it's augustus executor - -- TODO: also add 3rd party executor fee compensation -- based on spent native token, divided by amount of orders if multiple - 0 - ) AS gas_fee_usd + case + WHEN w.executorFeeAmount > 0 + then + COALESCE( + d.price * w.executorFeeAmount / POWER(10, d.decimals), -- compute directly (dest token is gas fee compensation if it's augustus axecutor) + s.price * w.srcAmount / POWER(10, s.decimals) * CAST (w.executorFeeAmount AS DECIMAL) / (CAST (w.destAmount AS DECIMAL)) -- compute pro-rata based on src token if it's augustus executor + ) + else + -- if can't parse executorFeeAmount - fall back to spent native token, divided by amount of orders if multiple + wnt_usd.price * raw_tx_gas_used * raw_tx_gas_price / POWER(10, wnt_usd.decimals) / ordersCount + END AS gas_fee_usd {% endmacro %} diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/methods/swap_settle.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/methods/swap_settle.sql index e45085a981f..85372e3de98 100644 --- a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/methods/swap_settle.sql +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/methods/swap_settle.sql @@ -1,5 +1,30 @@ {% macro delta_v2_swap_settle(blockchain) %} -- since this call always is a whole-order-at-once fulfillment, can source it from method calls and no need to join with events as all data is in the call +{% set method_start_date = '2024-11-04' %} +-- order_hash_computed + + + +-- ParaswapDeltav2_evt_OrderSettled +-- contract_address varbinary +-- evt_tx_hash varbinary +-- evt_tx_from varbinary +-- evt_tx_to varbinary +-- evt_index bigint +-- evt_block_time timestamp +-- evt_block_number bigint +-- owner varbinary +-- beneficiary varbinary +-- orderHash varbinary +-- srcToken varbinary +-- destToken varbinary +-- srcAmount uint256 +-- destAmount uint256 +-- returnAmount uint256 +-- protocolFee uint256 +-- partnerFee uint256 + + v2_swap_settle_withParsedOrderData AS ( SELECT call_trace_address, @@ -11,9 +36,16 @@ v2_swap_settle_withParsedOrderData AS ( orderWithSig, executor, executorData, - contract_address - FROM {{ source("paraswapdelta_"+ blockchain, "ParaswapDeltav2_call_swapSettle") }} - where call_success = true + contract_address, + raw_txs.gas_used as raw_tx_gas_used, + raw_txs.gas_price as raw_tx_gas_price, + 1 as ordersCount + FROM {{ source("paraswapdelta_"+ blockchain, "ParaswapDeltav2_call_swapSettle") }} ss + left join {{source(blockchain, "transactions")}} raw_txs + on block_time > TIMESTAMP '{{method_start_date}}' + AND raw_txs.hash = ss.call_tx_hash + WHERE call_block_time > TIMESTAMP '{{method_start_date}}' + AND call_success = true {% if is_incremental() %} AND {{ incremental_predicate('call_block_time') }} {% endif %} @@ -33,6 +65,7 @@ v2_swap_settle_unparsedOrders AS ( ), v2_swap_settle_parsedOrders AS ( SELECT + JSON_EXTRACT_SCALAR(JSON_PARSE(TRY_CAST("order" AS VARCHAR)), '$.bridge') AS "bridge", from_hex(JSON_EXTRACT_SCALAR("order", '$.owner')) as owner, from_hex(JSON_EXTRACT_SCALAR("order", '$.beneficiary')) as beneficiary, from_hex(JSON_EXTRACT_SCALAR("order", '$.srcToken')) as srcToken, @@ -40,21 +73,35 @@ v2_swap_settle_parsedOrders AS ( cast(JSON_EXTRACT_SCALAR("order", '$.srcAmount') as uint256) as srcAmount, cast(JSON_EXTRACT_SCALAR("order", '$.destAmount') as uint256) as destAmount, cast(JSON_EXTRACT_SCALAR("order", '$.expectedDestAmount') as uint256) as expectedDestAmount, - JSON_EXTRACT_SCALAR("order", '$.deadline') as deadline, - JSON_EXTRACT_SCALAR("order", '$.nonce') as nonce, - JSON_EXTRACT_SCALAR("order", '$.partnerAndFee') as partnerAndFee, - JSON_EXTRACT_SCALAR("order", '$.permit') as permit, + cast(JSON_EXTRACT_SCALAR("order", '$.deadline') as uint256) as deadline, + cast(JSON_EXTRACT_SCALAR("order", '$.nonce') as uint256) as nonce, + cast(JSON_EXTRACT_SCALAR("order", '$.partnerAndFee') as uint256) as partnerAndFee, + from_hex(JSON_EXTRACT_SCALAR("order", '$.permit')) as permit, {{executor_fee_amount()}}, * FROM v2_swap_settle_unparsedOrders ), v2_swap_settle_with_wrapped_native AS ( SELECT + from_hex(JSON_EXTRACT_SCALAR("bridge", '$.multiCallHandler')) as bridgeMultiCallHandler, + from_hex(JSON_EXTRACT_SCALAR("bridge", '$.outputToken')) as bridgeOutputToken, + cast(JSON_EXTRACT_SCALAR("bridge", '$.maxRelayerFee') as uint256) as bridgeMaxRelayerFee, + cast(JSON_EXTRACT_SCALAR("bridge", '$.destinationChainId') as uint256) as bridgeDestinationChainId, {{to_wrapped_native_token(blockchain, 'destToken', 'dest_token_for_joining')}}, {{to_wrapped_native_token(blockchain, 'srcToken', 'src_token_for_joining')}}, * FROM v2_swap_settle_parsedOrders -), delta_v2_swapSettle_master as ( +), v2_swap_settle_with_wrapped_native_with_orderhash as ( + select + *, + CASE WHEN bridge IS NULL THEN + {{ compute_order_hash(blockchain) }} + ELSE + {{ compute_order_hash_with_bridge(blockchain) }} + END as computed_order_hash + from v2_swap_settle_with_wrapped_native +), +delta_v2_swapSettle_master as ( select 'swapSettle' as method, COALESCE(CAST(s.price AS DECIMAL(38,18)), 0) AS src_token_price_usd, @@ -62,25 +109,48 @@ select {{ gas_fee_usd() }}, s.price * w.srcAmount / POWER(10, s.decimals) AS src_token_order_usd, d.price * w.destAmount / POWER(10, d.decimals) AS dest_token_order_usd, + wrapped_native_token_address, + COALESCE(CAST(wnt_usd.price AS DECIMAL(38,18)), 0) AS wnt_price_usd, w.destToken AS fee_token, - w.* - FROM v2_swap_settle_with_wrapped_native w + w.*, + events.evt_index, + events.returnAmount as evt_return_amount, + events.protocolFee as evt_protocol_fee, + events.partnerFee as evt_partner_fee, + events.orderHash as evt_order_hash + FROM v2_swap_settle_with_wrapped_native_with_orderhash w + left join {{ source('evms','info') }} evm_info on evm_info.blockchain='{{blockchain}}' + LEFT JOIN {{ source('prices', 'usd') }} wnt_usd + ON wnt_usd.minute > TIMESTAMP '{{method_start_date}}' + AND wnt_usd.blockchain = '{{blockchain}}' + {% if is_incremental() %} + AND {{ incremental_predicate('wnt_usd.minute') }} + {% endif %} + AND wnt_usd.contract_address = evm_info.wrapped_native_token_address + AND wnt_usd.minute = DATE_TRUNC('minute', w.call_block_time) LEFT JOIN {{ source('prices', 'usd') }} d - ON d.blockchain = '{{blockchain}}' - AND d.minute > TIMESTAMP '2024-06-01' + ON d.minute > TIMESTAMP '{{method_start_date}}' + AND d.blockchain = '{{blockchain}}' {% if is_incremental() %} AND {{ incremental_predicate('d.minute') }} {% endif %} AND d.contract_address = w.dest_token_for_joining AND d.minute = DATE_TRUNC('minute', w.call_block_time) LEFT JOIN {{ source('prices', 'usd') }} s - ON s.blockchain = '{{blockchain}}' - AND s.minute > TIMESTAMP '2024-06-01' + ON s.minute > TIMESTAMP '{{method_start_date}}' + AND s.blockchain = '{{blockchain}}' {% if is_incremental() %} AND {{ incremental_predicate('s.minute') }} {% endif %} AND s.contract_address = w.src_token_for_joining AND s.minute = DATE_TRUNC('minute', w.call_block_time) + + LEFT JOIN {{ source("paraswapdelta_"+ blockchain, "ParaswapDeltav2_evt_OrderSettled") }} events + ON + evt_block_time = call_block_time + -- suffices for fill-all-at-once methods (unlike partials, because with partials there's an edge case when you can mismatch still, although very unlikely to happen in real life) + AND computed_order_hash = events.orderHash + AND call_tx_hash = events.evt_tx_hash ), delta_v2_swapSettle as ( SELECT -- NB: columns mapping must match accross all the methods, since they're uninoned into one in master macro @@ -93,8 +163,8 @@ SELECT call_tx_hash, call_tx_from, call_tx_to, - cast(NULL as bigint) as evt_index, -- TODO - executorFeeAmount as fee_amount, + evt_index, + executorFeeAmount as executor_fee_amount, -- orderWithSig as order_with_sig, executor, executorData as calldata_to_execute, @@ -110,10 +180,28 @@ SELECT fee_token, src_token_price_usd, dest_token_price_usd, - gas_fee_usd, + gas_fee_usd, + raw_tx_gas_used, + raw_tx_gas_price, + wnt_price_usd, + ordersCount, src_token_order_usd, dest_token_order_usd, - contract_address + contract_address, + partnerAndFee, + computed_order_hash, + evt_order_hash, + evt_return_amount, + evt_protocol_fee, + evt_partner_fee, + bridgeMultiCallHandler, + bridgeOutputToken, + bridgeMaxRelayerFee, + bridgeDestinationChainId, + bridge, + "order", + wrapped_native_token_address + FROM delta_v2_swapSettle_master ) {% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/methods/swap_settle_batch.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/methods/swap_settle_batch.sql index c4367a477a2..91c5771da86 100644 --- a/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/methods/swap_settle_batch.sql +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/delta/v2/methods/swap_settle_batch.sql @@ -1,58 +1,46 @@ {% macro delta_v2_swap_settle_batch(blockchain) %} + +{% set method_start_date = '2024-11-04' %} + delta_v2_swap_settle_batch_ExpandedOrders as ( select - ROW_NUMBER() OVER (ORDER BY call_block_time, call_tx_hash, call_trace_address, order_index) AS rn, - * from - ( - SELECT - order_index, - contract_address, -- varbinary - -- call_success, -- boolean - call_tx_hash, -- varbinary - call_tx_from, -- varbinary - call_tx_to, -- varbinary - call_trace_address, -- array(bigint) - call_block_time, -- timestamp - call_block_number, -- bigint - -- ordersWithSigs[order_index] as extractedOrderWithSig, - JSON_EXTRACT_SCALAR(ordersWithSigs[order_index], '$.order') as "order", -- returns json - JSON_EXTRACT_SCALAR(ordersWithSigs[order_index], '$.signature') as signature, - executor, - executorData[order_index] as executorData - FROM {{ source("paraswapdelta_"+ blockchain, "ParaswapDeltav2_call_swapSettleBatch") }} - CROSS JOIN UNNEST ( - -- SQL array indices start at 1 - -- also NB: if one order fails -- whole batch fails - -- also NB: edge case: a multi-tx call, where some other method emits event with similar signature --> not valid as it won't end up in the table - SEQUENCE(1, CARDINALITY(ordersWithSigs) ) - ) AS t (order_index) - WHERE - call_success = true - {% if is_incremental() %} - AND {{ incremental_predicate('call_block_time') }} - {% endif %} - ) -), -delta_v2_swap_settle_batch_OrderSettledEvents as ( - SELECT - -- TODO: need a sample tx to make sure this ordering and then joining by the order down below is correct - ROW_NUMBER() OVER (ORDER BY evt_block_time, evt_tx_hash, evt_index) AS rn, - * - FROM - - ( - SELECT * FROM {{ source("paraswapdelta_"+ blockchain, "ParaswapDeltav2_evt_OrderSettled") }} - -- important conditional - since OrderSettled is emitted by multilple methods - -- this filtering still not 100% fix -- as theoretically multiple methods can be combined in on call - -- consider case when settleSwap and settleBatchSwap are combined in one call - WHERE evt_tx_hash in (select call_tx_hash from delta_v2_swap_settle_batch_ExpandedOrders) + order_index, + contract_address, -- varbinary + -- call_success, -- boolean + call_tx_hash, -- varbinary + call_tx_from, -- varbinary + call_tx_to, -- varbinary + call_trace_address, -- array(bigint) + call_block_time, -- timestamp + call_block_number, -- bigint + -- ordersWithSigs[order_index] as extractedOrderWithSig, + JSON_EXTRACT_SCALAR(ordersWithSigs[order_index], '$.order') as "order", -- returns json + JSON_EXTRACT_SCALAR(ordersWithSigs[order_index], '$.signature') as signature, + CARDINALITY(ordersWithSigs) as ordersCount, + executor, + executorData[order_index] as executorData, + raw_txs.gas_used as raw_tx_gas_used, + raw_txs.gas_price as raw_tx_gas_price + FROM {{ source("paraswapdelta_"+ blockchain, "ParaswapDeltav2_call_swapSettleBatch") }} ssb + left join {{source(blockchain, "transactions")}} raw_txs + on block_time > TIMESTAMP '{{method_start_date}}' + AND raw_txs.hash = ssb.call_tx_hash + CROSS JOIN UNNEST ( + -- SQL array indices start at 1 + -- also NB: if one order fails -- whole batch fails + -- also NB: edge case: a multi-tx call, where some other method emits event with similar signature --> not valid as it won't end up in the table + SEQUENCE(1, CARDINALITY(ordersWithSigs) ) + ) AS t (order_index) + WHERE call_block_time > TIMESTAMP '{{method_start_date}}' + AND call_success = true {% if is_incremental() %} - AND {{ incremental_predicate('evt_block_time') }} - {% endif %} - ) + AND {{ incremental_predicate('call_block_time') }} + {% endif %} + ), delta_v2_swap_settle_batch_parsed_orders as ( select + JSON_EXTRACT_SCALAR(JSON_PARSE(TRY_CAST("order" AS VARCHAR)), '$.bridge') AS "bridge", from_hex(JSON_EXTRACT_SCALAR("order", '$.owner')) as owner, from_hex(JSON_EXTRACT_SCALAR("order", '$.beneficiary')) as beneficiary, from_hex(JSON_EXTRACT_SCALAR("order", '$.srcToken')) as srcToken, @@ -60,61 +48,90 @@ delta_v2_swap_settle_batch_parsed_orders as ( cast(JSON_EXTRACT_SCALAR("order", '$.srcAmount') as uint256) as srcAmount, cast(JSON_EXTRACT_SCALAR("order", '$.destAmount') as uint256) as destAmount, cast(JSON_EXTRACT_SCALAR("order", '$.expectedDestAmount') as uint256) as expectedDestAmount, - JSON_EXTRACT_SCALAR("order", '$.deadline') as deadline, - JSON_EXTRACT_SCALAR("order", '$.nonce') as nonce, - JSON_EXTRACT_SCALAR("order", '$.partnerAndFee') as partnerAndFee, - JSON_EXTRACT_SCALAR("order", '$.permit') as permit, + cast(JSON_EXTRACT_SCALAR("order", '$.deadline') as uint256) as deadline, + cast(JSON_EXTRACT_SCALAR("order", '$.nonce') as uint256) as nonce, + cast(JSON_EXTRACT_SCALAR("order", '$.partnerAndFee') as uint256) as partnerAndFee, + from_hex(JSON_EXTRACT_SCALAR("order", '$.permit')) as permit, {{executor_fee_amount()}}, * from delta_v2_swap_settle_batch_ExpandedOrders -), delta_v2_swap_settle_batch_withWrapped as ( +), +delta_v2_swap_settle_batch_parsed_orders_with_orderhash as ( + select + *, + from_hex(JSON_EXTRACT_SCALAR("bridge", '$.multiCallHandler')) as bridgeMultiCallHandler, + from_hex(JSON_EXTRACT_SCALAR("bridge", '$.outputToken')) as bridgeOutputToken, + cast(JSON_EXTRACT_SCALAR("bridge", '$.maxRelayerFee') as uint256) as bridgeMaxRelayerFee, + cast(JSON_EXTRACT_SCALAR("bridge", '$.destinationChainId') as uint256) as bridgeDestinationChainId + from delta_v2_swap_settle_batch_parsed_orders +), +delta_v2_swap_settle_batch_withWrapped as ( SELECT + CASE WHEN bridge IS NULL THEN + {{ compute_order_hash(blockchain) }} + ELSE + {{ compute_order_hash_with_bridge(blockchain) }} + END as computed_order_hash, {{to_wrapped_native_token(blockchain, 'orders.destToken', 'dest_token_for_joining')}}, {{to_wrapped_native_token(blockchain, 'orders.srcToken', 'src_token_for_joining')}}, - events.returnAmount, - events.protocolFee, - events.partnerFee, + orders.* + FROM delta_v2_swap_settle_batch_parsed_orders_with_orderhash orders +), +delta_v2_swap_settle_batch_withEvents as ( + select events.evt_index, - orders.* - FROM delta_v2_swap_settle_batch_parsed_orders orders - --- NB: sourcing from calls and joining events, not the opposite, because some methods emit different events (*fill* -> OrderSettled / OrderPartiallyFilled). Sorting them by evt_index would make them match orders sorted by their index in array + call_trace_address -> source of truth bettr be calls - LEFT JOIN delta_v2_swap_settle_batch_OrderSettledEvents events - ON orders.rn = events.rn - AND orders.call_tx_hash = events.evt_tx_hash - -- TODO: compute hash and join by orderHash instead -- that would be sufficiently strict for fill-all-at-once methods (unlike partials, because with partials there's an edge case when you can mismatch still, although very unlikely to happen in real life) - -- but for "full-single-fulfillment" methods, -- this template will work - -- https://paraswap.slack.com/archives/C073CNPHUS2/p1736331626761619?thread_ts=1736325828.398779&cid=C073CNPHUS2 - AND orders.owner = events.owner - AND orders.beneficiary = events.beneficiary - AND orders.srcToken = events.srcToken - AND orders.destToken = events.destToken - AND orders.srcAmount = events.srcAmount - AND orders.destAmount = events.destAmount -), delta_v2_swapSettleBatch_master as ( + events.orderHash as evt_order_hash, + events.returnAmount as evt_return_amount, + events.protocolFee as evt_protocol_fee, + events.partnerFee as evt_partner_fee, + withWrapped.* + from delta_v2_swap_settle_batch_withWrapped withWrapped + --- NB: sourcing from calls and joining events, not the opposite, because some methods emit different events (*fill* -> OrderSettled / OrderPartiallyFilled). Sorting them by evt_index would make them match orders sorted by their index in array + call_trace_address -> source of truth bettr be calls + LEFT JOIN {{ source("paraswapdelta_"+ blockchain, "ParaswapDeltav2_evt_OrderSettled") }} events + ON + evt_block_time = call_block_time + -- suffices for fill-all-at-once methods (unlike partials, because with partials there's an edge case when you can mismatch still, although very unlikely to happen in real life) + AND computed_order_hash = events.orderHash + AND call_tx_hash = events.evt_tx_hash + +), + delta_v2_swapSettleBatch_master as ( select 'swapSettleBatch' as method, + -- COALESCE(CAST(s.price AS DECIMAL(38,18)), 0) AS src_token_price_usd, - COALESCE(CAST(d.price AS DECIMAL(38,18)), 0) AS dest_token_price_usd, - {{ gas_fee_usd() }}, + COALESCE(CAST(d.price AS DECIMAL(38,18)), 0) AS dest_token_price_usd, s.price * w.srcAmount / POWER(10, s.decimals) AS src_token_order_usd, d.price * w.destAmount / POWER(10, d.decimals) AS dest_token_order_usd, w.destToken AS fee_token, + wrapped_native_token_address, + COALESCE(CAST(wnt_usd.price AS DECIMAL(38,18)), 0) AS wnt_price_usd, + {{ gas_fee_usd() }}, w.* -from delta_v2_swap_settle_batch_withWrapped w +from delta_v2_swap_settle_batch_withEvents w LEFT JOIN {{ source('prices', 'usd') }} d - ON d.blockchain = '{{blockchain}}' - AND d.minute > TIMESTAMP '2024-06-01' + ON d.minute > TIMESTAMP '{{method_start_date}}' + AND d.blockchain = '{{blockchain}}' {% if is_incremental() %} AND {{ incremental_predicate('d.minute') }} {% endif %} AND d.contract_address = w.dest_token_for_joining AND d.minute = DATE_TRUNC('minute', w.call_block_time) + left join {{ source('evms','info') }} evm_info on evm_info.blockchain='{{blockchain}}' + LEFT JOIN {{ source('prices', 'usd') }} wnt_usd + ON wnt_usd.minute > TIMESTAMP '{{method_start_date}}' + AND wnt_usd.blockchain = '{{blockchain}}' + {% if is_incremental() %} + AND {{ incremental_predicate('wnt_usd.minute') }} + {% endif %} + AND wnt_usd.contract_address = evm_info.wrapped_native_token_address + AND wnt_usd.minute = DATE_TRUNC('minute', w.call_block_time) LEFT JOIN {{ source('prices', 'usd') }} s - ON s.blockchain = '{{blockchain}}' - AND s.minute > TIMESTAMP '2024-06-01' + ON s.minute > TIMESTAMP '{{method_start_date}}' + AND s.blockchain = '{{blockchain}}' {% if is_incremental() %} AND {{ incremental_predicate('s.minute') }} {% endif %} @@ -137,13 +154,13 @@ from delta_v2_swap_settle_batch_withWrapped w -- destToken varbinary -- srcAmount uint256 -- destAmount uint256 --- returnAmount uint256 -- TODO: add this field to the model --- protocolFee uint256 -- TODO: add this field to the model --- partnerFee uint256 -- TODO: add this field to the model +-- returnAmount uint256 +-- protocolFee uint256 +-- partnerFee uint256 ), delta_v2_swapSettleBatch as ( SELECT - -- NB: columns mapping must match accross all the methods, since they're uninoned into one in master macro - '{{blockchain}}' as blockchain, + -- NB: columns mapping must match accross all the methods, since they're unioned into one in master macro + '{{blockchain}}' as blockchain, method, order_index, call_trace_address, @@ -153,7 +170,7 @@ SELECT call_tx_from, call_tx_to, evt_index, - executorFeeAmount as fee_amount, + executorFeeAmount as executor_fee_amount, -- orderWithSig as order_with_sig, executor, executorData as calldata_to_execute, @@ -169,10 +186,27 @@ SELECT fee_token, src_token_price_usd, dest_token_price_usd, - gas_fee_usd, + gas_fee_usd, + raw_tx_gas_used, + raw_tx_gas_price, + wnt_price_usd, + ordersCount, src_token_order_usd, dest_token_order_usd, - contract_address + contract_address, + partnerAndFee, + computed_order_hash, + evt_order_hash, + evt_return_amount, + evt_protocol_fee, + evt_partner_fee, + bridgeMultiCallHandler, + bridgeOutputToken, + bridgeMaxRelayerFee, + bridgeDestinationChainId, + bridge, + "order", + wrapped_native_token_address FROM delta_v2_swapSettleBatch_master ) {% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/arbitrum/tokens_arbitrum_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/arbitrum/tokens_arbitrum_balances.sql index d6becb3d289..c3393519d74 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/arbitrum/tokens_arbitrum_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/arbitrum/tokens_arbitrum_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_arbitrum', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["arbitrum"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/arbitrum/tokens_arbitrum_balances_daily.sql b/dbt_subprojects/tokens/models/transfers_and_balances/arbitrum/tokens_arbitrum_balances_daily.sql index a0171f63ef9..9a994f93cc5 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/arbitrum/tokens_arbitrum_balances_daily.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/arbitrum/tokens_arbitrum_balances_daily.sql @@ -2,11 +2,7 @@ schema = 'tokens_arbitrum', alias = 'balances_daily', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["arbitrum"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["0xRob"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/avalanche_c/tokens_avalanche_c_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/avalanche_c/tokens_avalanche_c_balances.sql index 4b81b675faf..9129b19905d 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/avalanche_c/tokens_avalanche_c_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/avalanche_c/tokens_avalanche_c_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_avalanche_c', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["avalanche_c"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/avalanche_c/tokens_avalanche_c_balances_daily.sql b/dbt_subprojects/tokens/models/transfers_and_balances/avalanche_c/tokens_avalanche_c_balances_daily.sql index 5568b2beaa4..ab3aae499a1 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/avalanche_c/tokens_avalanche_c_balances_daily.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/avalanche_c/tokens_avalanche_c_balances_daily.sql @@ -2,11 +2,7 @@ schema = 'tokens_avalanche_c', alias = 'balances_daily', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["avalanche_c"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["0xRob"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/base/tokens_base_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/base/tokens_base_balances.sql index e26ba41c5b4..0580f9a249f 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/base/tokens_base_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/base/tokens_base_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_base', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["base"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/base/tokens_base_balances_daily.sql b/dbt_subprojects/tokens/models/transfers_and_balances/base/tokens_base_balances_daily.sql index 3b66eaa17d1..18276ccb4fe 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/base/tokens_base_balances_daily.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/base/tokens_base_balances_daily.sql @@ -2,11 +2,7 @@ schema = 'tokens_base', alias = 'balances_daily', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["base"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["0xRob"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/bitcoin/balances_bitcoin_satoshi_day.sql b/dbt_subprojects/tokens/models/transfers_and_balances/bitcoin/balances_bitcoin_satoshi_day.sql index c24ac2a15c7..69e504157bb 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/bitcoin/balances_bitcoin_satoshi_day.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/bitcoin/balances_bitcoin_satoshi_day.sql @@ -3,10 +3,7 @@ alias = 'satoshi_day', partition_by = ['day'], - post_hook='{{ expose_spells(\'["bitcoin"]\', - "sector", - "balances", - \'["longnhbkhn"]\') }}' + post_hook='{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/bitcoin/balances_bitcoin_satoshi_latest_day.sql b/dbt_subprojects/tokens/models/transfers_and_balances/bitcoin/balances_bitcoin_satoshi_latest_day.sql index 02d4b313002..f43bb4aeb63 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/bitcoin/balances_bitcoin_satoshi_latest_day.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/bitcoin/balances_bitcoin_satoshi_latest_day.sql @@ -3,10 +3,7 @@ alias = 'satoshi_latest_day', materialized='view', - post_hook='{{ expose_spells(\'["bitcoin"]\', - "sector", - "balances", - \'["gandalf"]\') }}' + post_hook='{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/bnb/tokens_bnb_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/bnb/tokens_bnb_balances.sql index 9016b5a430f..7eba1d35ea7 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/bnb/tokens_bnb_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/bnb/tokens_bnb_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_bnb', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["bnb"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/ethereum/tokens_ethereum_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/ethereum/tokens_ethereum_balances.sql index 8b2f5b05427..cdd8ec510b3 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/ethereum/tokens_ethereum_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/ethereum/tokens_ethereum_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_ethereum', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["ethereum"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/ethereum/tokens_ethereum_balances_daily.sql b/dbt_subprojects/tokens/models/transfers_and_balances/ethereum/tokens_ethereum_balances_daily.sql index b40c2ab306f..c158bb6ace8 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/ethereum/tokens_ethereum_balances_daily.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/ethereum/tokens_ethereum_balances_daily.sql @@ -2,11 +2,7 @@ schema = 'tokens_ethereum', alias = 'balances_daily', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["ethereum"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["0xRob"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/kaia/tokens_kaia_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/kaia/tokens_kaia_balances.sql index f272f899bf5..ae0e917b6a2 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/kaia/tokens_kaia_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/kaia/tokens_kaia_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_kaia', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["kaia"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/kaia/tokens_kaia_balances_daily.sql b/dbt_subprojects/tokens/models/transfers_and_balances/kaia/tokens_kaia_balances_daily.sql index 4d75e57f504..26d3cec3712 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/kaia/tokens_kaia_balances_daily.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/kaia/tokens_kaia_balances_daily.sql @@ -2,11 +2,7 @@ schema = 'tokens_kaia', alias = 'balances_daily', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["kaia"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["0xRob"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/linea/tokens_linea_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/linea/tokens_linea_balances.sql index 21276af0455..1e7440dbc76 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/linea/tokens_linea_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/linea/tokens_linea_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_linea', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["linea"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/linea/tokens_linea_balances_daily.sql b/dbt_subprojects/tokens/models/transfers_and_balances/linea/tokens_linea_balances_daily.sql index 33f32d8802b..cdac4effc5e 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/linea/tokens_linea_balances_daily.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/linea/tokens_linea_balances_daily.sql @@ -2,11 +2,7 @@ schema = 'tokens_linea', alias = 'balances_daily', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["linea"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["0xRob"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/optimism/tokens_optimism_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/optimism/tokens_optimism_balances.sql index 38818defdc0..266a43d031b 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/optimism/tokens_optimism_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/optimism/tokens_optimism_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_optimism', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["optimism"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/optimism/tokens_optimism_balances_daily.sql b/dbt_subprojects/tokens/models/transfers_and_balances/optimism/tokens_optimism_balances_daily.sql index fde7c997840..3bb3362dfb0 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/optimism/tokens_optimism_balances_daily.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/optimism/tokens_optimism_balances_daily.sql @@ -2,11 +2,7 @@ schema = 'tokens_optimism', alias = 'balances_daily', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["optimism"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["0xRob"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/polygon/tokens_polygon_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/polygon/tokens_polygon_balances.sql index 6783852122a..ca0caaa8c58 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/polygon/tokens_polygon_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/polygon/tokens_polygon_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_polygon', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["polygon"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/polygon/tokens_polygon_balances_daily.sql b/dbt_subprojects/tokens/models/transfers_and_balances/polygon/tokens_polygon_balances_daily.sql index a6c35a796f0..af3b5897741 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/polygon/tokens_polygon_balances_daily.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/polygon/tokens_polygon_balances_daily.sql @@ -2,11 +2,7 @@ schema = 'tokens_polygon', alias = 'balances_daily', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["polygon"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["0xRob"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/scroll/tokens_scroll_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/scroll/tokens_scroll_balances.sql index 3fa61f14926..9e33f40abda 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/scroll/tokens_scroll_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/scroll/tokens_scroll_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_scroll', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["scroll"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/scroll/tokens_scroll_balances_daily.sql b/dbt_subprojects/tokens/models/transfers_and_balances/scroll/tokens_scroll_balances_daily.sql index 27843664ea8..40674a32cb1 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/scroll/tokens_scroll_balances_daily.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/scroll/tokens_scroll_balances_daily.sql @@ -2,11 +2,7 @@ schema = 'tokens_scroll', alias = 'balances_daily', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["scroll"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["0xRob"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/worldchain/tokens_worldchain_balances.sql b/dbt_subprojects/tokens/models/transfers_and_balances/worldchain/tokens_worldchain_balances.sql index 16355b0f978..66714f04b1f 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/worldchain/tokens_worldchain_balances.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/worldchain/tokens_worldchain_balances.sql @@ -2,11 +2,7 @@ schema = 'tokens_worldchain', alias = 'balances', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["worldchain"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["aalan3"]\') }}' + post_hook = '{{ hide_spells() }}' ) }} diff --git a/dbt_subprojects/tokens/models/transfers_and_balances/worldchain/tokens_worldchain_balances_daily.sql b/dbt_subprojects/tokens/models/transfers_and_balances/worldchain/tokens_worldchain_balances_daily.sql index 63b4b4665fb..91d32490d41 100644 --- a/dbt_subprojects/tokens/models/transfers_and_balances/worldchain/tokens_worldchain_balances_daily.sql +++ b/dbt_subprojects/tokens/models/transfers_and_balances/worldchain/tokens_worldchain_balances_daily.sql @@ -2,11 +2,7 @@ schema = 'tokens_worldchain', alias = 'balances_daily', materialized = 'view', - post_hook = '{{ expose_spells( - blockchains = \'["worldchain"]\', - spell_type = "sector", - spell_name = "balances", - contributors = \'["0xRob"]\') }}' + post_hook = '{{ hide_spells() }}' ) }}