initial commit

This commit is contained in:
San Yong 2025-05-29 01:11:14 +08:00
parent ec439d1bc2
commit 082ed7ece5
18 changed files with 2074 additions and 0 deletions

View File

@ -0,0 +1,94 @@
chain,eid
Ape, 30312
Arbitrum, 30110
Arbitrum Nova, 30175
Astar, 30210
Astar zkEVM, 30257
Avalanche, 30106
Base, 30184
Bevm, 30317
Binance Smart Chain, 30102
Bitlayer, 30314
Blast, 30243
Bob, 30279
Canto, 30159
Celo, 30125
Codex, 30323
Conflux eSpace, 30212
Core Blockchain, 30153
Cyber, 30283
DOS Chain, 30149
DeFi Kingdoms, 30115
Degen, 30267
Dexalot Subnet, 30118
Dm2verse, 30315
EBI, 30282
Edu, 30328
Ethereum, 30101
Etherlink, 30292
Fantom, 30112
Flare, 30295
Fraxtal, 30255
Fuse, 30138
Gnosis, 30145
Gravity, 30294
Harmony, 30116
Hedera, 30316
Hemi, 30329
Homeverse, 30265
Horizen EON, 30215
Hubble, 30182
Iota, 30284
Japan Open Chain, 30285
Kaia, 30150
Kava, 30177
Lightlink, 30309
Linea, 30183
Lisk, 30321
Loot, 30197
Lyra, 30311
Manta, 30217
Mantle, 30181
Masa, 30263
Meritcircle, 30198
Merlin, 30266
Meter, 30176
Metis, 30151
Mode, 30260
Moonbeam, 30126
Moonriver, 30167
Morph, 30322
Near Aurora, 30211
OKXChain, 30155
Optimism, 30111
Orderly, 30213
Peaq, 30302
Polygon, 30109
Polygon zkEVM, 30158
Rari Chain, 30235
Reya, 30313
Sanko, 30278
Scroll, 30214
Sei, 30280
Shimmer, 30230
Skale, 30273
Solana, 30168
Superposition, 30327
Taiko, 30290
TelosEVM, 30199
Tenet, 30173
Tiltyard, 30238
Tron, 30420
Viction, 30196
Worldchain, 30319
X Layer, 30274
XChain, 30291
XPLA, 30216
Xai, 30236
Zircuit, 30303
Zora, 30195
inEVM, 30234
opBNB, 30202
re.al, 30237
zkLink, 30301
zkSync Era, 30165
1 chain eid
2 Ape 30312
3 Arbitrum 30110
4 Arbitrum Nova 30175
5 Astar 30210
6 Astar zkEVM 30257
7 Avalanche 30106
8 Base 30184
9 Bevm 30317
10 Binance Smart Chain 30102
11 Bitlayer 30314
12 Blast 30243
13 Bob 30279
14 Canto 30159
15 Celo 30125
16 Codex 30323
17 Conflux eSpace 30212
18 Core Blockchain 30153
19 Cyber 30283
20 DOS Chain 30149
21 DeFi Kingdoms 30115
22 Degen 30267
23 Dexalot Subnet 30118
24 Dm2verse 30315
25 EBI 30282
26 Edu 30328
27 Ethereum 30101
28 Etherlink 30292
29 Fantom 30112
30 Flare 30295
31 Fraxtal 30255
32 Fuse 30138
33 Gnosis 30145
34 Gravity 30294
35 Harmony 30116
36 Hedera 30316
37 Hemi 30329
38 Homeverse 30265
39 Horizen EON 30215
40 Hubble 30182
41 Iota 30284
42 Japan Open Chain 30285
43 Kaia 30150
44 Kava 30177
45 Lightlink 30309
46 Linea 30183
47 Lisk 30321
48 Loot 30197
49 Lyra 30311
50 Manta 30217
51 Mantle 30181
52 Masa 30263
53 Meritcircle 30198
54 Merlin 30266
55 Meter 30176
56 Metis 30151
57 Mode 30260
58 Moonbeam 30126
59 Moonriver 30167
60 Morph 30322
61 Near Aurora 30211
62 OKXChain 30155
63 Optimism 30111
64 Orderly 30213
65 Peaq 30302
66 Polygon 30109
67 Polygon zkEVM 30158
68 Rari Chain 30235
69 Reya 30313
70 Sanko 30278
71 Scroll 30214
72 Sei 30280
73 Shimmer 30230
74 Skale 30273
75 Solana 30168
76 Superposition 30327
77 Taiko 30290
78 TelosEVM 30199
79 Tenet 30173
80 Tiltyard 30238
81 Tron 30420
82 Viction 30196
83 Worldchain 30319
84 X Layer 30274
85 XChain 30291
86 XPLA 30216
87 Xai 30236
88 Zircuit 30303
89 Zora 30195
90 inEVM 30234
91 opBNB 30202
92 re.al 30237
93 zkLink 30301
94 zkSync Era 30165

View File

