Updated 2025-05-07
    with main as (
    select
    date_trunc('year', block_timestamp) as date,
    sum(coalesce(from_amount_usd, to_amount_usd)) as volume,
    count(DISTINCT tx_id) as n_swaps,
    count(DISTINCT from_address) as n_swappers ,
    sum(liq_fee_rune_usd) as liquidity_fee
    from thorchain.defi.fact_swaps
    where tx_id not in (select tx_id from thorchain.defi.fact_refund_events)
    group by 1
    )
    ,
    new_wallet as (
    select
    date_trunc('year', first_tx) as date,
    count(DISTINCT from_address) as n_new_user
    from (
    select
    from_address,
    min(block_timestamp) as first_tx
    from thorchain.defi.fact_swaps
    group by 1
    )
    group by 1
    )
    ,
    affiliate_volume as (
    with pools_count as (
    select
    tx_id,
    count(DISTINCT pool_name) as n_pools
    from thorchain.defi.fact_swaps
    where tx_id not in (select tx_id from thorchain.defi.fact_refund_events)
    group by 1
    )
    select
    Last run: about 1 month ago
    DATE
    VOLUME
    AFFILIATE_VOLUME
    N_SWAPS
    AVG_VOLUME_PER_TXNS
    N_SWAPPERS
    AVG_VOLUME_PER_WALLET
    AVG_DAILY_VOLUME
    LIQUIDITY_FEE
    AFFILIATE_FEE
    N_NEW_USER
    Bond Earning
    Pool & Dev Earning
    VOLUME_GROWTH
    AFFILIATE_VOLUME_GROWTH
    AFFILIATE_FEE_GROWTH
    SWAPS_GROWTH
    SWAPPERS_GROWTH
    LIQUIDITY_FEE_GROWTH
    NEW_USER_GROWTH
    BOND_EARING_GROWTH
    POOLS_EARING_GROWTH
    AVG_VOLUME_PER_TXNS_GROWTH
    AVG_VOLUME_PER_WALLET_GROWTH
    AVG_DAILY_VOLUME_GROWTH
    1
    2024-01-01 00:00:00.00055182284424.23475279211073.39546102852025365.211536364367841150016.676836554151184340.88831430597028.757963419669173.31207643501373990216242544151205.334834629204.079566661745.55207868948.1847463.816891120.91210409162.377858151.469152551103.097691868106.05011979386.387882555205.334834629
    1
    341B
    93s