m0rt3zaBendDAO - total stats last 30 days
Updated 2022-09-05Copy 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
›
⌄
WITH events as (
SELECT
block_timestamp,
date_trunc(HOUR, block_timestamp) as hour,
origin_from_address as user_wallet,
event_name as action_type,
CASE
WHEN action_type = 'Deposit' THEN event_inputs:value
WHEN action_type = 'Withdrawal' THEN event_inputs:wad
END AS eth_value_raw,
eth_value_raw / pow(10, 18) as eth_value
FROM ethereum.core.fact_event_logs
WHERE origin_to_address = '0x3b968d2d299b895a5fcf3bba7a64ad0f566e6f88'
AND event_name in ('Deposit', 'Withdrawal')
AND block_timestamp > CURRENT_DATE - 30
), actions as (
SELECT a.*, a.eth_value * b.price as usd_value,
CASE WHEN action_type = 'Withdrawal' THEN eth_value END as withdraw_amount,
CASE WHEN action_type = 'Deposit' THEN eth_value END as deposit_amount,
CASE WHEN action_type = 'Withdrawal' THEN usd_value END as withdraw_amount_usd,
CASE WHEN action_type = 'Deposit' THEN usd_value END as deposit_amount_usd
FROM events as a JOIN ethereum.core.fact_hourly_token_prices as b
ON a.hour = b.hour AND b.token_address is NULL
)
SELECT
sum(withdraw_amount) as "Withdraw",
sum(deposit_amount) as "Deposit",
sum(withdraw_amount_usd) as "Withdraw USD Volume",
sum(deposit_amount_usd) as "Deposit USD Volume",
count(DISTINCT user_wallet) as "Unique Wallets"
FROM actions
Run a query to Download Data