CoinConverseStaking STBL on AlgoFi all stake
Updated 2022-03-10
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
›
⌄
with staking as (select date_trunc('day', call_txs.block_timestamp) as dt, case
when try_base64_decode_string(call_txs.tx_message:txn:note::string) = 'Market: mt' then 'staking'
when try_base64_decode_string(call_txs.tx_message:txn:note::string) = 'Market: rcu' then 'unstaking'
end as liq_action,
sum(round(tran_txs.asset_amount/pow(10,6), 2)) as amount_stake_stbl
from algorand.application_call_transaction call_txs
join algorand.asset_transfer_transaction tran_txs on
call_txs.tx_group_id = tran_txs.tx_group_id
where tran_txs.asset_id = 465865291 and tran_txs.asset_receiver = 'DYLJJES76YQCOUK6D4RALIPJ76U5QT7L6A2KP6QTOH63OBLFKLTER2J6IA'
and liq_action in ('staking') and call_txs.app_id = 482608867
group by 1,2),
unstaking as (select date_trunc('day', block_timestamp) as dt, case
when try_base64_decode_string(tx_message:txn:note::string) = 'Market: mt' then 'staking'
when try_base64_decode_string(tx_message:txn:note::string) = 'Market: rcu' then 'unstaking'
end as liq_action,
sum(round(tx_message:dt:itx[0]:txn:aamt/pow(10,6), 2)) as amount_unstake_stbl
from algorand.application_call_transaction
where liq_action in ('unstaking') and app_id = 482608867
group by 1, 2)
select round((sum(s.amount_stake_stbl) - sum(u.amount_unstake_stbl)),2)as corrected_amount_of_stake_stbl
from staking s
join unstaking u on
s.dt = u.dt
Run a query to Download Data