nickpayiatis_GARD TVL
Updated 2022-07-27
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 algo_price as (
SELECT date_trunc('day',block_hour) as date,
avg(price_usd) as avg_price
FROM flipside_prod_db.algorand.prices_swap
WHERE asset_id = 0
GROUP BY date)
SELECT dep.dates,
dep.label,
dep.dep_algo_amnt,
dep.avg_algo_amnt,
sum(dep.dep_algo_amnt)over(ORDER BY dep.dates) as dep_algo,
withd.withd_algo_amnt,
sum(withd.withd_algo_amnt)over(ORDER BY dep.dates) as withd_algo,
dep.dep_algo_amnt-withd.withd_algo_amnt as daily_ALGO_collateral,
sum(daily_ALGO_collateral) OVER (ORDER BY dep.dates) as cum_TVL,
dep.dep_usd_amnt,
sum(dep.dep_usd_amnt)over(ORDER BY dep.dates) as dep_in_usd,
withd.withd_usd_amnt,
sum(withd.withd_usd_amnt)over(ORDER BY dep.dates) as withd_in_usd,
dep.dep_usd_amnt-withd.withd_usd_amnt as daily_usd_collateral,
sum(daily_usd_collateral) OVER (ORDER BY dep.dates) as cum_TVL_usd
FROM (
SELECT 'ALGO_collateral' as label,
date_trunc('day',block_timestamp) as dates,
sum(amount) as dep_ALGO_amnt,
avg(amount) as avg_algo_amnt,
sum(a.amount*b.avg_price) as dep_usd_amnt
FROM algorand.payment_transaction a
LEFT JOIN algo_price b
ON date_trunc('day',a.block_timestamp) = b.date
WHERE tx_group_id IN (
SELECT tx_group_id
FROM algorand.application_call_transaction
WHERE (TRY_BASE64_DECODE_STRING(tx_message:txn:apaa[0]::STRING) = 'NewPosition' or TRY_BASE64_DECODE_STRING(tx_message:txn:apaa[0]::STRING) = 'MoreGARD')
AND app_id = '684650147'
Run a query to Download Data