HosseinOvertime
    Updated 2024-01-20
    WITH

    t1 as (
    SELECT
    timestamp::date as date,
    token_contract,
    avg(price_usd) as price_usd
    from near.price.fact_prices
    GROUP BY date, token_contract
    ),

    t2 as (
    SELECT
    hour::date as date,
    token_address,
    avg(price) as price_usd
    FROM ethereum.price.ez_hourly_token_prices
    GROUP BY date, token_address
    ),

    t3 as (
    SELECT
    a.tx_hash,
    a.block_timestamp,
    amount_in_usd as amount_usd,
    origin_from_address as swapper,
    tx_fee * t2.price_usd as transaction_fee,
    'Uniswap' as platform
    FROM ethereum.defi.ez_dex_swaps a
    JOIN ethereum.core.fact_transactions b
    JOIN t2 on a.block_timestamp::date = t2.date AND t2.token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    WHERE platform ilike 'uniswap%'
    AND a.tx_hash = b.tx_hash
    Union all

    SELECT
    Last run: over 1 year ago
    Month
    Platform
    Swaps
    Traders
    Volume ($)
    Average Volume ($)
    Median Volume ($)
    Fee ($)
    Average Fee ($)
    Median FEE ($)
    Cum Swaps
    Cum Volume ($)
    1
    2021-10-01 00:00:00.000Uniswap322293973378658536030001.2518567.1700404552108.83352594136.26138589.45851990264.677736671322293958536030001.25
    2
    2021-10-01 00:00:00.000Ref-Finance49505632436646225.4384757606.03326396111.3285027921260.2223326020.020840799960.017156215614950536646225.4384757
    3
    2021-11-01 00:00:00.000Ref-Finance75533769864916870.7157985744.95502416531.5591669791549.9063475320.017785985490.01552754861125038101563096.154274
    4
    2021-11-01 00:00:00.000Uniswap380539284801879725317803.7722027.3654364092833.49636854338.93487135.571564616100.6781926257028331138261347805.02
    5
    2021-12-01 00:00:00.000Ref-Finance61476246660003571.7432319838.882280271100.0248566811472.373396250.020584573820.01816251126186514161566667.897506
    6
    2021-12-01 00:00:00.000Uniswap292875267228181296519517.4528260.7131173042416.865305825414.18320684.10748532560.0568590029957083219557867322.47
    7
    2022-01-01 00:00:00.000Uniswap223314154371369987785569.0229307.9215419913250.91274347560.53385498.67712153570.2923398712190224289545652891.49
    8
    2022-01-01 00:00:00.000Ref-Finance73136313364721993.4322558733.67635612995.5945075672522.5622552340.028595291730.02516962806259650226288661.329762
    9
    2022-02-01 00:00:00.000Ref-Finance39741141932932790.1334866682.700514801273.6302628641008.9360765080.020915360530.01739781709299391259221451.463248
    10
    2022-02-01 00:00:00.000Uniswap201965046770053380337363.4227133.9029638292238.95143657640.85350157.78210601838.72355313614209874342925990254.91
    11
    2022-03-01 00:00:00.000Ref-Finance3637446029297022.1452484709.147777824400.240679815842.9878355530.020404904890.01675183649335765288518473.608497
    12
    2022-03-01 00:00:00.000Uniswap254747551581549559677241.8821556.2332724451722.11104635931.12095633.07470518720.72513787716757349392485667496.79
    13
    2022-04-01 00:00:00.000Ref-Finance512862462008605.7988216959.57360299311.49580262112.347719250.032688254890.0238034952387051350527079.407318
    14
    2022-04-01 00:00:00.000Uniswap249244347303148255862739.4823518.1527063692280119950151.86442939.06796934226.23016266419249792440741530236.27
    15
    2022-05-01 00:00:00.000Ref-Finance4861730104097325.6749841283.314335951144.402199561525.8052705610.018810164090.01719049269435668454624405.082302
    16
    2022-05-01 00:00:00.000Uniswap214813841624261360012831.4628712.0401179831885.3492898309.900720834.4615114315.37895732921397930502101543067.73
    17
    2022-06-01 00:00:00.000Ref-Finance696314088101628.3070247943.070309431683.929441791427.6186261560.0045773777150.00437874301505299542726033.389327
    18
    2022-06-01 00:00:00.000Uniswap184019231606345357815527.3624167.9559496261594.6546714826.858543819.85618266811.01181851723238122547459358595.09
    19
    2022-07-01 00:00:00.000Uniswap244189533736736914543562.4717182.2700251531014.6529693382.77358579.4036452394.992931325680017584373902157.56
    20
    2022-07-01 00:00:00.000Ref-Finance445793651756191.0604446879.713614136714.438736869280.1684043010.0047620961760.004071369713549878594482224.449771
    56
    9KB
    259s