connorhAll Luna/Terra Mints + Burns
Updated 2021-11-15
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 burns AS (
-- BURNS
SELECT
CONCAT(r.tx_id,r.msg_index, CASE WHEN SUBSTR(a.key,0,1) = 'a' THEN 0 ELSE REGEXP_SUBSTR(a.key,'^[0-9]+') END) AS skey, -- shorter key for convenience,
r.tx_id,r.event_index,CASE WHEN SUBSTR(a.key,0,1) = 'a' THEN 0 ELSE SUBSTR(a.key,0,1) END::INT AS subevent_index,
r.event_type,
a.value[0]:denom::STRING AS denom,
a.value[0]:amount::NUMERIC AS amount,
r.block_id,r.block_timestamp,r.blockchain,r.chain_id,r.tx_status,
r.msg_module--,r.event_attributes
FROM terra.msg_events r,
lateral flatten(input => r.event_attributes) a
WHERE block_timestamp >= CURRENT_DATE - 40 AND event_type = 'burn'
AND a.value[0]:denom::STRING IS NOT NULL
), burners AS( --not actually sure if its ever different from terra1untf85jwv3kt0puyyc39myxjvplagr3wstgs5s (mystery address that never appears in the block explorer)
-- BURNERS
SELECT
CONCAT(r.tx_id,r.msg_index, CASE WHEN SUBSTR(a.key,0,1) = 'b' THEN 0 ELSE REGEXP_SUBSTR(a.key,'^[0-9]+') END) AS skey, -- shorter key for convenience,
value::STRING AS burner
FROM terra.msg_events r,
lateral flatten(input => r.event_attributes) a
WHERE block_timestamp >= CURRENT_DATE - 40 AND event_type = 'burn'
AND a.value[0]:denom::STRING IS NULL AND SUBSTR(a.key,0,1) <> 'a'
),
mints AS (
-- MINTS
SELECT
CONCAT(r.tx_id,r.msg_index, CASE WHEN SUBSTR(a.key,0,1) = 'a' THEN 0 ELSE REGEXP_SUBSTR(a.key,'^[0-9]+') END) AS skey, -- shorter key for convenience
--r.event_attributes,
a.value[0]:denom::STRING AS denom,
a.value[0]:amount::NUMERIC AS amount
FROM terra.msg_events r,
lateral flatten(input => r.event_attributes) a
Run a query to Download Data