Abbas_ra21Average Balance 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
›
⌄
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,
avg(Balance) AS "Borrowers Average Balance (USD)"
from tb4 group by 1
Run a query to Download Data