binhachon125. [Easy] Anchor Users - Number of active user Anchor Earn
    Updated 2021-12-27
    with Anchor_earn_deposit as (
    select
    block_timestamp,
    event_attributes:to::string as sender,
    event_attributes:amount::float/1e6 as amount
    from terra.msg_events
    where tx_status = 'SUCCEEDED'
    and event_type = 'from_contract'
    and event_attributes:"0_action"::string = 'deposit_stable'
    and event_attributes:"0_contract_address"::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    ),
    Anchor_earn_withdraw as (
    select
    block_timestamp,
    event_attributes:"0_from"::string as sender,
    event_attributes:"0_amount"::float/1e6 as amount
    from
    terra.msg_events
    where event_type = 'from_contract'
    and tx_status = 'SUCCEEDED'
    and event_attributes:"1_action"::string = 'redeem_stable'
    and event_attributes:to::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
    ),
    Anchor_earn as (
    select sender as address, amount from Anchor_earn_deposit
    union all
    select sender as address, -amount as amount from Anchor_earn_withdraw
    ),
    new_Anchor_users as (
    select
    sender
    from (
    select
    block_timestamp,
    sender,
    row_number() over (partition by sender order by block_timestamp) as rownumber
    Run a query to Download Data