forgash[terradash] Anchor Collateral Gross TVL
Updated 2022-07-07Copy Reference Fork
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
›
⌄
WITH DEPOSIT AS (
SELECT
date(block_timestamp) as date,
currency,
sum(amount) as collateral_deposit
FROM anchor.collateral
WHERE event_type = 'provide'
GROUP BY 1,2
),
WITHDRAW AS (
SELECT
date(block_timestamp) as date,
currency,
sum(amount) as collateral_withdraw
FROM anchor.collateral
WHERE event_type = 'withdraw'
GROUP BY 1,2
),
LIQUIDATIONS AS (
SELECT
date(block_timestamp) as date,
liquidated_currency as currency,
sum(LIQUIDATED_AMOUNT) as collateral_liquidated
FROM anchor.liquidations
GROUP BY 1,2
),
PRICES AS (
SELECT
DATE(block_timestamp) as date_prices,
currency as token,
avg(price_usd) as avg_price_usd
FROM terra.oracle_prices
WHERE block_timestamp > '2021-03-17'
AND currency IN ('terra1dzhzukyezv0etz22ud940z7adyv7xgcjkahuun', 'terra1kc87mu460fwkqte29rquh4hc20m54fxwtsx7gp',
'terra18zqcnl83z98tf6lly37gghm7238k7lh79u4z9a', 'terra1z3e2e4jpk4n0xzzwlkgcfvc95pc5ldq0xcny58')
GROUP BY 1,2
Run a query to Download Data