Spot-WiggumThorswap vs Affiliates Weekly Volume
    Updated 23 hours ago
    -- forked from SwapKit Affiliates Daily Volumes @ https://flipsidecrypto.xyz/studio/queries/68248f53-fea9-40d9-a15a-d5a6efcd4ef4

    WITH attempted_txs AS (
    SELECT
    DISTINCT tx_id,
    block_timestamp,
    from_address,
    from_amount_usd,
    affiliate_address
    FROM
    thorchain.defi.fact_swaps
    WHERE
    block_timestamp >= '2024-01-01'
    ),
    successful_txs AS (
    SELECT *
    FROM attempted_txs AS a
    WHERE NOT EXISTS (
    SELECT 1
    FROM thorchain.defi.fact_refund_events AS r
    WHERE r.tx_id = a.tx_id
    )
    ),
    affiliate_swaps AS (
    SELECT
    DISTINCT tx_id,
    DATE_TRUNC(week,block_timestamp) AS week,
    from_address,
    from_amount_usd,
    affiliate_address,
    CASE
    WHEN affiliate_address IN ('t', 'T','ts','thor160yye65pf9rzwrgqmtgav69n6zlsyfpgm9a7xk','thor17suv0n437snv68axkx64whutkrvefv7pzq7xep') THEN 'Thorswap'
    WHEN affiliate_address IN ('ti', 'te','tr', 'td','dx','thor1ap5vn4svwkpch2c9jm7hlpr2pj47e62xwpcvtw','wr','thor1a427q3v96psuj4fnughdw8glt5r7j38lj7rkp8','ds','rg','ss','lends','bp','dcf','tl','ej','lifi','okw','sy','oky','xdf','zengo','cb','pl','bqx','ELD','cakewallet','kf','ferz','runifier','zcx-com', '0xbami','cs','moca','va','vi','v0') THEN 'Other Affiliates'
    ELSE 'Unknown Affiliates' -- edit this one day to filter between unknown affiliates and no aff code
    END AS affiliate_name
    FROM
    Last run: about 23 hours agoAuto-refreshes every 12 hours
    WEEK
    AFFILIATE_NAME
    Swap Count
    Swap Volume
    1
    2025-04-21 00:00:00.000Other Affiliates670689788564
    2
    2025-04-21 00:00:00.000Thorswap366467012
    3
    2025-04-14 00:00:00.000Other Affiliates6171124630157
    4
    2025-04-14 00:00:00.000Thorswap40872263
    5
    2025-04-07 00:00:00.000Other Affiliates7429101277588
    6
    2025-04-07 00:00:00.000Thorswap55961785
    7
    2025-03-31 00:00:00.000Other Affiliates628262074941
    8
    2025-03-31 00:00:00.000Thorswap24045929
    9
    2025-03-24 00:00:00.000Other Affiliates816955782147
    10
    2025-03-24 00:00:00.000Thorswap350371905
    11
    2025-03-17 00:00:00.000Other Affiliates7960112383584
    12
    2025-03-17 00:00:00.000Thorswap352181232
    13
    2025-03-10 00:00:00.000Other Affiliates8457103742017
    14
    2025-03-10 00:00:00.000Thorswap325103957
    15
    2025-03-03 00:00:00.000Other Affiliates10272406092018
    16
    2025-03-03 00:00:00.000Thorswap24554006
    17
    2025-02-24 00:00:00.000Other Affiliates154111214746830
    18
    2025-02-24 00:00:00.000Thorswap4391626081
    19
    2025-02-17 00:00:00.000Other Affiliates10432124558642
    20
    2025-02-17 00:00:00.000Thorswap2771063840
    ...
    138
    8KB
    10s