feyikemiGotchi TL
Updated 2024-09-20
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
›
⌄
WITH
tab1 as (
SELECT defillama.get('/protocol/Aavegotchi', {}) as resp
),
polygon_tvl AS (
SELECT
TO_TIMESTAMP(value:date::INT) AS date,
value:totalLiquidityUSD::FLOAT AS TVL
FROM
tab1,
LATERAL FLATTEN(input => resp['data']['chainTvls']['Polygon']['tvl'])
),
ethereum_tvl AS (
SELECT
TO_TIMESTAMP(value:date::INT) AS date,
value:totalLiquidityUSD::FLOAT AS TVL
FROM
tab1,
LATERAL FLATTEN(input => resp['data']['chainTvls']['Ethereum']['tvl'])
)
SELECT
COALESCE(polygon_tvl.date, ethereum_tvl.date) AS date,
'Aavegotchi' as protocol,
COALESCE(polygon_tvl.TVL, 0) + COALESCE(ethereum_tvl.TVL, 0) AS TVL
FROM
polygon_tvl
FULL OUTER JOIN
ethereum_tvl
ON
polygon_tvl.date = ethereum_tvl.date
ORDER BY Date DESC;
QueryRunArchived: QueryRun has been archived