Kruys-Collinsearly-blush
Updated 2025-01-22
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 NET_AMOUNT AS (
SELECT
sender_id,
SUM(CASE WHEN actions in ('deposit_to_reserve', 'deposit') THEN amount_usd ELSE 0 END) AS total_supplied_usd,
SUM(CASE WHEN actions in ('withdraw_succeeded') THEN amount_usd ELSE 0 END) AS total_withdrawn_usd
FROM
near.defi.ez_lending
GROUP BY
1
),
SUPPLIERS AS (
SELECT
sender_id,
actions,
COUNT(DISTINCT tx_hash) AS n_transactions,
SUM(CASE WHEN actions in ('deposit_to_reserve', 'deposit') THEN amount_usd ELSE 0 END) AS total_supplied_usd
FROM
near.defi.ez_lending
WHERE
actions in ('deposit_to_reserve', 'deposit')
GROUP BY
1,2
),
WITHDRAWERS AS (
SELECT
sender_id,
actions,
COUNT(DISTINCT tx_hash) AS n_transactions,
SUM(CASE WHEN actions in ('withdraw_succeeded') THEN amount_usd ELSE 0 END) AS total_withdrawn_usd
FROM
near.defi.ez_lending
WHERE
actions in ('withdraw_succeeded')
GROUP BY
1,2
)
QueryRunArchived: QueryRun has been archived