winnie-fsCapybara rq analyst 2 copy
Updated 2024-07-26
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
›
⌄
-- forked from Sajjadiii / Capybara rq analyst 2 @ https://flipsidecrypto.xyz/Sajjadiii/q/WBhXmbDgbFhe/capybara-rq-analyst-2
with current_price_tab AS (
SELECT
TO_TIMESTAMP(log.value[0] :: string) as date,
log.value[1]::string as price,
'WKLAY' :: string AS token_contract
FROM (SELECT livequery.live.udf_api('https://api.coingecko.com/api/v3/coins/klay-token/market_chart?vs_currency=usd&days=365&interval=daily&precision=3') as resp)
,LATERAL FLATTEN (input => resp:data:prices) log
),
current_price_tab2 AS (
SELECT
TO_TIMESTAMP(log.value[0] :: string) as date,
log.value[1]::string as price,
'WETH' :: string AS token_contract
FROM (SELECT livequery.live.udf_api('https://api.coingecko.com/api/v3/coins/weth/market_chart?vs_currency=usd&days=365&interval=daily&precision=3') as resp)
,LATERAL FLATTEN (input => resp:data:prices) log
),
current_price_tab_lp AS (
SELECT * FROM current_price_tab
UNION all
SELECT * FROM current_price_tab2
),
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
data_tab_lp_swap AS (
SELECT
log.value:SYMBOL::string AS symbol
,log.value:TOKEN_ADDRESS::string AS token_address
,log.value:DECIMAL::string AS decimal
FROM (SELECT livequery.live.udf_api( 'https://flipsidecrypto.xyz/api/v1/queries/9cedd64b-79e6-4e93-882f-475718345fb5/data/latest') as resp )
,LATERAL FLATTEN (input => resp:data) log
QueryRunArchived: QueryRun has been archived