hesstop daily platform type
    Updated 2023-06-09
    with swap_to as ( select DISTINCT origin_from_address, case when token_out = '0x68327a91e79f87f501bc8522fc333fb7a72393cb' then 'Aux Users'
    else 'AGX Users' end as label
    from avalanche.core.ez_dex_swaps
    where token_out in ('0x68327a91e79f87f501bc8522fc333fb7a72393cb','0x13e7bcefdde72492e656f3fa58bae6029708e673'))
    ,
    final as ( select trunc(block_timestamp,'week') as monthly, tx_hash, origin_from_address, avax_to_address as platform_address, amount_usd
    from avalanche.core.ez_avax_transfers
    where block_timestamp::date >= current_date - 180
    and origin_from_address in (select DISTINCT origin_from_address from swap_to)
    and tx_hash not in (select DISTINCT tx_hash from avalanche.core.ez_dex_swaps
    where token_out in ('0x68327a91e79f87f501bc8522fc333fb7a72393cb','0x13e7bcefdde72492e656f3fa58bae6029708e673'))
    UNION
    select trunc(block_timestamp,'week') as monthly, tx_hash, origin_from_address, to_address as platform_address, amount_usd
    from avalanche.core.ez_token_transfers
    where block_timestamp::date >= current_date - 180
    and origin_from_address in (select DISTINCT origin_from_address from swap_to)
    and tx_hash not in (select DISTINCT tx_hash from avalanche.core.ez_dex_swaps
    where token_out in ('0x68327a91e79f87f501bc8522fc333fb7a72393cb','0x13e7bcefdde72492e656f3fa58bae6029708e673')))
    ,
    final_2 as ( select monthly, origin_from_address,label_type ,count(DISTINCT(tx_hash)) as total_tx ,sum(amount_usd) as volume
    from final a join avalanche.core.dim_labels b on a.platform_address = address
    where label_type not in ('chadmin','token')
    and amount_usd is not null
    group by 1,2,3)

    select monthly, label, label_type, sum(total_tx) as total_txs, sum(volume) as usd_volume
    from final_2 a join swap_to b on a.origin_from_address = b.origin_from_address
    group by 1,2,3


    Run a query to Download Data