Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DUX-839 Initiate sophon chain #7541

Merged
merged 22 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dbt_subprojects/daily_spellbook/models/evms/evms_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ FROM (
, (21000000, 'corn', 'Corn', 'Layer 1', NULL, 'BTCN', NULL, 'https://cornscan.io/', timestamp '2024-11-19 10:29:11', NULL, NULL, NULL, true)
, (146, 'sonic', 'Sonic', 'Layer 1', NULL, 'SONIC', NULL, 'https://sonicscan.org/', timestamp '2024-12-01 00:00', NULL, NULL, NULL, true)
, (57073, 'ink', 'Ink', 'Layer 2', 'Optimistic Rollup', 'ETH', 0x4200000000000000000000000000000000000006, 'https://explorer.inkonchain.com/', timestamp '2024-12-06 15:20', 'OP Stack', 'Ethereum Blobs', 'Ethereum', true)
, (50104, 'sophon', 'Sophon', 'Layer 2', 'Validium', 'SOPH', NULL, 'https://explorer.sophon.xyz/', timestamp '2024-10-22 01:23', 'ZK Stack', 'Ethereum Blobs', 'Ethereum', true)
, (2741, 'abstract', 'Abstract', 'Layer 2', 'ZK Rollup', 'ETH', 0x3439153EB7AF838Ad19d56E1571FBD09333C2809, 'https://abscan.org/', timestamp '2024-10-25 18:31', 'ZK Stack', 'Ethereum Blobs', 'Ethereum', true)
, (80094, 'berachain', 'Berachain', 'Layer 1', NULL, 'BERA', NULL, 'https://berascan.com/', timestamp '2024-01-20 14:14:11', NULL, NULL, NULL, true)
, (130, 'unichain', 'Unichain', 'Layer 2', 'Optimistic Rollup', 'ETH', 0x4200000000000000000000000000000000000006, 'https://uniscan.xyz/', timestamp '2024-11-04 19:26', 'OP Stack', 'Ethereum Blobs', 'Ethereum', true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ models:

- name: evms_info
meta:
blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, goerli, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei, ronin, ink
blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, goerli, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei, ronin, ink, sophon
sector: evms
contributors: hildobby
config:
Expand Down
2 changes: 2 additions & 0 deletions dbt_subprojects/tokens/models/prices/prices_tokens.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
, "sei"
, "solana"
, "sonic"
, "sophon"
, "unichain"
, "viction"
, "worldchain"
Expand Down Expand Up @@ -78,6 +79,7 @@ ref('prices_native_tokens')
,ref('prices_corn_tokens')
,ref('prices_sonic_tokens')
,ref('prices_ink_tokens')
,ref('prices_sophon_tokens')
,ref('prices_unichain_tokens')
,ref('prices_abstract_tokens')
,ref('prices_berachain_tokens')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ WITH trusted_tokens AS (
, ('gnosis', 0xdd96b45877d0e8361a4ddb732da741e97f3191ff)
, ('ink', 0x4200000000000000000000000000000000000006)
, ('ink', 0xf1815bd50389c46847f0bda824ec8da914045d14)
, ('sophon', 0x72af9F169B619D85A47Dfa8fefbCD39dE55c567D)
, ('kaia', 0x5c13e303a62fc5dedf5b52d66873f2e59fedadc2)
, ('kaia', 0x608792deb376cce1c9fa4d0e6b7b44f507cffa6a)
, ('kaia', 0x19aac5f612f524b754ca7e7c41cbfa2e981a4432)
Expand Down
29 changes: 29 additions & 0 deletions dbt_subprojects/tokens/models/prices/sophon/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 2

models:
- name: prices_sophon_tokens
meta:
blockchain: sophon
sector: prices
contributors: hosuke
config:
tags: ['prices', 'tokens', 'usd', 'sophon']
description: "Price tokens on Sophon EVM chain"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- contract_address
columns:
- name: token_id
description: "Id of the token at coinpaprika. This id is required to pull the price feed data. NOTE: Not all tokens are listed at coinpaprika - consider using price data from DEX sources in this case or submit a listing request at coinpaprika."
- name: blockchain
description: "Native blockchain of the token, if any"
data_tests:
- accepted_values:
values: [ "sophon" ]
- name: contract_address
description: "Contract address of the token, if any"
- name: symbol
description: "Token symbol"
- name: decimals
description: "Number of decimals for the token contract"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% set blockchain = 'sophon' %}

{{ config(
schema = 'prices_' + blockchain,
alias = 'tokens',
materialized = 'table',
file_format = 'delta',
tags = ['static']
)
}}

SELECT
token_id
, '{{ blockchain }}' as blockchain
, symbol
, contract_address
, decimals
FROM
(
VALUES
-- ('soph-sophon', 'SOPH', 0x000000000000000000000000000000000000800A, 18) -- Temporarily removed as no price data available yet
('eth-ethereum', 'ETH', 0x72af9F169B619D85A47Dfa8fefbCD39dE55c567D, 18)
) as temp (token_id, symbol, contract_address, decimals)
4 changes: 2 additions & 2 deletions dbt_subprojects/tokens/models/tokens/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ version: 2
models:
- name: tokens_erc20
meta:
blockchain: arbitrum, avalanche_c, bnb, ethereum, gnosis, mantle, optimism, fantom, polygon, base, blast, sepolia, sei, nova, worldchain, kaia, ronin, boba, flare, viction, sonic, ink, abstract
blockchain: arbitrum, avalanche_c, bnb, ethereum, gnosis, mantle, optimism, fantom, polygon, base, blast, sepolia, sei, nova, worldchain, kaia, ronin, boba, flare, viction, sonic, ink, abstract, sophon
sector: tokens
contributors: hildobby, 0xManny, dot2dotseurat, soispoke, mtitus6, wuligy, angus_1, Henrystats, viniabussafi, jeff-dude, rantum, hosuke, irishlatte19
config:
tags: ['tokens','erc20', 'arbitrum', 'avalanche_c', 'bnb', 'ethereum', 'gnosis', 'mantle', 'optimism', 'fantom', 'base', 'blast', 'sei', 'nova', 'linea', 'worldchain', 'kaia', 'ronin', 'boba', 'flare', 'viction', 'sonic', 'ink', 'abstract']
tags: ['tokens','erc20', 'arbitrum', 'avalanche_c', 'bnb', 'ethereum', 'gnosis', 'mantle', 'optimism', 'fantom', 'base', 'blast', 'sei', 'nova', 'linea', 'worldchain', 'kaia', 'ronin', 'boba', 'flare', 'viction', 'sonic', 'ink', 'abstract', 'sophon']

description: >
Crosschain ERC20 tokens
Expand Down
21 changes: 21 additions & 0 deletions dbt_subprojects/tokens/models/tokens/sophon/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2

models:
- name: tokens_sophon_erc20
meta:
blockchain: sophon
sector: tokens
project: erc20
contributors: hosuke
config:
tags: ['table', 'erc20', 'sophon']
description: "ERC20 Token Addresses, Symbols and Decimals"
columns:
- name: contract_address
description: "ERC20 token contract address"
data_tests:
- unique
- name: symbol
description: "ERC20 token symbol"
- name: decimals
description: "Number of decimals, refers to how divisible an ERC20 token can be"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{
config(
schema = 'tokens_sophon'
,alias = 'erc20'
,tags = ['static']
,materialized = 'table'
)
}}

SELECT
contract_address
, symbol
, decimals
FROM (VALUES
(0x000000000000000000000000000000000000800A, 'SOPH', 18)
, (0x72af9F169B619D85A47Dfa8fefbCD39dE55c567D, 'ETH', 18)
) AS temp_table (contract_address, symbol, decimals)
2 changes: 2 additions & 0 deletions dbt_subprojects/tokens/models/tokens/tokens_erc20.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
,"zora"
,"bob"
,"sonic"
,"sophon"
,"berachain"
,"unichain"
]\',
Expand Down Expand Up @@ -84,6 +85,7 @@
,'tokens_sonic': {'blockchain': 'sonic', 'model': ref('tokens_sonic_erc20')}
,'tokens_corn': {'blockchain': 'corn', 'model': ref('tokens_corn_erc20')}
,'tokens_ink': {'blockchain': 'ink', 'model': ref('tokens_ink_erc20')}
,'tokens_sophon': {'blockchain': 'sophon', 'model': ref('tokens_sophon_erc20')}
,'tokens_abstract': {'blockchain': 'abstract', 'model': ref('tokens_abstract_erc20')}
,'tokens_berachain': {'blockchain': 'berachain', 'model': ref('tokens_berachain_erc20')}
,'tokens_unichain': {'blockchain': 'unichain', 'model': ref('tokens_unichain_erc20')}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
version: 2

