mirror of
https://github.com/FlipsideCrypto/blast-models.git
synced 2026-02-06 14:11:55 +00:00
tweaks
This commit is contained in:
parent
003e49ffeb
commit
f13201aabe
@ -20,6 +20,7 @@ WITH base_evt AS (
|
||||
topics,
|
||||
DATA,
|
||||
event_index,
|
||||
event_name,
|
||||
utils.udf_hex_to_int(
|
||||
topics [1] :: STRING
|
||||
) AS destinationChainId,
|
||||
|
||||
@ -18,10 +18,10 @@ WITH dispatch AS (
|
||||
event_index,
|
||||
contract_address,
|
||||
event_removed,
|
||||
CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS sender,
|
||||
CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS src_bridge_token,
|
||||
-- src bridge token address, not user address
|
||||
TRY_TO_NUMBER(utils.udf_hex_to_int(topics [2] :: STRING)) AS destination,
|
||||
CONCAT('0x', SUBSTR(topics [3] :: STRING, 27, 40)) AS recipient,
|
||||
CONCAT('0x', SUBSTR(topics [3] :: STRING, 27, 40)) AS dst_bridge_token,
|
||||
-- dst bridge token address, not recipient address
|
||||
DATA,
|
||||
CASE
|
||||
@ -187,22 +187,14 @@ SELECT
|
||||
'Dispatch' AS event_name,
|
||||
event_removed,
|
||||
tx_succeeded,
|
||||
-- from dispatch
|
||||
sender,
|
||||
-- src bridge token
|
||||
recipient AS destination_chain_receiver,
|
||||
-- dst bridge token
|
||||
destination AS destination_chain_id,
|
||||
-- from dispatch_id
|
||||
messageId AS message_id,
|
||||
-- from gas_payment
|
||||
messageId :: STRING AS message_id,
|
||||
gasAmount AS gas_amount,
|
||||
payment,
|
||||
-- from sent_transfer_remote
|
||||
origin_from_address AS sender,
|
||||
recipient AS receiver,
|
||||
-- actual receiver address
|
||||
amount,
|
||||
-- from token_transfer
|
||||
token_address,
|
||||
'hyperlane' AS platform,
|
||||
_log_id,
|
||||
|
||||
@ -6,33 +6,33 @@
|
||||
tags = ['curated','reorg']
|
||||
) }}
|
||||
|
||||
WITH oft_asset_contract_creation AS (
|
||||
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
|
||||
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 >= (
|
||||
@ -67,13 +67,13 @@ oft_asset_base_token AS (
|
||||
END AS trace_succeeded,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ref('core__fact_traces')}}
|
||||
{{ ref('core__fact_traces') }}
|
||||
WHERE
|
||||
tx_hash IN (
|
||||
SELECT
|
||||
tx_hash
|
||||
FROM
|
||||
contract_creation
|
||||
oft_asset_contract_creation
|
||||
)
|
||||
AND TYPE = 'STATICCALL'
|
||||
AND input = '0x313ce567' qualify ROW_NUMBER() over (
|
||||
@ -83,22 +83,14 @@ oft_asset_base_token AS (
|
||||
) = 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
|
||||
SELECT
|
||||
oft_address,
|
||||
underlying_address
|
||||
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
|
||||
),
|
||||
oft_sent AS (
|
||||
-- bridging transactions
|
||||
@ -111,41 +103,66 @@ oft_sent AS (
|
||||
origin_to_address,
|
||||
contract_address,
|
||||
event_index,
|
||||
{# '' AS event_name, #}
|
||||
'OFTSent' 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,
|
||||
SUBSTR(
|
||||
topics [1] :: STRING,
|
||||
2,
|
||||
64
|
||||
) AS guid,
|
||||
CONCAT('0x', SUBSTR(topics [2] :: STRING, 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,
|
||||
TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [0] :: STRING)) AS dstEid,
|
||||
TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [1] :: STRING)) AS amountSentLD,
|
||||
TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [2] :: STRING)) AS amountReceivedLD,
|
||||
CONCAT(
|
||||
tx_hash,
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ref('core__fact_event_logs')}}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
e
|
||||
INNER JOIN oft_asset
|
||||
ON oft_address = contract_address
|
||||
WHERE
|
||||
topics [0] = '0x85496b760a4b7f8d66384b9df21b381f5d1b1e79f229a47aaf4c232edc2fe59a'
|
||||
{# AND DATE(block_timestamp) >= '2024-11-01' #}
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND e.modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND e.modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
'0x1a44076050125825900e736c501f859c50fe728c' AS bridge_address,
|
||||
event_index,
|
||||
event_name,
|
||||
platform,
|
||||
from_address AS sender,
|
||||
from_address AS receiver,
|
||||
from_address AS destination_chain_receiver,
|
||||
amountSentLD AS amount,
|
||||
dstEid AS destination_chain_id,
|
||||
COALESCE(
|
||||
underlying_address,
|
||||
oft_address
|
||||
) AS token_address,
|
||||
oft_address,
|
||||
_log_id,
|
||||
modified_timestamp
|
||||
FROM
|
||||
oft_sent
|
||||
-- inner join chain_id using(dstEid)
|
||||
oft_sent {# inner join chain_id using(dstEid) #}
|
||||
|
||||
@ -24,7 +24,7 @@ WITH bridge_router AS (
|
||||
origin_from_address AS depositor,
|
||||
RIGHT(utils.udf_hex_to_int(DATA :: STRING), 4) AS destinationChainId,
|
||||
TRY_TO_NUMBER(utils.udf_hex_to_int(DATA :: STRING)) AS amount,
|
||||
origin_from_address AS receipient,
|
||||
origin_from_address AS recipient,
|
||||
CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS bridge_address,
|
||||
CASE
|
||||
WHEN tx_status = 'SUCCESS' THEN TRUE
|
||||
@ -74,7 +74,7 @@ bridge_native AS (
|
||||
4
|
||||
) AS destinationChainId,
|
||||
amount_precise_raw,
|
||||
et.from_address AS receipient,
|
||||
et.from_address AS recipient,
|
||||
et.to_address AS bridge_address,
|
||||
native_transfers_id,
|
||||
et.modified_timestamp
|
||||
@ -117,7 +117,7 @@ bridge_combined AS (
|
||||
depositor,
|
||||
destinationChainId AS orbiter_chain_id,
|
||||
amount AS amount_unadj,
|
||||
receipient,
|
||||
recipient,
|
||||
bridge_address,
|
||||
tx_succeeded,
|
||||
_log_id AS _id,
|
||||
@ -139,7 +139,7 @@ bridge_combined AS (
|
||||
depositor,
|
||||
destinationChainId AS orbiter_chain_id,
|
||||
amount_precise_raw AS amount_unadj,
|
||||
receipient,
|
||||
recipient,
|
||||
bridge_address,
|
||||
TRUE AS tx_succeeded,
|
||||
native_transfers_id AS _id,
|
||||
@ -163,10 +163,10 @@ SELECT
|
||||
s.chainid AS destination_chain_id,
|
||||
s.name AS destination_chain,
|
||||
amount_unadj,
|
||||
receipient AS receiver,
|
||||
receipient AS destination_chain_receiver,
|
||||
recipient AS receiver,
|
||||
recipient AS destination_chain_receiver,
|
||||
bridge_address,
|
||||
'orbiter finance' AS platform,
|
||||
'orbiter' AS platform,
|
||||
'0x4300000000000000000000000000000000000004' AS token_address,
|
||||
--weth contract address
|
||||
tx_succeeded,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user