banbannardTHORChain vs Maya Protocol copy
Updated 2024-06-06
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 Rayyyk / THORChain vs Maya Protocol @ https://flipsidecrypto.xyz/Rayyyk/q/drZTYpYSHnJ6/thorchain-vs-maya-protocol
with base_tc as (select defillama.get('/protocol/Thorchain', {}) as resp),
tc as (select 'THORChain' as protocol,
to_timestamp(f.value:date) as date,
f.value:totalLiquidityUSD as tvl_usd
from base_tc,
lateral flatten(input => base_tc.resp['data']['tvl']) f),
rune as (select date_trunc('day', block_timestamp) as day,
avg(rune_usd) as rune_price
from thorchain.price.fact_prices
where day >= '2024-01-01'
group by 1),
maya as (select 'Maya Protocol' as protocol,
date,
tvl_usd*2 as tvl_usd
from external.defillama.fact_chain_tvl
where chain = 'Mayachain'
and date >= '2024-01-01'),
res1 AS (select livequery.live.udf_api('GET',
'https://science.flipsidecrypto.xyz/googlesheets/readsheet',
{ 'Content-Type': 'application/json' },
{
'sheets_id' : '1AWmBz6No3GMy3ddpP74-eelfW8MZ3w4rjSWxOA-U218',
'tab_name' : 'Cacao Price'
}
) as result
from DUAL),
data1 AS (select result:data as json_result_must_pivot from res1),
cacao as (SELECT TO_TIMESTAMP_NTZ(SUBSTR(d.value:snapped_at, 1, 19)) as day,
QueryRunArchived: QueryRun has been archived