mirror of
https://github.com/FlipsideCrypto/polygon-models.git
synced 2026-02-06 13:22:04 +00:00
initial commit
This commit is contained in:
parent
99aa39a1c0
commit
83df5eeb9a
75
data/silver_bridge__ccip_chain_seed.csv
Normal file
75
data/silver_bridge__ccip_chain_seed.csv
Normal file
@ -0,0 +1,75 @@
|
||||
chain_name,chain_selector
|
||||
apechain,14894068710063348487
|
||||
arbitrum,4949039107694359620
|
||||
l3x,3162193654116181371
|
||||
treasure,1010349088906777999
|
||||
areon,1939936305787790600
|
||||
astar-zkevm,1540201334317828111
|
||||
avalanche,6433500567565415381
|
||||
dexalot,5463201557265485081
|
||||
base,15971525489660198786
|
||||
berachain,1294465214383781161
|
||||
bsc,11344663589394136015
|
||||
opbnb,465944652040885897
|
||||
bitcichain,4874388048629246000
|
||||
bitlayer,7937294810946806131
|
||||
bittorrent,3776006016387883143
|
||||
blast,4411394078118774322
|
||||
bob,3849287863852499584
|
||||
botanix,4560701533377838164
|
||||
bsquared,5406759801798337480
|
||||
celo,1346049177634351622
|
||||
coinex_smart_chain,1761333065194157300
|
||||
core,1224752112135636129
|
||||
corn,9043146809313071210
|
||||
cronos,1456215246176062136
|
||||
cronos-zkevm,8788096068760390840
|
||||
ethereum,5009297550715157269
|
||||
fantom,3768048213127883732
|
||||
filecoin,4561443241176882990
|
||||
fraxtal,1462016016387883143
|
||||
gnosis,465200170687744372
|
||||
hashkey,7613811247471741961
|
||||
hedera,3229138320728879060
|
||||
immutable-zkevm,1237925231416731909
|
||||
ink,3461204551265785888
|
||||
kava,7550000543357438061
|
||||
kroma,3719320017875267166
|
||||
moonriver,1355020143337428062
|
||||
lens,5608378062013572713
|
||||
linea,4627098889531055414
|
||||
mantle,1556008542357238666
|
||||
merlin,241851231317828981
|
||||
metis,8805746078405598895
|
||||
mind,11690709103138290329
|
||||
mode,7264351850409363825
|
||||
morph,18164309074156128038
|
||||
near,2039744413822257700
|
||||
neonlink,8239338020728974000
|
||||
optimism,3734403246176062136
|
||||
plume,3208172210661564830
|
||||
astar-polkadot,6422105447186081193
|
||||
centrifuge,8175830712062617656
|
||||
darwinia,8866418665544333000
|
||||
moonbeam,1252863800116739621
|
||||
polygon,4051577828743386545
|
||||
polygon-zkevm,4348158687435793198
|
||||
private-testnet-mica,4489326297382772450
|
||||
ronin,6916147374840168594
|
||||
rootstock,11964252391146578476
|
||||
scroll,13204309965629103672
|
||||
sei,9027416829622342829
|
||||
shibarium,3993510008929295315
|
||||
soneium,12505351618335765396
|
||||
sonic,1673871237479749969
|
||||
taiko,16468599424800719238
|
||||
telos-evm,1477345371608778000
|
||||
treasure,5214452172935136222
|
||||
unichain,1923510103922296319
|
||||
velas,374210358663784372
|
||||
wemix,5142893604156789321
|
||||
worldchain,2049429975587534727
|
||||
xlayer,3016212468291539606
|
||||
zircuit,17198166215261833993
|
||||
zklink_nova,4350319965322101699
|
||||
zksync,1562403441176082196
|
||||
|
@ -0,0 +1,146 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = "block_number",
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['curated','reorg']
|
||||
) }}
|
||||
|
||||
WITH on_ramp_set AS (
|
||||
|
||||
SELECT
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
event_name,
|
||||
TRY_TO_NUMBER(
|
||||
decoded_log :destChainSelector :: STRING
|
||||
) AS destChainSelector,
|
||||
chain_name,
|
||||
decoded_log :onRamp :: STRING AS onRampAddress,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('core__ez_decoded_event_logs') }}
|
||||
INNER JOIN {{ ref('silver_bridge__ccip_chain_seed') }}
|
||||
ON destChainSelector = chain_selector
|
||||
WHERE
|
||||
contract_address = LOWER('0x849c5ED5a80F5B408Dd4969b78c2C8fdf0565Bfe') -- ccip router
|
||||
AND topic_0 = '0x1f7d0ec248b80e5c0dde0ee531c4fc8fdb6ce9a2b3d90f560c74acd6a7202f23' -- onrampset
|
||||
AND tx_succeeded
|
||||
AND event_removed = FALSE
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
ccip_sent AS (
|
||||
SELECT
|
||||
l.block_number,
|
||||
l.block_timestamp,
|
||||
l.tx_hash,
|
||||
l.origin_function_signature,
|
||||
l.origin_from_address,
|
||||
l.origin_to_address,
|
||||
contract_address,
|
||||
l.event_name,
|
||||
l.event_index,
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
CONCAT(
|
||||
'0x',
|
||||
segmented_data [13] :: STRING
|
||||
) AS message_id,
|
||||
l.decoded_log,
|
||||
decoded_log :message :feeToken :: STRING AS fee_token,
|
||||
TRY_TO_NUMBER(
|
||||
decoded_log :message :feeTokenAmount :: STRING
|
||||
) AS fee_token_amount,
|
||||
TRY_TO_NUMBER(
|
||||
decoded_log :message :gasLimit :: STRING
|
||||
) AS gas_limit,
|
||||
TRY_TO_NUMBER(
|
||||
decoded_log :message :nonce :: STRING
|
||||
) AS nonce,
|
||||
decoded_log :message :receiver :: STRING AS receiver,
|
||||
decoded_log :message :sender :: STRING AS sender,
|
||||
TRY_TO_NUMBER(
|
||||
decoded_log :message :sequenceNumber :: STRING
|
||||
) AS sequence_number,
|
||||
TRY_TO_NUMBER(
|
||||
decoded_log :message :sourceChainSelector :: STRING
|
||||
) AS source_chain_selector,
|
||||
destChainSelector AS dest_chain_selector,
|
||||
chain_name,
|
||||
decoded_log :message :tokenAmounts AS token_amounts,
|
||||
ARRAY_SIZE(
|
||||
decoded_log :message :tokenAmounts
|
||||
) AS token_amounts_count,
|
||||
CONCAT(
|
||||
l.tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
l.modified_timestamp
|
||||
FROM
|
||||
{{ ref('core__ez_decoded_event_logs') }}
|
||||
l
|
||||
INNER JOIN on_ramp_set
|
||||
ON onRampAddress = contract_address
|
||||
WHERE
|
||||
topic_0 = '0xd0c3c799bf9e2639de44391e7f524d229b2b55f5b1ea94b2bf7da42f7243dddd' -- CCIPSendRequested
|
||||
AND tx_succeeded
|
||||
AND event_removed = FALSE
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND l.modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND l.modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
C.block_number,
|
||||
C.block_timestamp,
|
||||
C.origin_function_signature,
|
||||
C.origin_from_address,
|
||||
C.origin_to_address,
|
||||
C.tx_hash,
|
||||
C.event_name,
|
||||
C.event_index,
|
||||
'chainlink-ccip' AS platform,
|
||||
'v1' AS version,
|
||||
C.contract_address AS bridge_address,
|
||||
C.message_id,
|
||||
C.nonce,
|
||||
C.receiver,
|
||||
C.sender,
|
||||
C.receiver AS destination_chain_receiver,
|
||||
C.sequence_number,
|
||||
C.source_chain_selector,
|
||||
C.dest_chain_selector AS destination_chain_id,
|
||||
C.chain_name AS destination_chain,
|
||||
C.gas_limit,
|
||||
C.fee_token,
|
||||
-- Divide the fee evenly by the number of tokens in the array
|
||||
C.fee_token_amount / C.token_amounts_count AS fee_token_amount_per_token,
|
||||
C.token_amounts_count,
|
||||
TRY_TO_NUMBER(
|
||||
tokens.value :amount :: STRING
|
||||
) AS amount_unadj,
|
||||
tokens.value :token :: STRING AS token_address,
|
||||
C._log_id,
|
||||
C.modified_timestamp
|
||||
FROM
|
||||
ccip_sent C,
|
||||
LATERAL FLATTEN(
|
||||
input => C.token_amounts
|
||||
) AS tokens
|
||||
WHERE
|
||||
token_amounts_count > 0
|
||||
@ -0,0 +1,70 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver_bridge__ccip_send_requested
|
||||
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
|
||||
- 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
|
||||
- name: DESTINATION_CHAIN_RECEIVER
|
||||
tests:
|
||||
- not_null
|
||||
- name: AMOUNT_UNADJ
|
||||
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]+
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
Loading…
Reference in New Issue
Block a user