Skip to content

Commit

Permalink
Merge branch 'main' into fasol
Browse files Browse the repository at this point in the history
  • Loading branch information
whalehunting authored Jan 23, 2025
2 parents 61d7c6d + 35d1d10 commit b9b79cc
Show file tree
Hide file tree
Showing 24 changed files with 608 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ FROM (VALUES
-- ,('Project', TBD , '[RFG-3] Trail of Bits Security Reviews', 'Season 4')
,('Project', 0xB6B9E9e56AB5a4AF927faa802ac93786352f3af9, 'Cantina.xyx and Spearbit Labs: RFG-3', 'Season 4')
,('Project', 0x697008C9CcA249eB5AbE9583f041A18A850453A4, 'LlamaNodes | High-Performant & Cost-Effective RPCs', 'Season 4')
-- ,('Project', TBD, 'FHE x OP ', 'Season 4')
-- ,('Project', TBD, 'Identity Fusion in the Optimism Ecosystem ', 'Season 4')
-- ,('Project', TBD, 'Metagov', 'Season 4')
-- ,('Project', TBD, 'Shapley Values', 'Season 4')
,('Project', 0x4a364125054B47b669af9D16cc65dCE6C6Fbd573, 'FHE x OP', 'Season 4')
,('Project', 0x6297Be9555d698916F1148507e6bA28B67cFbc54, 'Identity Fusion in the Optimism Ecosystem', 'Season 4')
,('Project', 0x9D31e30003f253563Ff108BC60B16Fdf2c93abb5, 'Metagov', 'Season 4')
,('Project', 0x6eDf76FD16Bb290A544fDc14fBB4b403D1DEeD9f, 'Shapley Values', 'Season 4')
,('Project', 0xd6E193cb08efaaF78ec2559fc0617F2ef7245e49, 'Tokenbound: Tooling for 6551', 'Season 4')
,('Project', 0x4a364125054B47b669af9D16cc65dCE6C6Fbd573, 'Compete Guide To Cross Chain / Rollup Interoperability', 'Season 4')
,('Project', 0x6297Be9555d698916F1148507e6bA28B67cFbc54, 'Cross-chain interoperability research', 'Season 4')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ WITH base_trades as (
minute,
blockchain,
wrapped_token,
underlying_token,
underlying_token_symbol,
decimals,
APPROX_PERCENTILE(median_price, 0.5) AS price,
LEAD(minute, 1, NOW()) OVER (PARTITION BY wrapped_token ORDER BY minute) AS time_of_next_change
FROM {{ source('balancer_v3', 'erc4626_token_prices') }}
GROUP BY 1, 2, 3, 4
GROUP BY 1, 2, 3, 4, 5, 6
)

SELECT
Expand All @@ -85,9 +87,12 @@ SELECT
, block_date
, block_time
, block_number
, token_bought_symbol
, token_sold_symbol
, token_pair
, COALESCE(erc4626a.underlying_token_symbol,
token_bought_symbol) AS token_bought_symbol
, COALESCE(erc4626b.underlying_token_symbol,
token_sold_symbol) AS token_sold_symbol
, CONCAT(COALESCE(erc4626a.underlying_token_symbol, token_bought_symbol), '-',
COALESCE(erc4626b.underlying_token_symbol, token_sold_symbol)) AS token_pair
, token_bought_amount
, token_sold_amount
, token_bought_amount_raw
Expand All @@ -97,8 +102,10 @@ SELECT
dexs.token_bought_amount * erc4626a.price,
dexs.token_sold_amount * erc4626a.price
) AS amount_usd
, token_bought_address
, token_sold_address
, COALESCE(erc4626a.underlying_token,
token_bought_address) AS token_bought_address
, COALESCE(erc4626b.underlying_token,
token_sold_address) AS token_sold_address
, taker
, maker
, project_contract_address
Expand Down
19 changes: 18 additions & 1 deletion dbt_subprojects/dex/models/trades/sonic/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,21 @@ models:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('beets_sonic_base_trades_seed')
seed_file: ref('beets_sonic_base_trades_seed')

- name: wagmi_sonic_base_trades
meta:
blockchain: sonic
sector: dex
project: wagmi
contributors: hosuke
config:
tags: ['sonic', 'dex', 'trades', 'wagmi']
description: "wagmi sonic base trades"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('wagmi_sonic_base_trades_seed')
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

{% set base_models = [
ref('beets_sonic_base_trades')
, ref('wagmi_sonic_base_trades')
] %}

