Updated 2024-09-29
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 price_data AS (
SELECT
symbol,
MAX(price) AS avg_price -- Use MAX price or choose another method based on your needs
FROM
gnosis.price.ez_prices_hourly
GROUP BY
symbol
)
SELECT
l.borrower, -- Include borrower in the select statement
SUM(l.amount * pd.avg_price) AS total_volume_usd -- Calculate total volume in USD per borrower
FROM
gnosis.defi.ez_lending_liquidations l
JOIN
price_data pd ON l.collateral_token_symbol = pd.symbol
GROUP BY
l.borrower -- Group by borrower
ORDER BY
total_volume_usd DESC
LIMIT 20 -- Optionally order by total volume in USD
*/
SELECT
depositor,
SUM(amount_usd) AS total_volume_usd
FROM
gnosis.defi.ez_lending_deposits
WHERE
depositor = '0xb83ad7d7efe3fc000a6344c73b3e4407a734d1a8'
GROUP BY
depositor
HAVING
SUM(amount_usd) > 0; -- Only return results if there's a positive sum
QueryRunArchived: QueryRun has been archived