CyberaResearchJUP Staking - v2 sw total v2
Updated 2024-11-28
999
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
›
⌄
-- Enable recursive CTEs
WITH RECURSIVE
-- 1. Filter relevant transactions without restricting to a specific signer
filtered_signers AS (
SELECT DISTINCT
di.block_timestamp,
di.block_id,
di.tx_id,
s.value::STRING AS signer_pubkey, -- Identify the wallet
di.program_id,
di.event_type,
di.decoded_instruction
FROM
solana.core.fact_decoded_instructions di,
LATERAL FLATTEN(input => di.signers) s
WHERE
di.program_id = 'voTpe3tHQ7AjQHMapgSue2HJFAh2cGsdokqN3XqmVSj'
AND di.event_type IN (
'mergePartialUnstaking',
'openPartialUnstaking',
'increaseLockedAmount',
'toggleMaxLock',
'newEscrow',
'withdraw',
'withdrawPartialUnstaking'
)
),
-- 2. Extract and sum withdrawal amounts per transaction
withdrawals AS (
SELECT
fe.tx_id,
SUM(
CASE
WHEN ed.event_type IN ('withdraw', 'withdrawPartialUnstaking') THEN
QueryRunArchived: QueryRun has been archived