cheeyoung-kekSolana 3
Updated 2022-08-03Copy Reference Fork
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 balance_left as(
select
a.BLOCK_TIMESTAMP::date as date,
INSTRUCTION:accounts as users,
sum(inner_instruction:instructions[1]:parsed:info:amount)/1e6 as borrowed_volume
from solana.core.fact_events a
where
instruction:programId = 'So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'
and instruction:accounts[0] = '8SheGtsopRUDzdiD6v6BR9a6bqZ9QwywYQY99Fp5meNf'
and instruction:accounts[2] = 'BgxfHJDzm44T7XG68MYKx7YisTjZu73tVovyZSjJMpmw'
and succeeded = 'TRUE'
and date >= '2022-01-01'
group by 1,2
order by 3
),
data_1 as (
select
date,
users,
(borrowed_volume) as total_usd_borrow
from balance_left
)
SELECT
date,
CASE
WHEN total_usd_borrow <100 then 'Under 100 USDC Borrowed'
WHEN total_usd_borrow >=100 and total_usd_borrow <5000 then 'between 100 USDC and 1000 USDC Borrowed'
WHEN total_usd_borrow >=5000 and total_usd_borrow <10000 then 'between 5000 USDC and 10000 USDC Borrowed'
WHEN total_usd_borrow >=10000 and total_usd_borrow <100000 then 'between 10000 USDC and 100000 USDC Borrowed'
WHEN total_usd_borrow >=100000 and total_usd_borrow <1000000 then 'between 100000 USDC and 1000000 USDC Borrowed'
WHEN total_usd_borrow >=1000000 then 'Above 1 million USDC Borrowed'
end as distribution,
count(distribution)
from data_1
Run a query to Download Data