Skip to content

Commit

Permalink
artemis event unification layer (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny77D authored Feb 21, 2025
1 parent aaac6e8 commit 72b0c8f
Show file tree
Hide file tree
Showing 22 changed files with 388 additions and 826 deletions.
5 changes: 3 additions & 2 deletions macros/across/across_v2_decode_filled_relay.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'{{ chain }}' as chain
from {{chain}}_flipside.core.fact_decoded_event_logs
where
event_name = 'FilledRelay'
event_name = 'FilledRelay' and block_timestamp < '2025-02-07'
and
contract_address = '{{ spot_fee_contract }}'
{% if is_incremental() %}
Expand Down Expand Up @@ -66,8 +66,9 @@
from
{{ source("PROD_LANDING", "raw_across_v2_" ~ chain ~ "_filled_relay_events") }},
lateral flatten(input => parse_json(source_json)) as flat_json
WHERE flat_json.value:"block_timestamp"::timestamp < '2025-02-07'
{% if is_incremental() %}
where
and
date_trunc('day', flat_json.value:"block_timestamp"::timestamp) >= (select dateadd('day', -3, max(block_timestamp)) from {{ this }})
{% endif %}
)
Expand Down
6 changes: 3 additions & 3 deletions macros/across/across_v2_decode_funds_deposited.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
decoded_log:"relayerFeePct"::integer / 1e18 as relayer_fee_pct,
'{{ chain }}' as chain
from {{ chain }}_flipside.core.fact_decoded_event_logs
where
event_name = 'FundsDeposited'
where block_timestamp < '2025-02-07' and event_name = 'FundsDeposited'
and
contract_address = '{{ spot_fee_contract }}'
{% if is_incremental() %}
Expand Down Expand Up @@ -59,8 +58,9 @@
from
{{ source("PROD_LANDING", "raw_across_v2_" ~ chain ~ "_funds_deposited_events") }},
lateral flatten(input => parse_json(source_json)) as flat_json
WHERE flat_json.value:"block_timestamp"::timestamp < '2025-02-07'
{% if is_incremental() %}
where
and
date_trunc('day', flat_json.value:"block_timestamp"::timestamp) >= (select dateadd('day', -3, max(block_timestamp)) from {{ this }})
{% endif %}
)
Expand Down
78 changes: 39 additions & 39 deletions macros/across/across_v3_decode_filled_relay.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
block_timestamp,
tx_hash,
event_index,
decoded_log:"depositId"::integer as deposit_id,
decoded_log:"inputToken"::string as origin_token,
decoded_log:"inputAmount"::double as src_amount,
coalesce(decoded_log:"relayExecutionInfo":"updatedOutputAmount"::double, decoded_log:"outputAmount"::double) as dst_amount,
decoded_log:"depositor"::string as depositor,
coalesce(decoded_log:"relayExecutionInfo":"updatedRecipient"::string, decoded_log:"recipient"::string) as recipient,
decoded_log:"destinationChainId"::integer as destination_chain_id,
decoded_log:"outputToken"::string as destination_token,
decoded_log:"originChainId"::integer as origin_chain_id,
TRY_TO_NUMBER(decoded_log:"depositId"::string) as deposit_id,
IFF(event_name = 'FilledRelay', '0x' || substr(decoded_log:"inputToken"::string, 27, 40), decoded_log:"inputToken") as origin_token,
TRY_TO_DOUBLE(decoded_log:"inputAmount"::string) as src_amount,
TRY_TO_DOUBLE(decoded_log:"outputAmount"::string) as dst_amount,
IFF(event_name = 'FilledRelay', '0x' || substr(decoded_log:"depositor"::string, 27, 40), decoded_log:"depositor") as depositor,
IFF(event_name = 'FilledRelay', '0x' || substr(decoded_log:"recipient"::string, 27, 40), decoded_log:"recipient") as recipient,
TRY_TO_NUMBER(decoded_log:"destinationChainId"::string) as destination_chain_id,
IFF(event_name = 'FilledRelay', '0x' || substr(decoded_log:"outputToken"::string, 27, 40), decoded_log:"outputToken") as destination_token,
TRY_TO_NUMBER(decoded_log:"originChainId"::string) as origin_chain_id,
null as realized_lp_fee_pct,
null as relayer_fee_pct,
src_amount - dst_amount as protocol_fee,
Expand All @@ -21,7 +21,7 @@
decoded_log
from {{chain}}_flipside.core.fact_decoded_event_logs
where
event_name = 'FilledV3Relay'
((event_name = 'FilledV3Relay') or (event_name = 'FilledRelay' and block_timestamp >= '2025-02-07'))
and
lower(contract_address) = lower('{{ spot_fee_contract }}')
{% if is_incremental() %}
Expand All @@ -33,37 +33,37 @@
{% endmacro %}

