Multipartite2022-07-02 (BNB.BUSD) Synth Utilisation chart (row-sampled)
    Updated 2022-07-02

    --Note that doom at Synth Liability 100%, when Synth Utilisation is at 200%.

    WITH
    for_row_sampling AS
    (
    SELECT block_timestamp, block_id,
    --SPLIT(pool_name, '-')[0] AS coin,
    100 * synth_e8/asset_e8 as synth_utilisation
    FROM thorchain.block_pool_depths
    WHERE (synth_e8 > 0)
    AND (asset_e8 > 0)
    AND (pool_name = 'BNB.BUSD-BD1')
    ),

    rowcounting AS
    (
    SELECT
    COUNT(1) AS rowcount,
    50000 AS target_rows
    FROM for_row_sampling
    )
    SELECT for_row_sampling.*
    FROM for_row_sampling, rowcounting
    QUALIFY (
    (MOD((ROW_NUMBER() OVER(ORDER BY block_id ASC)), CEIL(rowcount/target_rows)) = 0)
    --Row-sampling.
    OR (ROW_NUMBER() OVER(ORDER BY block_id ASC) = 1)
    --Include the first data point.
    OR (ROW_NUMBER() OVER(ORDER BY block_id DESC) = 1)
    --Include the last data point.
    )
    ORDER BY block_id DESC

    Run a query to Download Data