MultipartiteSynth-origin percentages of cumulative outbound fees (in RUNE)
    Updated 2024-01-19
    /*
    This is counting from the block which had the first synth transaction.

    Notable blocks:

    4610718 (2022-03-09): First synth transaction (Mimir MaxSynthPerAssetDepth 500 = 5%).
    4897156 (2022-03-29): Mimir MaxSynthPerAssetDepth 1500 = 15%
    4931416 (2022-04-01): Mimir VirtualMultSynths set as 1 (to prevent front-running, discovered by Bas1c; overrides Constants)

    7134336 (2022-09-01): Mimir MinimumL1OutboundFeeUSD [unset]->100000000 = 1 USD minimum outbound fee.
    */

    WITH
    outfees AS
    (
    SELECT fees.block_timestamp, block_id,
    (CASE WHEN asset LIKE '%/%' THEN 1 ELSE 0 END) *
    POWER(10,-8) * pool_deduct AS synth_outfee,
    (CASE WHEN asset LIKE '%/%' THEN 0 ELSE 1 END) *
    POWER(10,-8) * pool_deduct AS native_outfee,
    AS_CHAR(SPLIT(SPLIT(asset, '.')[0], '/')[0]) AS chain
    FROM (thorchain.defi.fact_fee_events AS fees INNER JOIN thorchain.core.dim_block AS blocks ON fees.block_timestamp = blocks.block_timestamp)
    WHERE (block_id >= 4610718)
    AND (chain <> 'THOR') --Only interested in the fees from outbounds to external chains.
    ),

    dategrouped AS
    (
    SELECT DATE(block_timestamp) AS date,
    SUM(native_outfee) AS daily_native_outbound_fees,
    SUM(synth_outfee) AS daily_synth_outbound_fees,
    daily_native_outbound_fees + daily_synth_outbound_fees AS daily_full_outbound_fees,
    chain
    FROM outfees
    GROUP BY date, chain
    QUALIFY ROW_NUMBER() OVER(ORDER BY date DESC) <> 1
    QueryRunArchived: QueryRun has been archived