Flipside Docs
Search…
Solving Your First Bounty
What is the volume of Luna and UST moving to and from Terra to Ethereum across the bridge? How has that changed over time.
We’ll be using this transaction, which Flipside has provided.
Transaction ID: 6892DA0473CD77F28436A58B9AAF20D3E2C95D50734FD7ECED5DC17019B0FBBD
  1. 1.
    Start by visiting https://finder.terra.money/ and pasting the ID above into the search box.
  1. 1.
    Then, scroll down and look for the msg event. Here you can see details on the amount sent, the recipient (to_address), sender(from_address), and the event logs. As we can see, the sender sent 50UST to the recipient. But who is the sender and who is the receiver? We can figure that out using Velocity.
2. If you haven’t already, sign up for a free Velocity account. Next, click on “new” and select “new query” to begin your first dashboard.
3. We’ll be extracting Terra data to solve this query, so select the “Terra” table from the drop-down menu on the left.
4. Next, find the list of table schemas, and select the transfers table.
5. Since we would like to know the volume of LUNA and UST moving to and from Terra to Eth across time, we will need to use the following columns:
  • Block_timestamp — the time when the transaction occurred
  • Event_from_address_name — The name of the sender
  • Event_to_address_name — the name of the recipient
  • Event_amount_usd — the USD amount of transaction transfers
  • Event_currency — the currency that is being sent
6. Next, write some code to run the SQL. Here is the example code we’ll need to run to observe the data.
1
SELECT sum(event_amount_usd) as total_usd, event_from_address_name, event_currency, date_trunc('day',block_timestamp) as dt
2
FROM terra.transfers
3
WHERE event_from ='terra13yxhrk08qvdf5zdc9ss5mwsg5sf7zva9xrgwgc'
4
AND dt > CURRENT_DATE - 30
5
AND event_currency IN ('LUNA', 'UST')
6
GROUP BY 2,3,4
Copied!
The result is shown below. The total_usd column shows the total_amount transfer, while event_from_address_name is the name for the address. We already know this address (terra13yxhrk08qvdf5zdc9ss5mwsg5sf7zva9xrgwgc) is the ETH shuttle to and from Terra. The next two columns are the currency sent (either UST or LUNA) and the date when the transaction occurred.
This is only the data for transactions from the ETH shuttle, however. How about data for transactions to the ETH shuttle?
7. Here is the full code to get that data. We are using a SQL “union” command to combine two different select statements. We must change the total_usd for to_address as negative to identify the direction of the bridge. You may adjust this on your own.
1
SELECT sum(event_amount_usd) AS total_usd, event_from_address_name, event_currency, date_trunc('day', block_timestamp) AS dt
2
FROM terra.transfers
3
WHERE event_from = 'terra13yxhrk08qvdf5zdc9ss5mwsg5sf7zva9xrgwgc'
4
AND dt > CURRENT_DATE - 30
5
AND event_currency IN ('LUNA', 'UST')
6
GROUP BY 2,3,4
7
UNION
8
SELECT sum(event_amount_usd) *-1 AS total_usd, event_from_address_name, event_currency, date_trunc('day', block_timestamp) AS dt
9
FROM terra.transfers
10
WHERE event_to = 'terra13yxhrk08qvdf5zdc9ss5mwsg5sf7zva9xrgwgc'
11
AND dt > CURRENT_DATE - 30
12
AND event_currency IN ('LUNA', 'UST')
13
GROUP BY 2,3,4
Copied!
Last modified 4mo ago
Copy link