pietrektSwap Volume
    Updated 20 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 20 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-04-14 00:00:00.000029690900.449872124058675.374806553749575.8246786103726981885.885
    2
    2025-04-13 00:00:00.000056017102.245051545194742.234026101211844.479078103673232310.06
    3
    2025-04-12 00:00:00.000042698747.489337129061297.461298171760044.9506352103572020465.581
    4
    2025-04-11 00:00:00.000046788561.701378731057187.826463377845749.527842103500260420.631
    5
    2025-04-10 00:00:00.000034637657.711486421865474.180880756503131.8923671103422414671.103
    6
    2025-04-09 00:00:00.000084866692.998802441699027.551109126565720.549911103365911539.21
    7
    2025-04-08 00:00:00.000046749758.730189527116130.538945273865889.2691347103239345818.661
    8
    2025-04-07 00:00:00.000056095077.623043917936812.288590674031889.9116344103165479929.391
    9
    2025-04-06 00:00:00.000035123944.766625216492877.48178551616822.2484103103091448039.48
    10
    2025-04-05 00:00:00.000017308545.031578315050693.190251332359238.2218296103039831217.231
    11
    2025-04-04 00:00:00.000024096979.358388713248617.771114537345597.1295032103007471979.01
    12
    2025-04-03 00:00:00.000027328157.199557815066185.028477842394342.2280357102970126381.88
    13
    2025-04-02 00:00:00.000035417062.592934913136355.48673248553418.0796669102927732039.652
    14
    2025-04-01 00:00:00.000044177373.73453925984565.019050370161938.7535893102879178621.572
    15
    2025-03-31 00:00:00.000057538387.963720137856558.894213995394946.857934102809016682.819
    16
    2025-03-30 00:00:00.000032273874.51813920277184.390219352551058.9083583102713621735.961
    17
    2025-03-29 00:00:00.000045692847.200640335340440.147627781033287.348268102661070677.052
    18
    2025-03-28 00:00:00.0000103101910.82166783812429.1481827186914339.96985102580037389.704
    19
    2025-03-27 00:00:00.000039247040.163057625763213.997100965010254.1601585102393123049.734
    20
    2025-03-26 00:00:00.000077485859.450679855084639.4072209132570498.857901102328112795.574
    ...
    1392
    132KB
    6s