binhachonCross-chain Anchor - Stats
    Updated 2022-03-27
    with Anchor_earn_deposit as (
    select
    block_timestamp,
    event_attributes:to::string as sender,
    event_attributes:amount::float/1e6 as amount,
    event_attributes:deposit_amount::float/1e6 as UST_amount
    from terra.msg_events
    where block_timestamp::date > '2022-03-01'
    and 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,
    event_attributes:redeem_amount::float/1e6 as UST_amount
    from
    terra.msg_events
    where block_timestamp::date > '2022-03-01'
    and 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 block_timestamp, sender as address, amount, UST_amount from Anchor_earn_deposit
    union all
    select block_timestamp, sender as address, -amount as amount, UST_amount from Anchor_earn_withdraw
    ),
    Anchor_earn_quarter as (
    select
    date_trunc('day', block_timestamp) as blocktime,
    sum(amount) as amount,
    Run a query to Download Data