Ali3NOverview Inflow & Outflow To/From CEXs (THORChain)
    Updated 2024-11-07
    select 'Inflow' as type,
    count (distinct fact_transfers_id) as Transfers,
    count (distinct to_address) as Users,
    sum (rune_amount_usd) as Volume,
    avg (rune_amount_usd) as Average_Volume,
    transfers / users as Transfer_Per_User,
    volume / users as Volume_Per_User
    from thorchain.core.fact_transfers
    where block_timestamp >= '{{From_Date}}' and block_timestamp <= '{{To_Date}}'
    and from_address in (select distinct address from thorchain.core.dim_labels where label_type = 'cex' group by 1)
    group by 1

    union all

    select 'Outflow' as type,
    count (distinct fact_transfers_id) as Transfers,
    count (distinct from_address) as Users,
    sum (rune_amount_usd) as Volume,
    avg (rune_amount_usd) as Average_Volume,
    transfers / users as Transfer_Per_User,
    volume / users as Volume_Per_User
    from thorchain.core.fact_transfers
    where block_timestamp >= '{{From_Date}}' and block_timestamp <= '{{To_Date}}'
    and to_address in (select distinct address from thorchain.core.dim_labels where label_type = 'cex' group by 1)
    group by 1
    order by 1
    QueryRunArchived: QueryRun has been archived