models:
- name: tokens_sophon_base_transfers
meta:
blockchain: sophon
sector: tokens
contributors: hosuke
config:
tags: ['tokens','transfers', 'sophon']
description: >
Token transfers
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- block_date
- unique_key
columns:
- name: unique_key
description: "Surrogate key to identify unique row"
- name: blockchain
description: "The blockchain of the transfers"
- name: block_date
description: "The date of the block"
- name: block_time
description: "The time of the block"
- name: block_number
description: "The block number"
- name: tx_hash
description: "The transaction hash"
- name: evt_index
description: "The log event index of the transfer if any"
- name: trace_address
description: "The trace address of the transfer if any"
- name: token_standard
description: "The token standard of the transfer"
- name: tx_from
description: "The transaction sender"
- name: tx_to
description: "The transaction receiver"
- name: tx_index
description: "The transaction index"
- name: from
description: "The sender of the transfer"
- name: to
description: "The receiver of the transfer"
- name: contract_address
description: "The contract address of the transfer"
- name: amount_raw
description: "The raw amount of the transfer"

- name: tokens_sophon_transfers
meta:
blockchain: sophon
sector: tokens
contributors: hosuke
config:
tags: ['tokens','transfers', 'sophon']
description: >
Token transfers
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- block_date
- unique_key
columns:
- name: unique_key
description: "Surrogate key to identify unique row"
- name: blockchain
description: "The blockchain of the transfers"
- name: block_date
description: "The date of the block"
- name: block_time
description: "The time of the block"
- name: block_number
description: "The block number"
- name: tx_hash
description: "The transaction hash"
- name: evt_index
description: "The log event index of the transfer if any"
- name: trace_address
description: "The trace address of the transfer if any"
- name: token_standard
description: "The token standard of the transfer"
- name: tx_from
description: "The transaction sender"
- name: tx_to
description: "The transaction receiver"
- name: tx_index
description: "The transaction index"
- name: from
description: "The sender of the transfer"
- name: to
description: "The receiver of the transfer"
- name: contract_address
description: "The contract address of the transfer"
- name: symbol
description: "The token symbol transferred"
- name: amount_raw
description: "The raw amount of the transfer"
- name: amount
description: "The formatted amount of the transfer"
- name: price_usd
description: "The USD price used to calculate the amount_usd"
- name: amount_usd
description: "The USD amount of the transfer"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{ config(
schema = 'tokens_sophon',
alias = 'base_transfers',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['block_date','unique_key'],
)
}}

