AlexayUntitled Query
Updated 2022-08-02Copy 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 solend_table as (
select distinct a.signers[0] as wallets
from solana.fact_transactions a
inner join solana.dim_labels b
on a.instructions[0]:programId = b.address
-- last day
where block_timestamp >= CURRENT_DATE -1
and b.label = 'solend'
and b.label_subtype != 'token_contract'
and a.succeeded = 'TRUE' ),
tokens as ( select address,label
from solana.core.dim_labels
where label_type ='token'),
withdrawals as (select sum(amount) as amount, tx_from as wallet, mint
FROM solana.core.fact_transfers
WHERE wallet in (select * from solend_table) and mint ='So11111111111111111111111111111111111111112'--in (select address from tokens)
group by wallet, mint
order by wallet, mint desc
),
deposits as ( select sum(amount) as amount, tx_to as wallet, mint
from solana.core.fact_transfers
where wallet in (select * from solend_table) and mint ='So11111111111111111111111111111111111111112'--in (select address from tokens)
group by wallet, mint
order by wallet, mint desc),
swaps_out as (
select sum(swap_from_amount) as amount, swapper as wallet, swap_from_mint as mint
from solana.core.fact_swaps
where wallet in (select * from solend_table) and mint ='So11111111111111111111111111111111111111112'--in (select address from tokens)
group by wallet, mint),
swaps_dep as (
Run a query to Download Data