winnie-fsbase query
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
›
⌄
-- Base query without parameters (save as 'klend_volume_base')
with Deposit as (
select
tx_id,
block_timestamp,
signers [0] as Depositor,
DECODED_INSTRUCTION:accounts [3] :pubkey :: string as lendingMarketAuthority
from
solana.core.fact_decoded_instructions
where
program_id = 'KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD'
and event_type = 'depositReserveLiquidityAndObligationCollateral'
group by
1, 2, 3, 4
),
prices as (
select
date_trunc(day, hour) as date,
TOKEN_ADDRESS,
SYMBOL,
avg(price) as price
from
solana.price.ez_prices_hourly
group by
1, 2, 3
),
Deposit_Volume as (
select
date_trunc(day, fact_transfers.block_timestamp) as date,
sum(AMOUNT * price) as DepositVolume
from
solana.core.fact_transfers
join Deposit on fact_transfers.tx_id = Deposit.tx_id
and fact_transfers.block_timestamp :: date = Deposit.block_timestamp :: date
and fact_transfers.tx_from = Deposit.Depositor
and fact_transfers.tx_to = Deposit.lendingMarketAuthority
Run a query to Download Data