h4wkpoly stable pool
    Updated 2024-06-17
    -- forked from stable pool @ https://flipsidecrypto.xyz/edit/queries/353c1e89-db1d-443d-9635-0e6f0dc08b93

    select date_trunc('day', block_timestamp) as date,
    -- case when from_address = '0x0000000000000000000000000000000000000000' then 'Deposit'
    -- else 'Withdrawal' end as type,
    count(distinct tx_hash) as tx_count,
    count(distinct origin_from_address) as user_count,
    sum(case when from_address = '0x0000000000000000000000000000000000000000' then raw_amount_precise::float/1e18 else 0 end) as deposit_vol,
    sum(case when to_address = '0x0000000000000000000000000000000000000000' then -raw_amount_precise::float/1e18 else 0 end) as withdrawal_vol,
    deposit_vol + withdrawal_vol as net_vol,
    sum(net_vol) over (order by date) as TVL
    from polygon.core.fact_token_transfers
    where 1 = 1
    -- and tx_hash = '0xc3869010f5f9a85ccd3d252c7640f8c937fb5f787118c893687386245dd7d383'
    and contract_address = lower('0xDa43Bfd7Ecc6835AA6f1761ced30b986A574c0d2')
    and (from_address = '0x0000000000000000000000000000000000000000'
    or to_address = '0x0000000000000000000000000000000000000000')
    group by 1
    order by date desc


    QueryRunArchived: QueryRun has been archived