scottincryptoQuickswap WMATIC/MaticX Staker Balances -
    Updated 2022-10-04
    with dates as (
    select
    date_day as block_day
    from ethereum.core.dim_dates
    where date_day > '2022-04-26'
    and date_day <= current_date
    )

    , stakes as (
    select
    date_trunc('day', block_timestamp) as block_day
    , event_inputs:user as wallet_address
    , sum(event_inputs:amount::int) / 1e18 as stake_amount
    from polygon.core.fact_event_logs
    where 1=1
    and contract_address = '0x1e16ecc4f912d8db04b8177b4186bb597267fc25' -- Quickswap WMATIC/MaticX staking contract
    and event_name = 'Staked'
    and block_day > '2022-04-26'
    and tx_status = 'SUCCESS'
    group by block_day, wallet_address
    order by block_day
    )

    , withdraws as (
    select
    date_trunc('day', block_timestamp) as block_day
    , event_inputs:account as wallet_address
    , sum(event_inputs:amount::int) / 1e18 as withdraw_amount
    from polygon.core.fact_event_logs
    where 1=1
    and contract_address = '0x1e16ecc4f912d8db04b8177b4186bb597267fc25' -- Quickswap WMATIC/MaticX staking contract
    and event_name = 'Withdrawn'
    and block_day > '2022-04-26'
    and tx_status = 'SUCCESS'
    group by block_day, wallet_address
    order by block_day
    Run a query to Download Data