hamedfarabase-token-transfer-total-supply
    Updated 2025-02-23
    -- forked from base-token-transfer @ https://flipsidecrypto.xyz/studio/queries/0a428806-4580-4e35-ab80-c88283732f35
    with tab1 as(
    select
    day,
    sum(total_supply) AS total_supply
    from
    (
    select
    *
    from (
    select
    date(block_timestamp) as day,
    'USDC' as token,
    sum(
    case when from_address like '0x0000000000000000000000000000000000000000' then RAW_AMOUNT
    when to_address like '0x0000000000000000000000000000000000000000' then -RAW_AMOUNT
    else 0 end
    ) / power(10, 6) as net_supply,
    sum(net_supply) over (order by day) as total_supply
    from base.core.fact_token_transfers
    where contract_address like lower('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913')
    group by 1,2
    order by 1 desc
    )

    union all

    select
    *
    from (
    select
    date(block_timestamp) as day,
    'USDT' as token,
    sum(
    case when from_address like '0x0000000000000000000000000000000000000000' then RAW_AMOUNT
    when to_address like '0x0000000000000000000000000000000000000000' then -RAW_AMOUNT
    QueryRunArchived: QueryRun has been archived