@ -0,0 +1,81 @@
chain,short_coin_type
ailayer,0x0a59
ancient8,0xaaaa
Aptos,0x027d
Arbitrum,0x2329
Aurora,0x0a0a
Avalanche,0x2328
b2,0x00df
Base,0x2105
bb,0x1771
Beam,0x0504
Berachain,0x38de
bevm2,0x2ced
Bitcoin,0x0000
Bitlayer,0x10c5
Blast,0x1331
BNB Chain,0x02ca
Bob,0xed88
Celo,0xce10
ckb,0x0135
Coinweb,0x08ae
Conflux,0x01f7
Core,0x045c
corn,0x6f40
Crypto Chain,0x018a
duck,0x15a9
EOS,0x00c2
Ethereum,0x003c
Evmos,0x11bc
exsat,0x1c20
Fantom,0x03ef
Flow,0x021b
Gnosis,0x02bc
Harmony,0x03ff
hash,0x03ee
hemi,0xa867
inevm,0x09dd
iotex,0x1251
Kaia,0x2019
Kroma,0x00ff
Linea,0xe708
Lisk,0x046f
Manta,0x0263
Mantle,0x1388
Map,0x58f8
Merlin,0x6868
Metis,0x0440
Mode,0x868b
Moonbeam,0x0504
Moonriver,0x0505
Morph,0x0b02
Nautilus,0x56ce
Near,0x018d
Neox,0xba93
opBNB,0x00cc
Optimism,0x0266
Polygon POS,0x03c6
Polygon zkEVM,0x044d
rsk,0x001e
Scroll,0x2750
Sei,0x0531
SKALE Calypso,0x6c62
SKALE Europa,0x9296
SKALE Nebula,0xb4b1
Solana,0x01f5
Soneium,0x074c
Sonic,0x0092
Sui,0x0310
Taiko,0x28c5
Taker,0x0465
Terra,0x014a
Thorchain,0x03a3
Thunder,0x006c
Ton,0x025f
Tron,0x00c3
xlayer,0x00c4
zeta,0x1b58
zkFair,0xa70e
zklink,0x5cc4
zircuit,0xbf04
zkSync Era,0x0324
1 chain short_coin_type
2 ailayer 0x0a59
3 ancient8 0xaaaa
4 Aptos 0x027d
5 Arbitrum 0x2329
6 Aurora 0x0a0a
7 Avalanche 0x2328
8 b2 0x00df
9 Base 0x2105
10 bb 0x1771
11 Beam 0x0504
12 Berachain 0x38de
13 bevm2 0x2ced
14 Bitcoin 0x0000
15 Bitlayer 0x10c5
16 Blast 0x1331
17 BNB Chain 0x02ca
18 Bob 0xed88
19 Celo 0xce10
20 ckb 0x0135
21 Coinweb 0x08ae
22 Conflux 0x01f7
23 Core 0x045c
24 corn 0x6f40
25 Crypto Chain 0x018a
26 duck 0x15a9
27 EOS 0x00c2
28 Ethereum 0x003c
29 Evmos 0x11bc
30 exsat 0x1c20
31 Fantom 0x03ef
32 Flow 0x021b
33 Gnosis 0x02bc
34 Harmony 0x03ff
35 hash 0x03ee
36 hemi 0xa867
37 inevm 0x09dd
38 iotex 0x1251
39 Kaia 0x2019
40 Kroma 0x00ff
41 Linea 0xe708
42 Lisk 0x046f
43 Manta 0x0263
44 Mantle 0x1388
45 Map 0x58f8
46 Merlin 0x6868
47 Metis 0x0440
48 Mode 0x868b
49 Moonbeam 0x0504
50 Moonriver 0x0505
51 Morph 0x0b02
52 Nautilus 0x56ce
53 Near 0x018d
54 Neox 0xba93
55 opBNB 0x00cc
56 Optimism 0x0266
57 Polygon POS 0x03c6
58 Polygon zkEVM 0x044d
59 rsk 0x001e
60 Scroll 0x2750
61 Sei 0x0531
62 SKALE Calypso 0x6c62
63 SKALE Europa 0x9296
64 SKALE Nebula 0xb4b1
65 Solana 0x01f5
66 Soneium 0x074c
67 Sonic 0x0092
68 Sui 0x0310
69 Taiko 0x28c5
70 Taker 0x0465
71 Terra 0x014a
72 Thorchain 0x03a3
73 Thunder 0x006c
74 Ton 0x025f
75 Tron 0x00c3
76 xlayer 0x00c4
77 zeta 0x1b58
78 zkFair 0xa70e
79 zklink 0x5cc4
80 zircuit 0xbf04
81 zkSync Era 0x0324

View File

