binhachonFinancial Imagineering: Anchor Protocol - Deposits from customers - Earn
Updated 2022-01-28
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
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 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 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('quarter', block_timestamp) as blocktime,
sum(amount) as amount
from Anchor_earn
group by blocktime
Run a query to Download Data