fanta4unicexdex
    Updated 2023-05-20

    with cex as
    (
    select address,LABEL as CEX_NAME from ethereum.core.dim_labels
    where label_type='cex'
    )
    , dex as
    (
    select address,LABEL as DEX_NAME from ethereum.core.dim_labels
    where label_type='dex'
    )
    , cex_to_dex as
    (
    select TX_HASH , AMOUNT , AMOUNT_USD , FROM_ADDRESS , TO_ADDRESS , CEX_NAME , DEX_NAME , BLOCK_TIMESTAMP from ethereum.core.ez_token_transfers
    inner join cex on cex.address=FROM_ADDRESS
    inner join dex on dex.address=TO_ADDRESS
    where symbol ='UNI'
    )
    , dex_to_cex as
    (
    select TX_HASH , AMOUNT , AMOUNT_USD , FROM_ADDRESS , TO_ADDRESS , CEX_NAME , DEX_NAME , BLOCK_TIMESTAMP from ethereum.core.ez_token_transfers
    inner join dex on dex.address=FROM_ADDRESS
    inner join cex on cex.address=TO_ADDRESS
    where symbol ='UNI'
    )
    , total_info as (select 'CEX to DEX' as direction , sum(amount) as uni_amount , sum(amount_usd) as usd_amount
    , avg(amount) as uni_avg ,avg(amount_usd) as usd_avg
    , count(distinct tx_hash) as transfer_count
    , count(distinct from_address) as cex_address_count , count(distinct to_address) as dex_address_count
    from cex_to_dex

    UNION

    select 'DEX to CEX' as direction , sum(amount) as uni_amount , sum(amount_usd) as usd_amount
    Run a query to Download Data