@ -0,0 +1,117 @@
chain_name,chain_id
Abstract,324
Animechain,372
Ape,312
Aptos,108
Arbitrum,110
Arbitrum Nova,175
Astar zkEVM,257
Avalanche,106
BSC,102
BOB,279
Bahamut,363
Base,184
Beam,198
Berachain,362
Bevm,317
Bitlayer,314
Blast,243
Bouncebit,293
Canto,159
Celo,125
Codex,323
Concrete,366
Conflux eSpace,212
CoreDAO,153
Corn,331
Cronos EVM,359
Cronos zkEVM,360
Cyber,283
DFK,115
DM2 Verse,315
DOS Chain,149
Degen,267
Dexalot,118
EDU Chain,328
Flow EVM,336
Ethereum,101
Etherlink,292
Fantom,112
Flare,295
Fraxtal,255
Fuse,138
Glue,342
Gnosis,145
Goat,361
Gravity,294
Gunz,371
Harmony,116
Hedera,316
Hemi,329
Homeverse,265
Horizen EON,215
HyperEVM,367
Ink,339
Japan Open Chain,285
Kaia,150
Kava,177
Lens,373
Lightlink,309
Linea,183
Lisk,321
Loot,197
Lyra,311
Manta,217
Mantle,181
Merlin,266
Meter,176
Metis,151
Mode,260
Moonbeam,126
Moonriver,167
Morph,322
Aurora,211
Nibiru,369
OKX,155
Optimism,111
Orderly,213
Otherworld Space,341
Peaq,302
Plume,370
Polygon,109
Polygon zkEVM,158
Rari Chain,235
Reya,313
Rootstock,333
Sanko,278
Scroll,214
Sei,280
Shimmer,230
Skale,273
Soneium,340
Sonic Mainnet,332
Sophon,334
Story,364
Subtensor EVM,374
Superposition,327
Swell,335
Taiko,290
TelosEVM,199
Tenet,173
Tiltyard,238
Unichain,320
Vana,330
Viction,196
Worldchain,319
XChain,291
XDC,365
XLayer,274
XPLA,216
Xai,236
Zircuit,303
Zora,195
inEVM,234
opBNB,202
re.al,237
zkLink,301
zkSync Era,165
1 chain_name chain_id
2 Abstract 324
3 Animechain 372
4 Ape 312
5 Aptos 108
6 Arbitrum 110
7 Arbitrum Nova 175
8 Astar zkEVM 257
9 Avalanche 106
10 BSC 102
11 BOB 279
12 Bahamut 363
13 Base 184
14 Beam 198
15 Berachain 362
16 Bevm 317
17 Bitlayer 314
18 Blast 243
19 Bouncebit 293
20 Canto 159
21 Celo 125
22 Codex 323
23 Concrete 366
24 Conflux eSpace 212
25 CoreDAO 153
26 Corn 331
27 Cronos EVM 359
28 Cronos zkEVM 360
29 Cyber 283
30 DFK 115
31 DM2 Verse 315
32 DOS Chain 149
33 Degen 267
34 Dexalot 118
35 EDU Chain 328
36 Flow EVM 336
37 Ethereum 101
38 Etherlink 292
39 Fantom 112
40 Flare 295
41 Fraxtal 255
42 Fuse 138
43 Glue 342
44 Gnosis 145
45 Goat 361
46 Gravity 294
47 Gunz 371
48 Harmony 116
49 Hedera 316
50 Hemi 329
51 Homeverse 265
52 Horizen EON 215
53 HyperEVM 367
54 Ink 339
55 Japan Open Chain 285
56 Kaia 150
57 Kava 177
58 Lens 373
59 Lightlink 309
60 Linea 183
61 Lisk 321
62 Loot 197
63 Lyra 311
64 Manta 217
65 Mantle 181
66 Merlin 266
67 Meter 176
68 Metis 151
69 Mode 260
70 Moonbeam 126
71 Moonriver 167
72 Morph 322
73 Aurora 211
74 Nibiru 369
75 OKX 155
76 Optimism 111
77 Orderly 213
78 Otherworld Space 341
79 Peaq 302
80 Plume 370
81 Polygon 109
82 Polygon zkEVM 158
83 Rari Chain 235
84 Reya 313
85 Rootstock 333
86 Sanko 278
87 Scroll 214
88 Sei 280
89 Shimmer 230
90 Skale 273
91 Soneium 340
92 Sonic Mainnet 332
93 Sophon 334
94 Story 364
95 Subtensor EVM 374
96 Superposition 327
97 Swell 335
98 Taiko 290
99 TelosEVM 199
100 Tenet 173
101 Tiltyard 238
102 Unichain 320
103 Vana 330
104 Viction 196
105 Worldchain 319
106 XChain 291
107 XDC 365
108 XLayer 274
109 XPLA 216
110 Xai 236
111 Zircuit 303
112 Zora 195
113 inEVM 234
114 opBNB 202
115 re.al 237
116 zkLink 301
117 zkSync Era 165

View File

@ -0,0 +1,61 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true },
meta ={
'database_tags':{
'table':{
'PROTOCOL': 'MESON, STARGATE, SYMBIOSIS, GASZIP, COREBRIDGE, GASZIP',
'PURPOSE': 'BRIDGE'
} } }
) }}
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
bridge_address,
event_name,
platform,
sender,
receiver,
destination_chain_receiver,
COALESCE(
standard_destination_chain,
b.destination_chain
) AS destination_chain,
destination_chain_id,
token_address,
token_symbol,
amount_unadj,
amount,
ROUND(
CASE
WHEN amount_usd < 1e+15 THEN amount_usd
ELSE NULL
END,
2
) AS amount_usd,
COALESCE (
complete_bridge_activity_id,
{{ dbt_utils.generate_surrogate_key(
['_id']
) }}
) AS ez_bridge_activity_id,
COALESCE(
inserted_timestamp,
'2000-01-01'
) AS inserted_timestamp,
COALESCE(
modified_timestamp,
'2000-01-01'
) AS modified_timestamp
FROM
{{ ref('silver_bridge__complete_bridge_activity') }}
b
LEFT JOIN {{ ref('silver_bridge__standard_dst_chain_seed') }} C
ON b.destination_chain = C.destination_chain

View File

@ -0,0 +1,54 @@
version: 2
models:
- name: defi__ez_bridge_activity
description: '{{ doc("evm_ez_bridge_activity_table_doc") }}'
columns:
- name: BLOCK_NUMBER
description: '{{ doc("evm_block_number") }}'
- name: BLOCK_TIMESTAMP
description: '{{ doc("evm_block_timestamp") }}'
- name: TX_HASH
description: '{{ doc("evm_logs_tx_hash") }}'
- name: CONTRACT_ADDRESS
description: '{{ doc("evm_logs_contract_address") }}'
- name: EVENT_NAME
description: '{{ doc("evm_event_name") }}'
- name: EVENT_INDEX
description: '{{ doc("evm_event_index") }}'
- name: ORIGIN_FUNCTION_SIGNATURE
description: '{{ doc("evm_tx_origin_sig") }}'
- name: ORIGIN_FROM_ADDRESS
description: '{{ doc("evm_bridge_origin_from") }}'
- name: ORIGIN_TO_ADDRESS
description: '{{ doc("arb_origin_from") }}'
- name: PLATFORM
description: '{{ doc("evm_bridge_platform") }}'
- name: SENDER
description: '{{ doc("evm_bridge_sender") }}'
- name: RECEIVER
description: '{{ doc("evm_bridge_receiver") }}'
- name: DESTINATION_CHAIN_RECEIVER
description: '{{ doc("evm_bridge_destination_chain_receiver") }}'
- name: DESTINATION_CHAIN
description: '{{ doc("evm_bridge_destination_chain") }}'
- name: DESTINATION_CHAIN_ID
description: '{{ doc("evm_bridge_destination_chain_id") }}'
- name: BRIDGE_ADDRESS
description: '{{ doc("evm_bridge_address") }}'
- name: TOKEN_ADDRESS
description: '{{ doc("evm_bridge_token_address") }}'
- name: TOKEN_SYMBOL
description: '{{ doc("evm_bridge_token_symbol") }}'
- name: AMOUNT_UNADJ
description: '{{ doc("evm_bridge_amount_unadj") }}'
- name: AMOUNT
description: '{{ doc("evm_bridge_amount") }}'
- name: AMOUNT_USD
description: '{{ doc("evm_bridge_amount_usd") }}'
- name: EZ_BRIDGE_ACTIVITY_ID
description: '{{ doc("evm_pk") }}'
- name: INSERTED_TIMESTAMP
description: '{{ doc("evm_inserted_timestamp") }}'
- name: MODIFIED_TIMESTAMP
description: '{{ doc("evm_modified_timestamp") }}'

