grokenjoyerr-DdP2eY(Auto-updating) Protocol Owned Liquidity monitor (split by pool) copy copy copy
    Updated 2024-04-20
    -- forked from (Auto-updating) Protocol Owned Liquidity monitor (split by pool) copy copy @ https://flipsidecrypto.xyz/edit/queries/e42d25f4-313d-46e1-af04-4be3b705b3cc

    -- forked from Orion_9R / (Auto-updating) Protocol Owned Liquidity monitor (split by pool) copy @ https://flipsidecrypto.xyz/Orion_9R/q/IlB4fwDcLbfC/auto-updating-protocol-owned-liquidity-monitor-split-by-pool-copy

    -- forked from Multipartite / (Auto-updating) Protocol Owned Liquidity monitor (split by pool) @ https://flipsidecrypto.xyz/Multipartite/q/regular-reserve-pol-protocol-owned-liquidity-rune-only-ver-5-asym-l-per-mockup-different-pools-yb5zEC

    /*
    The Reserve only deposits and withdraws asymmetrically with its THORChain address, having a single position per pool, so it's easy to track.

    To check liquidity provider information for the Reserve for a given pool:
    https://thornode-v1.ninerealms.com/thorchain/pool/[CHAIN.COIN-ID]/liquidity_provider/thor1dheycdevq39qlkxs2a6wuuzyn4aqxhve4qxtxt?height=[BLOCK_ID]

    To check pool liquidity units (do not confuse with pool units, which are liquidity units plus synth units):
    https://thornode-v1.ninerealms.com/thorchain/pool/[CHAIN.COIN-ID]?height=[BLOCK_ID]

    Protocol Owned Liquidity was implemented in network version 1.95.0 (Merge Request 2458), from block 6967341 onwards (2022-08-20).
    https://gitlab.com/thorchain/thornode/-/merge_requests/2458
    */

    WITH

    detailstable AS (
    SELECT
    --'thor1dheycdevq39qlkxs2a6wuuzyn4aqxhve4qxtxt' AS rune_address --Reserve address (POL)
    'thor1m6rzcthddsvyqp47gh7k4wkx2x8f5lgkthelhd' AS rune_address --Asym LPer example address for BNB.BUSD-BD1
    --'thor1gu88fh5y78w9k954dzxnfpjutsjaqc4kj0rrxq' AS rune_address --Asym LPer example address for ETH.DAI-0X6B175474E89094C44DA98B954EEDEAC495271D0F
    ),

    -----

    reserve_deposits AS (
    SELECT DATE(fact_stake_events.block_timestamp) AS date,
    block_id, pool_name,
    stake_units AS pool_added_liquidity_units,
    IFF(rune_address = (SELECT rune_address FROM detailstable), pool_added_liquidity_units, 0) AS reserve_added_liquidity_units,
    IFF(rune_address = (SELECT rune_address FROM detailstable), POWER(10,-8) * rune_e8, 0) AS reserve_rune_deposit,
    QueryRunArchived: QueryRun has been archived