Sandeshxmetric distributed and treasury
    Updated 2023-02-16
    -- amount_usd -> amount itself

    with xmetrics_out AS

    (
    select
    block_timestamp,
    tx_hash,
    raw_amount/pow(10,18) as amount_usd,
    from_address,
    to_address
    from polygon.core.fact_token_transfers
    where 1=1
    -- and tx_hash=lower('0xcc93b9f5b86d176cae42fd31ec6c5c2771e913a085375f8039f6d3af5c1674d3')
    and origin_from_address='0xa0f00e59ef57d82449accb05b9512a47b264374b'
    and contract_address='0x15848c9672e99be386807b9101f83a16eb017bb5'
    and from_address='0x0000000000000000000000000000000000000000'

    ),
    temp as
    (
    select block_timestamp::date as "date",
    sum(amount_usd) as out
    from xmetrics_out
    group by 1
    )
    select "date", out, sum(out) over(order by "date" asc) as cummulative, 2079569-cummulative as balance --from polygonscan
    from temp
    order by 1 desc
    Run a query to Download Data