sage_olamide01_B - Uniswap L2 swaps, volume and protocol fees
Updated 2024-07-31
999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
WITH L2_data AS (
WITH swaps AS (
WITH swap_raw AS (
SELECT
block_timestamp,
blockchain as chain,
tx_hash,
CONCAT(symbol_out, '-', symbol_in) as pool_name,
contract_address as pool_contract_address,
trader,
token_in,
symbol_in,
amount_in_raw,
amount_in,
amount_in_usd,
token_out,
symbol_out,
amount_out_raw,
amount_out,
amount_out_usd,
'WETH' AS price_table_symbol
FROM crosschain.defi.ez_dex_swaps
WHERE block_timestamp::date >= '2023-01-01'
AND blockchain IN ('arbitrum', 'base', 'optimism')
)
SELECT
s.*,
COALESCE(t.tx_fee, 0) AS txn_fee,
COALESCE(t.tx_fee, 0) * p.price AS txn_fee_usd
FROM swap_raw s
LEFT JOIN (
SELECT tx_hash, tx_fee FROM arbitrum.core.fact_transactions WHERE block_timestamp::date >= '2023-01-01'
UNION ALL
SELECT tx_hash, tx_fee FROM base.core.fact_transactions WHERE block_timestamp::date >= '2023-01-01'
UNION ALL
SELECT tx_hash, tx_fee FROM optimism.core.fact_transactions WHERE block_timestamp::date >= '2023-01-01'
QueryRunArchived: QueryRun has been archived