flyingfishUse JOIN in first cte - bSOL mint actions copy copy
Updated 2023-09-03
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
›
⌄
-- forked from Use JOIN in first cte - bSOL mint actions copy @ https://flipsidecrypto.xyz/edit/queries/7275ed93-a83d-4e3f-8f1a-cc44836fdc9d
-- forked from test bSOL mint actions @ https://flipsidecrypto.xyz/edit/queries/ca862749-0d3a-4ef0-8dca-218c84bd1ba6
-- forked from test bSOL supply @ https://flipsidecrypto.xyz/edit/queries/3ee0b884-ddd3-4921-8647-dd9f02b51b59
-- with
-- mint_actions as (
/* This part takes anywhere from 20 to 40s */
with cte AS (
SELECT
a.block_timestamp
, a.mint
, a.mint_amount
, b.program_id
FROM solana.silver.mint_actions a
JOIN solana.core.fact_events b
using(tx_id, index)
WHERE a.succeeded
AND b.succeeded
and a.event_type = 'mintTo'
and a.mint = 'bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1'
AND a.block_timestamp::date BETWEEN '2023-01-01' AND '2023-01-31' -- The start of bSOL is 2022-05-02
AND b.block_timestamp::date BETWEEN '2023-01-01' AND '2023-01-31' -- > '2023-01-01'
AND b.inner_instruction IS NOT NULL
),
weekly_stats as (
SELECT
date_trunc(week, block_timestamp) AS date
, program_id
, sum(mint_amount) / pow(10, 9) AS mint_amount
, count(1) AS mint_events
FROM cte
GROUP BY 1, 2
Run a query to Download Data