hessfantastic-green
Updated 2024-09-12
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
›
⌄
-- CANVIAR SETMANA
-- mirar a Mercato el top 10 i extreure addresses de Wapal
-- Filtrar per aquestes 10 addresses
WITH
sales AS (
SELECT
a.BLOCK_TIMESTAMP::date AS date,
a.TX_HASH,
EVENT_ADDRESS,
CHANGE_DATA:collection:inner as collection,
CASE
WHEN EVENT_RESOURCE = 'BuyEvent' THEN EVENT_DATA:buyer
WHEN EVENT_RESOURCE = 'ListingFilledEvent' THEN EVENT_DATA:purchaser
ELSE EVENT_DATA:bid_buyer
END AS buyer,
CASE
WHEN EVENT_RESOURCE = 'BuyEvent' THEN EVENT_DATA:seller
WHEN EVENT_RESOURCE IN ('ListingFilledEvent', 'AcceptCollectionBidEvent', 'AcceptTokenBidEvent') THEN EVENT_DATA:seller
ELSE EVENT_DATA:bid_seller
END AS seller,
(CASE
WHEN EVENT_RESOURCE = 'BuyEvent' THEN EVENT_DATA:price
WHEN EVENT_RESOURCE = 'ListingFilledEvent' THEN EVENT_DATA:price
ELSE EVENT_DATA:price
END / 1e8) AS price
FROM aptos.core.fact_events a
JOIN aptos.core.fact_changes b ON a.BLOCK_TIMESTAMP = b.BLOCK_TIMESTAMP
AND a.TX_HASH = b.TX_HASH
WHERE EVENT_RESOURCE IN ('BuyEvent', 'ListingFilledEvent', 'AcceptCollectionBidEvent', 'AcceptTokenBidEvent')
AND b.SUCCESS = 'TRUE'
),
sales2 as (
select
date,
tx_hash,
buyer,
QueryRunArchived: QueryRun has been archived