{% macro across_v3_goldsky_decode_filled_relay(chain, spot_fee_contract) %}
select
contract_address as messaging_contract_address,
block_timestamp,
transaction_hash as tx_hash,
event_index,
decoded_log:"depositId"::integer as deposit_id,
decoded_log:"inputToken"::string as origin_token,
decoded_log:"inputAmount"::double as src_amount,
decoded_log:"outputAmount"::double as dst_amount,
decoded_log:"depositor"::string as depositor,
decoded_log:"recipient"::string as recipient,
decoded_log:"destinationChainId"::integer as destination_chain_id,
decoded_log:"outputToken"::string as destination_token,
decoded_log:"originChainId"::integer as origin_chain_id,
null as realized_lp_fee_pct,
null as relayer_fee_pct,
src_amount - dst_amount as protocol_fee,
decoded_log:"message"::string as message,
'{{ chain }}' as chain,
decoded_log
from {{ ref("fact_" ~ chain ~ "_decoded_events") }}
where
event_name = 'FilledV3Relay'
and
lower(contract_address) = lower('{{ spot_fee_contract }}')
{% if is_incremental() %}
select
contract_address as messaging_contract_address,
block_timestamp,
transaction_hash as tx_hash,
event_index,
decoded_log:"depositId"::integer as deposit_id,
IFF(event_name = 'FilledRelay', '0x' || substr(decoded_log:"inputToken"::string, 25, 40), decoded_log:"inputToken") as origin_token,
decoded_log:"inputAmount"::double as src_amount,
decoded_log:"outputAmount"::double as dst_amount,
IFF(event_name = 'FilledRelay', '0x' || substr(decoded_log:"depositor"::string, 25, 40), decoded_log:"depositor") as depositor,
IFF(event_name = 'FilledRelay', '0x' || substr(decoded_log:"recipient"::string, 25, 40), decoded_log:"recipient") as recipient,
decoded_log:"destinationChainId"::integer as destination_chain_id,
IFF(event_name = 'FilledRelay', '0x' || substr(decoded_log:"outputToken"::string, 25, 40), decoded_log:"outputToken") as destination_token,
decoded_log:"originChainId"::integer as origin_chain_id,
null as realized_lp_fee_pct,
null as relayer_fee_pct,
src_amount - dst_amount as protocol_fee,
decoded_log:"message"::string as message,
'{{ chain }}' as chain,
decoded_log
from {{ ref("fact_" ~ chain ~ "_decoded_events") }}
where
((event_name = 'FilledRelay' and block_timestamp >= '2025-02-07') or (event_name = 'V3FilledRelay'))
and
lower(contract_address) = lower('{{ spot_fee_contract }}')
{% if is_incremental() %}

and block_timestamp
>= (select dateadd('day', -3, max(block_timestamp)) from {{ this }})
and block_timestamp
>= (select dateadd('day', -3, max(block_timestamp)) from {{ this }})

{% endif %}
{% endif %}
{% endmacro %}

