MultipartiteSynth-origin percentages of cumulative liquidity 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
    liqfees AS
    (
    SELECT swaps.block_timestamp, block_id,
    (CASE WHEN ((to_asset LIKE '%/%') OR (from_asset LIKE '%/%')) THEN 1 ELSE 0 END) *
    POWER(10,-8) * liq_fee_in_rune_e8 AS synth_liqfee,
    (CASE WHEN ((to_asset LIKE '%/%') OR (from_asset LIKE '%/%')) THEN 0 ELSE 1 END) *
    POWER(10,-8) * liq_fee_in_rune_e8 AS native_liqfee,
    AS_CHAR(SPLIT(SPLIT(pool_name, '.')[0], '/')[0]) AS chain
    FROM (thorchain.defi.fact_swaps_events AS swaps INNER JOIN thorchain.core.dim_block AS blocks ON swaps.block_timestamp = blocks.block_timestamp)
    WHERE block_id >= 4610718
    ),

    dategrouped AS
    (
    SELECT DATE(block_timestamp) AS date,
    SUM(native_liqfee) AS daily_native_liquidity_fees,
    SUM(synth_liqfee) AS daily_synth_liquidity_fees,
    daily_native_liquidity_fees + daily_synth_liquidity_fees AS daily_full_liquidity_fees,
    chain
    FROM liqfees
    GROUP BY date, chain
    QUALIFY ROW_NUMBER() OVER(ORDER BY date DESC) <> 1
    --The last date isn't the full day yet, so leave it out.
    QueryRunArchived: QueryRun has been archived