pietrektSwap Count by DEX
    Updated 4 hours ago
    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(block_timestamp) as block_timestamp,
    tx_id, max(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(block_timestamp) as block_timestamp, tx_id, max(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 block_timestamp, 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(block_timestamp) as block_timestamp, tx_id, max(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 block_timestamp, 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 min(block_timestamp) AS block_timestamp, tx_id FROM thorchain.defi.fact_swaps_events
    WHERE RIGHT(memo,3) like '%::0%' and memo like '%=:%' AND block_timestamp < '2023-06-14'
    GROUP BY tx_id),
    Last run: about 4 hours agoAuto-refreshes every 24 hours
    DAY
    LABEL
    SWAP_COUNT
    CUMULATIVE_SWAP_COUNT
    1
    2025-04-22 00:00:00.000ShapeShift226624
    2
    2025-04-22 00:00:00.000THORWallet1258859
    3
    2025-04-22 00:00:00.000Bitget137631
    4
    2025-04-22 00:00:00.000Others3296009
    5
    2025-04-22 00:00:00.000THORSwap7381741
    6
    2025-04-22 00:00:00.000Trustwallet73982883
    7
    2025-04-22 00:00:00.000Asgardex6169526
    8
    2025-04-22 00:00:00.000Ledger49644
    9
    2025-04-22 00:00:00.000rj31343
    10
    2025-04-22 00:00:00.000brt13
    11
    2025-04-21 00:00:00.000Bitget527618
    12
    2025-04-21 00:00:00.000THORSwap56381734
    13
    2025-04-21 00:00:00.000Others14495977
    14
    2025-04-21 00:00:00.000Ledger409640
    15
    2025-04-21 00:00:00.000rj561340
    16
    2025-04-21 00:00:00.000THORWallet4858847
    17
    2025-04-21 00:00:00.000Trustwallet710982810
    18
    2025-04-21 00:00:00.000ShapeShift2226622
    19
    2025-04-21 00:00:00.000Asgardex54169520
    20
    2025-04-20 00:00:00.000brt12
    ...
    10893
    517KB
    9s