nsa2000osmo met6
Updated 2023-02-11
999
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
27
28
29
30
31
32
33
34
35
36
›
⌄
with swaps AS (
SELECT
block_id,
block_timestamp,
trader,
tx_id,
from_amount/pow(10, from_decimal) as from_amount1,
from_currency,
a.project_name as from_symbol,
---
to_amount/pow(10, to_decimal) as to_amount1,
to_currency,
nvl(b.project_name, to_currency) as to_symbol,
a.label as token_sold,
b.label as token_bought,
pool_ids
FROM osmosis.core.fact_swaps
LEFT JOIN osmosis.core.dim_labels a ON from_currency = a.address
LEFT JOIN osmosis.core.dim_labels b ON to_currency = b.address
WHERE from_currency = 'uosmo'
AND from_symbol IN ('USDC.axl', 'DAI.axl')
),
osmosis_swap_oracle AS ( -- swap and oracle price
SELECT
date(block_timestamp) as date,
to_currency,
sum(from_amount1)/sum(to_amount1) as usd -- estimate price from swaps
-- count(distinct tx_id) as buy_count,
-- sum(from_amount1) as buy_usd_volume
From swaps
WHERE to_symbol IS NOT NULL
GROUP BY 1,2
UNION
SELECT
date(recorded_at) as date,
symbol,
Run a query to Download Data