pietrektSwap Volume
    Updated 10 hours ago
    with init AS (SELECT to_date(block_timestamp) AS day, tx_id, from_asset,
    to_asset, from_amount_usd,
    IFF(to_asset like '%/%' or from_asset like '%/%', 1, 0) as is_synth,
    IFF(to_asset like '%~%' or from_asset like '%~%', 1, 0) as is_trade,
    FROM thorchain.defi.fact_swaps
    WHERE tx_id NOT IN (SELECT DISTINCT tx_id FROM thorchain.defi.fact_refund_events)),


    total_vol AS ( SELECT day, sum(from_amount_usd) as total_vol_usd FROM init group by day),

    synth_vol AS ( SELECT day, sum(from_amount_usd) as synth_vol_usd FROM init WHERE is_synth = 1 group by day),

    l1_vol AS ( SELECT day, sum(from_amount_usd) as l1_vol_usd FROM init WHERE is_synth = 0 and is_trade = 0 group by day),

    trade_asset_vol AS ( SELECT day, sum(from_amount_usd) as trade_asset_vol_usd FROM init WHERE is_trade = 1 group by day),


    volume AS (SELECT a.day,
    COALESCE(synth_vol_usd, 0) as synth_vol_usd,
    COALESCE(trade_asset_vol_usd, 0) as trade_asset_vol_usd,
    COALESCE(l1_vol_usd, 0) as l1_vol_usd,
    total_vol_usd
    FROM total_vol as a LEFT JOIN synth_vol as b ON a.day = b.day LEFT JOIN l1_vol as c on a.day = c.day LEFT JOIN trade_asset_vol as d on a.day = d.day)

    select *,
    SUM(total_vol_usd) OVER(ORDER BY day ASC) AS total_vol_usd_cumulative
    from volume
    WHERE day IS NOT null
    order by day desc
    Last run: about 10 hours agoAuto-refreshes every 24 hours
    DAY
    SYNTH_VOL_USD
    TRADE_ASSET_VOL_USD
    L1_VOL_USD
    TOTAL_VOL_USD
    TOTAL_VOL_USD_CUMULATIVE
    1
    2025-06-07 00:00:00.000015677126.702942112758755.029845228435881.7327873107863607280.706
    2
    2025-06-06 00:00:00.000055788078.416247342132109.081033597920187.4972808107835171398.974
    3
    2025-06-05 00:00:00.000052848610.756930922382053.03234475230663.7892749107737251211.476
    4
    2025-06-04 00:00:00.000034515728.212608913064755.988523447580484.2011323107662020547.687
    5
    2025-06-03 00:00:00.000060370179.401111533038055.17351393408234.5746244107614440063.486
    6
    2025-06-02 00:00:00.000053269592.694781527362338.663964580631931.358746107521031828.911
    7
    2025-06-01 00:00:00.000052200999.286942729400376.520464981601375.8074075107440399897.553
    8
    2025-05-31 00:00:00.000058718324.217449929033683.625036987752007.8424868107358798521.745
    9
    2025-05-30 00:00:00.000057623397.54702423859805.361892581483202.9089166107271046513.903
    10
    2025-05-29 00:00:00.000048156242.241996822127438.989138570283681.2311352107189563310.994
    11
    2025-05-28 00:00:00.000076306596.005833145166843.1925196121473439.198353107119279629.763
    12
    2025-05-27 00:00:00.000064240201.458958940736542.896557104976744.355516106997806190.564
    13
    2025-05-26 00:00:00.000061448075.795691239138730.4125433100586806.208235106892829446.209
    14
    2025-05-25 00:00:00.000067256781.935526742584738.4382006109841520.373727106792242640.001
    15
    2025-05-24 00:00:00.000057255191.788678434043395.164639191298586.9533175106682401119.627
    16
    2025-05-23 00:00:00.000065746910.448919329941360.236604895688270.6855241106591102532.673
    17
    2025-05-22 00:00:00.0000152857559.70029499052293.1811043251909852.881398106495414261.988
    18
    2025-05-21 00:00:00.0000159399086.536623120392036.797439279791123.334062106243504409.107
    19
    2025-05-20 00:00:00.000064188666.623630734312367.401949698501034.0255803105963713285.773
    20
    2025-05-19 00:00:00.000090800017.852214837791985.5824569128592003.434672105865212251.747
    ...
    1446
    137KB
    5s