0xaimantest 1
Updated 2022-04-11
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
›
⌄
-- UST sells at more than 1 USD
with aa as (with a as (select price_usd as UP, luna_exchange_rate as LP,date_trunc('day',block_timestamp) as e from terra.oracle_prices where symbol = 'UST' and price_usd<1 order by block_timestamp desc limit 1)
select
--buy 1 ust at this price
UP*1 as a, LP, UP,
--swap that 1 ust to get this much of LUNA
1/LP as b,
-- sell that luna to get this much usd
b * LP as c,
-- profit is
c-a as d, e
from a)
select e as "Date", UP as "Price of 1 USt in USD",
a as "Buy 1 UST using this amount of USD",
b as "Use that 1 UST to get this amount of LUNA",
c as "Trade that amount of Luna to get this much in USD",
d as "Profit (USD)" from aaSD",LP as "Price of 1 LUNA in USD", a as "Get 1 UST using this amount (10 usd worth) of LUNA", b as "Swap the 1 UST to get this much USD ", c as "Profit (USD)", c/LP as "Profit in LUNA" from aa
Run a query to Download Data