View File

@ -0,0 +1,78 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = "block_number",
cluster_by = ['block_timestamp::DATE'],
tags = ['silver_bridge','defi','bridge','curated']
) }}
WITH unwrap_token AS (
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
contract_address,
tx_hash,
event_index,
'UnwrapToken' AS event_name,
'core-bridge' AS platform,
'v1' AS version,
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS local_token,
CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS remote_token,
TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [2] :: STRING)) AS remote_chain_id,
CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS to_address,
TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [4] :: STRING)) AS amount_unadj,
CONCAT(
tx_hash :: STRING,
'-',
event_index :: STRING
) AS _log_id,
modified_timestamp AS _inserted_timestamp
FROM
core.core.fact_event_logs
WHERE
contract_address = '0xa4218e1f39da4aadac971066458db56e901bcbde'
AND topic_0 = '0x3b661011d9e0ff8f0dc432bac4ed79eabf70cf52596ed9de985810ef36689e9e'
AND tx_succeeded
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
)
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
contract_address AS bridge_address,
contract_address,
event_name,
platform,
'v1' AS version,
origin_from_address AS sender,
to_address AS receiver,
receiver AS destination_chain_receiver,
remote_chain_id :: STRING AS destination_chain_id,
s.chain_name AS destination_chain,
local_token AS token_address,
amount_unadj,
_log_id,
_inserted_timestamp
FROM
unwrap_token
LEFT JOIN {{ ref('silver_bridge__stargate_chain_id_seed') }}
s
ON unwrap_token.remote_chain_id :: STRING = s.chain_id :: STRING

View File

@ -0,0 +1,73 @@
version: 2
models:
- name: silver_bridge__corebridge_unwraptoken
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
- 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: _INSERTED_TIMESTAMP
tests:
- not_null

View File

@ -0,0 +1,152 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = "block_number",
cluster_by = ['block_timestamp::DATE'],
tags = ['silver_bridge','defi','bridge','curated']
) }}
WITH senddeposits AS (
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
contract_address,
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS to_address,
TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [2] :: STRING)) AS VALUE,
TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [3] :: STRING)) AS fee,
CONCAT('0x', SUBSTR(segmented_data [4] :: STRING, 25, 40)) AS from_address,
modified_timestamp AS _inserted_timestamp
FROM
{{ ref('core__fact_event_logs') }}
WHERE
contract_address = '0x26da582889f59eaae9da1f063be0140cd93e6a4f' -- gaszip l0 v2
AND topic_0 = '0xa22a487af6300dc77db439586e8ce7028fd7f1d734efd33b287bc1e2af4cd162' -- senddeposits
AND tx_succeeded
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
),
packetsent AS (
SELECT
tx_hash,
event_index,
DATA,
CONCAT('0x', SUBSTR(DATA, 155, 40)) AS send_lib,
utils.udf_hex_to_int(SUBSTR(DATA, 261, 16)) AS nonce,
utils.udf_hex_to_int(SUBSTR(DATA, 277, 8)) AS srcEid,
CONCAT('0x', SUBSTR(DATA, 258 + 18 + 8 + 25, 40)) AS src_app_address,
utils.udf_hex_to_int(SUBSTR(DATA, 258 + 18 + 8 + 64 + 1, 8)) AS dstEid,
CONCAT('0x', SUBSTR(DATA, 258 + 18 + 8 + 64 + 8 + 25, 40)) AS dst_app_address,
TRY_TO_NUMBER(utils.udf_hex_to_int(SUBSTR(DATA, 630 + 1, 32))) AS native_amount,
CONCAT('0x', SUBSTR(DATA, 630 + 1 + 32 + 24, 40)) AS receiver,
ROW_NUMBER() over (
PARTITION BY tx_hash
ORDER BY
event_index ASC
) event_rank
FROM
{{ ref('core__fact_event_logs') }}
WHERE
contract_address = '0x1a44076050125825900e736c501f859c50fe728c' -- l0 endpoint v2
AND topic_0 = '0x1ab700d4ced0c005b164c0f789fd09fcbb0156d4c2041b8a3bfbcd961cd1567f' -- packetsent
AND tx_hash IN (
SELECT
tx_hash
FROM
senddeposits
)
AND tx_succeeded
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
),
nativetransfers AS (
SELECT
tx_hash,
TRY_TO_NUMBER(amount_precise_raw) AS amount_precise_raw,
'0x40375c92d9faf44d2f9db9bd9ba41a3317a2404f' AS token_address,
-- wrapped native
ROW_NUMBER() over (
PARTITION BY tx_hash
ORDER BY
trace_index ASC
) transfer_rank
FROM
{{ ref('core__ez_native_transfers') }}
WHERE
from_address = '0x1a44076050125825900e736c501f859c50fe728c' -- l0 endpoint v2
AND to_address = '0x0bcac336466ef7f1e0b5c184aab2867c108331af' -- SendUln302
AND tx_hash IN (
SELECT
tx_hash
FROM
senddeposits
)
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
)
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
s.tx_hash,
p.event_index,
'SendDeposit' AS event_name,
'gaszip-lz-v2' AS platform,
'v2' AS version,
contract_address AS bridge_address,
contract_address,
from_address AS sender,
receiver,
receiver AS destination_chain_receiver,
nonce,
dstEid AS destination_chain_id,
chain AS destination_chain,
amount_precise_raw AS amount_unadj,
token_address,
CONCAT(
s.tx_hash :: STRING,
'-',
p.event_index :: STRING
) AS _log_id,
_inserted_timestamp
FROM
senddeposits s
INNER JOIN packetsent p
ON s.tx_hash = p.tx_hash
LEFT JOIN nativetransfers t
ON p.tx_hash = t.tx_hash
AND event_rank = transfer_rank
LEFT JOIN {{ ref('silver_bridge__layerzero_bridge_seed') }}
ON dstEid = eid