WITH base_union AS (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
schema = 'wagmi_sonic',
alias = 'base_trades',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_hash', 'evt_index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

{{
uniswap_compatible_v3_trades(
blockchain = 'sonic',
project = 'wagmi',
version = '3',
Pair_evt_Swap = source('wagmi_sonic', 'UniswapV3Pool_evt_Swap'),
Factory_evt_PoolCreated = source('wagmi_sonic', 'UniswapV3Factory_evt_PoolCreated')
)
}}
15 changes: 15 additions & 0 deletions dbt_subprojects/dex/seeds/trades/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4731,6 +4731,21 @@ seeds:
block_date: timestamp

- name: camelot_corn_base_trades_seed
config:
column_types:
blockchain: varchar
project: varchar
version: varchar
tx_hash: varbinary
evt_index: uint256
block_number: uint256
token_bought_address: varbinary
token_sold_address: varbinary
token_bought_amount_raw: uint256
token_sold_amount_raw: uint256
block_date: timestamp

- name: wagmi_sonic_base_trades_seed
config:
column_types:
blockchain: varchar
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw
sonic,wagmi,3,2025-01-21,0x8c447cc48a4488870ac0a5a39f42e764a50f159fa9fbadace10a2dca77640f1a,2,0x50c42deacd8fc9773493ed674b675be577f2634b,0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38,4847335,50421632945765830,271700000000000000000
sonic,wagmi,3,2025-01-21,0x38155f722ac19c89b6b9798d11467bcd9e2ec9ac463dbb09ad3e8b95d0e03cdd,8,0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38,0x50c42deacd8fc9773493ed674b675be577f2634b,4848299,2397204077986245906501,450000000000000000
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,65 @@
, incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)}}

WITH data AS (
SELECT
cast(date_trunc('month', t.block_time) AS date) AS block_month
, cast(date_trunc('day', t.block_time) AS date) AS block_date
, t.block_time
, t.block_number
, t.hash AS tx_hash
, t.index AS tx_index
, t.gas_price
, t.gas_used
, (t.gas_price / 1e18) * t.gas_used AS data_fee_native
, {{ evm_get_calldata_gas_from_data('t.data') }} AS calldata_gas_used
, (length(t.data)) AS data_length
, CASE -- If prior to shared bridge, chain_id is always equal to 324 for zksync era. If on shared bridge, fetch chain_id.
WHEN bytearray_substring(t.data, 1, 4) IN (
0x0c4dd810 -- Commit Block, pre-Boojum
, 0x701f58c5 -- Commit Batches, post-Boojum
, 0xce9dcf16 -- Execute Block, pre-Boojum
, 0xc3d93e7c -- Execute Batches, post-Boojum
) THEN 324
WHEN bytearray_substring(t.data, 1, 4) IN (
0x6edd4f12 -- Commit Batches Shared Bridge, post-v24
, 0x6f497ac6 -- Execute Batches Shared Bridge, post-v24
) THEN varbinary_to_uint256(varbinary_substring(t.data, 5, 32))
ELSE 324
END AS chain_id
FROM {{ source('ethereum', 'transactions') }} t
WHERE t.to IN (
0x3dB52cE065f728011Ac6732222270b3F2360d919 -- L1 transactions settle here pre-Boojum
, 0xa0425d71cB1D6fb80E65a5361a04096E0672De03 -- L1 transactions settle here post-Boojum
, 0xa8CB082A5a689E0d594d7da1E2d72A3D63aDc1bD -- L1 transactions settle here post-EIP4844
, 0x5D8ba173Dc6C3c90C8f7C04C9288BeF5FDbAd06E -- L1 transactions settle here post v24 upgrade (shared bridge)
)
AND bytearray_substring(t.data, 1, 4) IN (
0x0c4dd810 -- Commit Block, pre-Boojum
, 0xce9dcf16 -- Execute Block, pre-Boojum
, 0x701f58c5 -- Commit Batches, post-Boojum
, 0xc3d93e7c -- Execute Batches, post-Boojum
, 0x6edd4f12 -- Commit Batches, post v24 upgrade (shared bridge)
, 0x6f497ac6 -- Execute Batches, post v24 upgrade (shared bridge)
)
AND t.block_time >= TIMESTAMP '2023-02-14'
{% if is_incremental() %}
AND {{incremental_predicate('t.block_time')}}
{% endif %}
)