{% macro across_v3_rpc_decode_filled_relay(chain) %}
Expand Down
32 changes: 16 additions & 16 deletions macros/across/across_v3_decode_funds_deposited.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
block_timestamp,
tx_hash,
event_index,
decoded_log:"depositId"::integer as deposit_id,
decoded_log:"inputToken"::string as origin_token,
decoded_log:"inputAmount"::double as src_amount,
decoded_log:"outputAmount"::double as dst_amount,
decoded_log:"depositor"::string as depositor,
decoded_log:"recipient"::string as recipient,
decoded_log:"destinationChainId"::integer as destination_chain_id,
decoded_log:"outputToken"::string as destination_token,
decoded_log:"originChainId"::integer as origin_chain_id,
TRY_TO_NUMBER(decoded_log:"depositId"::string) as deposit_id,
IFF(event_name = 'FundsDeposited', '0x' || substr(decoded_log:"inputToken"::string, 27, 40), decoded_log:"inputToken") as origin_token,
TRY_TO_DOUBLE(decoded_log:"inputAmount"::string) as src_amount,
TRY_TO_DOUBLE(decoded_log:"outputAmount"::string) as dst_amount,
IFF(event_name = 'FundsDeposited', '0x' || substr(decoded_log:"depositor"::string, 27, 40), decoded_log:"depositor") as depositor,
IFF(event_name = 'FundsDeposited', '0x' || substr(decoded_log:"recipient"::string, 27, 40), decoded_log:"recipient") as recipient,
TRY_TO_NUMBER(decoded_log:"destinationChainId"::string) as destination_chain_id,
IFF(event_name = 'FundsDeposited', '0x' || substr(decoded_log:"outputToken"::string, 27, 40), decoded_log:"outputToken") destination_token,
TRY_TO_NUMBER(decoded_log:"originChainId"::string) as origin_chain_id,
null as realized_lp_fee_pct,
null as relayer_fee_pct,
src_amount - dst_amount as protocol_fee,
coalesce(src_amount, 0) - coalesce(dst_amount,0) as protocol_fee,
decoded_log:"message"::string as message,
'{{ chain }}' as chain,
decoded_log
from {{ chain }}_flipside.core.fact_decoded_event_logs
where
event_name = 'V3FundsDeposited'
((event_name = 'V3FundsDeposited') or (event_name = 'FundsDeposited' and block_timestamp >= '2025-02-07'))
and
lower(contract_address) = lower('{{ spot_fee_contract }}')
{% if is_incremental() %}
Expand All @@ -38,13 +38,13 @@
transaction_hash as tx_hash,
event_index,
decoded_log:"depositId"::integer as deposit_id,
decoded_log:"inputToken"::string as origin_token,
IFF(event_name = 'FundsDeposited', '0x' || substr(decoded_log:"inputToken"::string, 25, 40), decoded_log:"inputToken") as origin_token,
decoded_log:"inputAmount"::double as src_amount,
decoded_log:"outputAmount"::double as dst_amount,
decoded_log:"depositor"::string as depositor,
decoded_log:"recipient"::string as recipient,
IFF(event_name = 'FundsDeposited', '0x' || substr(decoded_log:"depositor"::string, 25, 40), decoded_log:"depositor") as depositor,
IFF(event_name = 'FundsDeposited', '0x' || substr(decoded_log:"recipient"::string, 25, 40), decoded_log:"recipient") as recipient,
decoded_log:"destinationChainId"::integer as destination_chain_id,
decoded_log:"outputToken"::string as destination_token,
IFF(event_name = 'FundsDeposited', '0x' || substr(decoded_log:"outputToken"::string, 25, 40), decoded_log:"outputToken") destination_token,
decoded_log:"originChainId"::integer as origin_chain_id,
null as realized_lp_fee_pct,
null as relayer_fee_pct,
Expand All @@ -54,7 +54,7 @@
decoded_log
from {{ ref("fact_" ~ chain ~ "_decoded_events") }}
where
event_name = 'V3FundsDeposited'
((event_name = 'V3FundsDeposited') or (event_name = 'FundsDeposited' and block_timestamp >= '2025-02-07'))
and
lower(contract_address) = lower('{{ spot_fee_contract }}')
{% if is_incremental() %}
Expand Down
2 changes: 2 additions & 0 deletions macros/decode/decode_goldsky_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
, {{ target.schema }}.decode_evm_event_log_v2(
topic_data, data, t2.event_info
) as decoded_log
, t2.topic_zero
, t2.event_info
from {{ ref("fact_" ~ chain ~ "_events") }} t1
left join {{ ref("dim_events_silver") }} t2 on t1.topic_zero = t2.topic_zero
{% if is_incremental() %}
Expand Down
21 changes: 21 additions & 0 deletions macros/flipside/clean_flipside_events.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% macro clean_flipside_evm_events(chain) %}
select
concat(coalesce(substring(topic_1, 3), ''), coalesce(substring(topic_2, 3), ''), coalesce(substring(topic_3, 3),'')) as topic_data
, SUBSTRING(data, 3) as data
, block_number
, null as block_hash
, block_timestamp
, tx_status
, tx_succeeded
, null as transaction_index
, tx_hash as transaction_hash
, event_index
, contract_address
, topics
, topics[0]::string as topic_zero
from {{ chain }}_flipside.core.fact_event_logs
{% if is_incremental() %}
where
block_timestamp >= (select dateadd('day', -3, max(block_timestamp)) from {{ this }})
{% endif %}
{% endmacro %}
4 changes: 4 additions & 0 deletions models/dimensions/contracts/dim_contract_abis.sql

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion models/dimensions/events/dim_events_silver.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ select
event_info,
topic_zero
from event_signatures
where event_id = 1 and event_name not in ('AuthorizationCanceled', 'ValidatorEcdsaPublicKeyUpdated', 'ValidatorBlsPublicKeyUpdated', 'AuthorizationUsed', 'TransferComment') -- These events emit types currently not supported by the decode_evm_event_log function
where event_id = 1 and event_name not in ('AuthorizationCanceled', 'ValidatorEcdsaPublicKeyUpdated', 'ValidatorBlsPublicKeyUpdated', 'AuthorizationUsed', 'TransferComment') -- These events emit types currently not supported by the decode_evm_event_log function
Loading

0 comments on commit 72b0c8f

Please sign in to comment.