-- SOPH token on ZK Stack chain
{{ transfers_base(
blockchain='sophon',
traces = source('sophon','traces'),
transactions = source('sophon','transactions'),
erc20_transfers = source('erc20_sophon','evt_transfer'),
native_contract_address = '0x000000000000000000000000000000000000800a',
include_traces = false
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{config(
schema = 'tokens_sophon',
alias = 'transfers',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_date','unique_key'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')],
post_hook='{{ expose_spells(blockchains = \'["sophon"]\',
spell_type = "sector",
spell_name = "tokens",
contributors = \'["hosuke"]\') }}'
)
}}

-- Sophon mainnet launch date: 2024-10-22 (Block #1 timestamp)
{{ transfers_enrich(
base_transfers = ref('tokens_sophon_base_transfers'),
tokens_erc20_model = source('tokens', 'erc20'),
prices_model = source('prices', 'usd'),
evms_info_model = source('evms','info'),
transfers_start_date = '2024-10-22',
blockchain = 'sophon'
)
}}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
,"polygon"
,"scroll"
,"sei"
,"sophon"
,"zkevm"
,"zksync"
,"zora"
Expand Down Expand Up @@ -46,6 +47,7 @@
,'ronin'
,'scroll'
,'sei'
,'sophon'
,'tron'
,'zkevm'
,'zksync'
Expand Down
Loading