ArioKamino net Borrow
Updated 2024-12-24
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
borrow as (
select
tx_id, block_timestamp, signers[0] as Borrower
from solana.core.fact_decoded_instructions
where program_id = 'KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD'
and event_type = 'borrowObligationLiquidity'
and block_timestamp >= current_timestamp - interval '{{days}} days'
group by 1,2,3
),
prices as (
select
date_trunc(day, hour) as date,
TOKEN_ADDRESS,
SYMBOL,
avg(PRICE) as price
from
solana.price.ez_prices_hourly
where
date >= current_timestamp - interval '{{days}} days'
group by
1,
2,
3
),
Borrow_Volume as (
select
date_trunc(day, fact_transfers.block_timestamp) as date,
sum(AMOUNT * price) as BorrowVolume
from
solana.core.fact_transfers
join borrow on fact_transfers.tx_id = borrow.tx_id
and fact_transfers.block_timestamp :: date = borrow.block_timestamp :: date
and fact_transfers.tx_to = borrow.Borrower
join prices on prices.TOKEN_ADDRESS = fact_transfers.MINT
and fact_transfers.block_timestamp :: date = prices.date :: date
QueryRunArchived: QueryRun has been archived