leo-lZzln2total Stablecoins In,out and netflow To FTX and Alameda Wallets (last weak)
    Updated 2022-11-09
    with alamedaftx as (
    select *
    from ethereum.core.dim_labels
    where label ilike '%alameda%' or label ilike 'ftx%' or address_name ilike 'ftx%' or address_name ilike '%alameda%'),
    Inflowt as (
    select symbol as Symbol_IN,
    sum (amount_usd) as Inflow_Volume
    from ethereum.core.ez_token_transfers
    where to_address in (select distinct address from alamedaftx)
    and from_address not in (select distinct address from alamedaftx)
    and symbol in ('USDC','USDT','TUSD','BUSD','USDP','DAI')
    and block_timestamp BETWEEN '2022-10-26' and '2022-11-02'
    group by 1),

    Outflowt as (
    select symbol as Symbol_Out,
    sum (amount_usd) as Outflow_Volume
    from ethereum.core.ez_token_transfers
    where from_address in (select distinct address from alamedaftx)
    and to_address not in (select distinct address from alamedaftx)
    and symbol in ('USDC','USDT','TUSD','BUSD','USDP','DAI')
    and block_timestamp BETWEEN '2022-10-26' and '2022-11-02'
    group by 1)


    select symbol_in,
    inflow_volume as Inflow,
    outflow_volume*-1 as Outflow,
    inflow_volume - outflow_volume as Net_Flow
    from Inflowt t1 join Outflowt t2 on t1.Symbol_IN = t2.Symbol_Out
    Run a query to Download Data