rustygeejGLP_Camelot_Price_feed
Updated 2023-03-10
99
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
›
⌄
-- forked from 5efc2f7a-a1dc-435d-8241-c6a6a0265f2b
with latestSwaps as (
SELECT *
FROM arbitrum.core.fact_event_logs
WHERE CONTRACT_ADDRESS = '0x616279ff3dbf57a55e3d1f2e309e5d704e4e58ae'
--and ORIGIN_FUNCTION_SIGNATURE = '0x431a4ad3' Swap
and EVENT_NAME = 'Swap'
--and EVENT_NAME = 'swapExactTokensForTokensSupportingFeeOnTransferTokens'
--and DATE(BLOCK_TIMESTAMP) = '2023-01-23'
),
InandOut as (
SELECT
BLOCK_TIMESTAMP as time,
CAST(EVENT_INPUTS:amount0In AS FLOAT) amt0_in,
CAST(EVENT_INPUTS:amount1In AS FLOAT) amt1_in,
CAST(EVENT_INPUTS:amount0Out AS FLOAT) amt0_out,
CAST(EVENT_INPUTS:amount1Out AS FLOAT) amt1_out
FROM latestSwaps
)
SELECT
time,
CASE
WHEN amt0_out IS NOT NULL AND amt0_out <> 0 THEN ((amt1_in) / (amt0_out)) * POW(10,12)
WHEN amt0_in IS NOT NULL AND amt0_in <> 0 THEN ((amt1_out) / (amt0_in)) * POW(10,12)
END AS price
FROM InandOut
ORDER BY time DESC
Run a query to Download Data