Deposits

Deposits can be calculated two ways, using the msgs table and using the msg_events table. The query we used uses the msg_events table and looks something like this:

select
  	block_id,
  	event_attributes:depositor::string as depositor,
	event_attributes:deposit_amount as deposit_amount_uust, 
  	event_attributes:deposit_amount / pow(10, 6) as deposit_amount_ust,
  	event_attributes:mint_amount as mint_amount_uaust,
  	event_attributes:mint_amount / pow(10, 6) as mint_amount_aust,
  	event_attributes:deposit_amount / event_attributes:mint_amount as aust_value
from terra.msg_events m
where m.event_attributes:deposit_amount is not null
and m.event_attributes:mint_amount is not null
and m.event_attributes:"0_contract_address"::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
and tx_status = 'SUCCEEDED'
order by 1;

We chose to use the msg_events instead of msgs since it seems like on flipside msgs_events has more deposit transactions than the msgs table. This is likely due to missing data

The following queries were used for verification:

select
  	count(tx_id) as total_deposit_transactions,
  	'Events Method' as methodology
from terra.msg_events m
where m.event_attributes:deposit_amount is not null
and m.event_attributes:mint_amount is not null
and m.event_attributes:"0_contract_address"::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
and tx_status = 'SUCCEEDED'
union
select
	count(tx_id) as total_deposit_transactions,
  	'Msgs Method' as methodology
from terra.msgs m
where m.msg_value:execute_msg:deposit_stable is not null
and m.msg_value:contract::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
and tx_status = 'SUCCEEDED'

with event_txs as (select
  	tx_id
from terra.msg_events m
where m.event_attributes:deposit_amount is not null
and m.event_attributes:mint_amount is not null
and m.event_attributes:"0_contract_address"::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
and tx_status = 'SUCCEEDED'),
msg_txs as (
select
	tx_id
from terra.msgs m
where m.msg_value:execute_msg:deposit_stable is not null
and m.msg_value:contract::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
and tx_status = 'SUCCEEDED')
select
	*
from msg_txs mt
where mt.tx_id not in (select tx_id from event_txs)
with event_txs as (select
  	tx_id
from terra.msg_events m
where m.event_attributes:deposit_amount is not null
and m.event_attributes:mint_amount is not null
and tx_status = 'SUCCEEDED'),
msg_txs as (
select
	tx_id
from terra.msgs m
where m.msg_value:execute_msg:deposit_stable is not null
and m.msg_value:contract::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
and tx_status = 'SUCCEEDED')
select
	*
from event_txs et
where et.tx_id not in (select tx_id from msg_txs)

Redemption

Our process for redemptions is very similar. We use the msg_events table, and the query looks like this:

select
  	m.block_id,
  	m.tx_id,
  	m.event_attributes:"0_from"::string as redeemer,
	m.event_attributes:redeem_amount as uust_redeemend,
  	m.event_attributes:redeem_amount / pow(10, 6) as ust_redeemed,
  	m.event_attributes:burn_amount as uaust_burnt,
  	m.event_attributes:burn_amount / pow(10, 6) as aust_burnt
from terra.msg_events m
where m.event_attributes:redeem_amount is not null
and m.event_attributes:burn_amount is not null
and m.event_attributes:"1_contract_address"::string = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'
and m.tx_status = 'SUCCEEDED'
order by 1;

We check for redemptions in msgs and msg_events in the same ways we check for deposits. The queries have are available to shreyash, somethingelse and angela on flipside. If you'd like access to the queries feel free to contact shreyash.

Transfers

Users may transfer aUST to another user or they may receive aUST from another user.

Our methodology for dealing with transfers is as follows:

Query for transfers here:

select
	m.block_id,
  	m.tx_id,
  	m.event_attributes:from::string as sender,
  	m.event_attributes:to::string as receiver,
  	m.event_attributes:amount as uaust_transferred,
  	m.event_attributes:amount / pow(10, 6) as aust_transferred
from terra.msg_events m
where m.event_attributes:contract_address::string = 'terra1hzh9vpxhsk8253se0vv5jj6etdvxu3nv8z07zu' -- aUST contract
and m.event_type = 'from_contract'
and m.tx_status = 'SUCCEEDED'