mondov2023-06-05 05:07 PM
Updated 2023-06-05
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 deposits AS (
SELECT
DATE_TRUNC('{{time_period}}', BLOCK_TIMESTAMP) AS deposit_date,
COUNT(*) AS num_deposits,
SUM(SUPPLIED_USD) AS total_deposit_usd
FROM ethereum.aave.ez_deposits
WHERE AAVE_MARKET = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9'
AND DATE_TRUNC('{{time_period}}', BLOCK_TIMESTAMP) >= CURRENT_DATE - {{past_days}}
GROUP BY deposit_date
),
withdrawals AS (
SELECT
DATE_TRUNC('{{time_period}}', BLOCK_TIMESTAMP) AS withdrawal_date,
COUNT(*) AS num_withdrawals,
SUM(WITHDRAWN_USD) AS total_withdrawal_usd
FROM ethereum.aave.ez_withdraws
WHERE AAVE_MARKET = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9'
AND DATE_TRUNC('{{time_period}}', BLOCK_TIMESTAMP) >= CURRENT_DATE - {{past_days}}
GROUP BY withdrawal_date
),
cumulative_deposits AS (
SELECT
deposit_date,
SUM(total_deposit_usd) OVER (ORDER BY deposit_date) AS cumulative_deposit_usd
FROM deposits
),
cumulative_withdrawals AS (
SELECT
withdrawal_date,
SUM(total_withdrawal_usd) OVER (ORDER BY withdrawal_date) AS cumulative_withdrawal_usd
FROM withdrawals
),
Run a query to Download Data