Multipartite(Regular) (from v1.88.1) Reserve model ver16 (Rows are potentially-incomplete-or-erroneous Flipside blocks)
Updated 2022-09-27
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
›
⌄
⌄
--All values used here are RUNE.
WITH
boundtable AS (SELECT 1 AS grouplength, 5531994 AS hajimari, POWER(10,7) AS owari),
/* For unbounded, hajimari '0' and/or owari '[number greater than last block]' (any way to use an infinity symbol?);
grouplength '1' for per-block (maximum granularity),
'1000' for representing 5 million blocks in 5 thousand rows,
'43200' for approximately one churn per group.
( ChurnInterval at https://thornode.thorchain.info/thorchain/mimir )
First block of network version 1.88.1: 5531994 (2022-05-12).
(Contains several akrokr accounting fixes.)
The last block is not yet up to 10 million, so POWER(10,7) is a convenient 'owari' upper bound.
*/
outtable AS (SELECT * FROM thorchain.outbound_events), --For convenient reference.
gastable AS (SELECT * FROM thorchain.gas_events), --For convenient reference.
tokengasses AS
( --Gas reimbursement for each external transaction, associated with transaction token type (not gas type).
SELECT outtable.block_timestamp, outtable.block_id,
TO_CHAR(SPLIT(outtable.asset, '-')[0]) AS asset,
-1 * POWER(10,-8) * gastable.rune_e8 / gastable.tx_count AS inflow
FROM outtable INNER JOIN gastable
ON (outtable.block_id = gastable.block_id) AND (SPLIT(outtable.asset, '.')[0] = SPLIT(gastable.asset, '.')[0])
--Keep in mind that 'gastable' will only have asset in terms of the gas asset, whereas 'outtable' will have them in terms of the tokens.
--(A single gas reimbursement may be for multiple token-type migrations.)
--Thus, SPLIT()[0] is necessary.
--Synths have no gas reimbursement and there is no (asset LIKE '%/%') in thorchain.gas_events , so don't split them with '/'.
HAVING inflow <> 0
),
churngasses AS
( --Gas costs for all internal extractions of a gas-type, associated with that gas type (not transaction token type, since not represented)..
SELECT *
FROM (
Run a query to Download Data