Terra UST Usage
We will take a look at the usages of UST in the Terra ecosystem.
Excluding cex transactions since it's not yet identified, UST usage is mostly in the form of defi activities judging from the volume of defi vs dexes. This could mean that Terra users mostly uses UST for yield farming in defi protocols where the APY is lucrative enough with no impermanent loss.
The same hypothesis can be drawn by comparing the labels too, where a large number of transactions goes through dexes while a large amount goes through defi.
However, anchor matches in volume when it has about 6 times lower number of transactions. This indicates that the average volume per transaction of anchor far exceeds the average volume of terraswap. Seeing that anchor's APY is currently hovering at about 17-20% and without the risk of impermanent loss, it can be said that most anchor transactions are in for the long haul judging from the average volume per transaction.
The graph below shows that terraswap dominates in terms of number of transactions.
UST transactions are 'UNION'-ed together with smart contract calls and the distinct tx_id is found out to get the unique transactions and the volume is summed up.
The table below shows how much UST is going through identified and unidentified addresses.
For swaps that swap an asset to UST, MIR for example, the coins array from msg_value will be empty. In this case, these swaps will be excluded if we follow the first methodology. So, another approach is needed. This time, terra.msg_events table is used. Through some digging, I've found out that when the user wants to swap an asset to UST, the event_attributes:"1_amount"[0]:denom param will be equal to uusd. So, the logical approach is to find all these transactions and filter them out properly.
Firstly, the contracts are found out through the param msg_type = 'wasm/MsgExecuteContract'. Next, the msg_vlue:coins param, which indicates that a certain native coin is used, is flattened into multiple rows so that no coins will be left unchecked. Next, the msg_vlue:coins:denom param is filtered to only include uusd.