View File

@ -0,0 +1,73 @@
version: 2
models:
- name: silver_bridge__gaszip_lz_sentdeposits
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
- 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: _INSERTED_TIMESTAMP
tests:
- not_null

View File

@ -0,0 +1,189 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = "block_number",
cluster_by = ['block_timestamp::DATE'],
tags = ['silver_bridge','defi','bridge','curated']
) }}
WITH token_transfers AS (
SELECT
block_number,
block_timestamp,
origin_function_signature,
origin_from_address,
origin_to_address,
tx_hash,
event_index,
contract_address,
from_address,
to_address,
raw_amount,
CONCAT(
tx_hash :: STRING,
'-',
event_index :: STRING
) AS _log_id,
modified_timestamp AS _inserted_timestamp
FROM
{{ ref('core__ez_token_transfers') }}
WHERE
from_address <> '0x0000000000000000000000000000000000000000'
AND to_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3'
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
),
native_transfers AS (
SELECT
et.block_number,
et.block_timestamp,
et.tx_hash,
tx.from_address AS origin_from_address,
tx.to_address AS origin_to_address,
tx.origin_function_signature,
et.from_address,
et.to_address,
amount_precise_raw,
et.ez_native_transfers_id AS _call_id,
et.modified_timestamp AS _inserted_timestamp
FROM
{{ ref('core__ez_native_transfers') }}
et
INNER JOIN {{ ref('core__fact_transactions') }}
tx
ON et.block_number = tx.block_number
AND et.tx_hash = tx.tx_hash
WHERE
et.to_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3'
and et.tx_hash not in (select tx_hash from token_transfers)
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
{% endif %}
),
all_transfers AS (
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
'Transfer' AS event_name,
to_address AS bridge_address,
from_address AS sender,
to_address AS receiver,
raw_amount AS amount_unadj,
contract_address AS token_address,
{{ dbt_utils.generate_surrogate_key(
['_log_id']
) }} AS _id,
_inserted_timestamp
FROM
token_transfers
UNION ALL
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
NULL AS event_index,
NULL AS event_name,
to_address AS bridge_address,
from_address AS sender,
to_address AS receiver,
amount_precise_raw AS amount_unadj,
LOWER('0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c') AS token_address,
{{ dbt_utils.generate_surrogate_key(
['_call_id']
) }} AS _id,
_inserted_timestamp
FROM
native_transfers
),
dst_info AS (
SELECT
block_number,
tx_hash,
topics [1] :: STRING AS encoded_data,
SUBSTR(RIGHT(encoded_data, 12), 1, 4) AS destination_chain_id,
CONCAT(
tx_hash :: STRING,
'-',
event_index :: STRING
) AS _log_id,
modified_timestamp AS _inserted_timestamp
FROM
{{ ref('core__fact_event_logs') }}
WHERE
contract_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3'
AND topic_0 IN (
'0x5ce4019f772fda6cb703b26bce3ec3006eb36b73f1d3a0eb441213317d9f5e9d',
'0x8d92c805c252261fcfff21ee60740eb8a38922469a7e6ee396976d57c22fc1c9'
)
AND tx_succeeded
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '16 hours'
FROM
{{ this }}
)
{% endif %}
)
SELECT
t.block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
t.tx_hash,
event_index,
event_name,
'meson' AS platform,
bridge_address,
sender,
receiver,
CASE
WHEN origin_from_address = '0x0000000000000000000000000000000000000000' THEN sender
ELSE origin_from_address
END AS destination_chain_receiver,
amount_unadj,
destination_chain_id,
COALESCE(LOWER(chain), 'other') AS destination_chain,
token_address,
_id,
t._inserted_timestamp
FROM
all_transfers t
INNER JOIN dst_info d
ON t.tx_hash = d.tx_hash
AND t.block_number = d.block_number
LEFT JOIN {{ ref('silver_bridge__meson_chain_id_seed') }}
s
ON d.destination_chain_id :: STRING = RIGHT(
s.short_coin_type,
4
) :: STRING
WHERE
origin_to_address IS NOT NULL qualify (ROW_NUMBER() over (PARTITION BY _id
ORDER BY
t._inserted_timestamp DESC)) = 1

View File

@ -0,0 +1,52 @@
version: 2
models:
- name: silver_bridge__meson_transfer
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- _ID
columns:
- name: BLOCK_NUMBER
tests:
- not_null
- name: BLOCK_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_LTZ
- TIMESTAMP_NTZ
- name: TX_HASH
tests:
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: TOKEN_ADDRESS
tests:
- not_null
- name: SENDER
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: BRIDGE_ADDRESS
tests:
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: AMOUNT_UNADJ
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- DECIMAL
- FLOAT
- NUMBER
- name: _INSERTED_TIMESTAMP
tests:
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 7

View File

