add ccip seed and send req

This commit is contained in:
San Yong 2025-03-20 15:56:48 +08:00
parent 09147d263c
commit d85aa2fd9e
2 changed files with 198 additions and 0 deletions

View 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
1 chain_name chain_selector
2 apechain 14894068710063348487
3 arbitrum 4949039107694359620
4 l3x 3162193654116181371
5 treasure 1010349088906777999
6 areon 1939936305787790600
7 astar-zkevm 1540201334317828111
8 avalanche 6433500567565415381
9 dexalot 5463201557265485081
10 base 15971525489660198786
11 berachain 1294465214383781161
12 bsc 11344663589394136015
13 opbnb 465944652040885897
14 bitcichain 4874388048629246000
15 bitlayer 7937294810946806131
16 bittorrent 3776006016387883143
17 blast 4411394078118774322
18 bob 3849287863852499584
19 botanix 4560701533377838164
20 bsquared 5406759801798337480
21 celo 1346049177634351622
22 coinex_smart_chain 1761333065194157300
23 core 1224752112135636129
24 corn 9043146809313071210
25 cronos 1456215246176062136
26 cronos-zkevm 8788096068760390840
27 ethereum 5009297550715157269
28 fantom 3768048213127883732
29 filecoin 4561443241176882990
30 fraxtal 1462016016387883143
31 gnosis 465200170687744372
32 hashkey 7613811247471741961
33 hedera 3229138320728879060
34 immutable-zkevm 1237925231416731909
35 ink 3461204551265785888
36 kava 7550000543357438061
37 kroma 3719320017875267166
38 moonriver 1355020143337428062
39 lens 5608378062013572713
40 linea 4627098889531055414
41 mantle 1556008542357238666
42 merlin 241851231317828981
43 metis 8805746078405598895
44 mind 11690709103138290329
45 mode 7264351850409363825
46 morph 18164309074156128038
47 near 2039744413822257700
48 neonlink 8239338020728974000
49 optimism 3734403246176062136
50 plume 3208172210661564830
51 astar-polkadot 6422105447186081193
52 centrifuge 8175830712062617656
53 darwinia 8866418665544333000
54 moonbeam 1252863800116739621
55 polygon 4051577828743386545
56 polygon-zkevm 4348158687435793198
57 private-testnet-mica 4489326297382772450
58 ronin 6916147374840168594
59 rootstock 11964252391146578476
60 scroll 13204309965629103672
61 sei 9027416829622342829
62 shibarium 3993510008929295315
63 soneium 12505351618335765396
64 sonic 1673871237479749969
65 taiko 16468599424800719238
66 telos-evm 1477345371608778000
67 treasure 5214452172935136222
68 unichain 1923510103922296319
69 velas 374210358663784372
70 wemix 5142893604156789321
71 worldchain 2049429975587534727
72 xlayer 3016212468291539606
73 zircuit 17198166215261833993
74 zklink_nova 4350319965322101699
75 zksync 1562403441176082196

View File

@ -0,0 +1,123 @@
{{ 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,
-- decoded_log,
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 arbitrum_dev.silver_bridge.ccip_chain_seed
ON destChainSelector = chain_selector
WHERE
contract_address = LOWER('0x141fa059441E0ca23ce184B6A78bafD2A517DdE8') -- 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_timestamp,
l.tx_hash,
contract_address,
l.event_name,
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,
decoded_log :message :tokenAmounts AS token_amounts,
ARRAY_SIZE(
decoded_log :message :tokenAmounts
) AS token_amounts_count,
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 modified_timestamp >= (
SELECT
MAX(modified_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
)
SELECT
C.block_timestamp,
C.tx_hash,
C.contract_address,
C.message_id,
C.nonce,
C.receiver,
C.sender,
C.sequence_number,
C.source_chain_selector,
C.dest_chain_selector,
C.gas_limit,
C.fee_token,
-- Divide the fee 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 token_amount,
tokens.value :token :: STRING AS token,
C.modified_timestamp
FROM
ccip_sent C,
LATERAL FLATTEN(
input => C.token_amounts
) AS tokens