pietrektSwap Volume
    Updated 13 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 13 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-05-19 00:00:00.000031637030.141247913389366.79638445026396.937632105781646645.25
    2
    2025-05-18 00:00:00.000082608652.660301329705822.8753823112314475.535684105736620248.312
    3
    2025-05-17 00:00:00.000056914434.176300529800934.065131386715368.2414318105624305772.777
    4
    2025-05-16 00:00:00.000068803019.223111124550395.946001193353415.1691121105537590404.535
    5
    2025-05-15 00:00:00.000064412796.333035216874869.769519881287666.102555105444236989.366
    6
    2025-05-14 00:00:00.000063917644.768640730073344.104547593990988.8731882105362949323.263
    7
    2025-05-13 00:00:00.0000101790011.77797534439839.455497136229851.233472105268958334.39
    8
    2025-05-12 00:00:00.0000126050059.87578219233289.6842182145283349.56105132728483.157
    9
    2025-05-11 00:00:00.000085264121.19399827402345.8199592112666467.013957104987445133.597
    10
    2025-05-10 00:00:00.000078897403.4129321173692.6728961100071096.085826104874778666.583
    11
    2025-05-09 00:00:00.000052942573.705738923052851.912291675995425.6180304104774707570.497
    12
    2025-05-08 00:00:00.000047295068.153939932069924.87969879364993.0336379104698712144.879
    13
    2025-05-07 00:00:00.000023077710.305976515020204.917539538097915.223516104619347151.845
    14
    2025-05-06 00:00:00.000034245936.36271618471881.137142352717817.4998583104581249236.622
    15
    2025-05-05 00:00:00.000030657298.595981110276902.866047640934201.4620287104528531419.122
    16
    2025-05-04 00:00:00.000039140742.280388215685635.258932154826377.5393204104487597217.66
    17
    2025-05-03 00:00:00.000027126406.348495813037958.382405940164364.7309017104432770840.121
    18
    2025-05-02 00:00:00.000044022669.038919823058135.927549467080804.9664692104392606475.39
    19
    2025-05-01 00:00:00.000032750739.761090718577151.532825951327891.2939166104325525670.423
    20
    2025-04-30 00:00:00.000046322417.090761526078119.908140372400536.9989018104274197779.129
    ...
    1427
    135KB
    4s