@ -0,0 +1,520 @@
-- depends_on: {{ ref('silver__complete_token_prices') }}
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = ['block_number','platform','version'],
cluster_by = ['block_timestamp::DATE','platform'],
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(tx_hash, origin_from_address, origin_to_address, origin_function_signature, bridge_address, sender, receiver, destination_chain_receiver, destination_chain_id, destination_chain, token_address, token_symbol), SUBSTRING(origin_function_signature, bridge_address, sender, receiver, destination_chain_receiver, destination_chain, token_address, token_symbol)",
tags = ['curated','reorg','heal']
) }}
WITH corebridge AS (
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
bridge_address,
event_name,
platform,
version,
sender,
receiver,
destination_chain_receiver,
destination_chain_id :: STRING AS destination_chain_id,
destination_chain,
token_address,
NULL AS token_symbol,
amount_unadj,
_log_id AS _id,
_inserted_timestamp
FROM
{{ ref('silver_bridge__corebridge_unwraptoken') }}
{% if is_incremental() and 'corebridge' not in var('HEAL_MODELS') %}
WHERE
_inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
FROM
{{ this }}
)
{% endif %}
),
gaszip_lz AS (
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
bridge_address,
event_name,
platform,
version,
sender,
receiver,
destination_chain_receiver,
destination_chain_id :: STRING AS destination_chain_id,
destination_chain,
token_address,
NULL AS token_symbol,
amount_unadj,
_log_id AS _id,
_inserted_timestamp
FROM
{{ ref('silver_bridge__gaszip_lz_sentdeposits') }}
{% if is_incremental() and 'gaszip_lz' not in var('HEAL_MODELS') %}
WHERE
_inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
FROM
{{ this }}
)
{% endif %}
),
meson AS (
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
bridge_address,
event_name,
platform,
'v1' AS version,
sender,
receiver,
destination_chain_receiver,
destination_chain_id :: STRING AS destination_chain_id,
destination_chain,
token_address,
NULL AS token_symbol,
amount_unadj,
_id,
_inserted_timestamp
FROM
{{ ref('silver_bridge__meson_transfer') }}
{% if is_incremental() and 'meson' not in var('HEAL_MODELS') %}
WHERE
_inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
FROM
{{ this }}
)
{% endif %}
),
stargate_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,
destination_chain,
token_address,
NULL AS token_symbol,
amount_unadj,
_log_id AS _id,
_inserted_timestamp
FROM
{{ ref('silver_bridge__stargate_v2_oftsent') }}
{% if is_incremental() and 'stargate_v2' not in var('HEAL_MODELS') %}
WHERE
_inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
FROM
{{ this }}
)
{% endif %}
),
symbiosis AS (
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
bridge_address,
event_name,
platform,
'v1' 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_unadj,
_log_id AS _id,
_inserted_timestamp
FROM
{{ ref('silver_bridge__symbiosis_synthesizerequest') }}
{% if is_incremental() and 'symbiosis' not in var('HEAL_MODELS') %}
WHERE
_inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
FROM
{{ this }}
)
{% endif %}
),
all_protocols AS (
SELECT
*
FROM
corebridge
UNION ALL
SELECT
*
FROM
gaszip_lz
UNION ALL
SELECT
*
FROM
meson
UNION ALL
SELECT
*
FROM
stargate_v2
UNION ALL
SELECT
*
FROM
symbiosis
),
complete_bridge_activity AS (
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
bridge_address,
event_name,
platform,
version,
sender,
receiver,
destination_chain_receiver,
CASE
WHEN CONCAT(
platform,
'-',
version
) IN (
'meson-v1',
'stargate-v2-v2',
'gaszip-lz-v2-v2',
'core-bridge-v1'
) THEN destination_chain_id :: STRING
WHEN d.chain_id IS NULL THEN destination_chain_id :: STRING
ELSE d.chain_id :: STRING
END AS destination_chain_id,
CASE
WHEN CONCAT(
platform,
'-',
version
) IN (
'meson-v1'
) THEN LOWER(destination_chain)
WHEN d.chain IS NULL THEN LOWER(destination_chain)
ELSE LOWER(
d.chain
)
END AS destination_chain,
b.token_address,
CASE
WHEN platform = 'axelar' THEN COALESCE(
C.token_symbol,
b.token_symbol
)
ELSE C.token_symbol
END AS token_symbol,
C.token_decimals AS token_decimals,
amount_unadj,
CASE
WHEN C.token_decimals IS NOT NULL THEN (amount_unadj / pow(10, C.token_decimals))
ELSE amount_unadj
END AS amount,
CASE
WHEN C.token_decimals IS NOT NULL THEN ROUND(
amount * p.price,
2
)
ELSE NULL
END AS amount_usd,
_id,
b._inserted_timestamp
FROM
all_protocols b
LEFT JOIN {{ ref('silver__contracts') }} C
ON b.token_address = C.contract_address
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
p
ON b.token_address = p.token_address
AND DATE_TRUNC(
'hour',
block_timestamp
) = p.hour
LEFT JOIN {{ source(
'external_gold_defillama',
'dim_chains'
) }}
d
ON d.chain_id :: STRING = b.destination_chain_id :: STRING
OR LOWER(
d.chain
) = LOWER(
b.destination_chain
)
),
{% if is_incremental() and var(
'HEAL_MODEL'
) %}
heal_model AS (
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
bridge_address,
event_name,
platform,
version,
sender,
receiver,
destination_chain_receiver,
destination_chain_id,
destination_chain,
t0.token_address,
C.token_symbol AS token_symbol,
C.token_decimals AS token_decimals,
amount_unadj,
CASE
WHEN C.token_decimals IS NOT NULL THEN (amount_unadj / pow(10, C.token_decimals))
ELSE amount_unadj
END AS amount_heal,
CASE
WHEN C.token_decimals IS NOT NULL THEN amount_heal * p.price
ELSE NULL
END AS amount_usd_heal,
_id,
t0._inserted_timestamp
FROM
{{ this }}
t0
LEFT JOIN {{ ref('silver__contracts') }} C
ON t0.token_address = C.contract_address
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
p
ON t0.token_address = p.token_address
AND DATE_TRUNC(
'hour',
block_timestamp
) = p.hour
WHERE
CONCAT(
t0.block_number,
'-',
t0.platform,
'-',
t0.version
) IN (
SELECT
CONCAT(
t1.block_number,
'-',
t1.platform,
'-',
t1.version
)
FROM
{{ this }}
t1
WHERE
t1.token_decimals IS NULL
AND t1._inserted_timestamp < (
SELECT
MAX(
_inserted_timestamp
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
FROM
{{ this }}
)
AND EXISTS (
SELECT
1
FROM
{{ ref('silver__contracts') }} C
WHERE
C._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
AND C.token_decimals IS NOT NULL
AND C.contract_address = t1.token_address)
GROUP BY
1
)
OR CONCAT(
t0.block_number,
'-',
t0.platform,
'-',
t0.version
) IN (
SELECT
CONCAT(
t2.block_number,
'-',
t2.platform,
'-',
t2.version
)
FROM
{{ this }}
t2
WHERE
t2.amount_usd IS NULL
AND t2._inserted_timestamp < (
SELECT
MAX(
_inserted_timestamp
) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}'
FROM
{{ this }}
)
AND EXISTS (
SELECT
1
FROM
{{ ref('silver__complete_token_prices') }}
p
WHERE
p._inserted_timestamp > DATEADD('DAY', -14, SYSDATE())
AND p.price IS NOT NULL
AND p.token_address = t2.token_address
AND p.hour = DATE_TRUNC(
'hour',
t2.block_timestamp
)
)
GROUP BY
1
)
),
{% endif %}
FINAL AS (
SELECT
*
FROM
complete_bridge_activity
{% if is_incremental() and var(
'HEAL_MODEL'
) %}
UNION ALL
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
bridge_address,
event_name,
platform,
version,
sender,
receiver,
destination_chain_receiver,
destination_chain_id,
destination_chain,
token_address,
token_symbol,
token_decimals,
amount_unadj,
amount_heal AS amount,
amount_usd_heal AS amount_usd,
_id,
_inserted_timestamp
FROM
heal_model
{% endif %}
)
SELECT
block_number,
block_timestamp,
origin_from_address,
origin_to_address,
origin_function_signature,
tx_hash,
event_index,
bridge_address,
event_name,
platform,
version,
sender,
receiver,
destination_chain_receiver,
destination_chain_id,
destination_chain,
token_address,
token_symbol,
token_decimals,
amount_unadj,
amount,
amount_usd,
_id,
_inserted_timestamp,
{{ dbt_utils.generate_surrogate_key(
['_id']
) }} AS complete_bridge_activity_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
FINAL
WHERE
destination_chain <> 'core' qualify (ROW_NUMBER() over (PARTITION BY _id
ORDER BY
_inserted_timestamp DESC)) = 1

