adriaparcerisasoa sol 4 m23 NO
    Updated 2023-03-22

    with
    ins as (
    select
    trunc(block_timestamp,'day') as date,
    case when mint='Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB' then 'USDT'
    when mint='83LGLCm7QKpYZbX8q4W2kYWbtt8NJBwbVwEepzkVnJ9y' then 'xUSD'
    else 'PAI' end as symbol,
    sum(amount) as amount_in
    from solana.core.fact_transfers x
    join solana.core.dim_labels y on x.tx_from = y.address
    where mint in ('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB','Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS','83LGLCm7QKpYZbX8q4W2kYWbtt8NJBwbVwEepzkVnJ9y') --USDC contract
    group by 1,2
    ),
    outs as (
    select
    trunc(block_timestamp,'day') as date,
    case when mint='Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB' then 'USDT'
    when mint='83LGLCm7QKpYZbX8q4W2kYWbtt8NJBwbVwEepzkVnJ9y' then 'xUSD'
    else 'PAI' end as symbol,
    sum(amount) as amount_out
    from solana.core.fact_transfers x
    join solana.core.dim_labels y on x.tx_to = y.address
    where mint in ('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB','Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS','83LGLCm7QKpYZbX8q4W2kYWbtt8NJBwbVwEepzkVnJ9y') --USDC contract
    group by 1,2
    ),
    final as (
    select
    x.date,
    x.symbol,
    amount_in,amount_out*(-1) as amount_outs,
    amount_in - amount_out as netflow,
    sum(amount_in) over (partition by x.symbol order by x.date) as total_amount_in,
    sum(amount_out) over (partition by x.symbol order by x.date) as total_amount_out,
    total_amount_in-total_amount_out as USDC_marketcap
    from ins x
    Run a query to Download Data