kimkimUser distribution by SOL borrowing
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 sol_borrow as (
select
BLOCK_TIMESTAMP::date as date,
INSTRUCTION:accounts[7] as users,
sum(inner_instruction:instructions[1]:parsed:info:amount)/1e9 as daily_sol_borrow
from solana.core.fact_events
where block_timestamp >= '2022-01-01'
and instruction:programId = 'So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'
and instruction:accounts[0] = '8UviNr47S8eL6J3WfDxMRa3hvLta1VDJwNWqsDgtN3Cv'
and instruction:accounts[2] = '8PbodeaosQP19SjYFx855UMqWxH2HynZLdBXmsrbac36'
and succeeded = 'TRUE'
group by 1,2
),
sol_price as (
select
date(block_timestamp) as date,
avg(swap_to_amount) / avg(swap_from_amount) as solprice
from solana.fact_swaps
where swap_from_mint = 'So11111111111111111111111111111111111111112'
and swap_to_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
and swap_to_amount > 0
and swap_from_amount > 0
and date(block_timestamp) >= '2022-01-01'
group by 1
order by 1 asc
),
T1 as (
select
a.date,
a.users,
(a.daily_sol_borrow * b.solprice) as usd_value_borrowed
from sol_borrow a
join sol_price b
Run a query to Download Data