Abbas_ra21Balance of Borrowers
Updated 2023-03-08
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 tb AS (select
DISTINCT BORROWER_ADDRESS AS BORROWER
from ethereum.aave.ez_borrows where SYMBOL in ('MKR') and AAVE_VERSION='Aave V2'),
tb2 AS ( SELECT
DISTINCT BORROWER_ADDRESS AS BORROWER
from ethereum.aave.ez_borrows where SYMBOL in ('SNX') and AAVE_VERSION='Aave V2' ),
tb3 AS (SELECT
DISTINCT BORROWER_ADDRESS AS BORROWER
from ethereum.aave.ez_borrows where SYMBOL in ('UNI') and AAVE_VERSION='Aave V2' ),
tb4 AS (select
'MKR' AS B_SYMBOL,
USER_ADDRESS AS User,
sum(USD_VALUE_NOW) AS Balance
from ethereum.core.ez_current_balances where USER_ADDRESS in (select BORROWER from tb) and SYMBOL in ('ETH','USDC','USDT','DAI')
group by 1,2
UNION ALL
select
'SNX' AS B_SYMBOL,
USER_ADDRESS AS User,
sum(USD_VALUE_NOW) AS Balance
from ethereum.core.ez_current_balances where USER_ADDRESS in (select BORROWER from tb2) and SYMBOL in ('ETH','USDC','USDT','DAI')
group by 1,2
UNION ALL
select
'UNI' AS B_SYMBOL,
USER_ADDRESS AS User,
sum(USD_VALUE_NOW) AS Balance
from ethereum.core.ez_current_balances where USER_ADDRESS in (select BORROWER from tb3) and SYMBOL in ('ETH','USDC','USDT','DAI')
group by 1,2)
select
B_SYMBOL AS Symbol,
case when Balance < 1000 then 'less than 1K USD'
when Balance >= 1000 and Balance <= 5000 then 'Between 1K and 5K USD'
when Balance >= 5000 and Balance <= 25000 then 'Between 5K and 25K USD'
when Balance >= 25000 and Balance <= 100000 then 'Between 25K and 100K USD'
Run a query to Download Data