SpecterArbitrum
Updated 2024-12-16
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 lockup AS (
SELECT
TRUNC(block_timestamp, 'day') AS day, -- Truncate to match `meprice`
block_timestamp,
tx_id,
signers[0] AS owner,
-- Extract amount staked, dividing by 10^6 to account for decimal places
utils.udf_hex_to_int(
TO_CHAR(REVERSE(TO_BINARY(SUBSTR(utils.udf_base58_to_hex(instruction:data), 19, 16))))
) / POW(10, 6) AS amount,
-- Extract lockup period and convert to a readable timestamp
TO_TIMESTAMP(
utils.udf_hex_to_int(
TO_CHAR(REVERSE(TO_BINARY(SUBSTR(utils.udf_base58_to_hex(instruction:data), 35, 8))))
)
) AS lockup_end_timestamp,
-- Calculate lockup length in days using DATEDIFF with 'day' as the unit
DATEDIFF(
'day',
block_timestamp,
TO_TIMESTAMP(
utils.udf_hex_to_int(
TO_CHAR(REVERSE(TO_BINARY(SUBSTR(utils.udf_base58_to_hex(instruction:data), 35, 8))))
)
)
) AS lockup_length_days,
-- Calculate staking power as amount * lockup length (in days)
(
utils.udf_hex_to_int(
TO_CHAR(REVERSE(TO_BINARY(SUBSTR(utils.udf_base58_to_hex(instruction:data), 19, 16))))
) / POW(10, 6)
) * DATEDIFF(
'day',
block_timestamp,
TO_TIMESTAMP(
utils.udf_hex_to_int(
QueryRunArchived: QueryRun has been archived