mirror of
https://github.com/FlipsideCrypto/blast-models.git
synced 2026-02-06 14:11:55 +00:00
layerzero temp
This commit is contained in:
parent
87b141a49f
commit
003e49ffeb
@ -1,6 +1,6 @@
|
||||
{% docs evm_bridge_table_doc %}
|
||||
|
||||
A convenience table that aggregates bridge activity from event_logs, traces and transfers, including bridge deposits and transfers sent from the following protocols: AXELAR, HYPERLANE, ORBITER, SYMBIOSIS, SYNAPSE along with other helpful columns, including an amount USD where available. Note, this table only includes records for the protocols listed above with live, onchain bridge activity and may not represent the complete bridging picture.
|
||||
A convenience table that aggregates bridge activity from event_logs, traces and transfers, including bridge deposits and transfers sent from the following protocols: ACROSS, AXELAR, HYPERLANE, LAYERZERO, ORBITER, SYMBIOSIS, SYNAPSE along with other helpful columns, including an amount USD where available. Note, this table only includes records for the protocols listed above with live, onchain bridge activity and may not represent the complete bridging picture.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
@ -0,0 +1,151 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = "block_number",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['curated','reorg']
|
||||
) }}
|
||||
|
||||
WITH oft_asset_contract_creation AS (
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
from_address AS oft_address,
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CASE
|
||||
WHEN trace_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS trace_succeeded,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('core__fact_traces') }}
|
||||
WHERE
|
||||
TYPE = 'CALL'
|
||||
AND LEFT(
|
||||
input,
|
||||
10
|
||||
) = '0xca5eb5e1'
|
||||
AND to_address = '0x1a44076050125825900e736c501f859c50fe728c' -- layerzero v2
|
||||
AND tx_succeeded
|
||||
AND trace_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
|
||||
qualify ROW_NUMBER() over (
|
||||
PARTITION BY oft_address
|
||||
ORDER BY
|
||||
block_timestamp DESC
|
||||
) = 1
|
||||
),
|
||||
oft_asset_base_token AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
from_address AS wrap_address,
|
||||
to_address AS underlying_address,
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS tx_succeeded,
|
||||
CASE
|
||||
WHEN trace_status = 'SUCCESS' THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS trace_succeeded,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ref('core__fact_traces')}}
|
||||
WHERE
|
||||
tx_hash IN (
|
||||
SELECT
|
||||
tx_hash
|
||||
FROM
|
||||
contract_creation
|
||||
)
|
||||
AND TYPE = 'STATICCALL'
|
||||
AND input = '0x313ce567' qualify ROW_NUMBER() over (
|
||||
PARTITION BY tx_hash
|
||||
ORDER BY
|
||||
trace_index ASC
|
||||
) = 1
|
||||
),
|
||||
oft_asset AS (
|
||||
SELECT
|
||||
oft_address,
|
||||
t3.token_symbol AS oft_symbol,
|
||||
t3.token_name AS oft_name,
|
||||
underlying_address,
|
||||
t4.token_symbol AS underlying_symbol,
|
||||
t4.token_name AS underlying_name
|
||||
FROM
|
||||
oft_asset_contract_creation t1
|
||||
LEFT JOIN oft_asset_base_token t2
|
||||
ON t1.tx_hash = t2.tx_hash
|
||||
AND oft_address = wrap_address
|
||||
LEFT JOIN {{ref('silver__contracts')}} t3
|
||||
ON oft_address = t3.contract_address
|
||||
LEFT JOIN {{ref('silver__contracts')}} t4
|
||||
ON underlying_address = t4.contract_address
|
||||
),
|
||||
oft_sent AS (
|
||||
-- bridging transactions
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
contract_address,
|
||||
event_index,
|
||||
{# '' AS event_name, #}
|
||||
'layerzero-v2' AS platform,
|
||||
oft_name,
|
||||
oft_symbol,
|
||||
oft_address,
|
||||
underlying_name,
|
||||
underlying_symbol,
|
||||
underlying_address,
|
||||
CONCAT('0x', SUBSTR(topics [2], 27, 40)) AS from_address,
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [0] :: STRING
|
||||
) :: FLOAT AS dstEid,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [1] :: STRING
|
||||
) :: FLOAT AS amountSentLD,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [2] :: STRING
|
||||
) :: FLOAT AS amountReceivedLD,
|
||||
CONCAT(
|
||||
tx_hash,
|
||||
'-',
|
||||
event_index
|
||||
) AS _log_id,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ref('core__fact_event_logs')}}
|
||||
INNER JOIN oft_asset
|
||||
ON oft_address = contract_address
|
||||
WHERE
|
||||
topics [0] = '0x85496b760a4b7f8d66384b9df21b381f5d1b1e79f229a47aaf4c232edc2fe59a'
|
||||
{# AND DATE(block_timestamp) >= '2024-11-01' #}
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
oft_sent
|
||||
-- inner join chain_id using(dstEid)
|
||||
@ -0,0 +1,72 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver_bridge__layerzero_bridge_v2
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 3
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
tests:
|
||||
- not_null
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: EVENT_INDEX
|
||||
tests:
|
||||
- not_null
|
||||
- name: EVENT_NAME
|
||||
tests:
|
||||
- not_null
|
||||
- name: BRIDGE_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: SENDER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: RECEIVER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: DESTINATION_CHAIN_RECEIVER
|
||||
tests:
|
||||
- not_null
|
||||
- name: AMOUNT
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- DECIMAL
|
||||
- FLOAT
|
||||
- NUMBER
|
||||
- name: TOKEN_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
@ -118,6 +118,42 @@ WHERE
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
layerzero_v2 AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
tx_hash,
|
||||
event_index,
|
||||
bridge_address,
|
||||
event_name,
|
||||
platform,
|
||||
'v2' AS version,
|
||||
sender,
|
||||
receiver,
|
||||
destination_chain_receiver,
|
||||
destination_chain_id :: STRING AS destination_chain_id,
|
||||
NULL AS destination_chain,
|
||||
token_address,
|
||||
NULL AS token_symbol,
|
||||
amount AS amount_unadj,
|
||||
_log_id AS _id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver_bridge__layerzero_bridge_v2') }}
|
||||
|
||||
{% if is_incremental() and 'layerzero_v2' not in var('HEAL_MODELS') %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
orbiter AS (
|
||||
SELECT
|
||||
block_number,
|
||||
@ -242,6 +278,11 @@ all_protocols AS (
|
||||
FROM
|
||||
hyperlane
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
layerzero_v2
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
|
||||
Loading…
Reference in New Issue
Block a user