View File

@ -0,0 +1,83 @@
version: 2
models:
- name: silver_bridge__complete_bridge_activity
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- _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:
where: PLATFORM NOT IN ('stargate')
- 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:
where: VERSION <> 'v1-native' AND PLATFORM NOT IN ('wormhole','meson')
- name: EVENT_NAME
tests:
- not_null:
where: VERSION <> 'v1-native' AND PLATFORM NOT IN ('wormhole','meson')
- name: BRIDGE_ADDRESS
tests:
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: DESTINATION_CHAIN
- not_null
- name: DESTINATION_CHAIN_RECEIVER
tests:
- not_null
- name: PLATFORM
- not_null
- name: VERSION
- not_null
- 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: 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: _INSERTED_TIMESTAMP
tests:
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 3

View File

@ -0,0 +1,254 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = "block_number",
cluster_by = ['block_timestamp::DATE'],
tags = ['silver_bridge','defi','bridge','curated']
) }}
WITH stargate_contracts AS (
SELECT
block_timestamp,
tx_hash,
to_address AS contract_address,
POSITION(
'00000000000000000000000000000000000000000000000000000000000000c0',
input,
LENGTH(input) - 703
) AS argument_start,
SUBSTR(input, argument_start, LENGTH(input) - argument_start + 1) AS arguments,
regexp_SUBSTR_all(SUBSTR(arguments, 0, len(arguments)), '.{64}') AS segmented_arguments,
ARRAY_SIZE(segmented_arguments) AS data_size,
CONCAT(
'0x',
SUBSTR(
segmented_arguments [2] :: STRING,
25,
40
)
) AS token_address,
utils.udf_hex_to_int(
segmented_arguments [data_size-8] :: STRING
) AS decimals,
utils.udf_hex_to_int(
segmented_arguments [data_size-7] :: STRING
) AS shared_decimals,
CONCAT(
'0x',
SUBSTR(
segmented_arguments [data_size-6] :: STRING,
25,
40
)
) AS endpoint,
CONCAT(
'0x',
SUBSTR(
segmented_arguments [data_size-5] :: STRING,
25,
40
)
) AS owner,
utils.udf_hex_to_string(
segmented_arguments [data_size-3] :: STRING
) AS token_name,
utils.udf_hex_to_string(
segmented_arguments [data_size-1] :: STRING
) AS token_symbol
FROM
{{ ref('core__fact_traces') }}
WHERE
origin_function_signature = '0x61014060'
AND from_address = '0x1d7c6783328c145393e84fb47a7f7c548f5ee28d'
AND trace_succeeded
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
),
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,
'OFTSent' AS event_name,
'stargate-v2' AS platform,
topic_1 AS guid,
CONCAT('0x', SUBSTR(topic_2, 27, 40)) AS from_address,
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
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 :: STRING,
'-',
event_index :: STRING
) AS _log_id,
modified_timestamp AS _inserted_timestamp
FROM
{{ ref('core__fact_event_logs') }}
e
INNER JOIN stargate_contracts USING(contract_address)
WHERE
topics [0] = '0x85496b760a4b7f8d66384b9df21b381f5d1b1e79f229a47aaf4c232edc2fe59a'
AND tx_succeeded
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
),
bus_mode AS (
SELECT
tx_hash,
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
TRY_TO_NUMBER(
utils.udf_hex_to_int(
segmented_data [0] :: STRING
)
) AS dst_eid,
TRY_TO_NUMBER(
utils.udf_hex_to_int(
segmented_data [1] :: STRING
)
) AS ticket,
TRY_TO_NUMBER(
utils.udf_hex_to_int(
segmented_data [2] :: STRING
)
) AS fare,
SUBSTR(
DATA,
3 + 64 * 5,
128
) AS passenger,
TRY_TO_NUMBER(utils.udf_hex_to_int(SUBSTR(passenger, 3, 4))) AS asset_id,
CONCAT('0x', SUBSTR(passenger, 3 + 4 + 24, 40)) AS receiver,
FROM
{{ ref('core__fact_event_logs') }}
WHERE
contract_address = LOWER('0xaf54be5b6eec24d6bfacf1cce4eaf680a8239398') -- tokenmessaging
AND topics [0] = '0x15955c5a4cc61b8fbb05301bce47fd31c0e6f935e1ab97fdac9b134c887bb074' -- BusRode
AND tx_hash IN (
SELECT
tx_hash
FROM
oft_sent
)
AND tx_succeeded
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
),
taxi_mode AS (
SELECT
tx_hash,
input,
SUBSTR(input, 11, len(input)),
regexp_substr_all(SUBSTR(input, 11, len(input)), '.{64}') AS segmented_data,
CONCAT('0x', SUBSTR(segmented_data [4] :: STRING, 25, 40)) AS sender,
TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [5] :: STRING)) AS dstEid,
CONCAT('0x', SUBSTR(segmented_data [6] :: STRING, 25, 40)) AS receiver,
TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [7] :: STRING)) AS amountSD
FROM
{{ ref('core__fact_traces') }}
WHERE
to_address = '0xaf54be5b6eec24d6bfacf1cce4eaf680a8239398'
AND from_address IN (
SELECT
contract_address
FROM
stargate_contracts
)
AND tx_hash IN (
SELECT
tx_hash
FROM
oft_sent
)
AND LEFT(
input,
10
) = '0xff6fb300'
AND tx_succeeded
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
)
SELECT
block_number,
b.block_timestamp,
b.tx_hash,
origin_function_signature,
origin_from_address,
origin_to_address,
'0x1a44076050125825900e736c501f859c50fe728c' AS bridge_address,
event_index,
event_name,
platform,
origin_from_address AS sender,
receiver,
receiver AS destination_chain_receiver,
amountSentLD AS amount_unadj,
b.dstEid AS destination_chain_id,
LOWER(
s.chain :: STRING
) AS destination_chain,
C.token_address,
_log_id,
b._inserted_timestamp
FROM
oft_sent b
INNER JOIN stargate_contracts C
ON b.contract_address = C.contract_address
LEFT JOIN (
SELECT
receiver,
tx_hash
FROM
bus_mode
UNION ALL
SELECT
receiver,
tx_hash
FROM
taxi_mode
) m
ON m.tx_hash = b.tx_hash
INNER JOIN {{ ref('silver_bridge__layerzero_bridge_seed') }}
s
ON b.dstEid :: STRING = s.eid :: STRING
ORDER BY
block_timestamp DESC