SELECT
'zksync era' AS name
, cast(date_trunc('month', t.block_time) AS date) AS block_month
, cast(date_trunc('day', t.block_time) AS date) AS block_date
, t.block_time
, t.block_number
, t.hash AS tx_hash
, t.index AS tx_index
, t.gas_price
, t.gas_used
, (t.gas_price / 1e18) * t.gas_used AS data_fee_native
, {{ evm_get_calldata_gas_from_data('t.data') }} AS calldata_gas_used
, (length(t.data)) AS data_length
FROM {{ source('ethereum', 'transactions') }} t
WHERE t.to IN (
0x3dB52cE065f728011Ac6732222270b3F2360d919 -- L1 transactions settle here pre-Boojum
, 0xa0425d71cB1D6fb80E65a5361a04096E0672De03 -- L1 transactions settle here post-Boojum
, 0xa8CB082A5a689E0d594d7da1E2d72A3D63aDc1bD -- L1 transactions settle here post-EIP4844
, 0x5D8ba173Dc6C3c90C8f7C04C9288BeF5FDbAd06E -- L1 transactions settle here post v24 upgrade (shared bridge)
)
AND bytearray_substring(t.data, 1, 4) IN (
0x0c4dd810 -- Commit Block, pre-Boojum
, 0xce9dcf16 -- Execute Block, pre-Boojum
, 0x701f58c5 -- Commit Batches, post-Boojum
, 0xc3d93e7c -- Execute Batches, post-Boojum
, 0x6edd4f12 -- Commit Batches, post v24 upgrade (shared bridge)
, 0x6f497ac6 -- Execute Batches, post v24 upgrade (shared bridge)
)
AND t.block_time >= TIMESTAMP '2023-02-14'
{% if is_incremental() %}
AND {{incremental_predicate('t.block_time')}}
{% endif %}
, block_month
, block_date
, block_time
, block_number
, tx_hash
, tx_index
, gas_price
, gas_used
, data_fee_native
, calldata_gas_used
, data_length
FROM data
WHERE chain_id = 324 -- zksync era
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,59 @@
, incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)}}

WITH data AS (
SELECT
cast(date_trunc('month', t.block_time) AS date) AS block_month
, cast(date_trunc('day', t.block_time) AS date) AS block_date
, t.block_time
, t.block_number
, t.hash AS tx_hash
, t.index AS tx_index
, t.gas_price
, t.gas_used
, (t.gas_price / 1e18) * t.gas_used AS verification_fee_native
, {{ evm_get_calldata_gas_from_data('t.data') }} AS calldata_gas_used
, 44*32 / cast(1024 AS double) / cast(1024 AS double) AS proof_size_mb
, CASE -- If prior to shared bridge, chain_id is always equal to 324 for zksync era. If on shared bridge, fetch chain_id.
WHEN bytearray_substring(t.data, 1, 4) IN (
0x7739cbe7 -- Prove Block, pre-Boojum
, 0x7f61885c -- Prove Batches, post-Boojum
) THEN 324
WHEN bytearray_substring(t.data, 1, 4) IN (
0xc37533bb -- Prove Batches Shared Bridge, post-v24
) THEN varbinary_to_uint256(varbinary_substring(t.data, 5, 32))
ELSE 324
END AS chain_id
FROM {{ source('ethereum', 'transactions') }} AS t
WHERE t.to IN (
0x3dB52cE065f728011Ac6732222270b3F2360d919 -- L1 transactions settle here pre-Boojum
, 0xa0425d71cB1D6fb80E65a5361a04096E0672De03 -- L1 transactions settle here post-Boojum
, 0xa8CB082A5a689E0d594d7da1E2d72A3D63aDc1bD -- L1 transactions settle here post-EIP4844
, 0x5D8ba173Dc6C3c90C8f7C04C9288BeF5FDbAd06E -- L1 transactions settle here post v24 upgrade (shared bridge)
)
AND bytearray_substring(t.data, 1, 4) IN (
0x7739cbe7 -- Prove Block, pre-Boojum
, 0x7f61885c -- Prove Batches, post-Boojum
, 0xc37533bb -- Prove Batches, post v24 upgrade (shared bridge)
)
AND t.block_time >= TIMESTAMP '2023-02-14'
{% if is_incremental() %}
AND {{incremental_predicate('t.block_time')}}
{% endif %}
)

