MLDZMNaal1
    Updated 2022-11-08
    with tb1 as(SELECT
    *
    from ethereum.core.dim_labels
    where label ilike '%alameda%'
    or label ilike 'ftx%'
    )

    select
    'Inflow to Alameda or FTX' as actions,
    SYMBOL,
    count(distinct tx_hash) as no_transfer,
    count(distinct from_ADDRESS) as no_sender,
    sum(AMOUNT_USD) as total_volume,
    avg(AMOUNT_USD) as avg_volume
    from ethereum.core.ez_token_transfers
    where SYMBOL in ('DAI','USDC','USDT','BUSD','TUSD')
    and to_ADDRESS in (select ADDRESS from tb1)
    and from_address not in (select ADDRESS from tb1)
    and BLOCK_TIMESTAMP>='2022-10-01'
    group by 1,2
    union all
    select
    'Outflow from Alameda or FTX' as actions,
    SYMBOL,
    count(distinct tx_hash) as no_transfer,
    count(distinct to_ADDRESS) as no_sender,
    sum(AMOUNT_USD) as total_volume,
    avg(AMOUNT_USD) as avg_volume
    from ethereum.core.ez_token_transfers
    where SYMBOL in ('DAI','USDC','USDT','BUSD','TUSD')
    and from_ADDRESS in (select ADDRESS from tb1)
    and to_address not in (select ADDRESS from tb1)
    and BLOCK_TIMESTAMP>='2022-10-01'
    group by 1,2
    Run a query to Download Data