View File

@ -0,0 +1,52 @@
version: 2
models:
- name: silver_bridge__stargate_v2_oftsent
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- _ID
columns:
- name: BLOCK_NUMBER
tests:
- not_null
- name: BLOCK_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_LTZ
- TIMESTAMP_NTZ
- name: TX_HASH
tests:
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: TOKEN_ADDRESS
tests:
- not_null
- name: SENDER
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: BRIDGE_ADDRESS
tests:
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: AMOUNT_UNADJ
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- DECIMAL
- FLOAT
- NUMBER
- name: _INSERTED_TIMESTAMP
tests:
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 3

View File

@ -0,0 +1,84 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = "block_number",
cluster_by = ['block_timestamp::DATE'],
tags = ['silver_bridge','defi','bridge','curated']
) }}
WITH base_evt AS (
SELECT
block_number,
block_timestamp,
tx_hash,
origin_function_signature,
origin_from_address,
origin_to_address,
contract_address,
'symbiosis' AS platform,
event_index,
topics [0] :: STRING AS topic_0,
event_name,
TRY_TO_NUMBER(
decoded_log :"amount" :: STRING
) AS amount_unadj,
TRY_TO_NUMBER(
decoded_log :"chainID" :: STRING
) AS chainID,
decoded_log :"from" :: STRING AS from_address,
decoded_log :"id" :: STRING AS id,
decoded_log :"revertableAddress" :: STRING AS revertableAddress,
decoded_log :"to" :: STRING AS to_address,
decoded_log :"token" :: STRING AS token,
CONCAT(
tx_hash :: STRING,
'-',
event_index :: STRING
) AS _log_id,
modified_timestamp AS _inserted_timestamp
FROM
{{ ref('core__ez_decoded_event_logs') }}
WHERE
topics [0] :: STRING = '0x31325fe0a1a2e6a5b1e41572156ba5b4e94f0fae7e7f63ec21e9b5ce1e4b3eab'
AND contract_address IN (
'0x292fc50e4eb66c3f6514b9e402dbc25961824d62'
)
AND tx_succeeded
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
{% endif %}
)
SELECT
block_number,
block_timestamp,
origin_function_signature,
origin_from_address,
origin_to_address,
tx_hash,
event_index,
topic_0,
event_name,
tx_status,
contract_address AS bridge_address,
platform,
from_address AS sender,
to_address AS receiver,
receiver AS destination_chain_receiver,
amount_unadj,
chainID AS destination_chain_id,
id,
revertableAddress AS revertable_address,
token AS token_address,
_log_id,
_inserted_timestamp
FROM
base_evt

View File

@ -0,0 +1,52 @@
version: 2
models:
- name: silver_bridge__symbiosis_synthesizerequest
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- _ID
columns:
- name: BLOCK_NUMBER
tests:
- not_null
- name: BLOCK_TIMESTAMP
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- TIMESTAMP_LTZ
- TIMESTAMP_NTZ
- name: TX_HASH
tests:
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: TOKEN_ADDRESS
tests:
- not_null
- name: SENDER
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: BRIDGE_ADDRESS
tests:
- not_null
- dbt_expectations.expect_column_values_to_match_regex:
regex: 0[xX][0-9a-fA-F]+
- name: AMOUNT_UNADJ
tests:
- not_null
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list:
- DECIMAL
- FLOAT
- NUMBER
- name: _INSERTED_TIMESTAMP
tests:
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 3

View File

@ -60,3 +60,8 @@ sources:
tables:
- name: logs
- name: decoded_logs
- name: external_gold_defillama
database: external
schema: defillama
tables:
- name: dim_chains