SELECT
'zksync era' AS name
, cast(date_trunc('month', t.block_time) AS date) AS block_month
, cast(date_trunc('day', t.block_time) AS date) AS block_date
, t.block_time
, t.block_number
, t.hash AS tx_hash
, t.index AS tx_index
, t.gas_price
, t.gas_used
, (t.gas_price / 1e18) * t.gas_used AS verification_fee_native
, {{ evm_get_calldata_gas_from_data('t.data') }} AS calldata_gas_used
, 44*32 / cast(1024 AS double) / cast(1024 AS double) AS proof_size_mb
FROM {{ source('ethereum', 'transactions') }} AS t
WHERE t.to IN (
0x3dB52cE065f728011Ac6732222270b3F2360d919 -- L1 transactions settle here pre-Boojum
, 0xa0425d71cB1D6fb80E65a5361a04096E0672De03 -- L1 transactions settle here post-Boojum
, 0xa8CB082A5a689E0d594d7da1E2d72A3D63aDc1bD -- L1 transactions settle here post-EIP4844
, 0x5D8ba173Dc6C3c90C8f7C04C9288BeF5FDbAd06E -- L1 transactions settle here post v24 upgrade (shared bridge)
)
AND bytearray_substring(t.data, 1, 4) IN (
0x7739cbe7 -- Prove Block, pre-Boojum
, 0x7f61885c -- Prove Batches, post-Boojum
, 0xc37533bb -- Prove Batches, post v24 upgrade (shared bridge)
)
AND t.block_time >= TIMESTAMP '2023-02-14'
{% if is_incremental() %}
AND {{incremental_predicate('t.block_time')}}
{% endif %}
, block_month
, block_date
, block_time
, block_number
, tx_hash
, tx_index
, gas_price
, gas_used
, verification_fee_native
, calldata_gas_used
, proof_size_mb
FROM data
WHERE chain_id = 324 -- zksync era
Original file line number Diff line number Diff line change
Expand Up @@ -716,5 +716,7 @@ FROM
('fxn-fxn', 'solana', 'FXN', '92cRC6kV5D7TiHX1j56AbkPbffo9jwcXxSDQZ8Mopump',6),
('griffain-test-griffaincom', 'solana', 'GRIFFAIN', 'KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP', 6),
('tank-agenttank', 'solana', 'TANK', 'GAMwtMB6onAvBNBQJCJFuxoaqfPH8uCQ2dewNMVVpump', 6),
('pengu-pudgy-penguins', 'solana', 'PENGU', '2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv', 6)
('pengu-pudgy-penguins', 'solana', 'PENGU', '2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv', 6),
('trump-official-trump', 'solana', 'TRUMP', '6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN', 6),
('melania-melania-meme','solana', 'MELANIA', 'FUAfBo2jgks6gB4Z4LfZkqSZgzNucisEHqnNebaRxM1P', 6)
) as temp (token_id, blockchain, symbol, contract_address, decimals)
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ FROM
('bnb-binance-coin', 'zksync', 'BNB', 0x7400793aad94c8ca801aa036357d10f5fd0ce08f, 18),
('xvs-venus', 'zksync', 'XVS', 0xd78abd81a3d57712a3af080dc4185b698fe9ac5a, 18),
('usd-overnightfi-usd-arbitrum', 'zksync', 'USD+', 0x8e86e46278518efc1c5ced245cba2c7e3ef11557, 6),
('vno-veno-finance', 'zksync', 'VNO', 0xe75a17b4f5c4f844688d5670b684515d7c785e63, 18)
('vno-veno-finance', 'zksync', 'VNO', 0xe75a17b4f5c4f844688d5670b684515d7c785e63, 18),
('deusd-elixir-deusd', 'zksync', 'deUSD', 0xb21f16d1ea2e8d96ccfafa397cef855bf368aa83, 18)
) as temp (token_id, blockchain, symbol, contract_address, decimals)
50 changes: 50 additions & 0 deletions dbt_subprojects/tokens/models/prices_v2/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: 2

models:
- name: prices_v2_dex_minute_raw
meta:
sector: prices
contributors: 0xRob
description: "sparse minute-level prices sourced from dex.trades, not filtered"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
- contract_address
- timestamp

- name: prices_v2_coinpaprika_minute
meta:
sector: prices
contributors: 0xRob
description: "sparse minute-level prices from coinpaprika (only trusted tokens)"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
- contract_address
- timestamp

- name: prices_v2_minute_sparse
meta:
sector: prices
contributors: 0xRob
description: "sparse minute-level prices from all sources"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
- contract_address
- timestamp

- name: prices_v2_day_sparse
meta:
sector: prices
contributors: 0xRob
description: "sparse day-level prices from all sources"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
- contract_address
- timestamp
Loading

0 comments on commit b9b79cc

Please sign in to comment.