kimkimSolend User distribution by SOL borrowing amount (in USDC) by day
Updated 2022-08-02
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 usd_borrow as (
select
BLOCK_TIMESTAMP::date as date,
INSTRUCTION:accounts[7] as users,
sum(inner_instruction:instructions[1]:parsed:info:amount)/1e6 as daily_usd_borrow
from solana.core.fact_events
where block_timestamp >= '2022-01-01' and block_timestamp < CURRENT_DATE
and instruction:programId = 'So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'
and instruction:accounts[0] = '8SheGtsopRUDzdiD6v6BR9a6bqZ9QwywYQY99Fp5meNf'
and instruction:accounts[2] = 'BgxfHJDzm44T7XG68MYKx7YisTjZu73tVovyZSjJMpmw'
and succeeded = 'TRUE'
group by 1,2
),
T1 as (
select
date,
users,
(daily_usd_borrow) as value_borrowed
from usd_borrow
)
SELECT
date,
CASE
WHEN value_borrowed <100 then 'Under 100 USDC Borrowed'
WHEN value_borrowed >=100 and value_borrowed <1000 then 'between 100 USDC and 1000 USDC Borrowed'
WHEN value_borrowed >=1000 and value_borrowed <10000 then 'between 1000 USDC and 10000 USDC Borrowed'
WHEN value_borrowed >=10000 and value_borrowed <100000 then 'between 10000 USDC and 100000 USDC Borrowed'
WHEN value_borrowed >=100000 and value_borrowed <1000000 then 'between 100000 USDC and 1000000 USDC Borrowed'
WHEN value_borrowed >=1000000 then 'Above 1 million USDC Borrowed'
end as category,
count(category)
from T1
where category is not null
Run a query to Download Data