Multipartite2022-06-30 Bond Module split-decimals address balance estimates
    Updated 2022-06-30
    -- Automatic row-sampling now built in.
    -- As always, beware estimate errors from missing Flipside identical rows.
    -- Check example block balances with the below URL format:
    -- https://thornode.ninerealms.com/bank/balances/[address]?height=[block_id]


    /*
    --'Run Selected' to check the transfer events sum for just one block.
    SELECT *
    FROM thorchain.transfer_events
    WHERE (CONCAT(to_address, from_address) LIKE '%thor1dheycdevq39qlkxs2a6wuuzyn4aqxhve4qxtxt%')
    AND (block_id = 5205058)
    */

    WITH
    target AS
    (
    SELECT
    TRIM('thor17gw75axcnr8747pkanye45pnrwk7p9c3cqncsv') AS target_address,
    SPLIT('THOR.RUNE', '-')[0] AS target_asset,
    10000 AS target_rows
    --For displaying full ranges in Flipside, this should be below 100000 (one hundred thousand).
    --In practice, there may be up to two extra rows per asset type (starting and ending non-zero balance estimates)
    ),
    /*
    thor1v8ppstuf6e3x0r4glqc68d5jqcs2tf38cg2q6y [Minter Module - THOR.RUNE Switcher (from IOU.RUNE) and Synth Minter/Burner Module ('Genesis address')]
    thor1dheycdevq39qlkxs2a6wuuzyn4aqxhve4qxtxt [Reserve Module]
    thor17gw75axcnr8747pkanye45pnrwk7p9c3cqncsv [Bond Module]
    thor1g98cy3n9mmjrpn0sxmn63lztelera37n8n67c0 [Pool Module]

    thor160yye65pf9rzwrgqmtgav69n6zlsyfpgm9a7xk is the THORSwap affiliate fee wallet.
    */
    changes AS
    (
    SELECT block_timestamp, block_id,
    Run a query to Download Data