Multipartite(Auto-updating) Saver yield-minting (cumulative absolute amounts)
Updated 2023-11-07Copy Reference Fork
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
dim_convert AS (
SELECT dim_block_id, block_id
FROM thorchain.core.dim_block
),
donates AS (
SELECT DATE(block_timestamp) AS date,
block_id,
SPLIT(pool_name, '-')[0] AS synth,
POWER(10, -8) * SUM(asset_e8) OVER(partition by date, synth) AS synth_minted
FROM (thorchain.core.fact_add_events AS table1 INNER JOIN dim_convert ON table1.dim_block_id = dim_convert.dim_block_id)
--(Donates)
WHERE (memo = 'THOR-SAVERS-YIELD')
AND (from_address = 'thor1v8ppstuf6e3x0r4glqc68d5jqcs2tf38cg2q6y')
--Minter Module from_address; ignore imitations.
AND pool_name LIKE '%/%'
--For an extra check that 'synth_amount' refers to synths.
QUALIFY (block_id = MAX(block_id) OVER(PARTITION BY date, synth))
AND (date <> (SELECT DATE(MAX(block_timestamp)) FROM thorchain.core.fact_rewards_events)) --Not complete yet, so leave it out.
)
SELECT date, synth,
synth_minted AS day_synth_minted,
SUM(synth_minted) OVER(PARTITION BY synth ORDER BY date ASC) AS cumulative_synth_minted
FROM donates
ORDER BY date DESC, synth ASC
/*
SELECT *
FROM thorchain.block_pool_depths
WHERE pool_name LIKE '%/%'
ORDER BY block_id DESC
LIMIT 1
*/
Run a query to Download Data