SocioAnalyticafact swap [Thala]
Updated 2025-03-09
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
›
⌄
with
fact_swaps as (
SELECT
a.block_number,
a.block_timestamp,
a.tx_hash,
a.success,
a.tx_type,
a.payload_function,
a.event_index,
event_module,
EVENT_RESOURCE,
sender as swapper,
event_data:idx_in as id_index_in,
event_data:idx_out as id_index_out,
event_data:amount_in as amounts_in,
event_data:amount_out as amounts_out,
CASE when id_index_in = '1' then SPLIT(event_type, ',')[1]
when id_index_in = '0' then SPLIT_PART(SPLIT(event_type, ',')[0], '<', 2)
end as token_in,
CASE when id_index_out = '0' then SPLIT_PART(SPLIT(event_type, ',')[0], '<', 2)
when id_index_out = '1' then SPLIT(event_type, ',')[1]
end as token_out,
SPLIT_PART(token_in, '::', 3) as symbol_in,
SPLIT_PART(token_out, '::', 3) as symbol_out
FROM aptos.core.fact_events a
JOIN aptos.core.fact_transactions b ON a.tx_hash = b.tx_hash
WHERE event_resource ilike 'Swap%'
AND event_address = '0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af'
)
,
token_price as ( -- last price of each token
SELECT *
FROM (
SELECT
hour,
Auto-refreshes every 24 hours
QueryRunArchived: QueryRun has been archived