From adbabc5e91d4098a683e42ecbb16fbaa7995de9c Mon Sep 17 00:00:00 2001 From: drethereum <71602799+drethereum@users.noreply.github.com> Date: Thu, 4 Jan 2024 16:08:15 -0500 Subject: [PATCH] add/bridge-updates-op (#224) * updates for native * docs * symbol for axelar * bridge dst chain seed --- data/silver_bridge__meson_chain_id_seed.csv | 3 +- ...silver_bridge__standard_dst_chain_seed.csv | 98 +++++++++++++++++++ .../bridge/evm_bridge_activity.md | 2 +- models/gold/defi/defi__ez_bridge_activity.sql | 8 +- .../meson/silver_bridge__meson_transfers.sql | 14 +-- ...ilver_bridge__complete_bridge_activity.sql | 35 +++++-- ...> silver_bridge__synapse_token_bridge.sql} | 6 +- ...> silver_bridge__synapse_token_bridge.yml} | 2 +- ...er_bridge__synapse_tokenbridgeandswap.sql} | 0 ...er_bridge__synapse_tokenbridgeandswap.yml} | 2 +- 10 files changed, 148 insertions(+), 22 deletions(-) create mode 100644 data/silver_bridge__standard_dst_chain_seed.csv rename models/silver/defi/bridge/synapse/{silver_bridge__synapse_tokenredeem.sql => silver_bridge__synapse_token_bridge.sql} (88%) rename models/silver/defi/bridge/synapse/{silver_bridge__synapse_tokenredeem.yml => silver_bridge__synapse_token_bridge.yml} (97%) rename models/silver/defi/bridge/synapse/{silver_bridge__synapse_tokenredeemandswap.sql => silver_bridge__synapse_tokenbridgeandswap.sql} (100%) rename models/silver/defi/bridge/synapse/{silver_bridge__synapse_tokenredeemandswap.yml => silver_bridge__synapse_tokenbridgeandswap.yml} (97%) diff --git a/data/silver_bridge__meson_chain_id_seed.csv b/data/silver_bridge__meson_chain_id_seed.csv index 2ffe6a09..f27fa1c8 100644 --- a/data/silver_bridge__meson_chain_id_seed.csv +++ b/data/silver_bridge__meson_chain_id_seed.csv @@ -37,4 +37,5 @@ Sui,0x0310 Terra,0x014a Thorchain,0x03a3 Tron,0x00c3 -zkSync Era,0x0324 \ No newline at end of file +zkSync Era,0x0324 +zkFair,0xa70e \ No newline at end of file diff --git a/data/silver_bridge__standard_dst_chain_seed.csv b/data/silver_bridge__standard_dst_chain_seed.csv new file mode 100644 index 00000000..c5d87776 --- /dev/null +++ b/data/silver_bridge__standard_dst_chain_seed.csv @@ -0,0 +1,98 @@ +destination_chain,standard_destination_chain +acala,acala +algorand,algorand +aptos,aptos +arbitrum,arbitrum +arbitrum nova,arbitrum nova +arbitrum one,arbitrum +archway,archway +astar,astar +aurora,aurora +aurora mainnet,aurora +avalanche,avalanche +avalanche c-chain,avalanche +base,base +bnb,bsc +bnb chain,bsc +bnb smart chain mainnet,bsc +boba bnb mainnet,boba +boba network,boba +bsc,bsc +canto,canto +carbon,carbon +celo,celo +celo mainnet,celo +coinweb,coinweb +conflux,conflux +conflux espace,conflux +crab network,crab +crescent,crescent +cronos mainnet,cronos +crypto chain,crypto +dfk chain,dfk +dogechain mainnet,dogechain +eos,eos +ethereum,ethereum +ethereum mainnet,ethereum +evmos,evmos +fantom,fantom +fantom opera,fantom +filecoin,filecoin +fuse,fuse +gnosis,gnosis +harmony mainnet shard 0,harmony +huobi eco chain mainnet,huobi eco +injective,injective +juno,juno +karura,karura +kava,kava +klaytn,klaytn +klaytn mainnet cypress,klaytn +kujira,kujira +linea,linea +manta,manta +mantle,mantle +metis,metis +metis andromeda mainnet,metis +moonbeam,moonbeam +moonriver,moonriver +nautilus,nautilus +near,near +neutron,neutron +oasis,oasis +okxchain mainnet,okxchain +ontology mainnet,ontology +op mainnet,optimism +opbnb,opbnb +optimism,optimism +osmosis,osmosis +polygon,polygon +polygon mainnet,polygon +polygon pos,polygon +polygon zkevm,polygon zkevm +ronin,ronin +scroll,scroll +secret-snip,secret +sei,sei +skale europa,skale europa +skale nebula,skale nebula +solana,solana +stargaze,stargaze +starknet,starknet +sui,sui +telos evm mainnet,telos +terra,terra +terra-2,terra2 +terra2,terra2 +tezos,tezos +tron,tron +umee,umee +waves,waves +xpla,xpla +xrpl,xrpl +zkfair,zkfair +zksync era,zksync era +zksync era mainnet,zksync era +zksync lite,zksync lite +zora,zora +zzz,zzz diff --git a/models/doc_descriptions/bridge/evm_bridge_activity.md b/models/doc_descriptions/bridge/evm_bridge_activity.md index 29825057..35918467 100644 --- a/models/doc_descriptions/bridge/evm_bridge_activity.md +++ b/models/doc_descriptions/bridge/evm_bridge_activity.md @@ -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: ACROSS, AXELAR, CELER, CBRIDGE, HOP, MESON, MULTICHAIN, NATIVE, STARGATE, SYMBIOSIS, SYNAPSE, WORMHOLE 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, CELER, CBRIDGE, HOP, MESON, MULTICHAIN, STARGATE, SYMBIOSIS, SYNAPSE, WORMHOLE 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 %} diff --git a/models/gold/defi/defi__ez_bridge_activity.sql b/models/gold/defi/defi__ez_bridge_activity.sql index e1692aaf..8cdb52b5 100644 --- a/models/gold/defi/defi__ez_bridge_activity.sql +++ b/models/gold/defi/defi__ez_bridge_activity.sql @@ -24,7 +24,10 @@ SELECT sender, receiver, destination_chain_receiver, - destination_chain, + COALESCE( + standard_destination_chain, + b.destination_chain + ) AS destination_chain, destination_chain_id, token_address, token_symbol, @@ -47,3 +50,6 @@ SELECT ) 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 diff --git a/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql b/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql index e3fc5a9b..4172c316 100644 --- a/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql +++ b/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql @@ -45,21 +45,21 @@ native_transfers AS ( tx.from_address AS origin_from_address, tx.to_address AS origin_to_address, tx.origin_function_signature, - et.eth_from_address, - et.eth_to_address, + et.from_address, + et.to_address, amount_precise_raw, identifier, _call_id, et._inserted_timestamp FROM - {{ ref('core__ez_eth_transfers') }} + {{ ref('silver__native_transfers') }} et INNER JOIN {{ ref('silver__transactions') }} tx ON et.block_number = tx.block_number AND et.tx_hash = tx.tx_hash WHERE - et.eth_to_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3' + et.to_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3' {% if is_incremental() %} AND et._inserted_timestamp >= ( @@ -101,9 +101,9 @@ all_transfers AS ( tx_hash, NULL AS event_index, NULL AS event_name, - eth_to_address AS bridge_address, - eth_from_address AS sender, - eth_to_address AS receiver, + to_address AS bridge_address, + from_address AS sender, + to_address AS receiver, amount_precise_raw AS amount_unadj, '0x4200000000000000000000000000000000000006' AS token_address, {{ dbt_utils.generate_surrogate_key( diff --git a/models/silver/defi/bridge/silver_bridge__complete_bridge_activity.sql b/models/silver/defi/bridge/silver_bridge__complete_bridge_activity.sql index 449f30fd..ebc3a26a 100644 --- a/models/silver/defi/bridge/silver_bridge__complete_bridge_activity.sql +++ b/models/silver/defi/bridge/silver_bridge__complete_bridge_activity.sql @@ -26,6 +26,7 @@ WITH across AS ( 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, _inserted_timestamp @@ -61,6 +62,7 @@ axelar AS ( NULL AS destination_chain_id, destination_chain, token_address, + token_symbol, amount AS amount_unadj, _log_id AS _id, _inserted_timestamp @@ -96,6 +98,7 @@ celer_cbridge AS ( 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, _inserted_timestamp @@ -131,6 +134,7 @@ hop AS ( 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, _inserted_timestamp @@ -166,6 +170,7 @@ meson AS ( destination_chain_id :: STRING AS destination_chain_id, destination_chain, token_address, + NULL AS token_symbol, amount_unadj, _id, _inserted_timestamp @@ -201,6 +206,7 @@ multichain AS ( 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, _inserted_timestamp @@ -236,6 +242,7 @@ stargate AS ( destination_chain_id :: STRING AS destination_chain_id, destination_chain, token_address, + NULL AS token_symbol, amount_unadj, _log_id AS _id, _inserted_timestamp @@ -271,6 +278,7 @@ symbiosis AS ( 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, _inserted_timestamp @@ -287,7 +295,7 @@ WHERE ) {% endif %} ), -synapse_tr AS ( +synapse_tb AS ( SELECT block_number, block_timestamp, @@ -299,18 +307,19 @@ synapse_tr AS ( bridge_address, event_name, platform, - 'v1-td' AS version, + 'v1-tb' 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, _inserted_timestamp FROM - {{ ref('silver_bridge__synapse_tokenredeem') }} + {{ ref('silver_bridge__synapse_token_bridge') }} {% if is_incremental() %} WHERE @@ -322,7 +331,7 @@ WHERE ) {% endif %} ), -synapse_trs AS ( +synapse_tbs AS ( SELECT block_number, block_timestamp, @@ -334,18 +343,19 @@ synapse_trs AS ( bridge_address, event_name, platform, - 'v1-tds' AS version, + 'v1-tbs' 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, _inserted_timestamp FROM - {{ ref('silver_bridge__synapse_tokenredeemandswap') }} + {{ ref('silver_bridge__synapse_tokenbridgeandswap') }} {% if is_incremental() %} WHERE @@ -376,6 +386,7 @@ wormhole AS ( destination_chain_id :: STRING AS destination_chain_id, destination_chain, token_address, + NULL AS token_symbol, amount_unadj, _id, _inserted_timestamp @@ -436,12 +447,12 @@ all_protocols AS ( SELECT * FROM - synapse_tr + synapse_tb UNION ALL SELECT * FROM - synapse_trs + synapse_tbs UNION ALL SELECT * @@ -485,7 +496,13 @@ FINAL AS ( ) END AS destination_chain, b.token_address, - C.token_symbol AS token_symbol, + 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 diff --git a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeem.sql b/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql similarity index 88% rename from models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeem.sql rename to models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql index 76fe6849..3eb7a640 100644 --- a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeem.sql +++ b/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql @@ -36,7 +36,11 @@ WITH base_evt AS ( FROM {{ ref('silver__decoded_logs') }} WHERE - topics [0] :: STRING = '0xdc5bad4651c5fbe9977a696aadc65996c468cde1448dd468ec0d83bf61c4b57c' + topics [0] :: STRING IN ( + '0xdc5bad4651c5fbe9977a696aadc65996c468cde1448dd468ec0d83bf61c4b57c', + --redeem + '0xda5273705dbef4bf1b902a131c2eac086b7e1476a8ab0cb4da08af1fe1bd8e3b' --deposit + ) AND contract_address = '0xaf41a65f786339e7911f4acdad6bd49426f2dc6b' AND origin_to_address IS NOT NULL diff --git a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeem.yml b/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.yml similarity index 97% rename from models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeem.yml rename to models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.yml index 290a4856..f6ff9661 100644 --- a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeem.yml +++ b/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.yml @@ -1,6 +1,6 @@ version: 2 models: - - name: silver_bridge__synapse_tokenredeem + - name: silver_bridge__synapse_token_bridge tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: diff --git a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeemandswap.sql b/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.sql similarity index 100% rename from models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeemandswap.sql rename to models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.sql diff --git a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeemandswap.yml b/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.yml similarity index 97% rename from models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeemandswap.yml rename to models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.yml index 766ea68f..67fd4c59 100644 --- a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeemandswap.yml +++ b/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.yml @@ -1,6 +1,6 @@ version: 2 models: - - name: silver_bridge__synapse_tokenredeemandswap + - name: silver_bridge__synapse_tokenbridgeandswap tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: