pietrektSwap Volume by Dex
    Updated 12 hours ago

    -- DOUBLE COUNTING
    with init AS ( SELECT
    block_timestamp, tx_id, from_amount_usd,
    affiliate_address,
    array_size(affiliate_addresses_array) as aff_adds_count,
    CASE
    WHEN aff_adds_count >= 2 AND affiliate_address = '-_' THEN affiliate_addresses_array[1]
    ELSE affiliate_address
    END AS fixed_aff_add
    from thorchain.defi.fact_swaps
    ),

    swaps_filtered AS (SELECT min(to_date(block_timestamp)) as day, tx_id, sum(from_amount_usd) as swap_volume_usd,
    fixed_aff_add as aff_add
    FROM init WHERE AFFILIATE_ADDRESS IS NOT NULL AND (tx_id NOT IN (SELECT DISTINCT tx_id FROM thorchain.defi.fact_refund_events))
    group by tx_id, aff_add),

    asgardex_swaps AS (SELECT min(to_date(block_timestamp)) as day, tx_id, sum(from_amount_usd) as swap_volume_usd, max(min_to_amount) as min_to_amount,
    CASE
    WHEN min(affiliate_address) IS NULL THEN 'dx'
    END AS aff_add
    FROM thorchain.defi.fact_swaps group by tx_id),

    asgardex_swaps_filtered AS (SELECT day, tx_id, swap_volume_usd, aff_add from asgardex_swaps WHERE (RIGHT(min_to_amount, 3) = '999')),
    thorswap_swaps_before_aff_address AS (SELECT min(to_date(block_timestamp)) as day, tx_id, sum(from_amount_usd) as swap_volume_usd, max(min_to_amount) as min_to_amount,
    CASE
    WHEN min(affiliate_address) IS NULL THEN 'T'
    END AS aff_add
    FROM thorchain.defi.fact_swaps WHERE (to_date(block_timestamp) < '2022-04-24') group by tx_id),

    thorswap_swaps_before_aff_address_filtered AS (SELECT day, tx_id, swap_volume_usd, aff_add from thorswap_swaps_before_aff_address WHERE RIGHT(min_to_amount, 3) = '111'),
    trust_ios_swap_ids AS (SELECT max(to_date(block_timestamp)) AS day, tx_id FROM thorchain.defi.fact_swaps_events
    WHERE RIGHT(memo,3) like '%::0%' AND memo like '%=:%' AND block_timestamp < '2023-06-14'
    Last run: about 12 hours agoAuto-refreshes every 24 hours
    DAY
    LABEL
    SWAP_VOLUME_USD
    CUMULATIVE_SWAP_VOLUME_USD
    WEEKLY_VOLUME_USD
    MONTHLY_VOLUME_USD
    WEEKLY_TOTAL_VOLUME_USD
    MONTHLY_TOTAL_VOLUME_USD
    WEEKLY_PCT_OF_TOTAL
    MONTHLY_PCT_OF_TOTAL
    1
    2025-04-22 00:00:00.000Bitget175.305541823267659115.6119051585225.5612285238785419.97151515416747.3166497474330137.60109410.282490398.176882913
    2
    2025-04-22 00:00:00.000THORSwap14096.888003456368217387.169251877432.9419074953831632.933977615416747.3166497474330137.60109412.177879711.348980102
    3
    2025-04-22 00:00:00.000Ledger49.326539907497529749.460948283481.79940156240445331.373751615416747.3166497474330137.6010941.8387912428.526831455
    4
    2025-04-22 00:00:00.000Others8418.618215274988646794.120001706484.86352759255008908.947135515416747.3166497474330137.6010944.58258054711.597177701
    5
    2025-04-22 00:00:00.000Trustwallet75003.6899425995140085150.258614846991.3242762586739274.64891515416747.3166497474330137.60109431.43977925318.286688484
    6
    2025-04-21 00:00:00.000Trustwallet4771987.634333655140010146.568664771987.6343336586664270.958972415416747.3166497474330137.60109430.95327137618.270875934
    7
    2025-04-21 00:00:00.000ShapeShift50095.038759491241964447.4438550095.038759497781583.9635126715416747.3166497474330137.6010940.32493909211.640541755
    8
    2025-04-21 00:00:00.000Ledger283432.472861655497529700.134408283432.47286165540445282.047211715416747.3166497474330137.6010941.8384712878.526821056
    9
    2025-04-21 00:00:00.000Bitget1585050.2556867267658940.3063641585050.255686738785244.665973115416747.3166497474330137.60109410.2813532798.176845954
    10
    2025-04-21 00:00:00.000THORWallet3609321.482342451091426127.670783609321.4823424599706430.076885615416747.3166497474330137.60109423.41169254621.020471223
    11
    2025-04-21 00:00:00.000THORSwap1863336.053904046368203290.281241863336.0539040453817536.045974215416747.3166497474330137.60109412.08644090511.346008145
    12
    2025-04-21 00:00:00.000Asgardex2457714.305206382665974629.787482457714.3052063892031555.685401415416747.3166497474330137.60109415.94184723119.402426367
    13
    2025-04-21 00:00:00.000Others698066.245312318988638375.501786698066.24531231855000490.328920215416747.3166497474330137.6010944.52797357911.595402857
    14
    2025-04-20 00:00:00.000Others370859.6052972987940309.25647323163145.186993754302424.0836079175860189.109239474330137.60109413.17134099811.448234
    15
    2025-04-20 00:00:00.000Asgardex1865704.577169662663516915.4822738642486.244641889573841.380195175860189.109239474330137.60109421.97341333518.884282123
    16
    2025-04-20 00:00:00.000THORWallet11071194.34784491087816806.1884355945135.754742296097108.5945431175860189.109239474330137.60109431.81227999220.259540977
    17
    2025-04-20 00:00:00.000Bitget531377.981676693266073890.05067711171235.578434537200194.4102864175860189.109239474330137.6010946.3523391147.84267991
    18
    2025-04-20 00:00:00.000Trustwallet1083404.179969965135238158.9343323414435.137141781892283.3246388175860189.109239474330137.60109413.31423288917.264828193
    19
    2025-04-20 00:00:00.000THORSwap650492.4792319246366339954.2273419763654.215588351954199.9920701175860189.109239474330137.60109411.23827644910.95317288
    20
    2025-04-20 00:00:00.000ShapeShift21596.8191099291241914352.405091366176.87822597731488.92475318175860189.109239474330137.6010940.77685397991.629980537
    ...
    7376
    1MB
    10s