pietrektTC Aff Fees
    Updated 5 hours ago
    -- Query by @banbannard -- RELEVANT UP TO 01.11.2024
    with base as (select tx_id,
    to_date(block_timestamp) as date,
    affiliate_address, affiliate_fee_basis_points,
    split(from_asset, '-')[0] as from_assets,
    case
    when from_assets ilike '%/%' then split(from_assets, '/')[1]
    else split(from_assets, '.')[1]
    end as from_asset_names,
    split(to_asset, '-')[0] as to_assets,
    case
    when to_assets ilike '%/%' then split(to_assets, '/')[1]
    else split(to_assets, '.')[1]
    end as to_asset_names,
    concat(from_asset_names, ' -> ', to_asset_names) as assets,
    case when assets ilike '%RUNE' then 2
    else 1
    end as numbering,
    sum(from_amount_usd) as swap_volume
    from thorchain.defi.fact_swaps
    where date < '2024-11-01'
    group by tx_id, date,
    affiliate_address, affiliate_fee_basis_points,
    from_asset, to_asset),

    base2 as (select date,
    tx_id,
    affiliate_address, affiliate_fee_basis_points,
    array_agg(distinct assets) within group (order by assets asc) as swap_direction, --merging 2 sep path to 1
    sum(swap_volume) as swap_volume
    from base
    group by 1,2,3,4),

    base3 as (select date,
    tx_id,
    affiliate_address, affiliate_fee_basis_points,
    Last run: about 5 hours agoAuto-refreshes every 24 hours
    DAY
    LABEL
    FEE_USD
    CUMULATIVE_FEE_USD
    TOTAL_CUMULATIVE_FEE_USD
    1
    2025-06-21 00:00:00.000TrustWallet4512.1076256614823022.284415537489731.8498323
    2
    2025-06-21 00:00:00.000ShapeShift85.8026391571065627.6355219737489731.8498323
    3
    2025-06-21 00:00:00.000Ledger579.9844659584427228.5282788137489731.8498323
    4
    2025-06-21 00:00:00.000Asgardex342.8688983172263162.9663219137489731.8498323
    5
    2025-06-21 00:00:00.000Others804.4982414162151261.2433600137489731.8498323
    6
    2025-06-21 00:00:00.000THORSwap1729.194319888103003.0150754337489731.8498323
    7
    2025-06-21 00:00:00.000t12363.04004157109181.41509129237489731.8498323
    8
    2025-06-21 00:00:00.000THORWallet25929.9375417633318220.4455552937489731.8498323
    9
    2025-06-21 00:00:00.000Swapkit362.1946249771050043.6351492337489731.8498323
    10
    2025-06-21 00:00:00.000leo48.8867817526572.41062480837489731.8498323
    11
    2025-06-21 00:00:00.000rj280.32688737711023.28909138337489731.8498323
    12
    2025-06-20 00:00:00.000jun0.093759043940.0937590439437452693.0077645
    13
    2025-06-20 00:00:00.000ShapeShift65.6921338891065541.8328828137452693.0077645
    14
    2025-06-20 00:00:00.000TrustWallet12785.1162034514818510.176789837452693.0077645
    15
    2025-06-20 00:00:00.000leo2.2469128446523.52384305637452693.0077645
    16
    2025-06-20 00:00:00.000-20.5276549381979.586475137452693.0077645
    17
    2025-06-20 00:00:00.000rj721.87625245610742.96220400637452693.0077645
    18
    2025-06-20 00:00:00.000Asgardex723.5186736162262820.0974235937452693.0077645
    19
    2025-06-20 00:00:00.000Others18322.7712577592150456.7451185937452693.0077645
    20
    2025-06-20 00:00:00.000THORSwap3531.1228784228101273.8207555637452693.0077645
    ...
    11268
    881KB
    18s