pietrektPOL Unrealized P/L
    Updated 2025-05-08
    -- FULL LP DEPOSIT TRANSACTIONS
    WITH lp_deposits AS (
    SELECT block_timestamp,
    CASE
    WHEN tx_id is not null then tx_id
    ELSE asset_tx_id
    END as tx_id,
    CASE
    WHEN from_address is not null THEN from_address
    ELSE asset_address
    END as address, pool_name, stake_units,
    rune_amount as amount_change_rune, rune_amount as true_amount_rune, 0 as slip_fee_rune,
    asset_amount as amount_change_asset, asset_amount as true_amount_asset, 0 as slip_fee_asset, 1 as type
    FROM thorchain.defi.fact_liquidity_actions WHERE lp_action = 'add_liquidity' and pool_name like '%.%'),
    -- FULL LP WITHDRAW TRANSACTIONS
    lp_withdrawals AS (
    SELECT block_timestamp,
    CASE
    WHEN tx_id is not null then tx_id
    ELSE asset_tx_id
    END as tx_id,
    CASE
    WHEN from_address is not null THEN from_address
    ELSE asset_address
    END as address, pool_name, -stake_units as stake_units,
    -rune_amount as amount_change_rune, -asset_amount as amount_change_asset, unstake_basis_points as basis_points, 0 as type
    FROM thorchain.defi.fact_liquidity_actions WHERE lp_action = 'remove_liquidity' and pool_name like '%.%'),

    lp_amount_withdrawn AS (SELECT a.block_timestamp, a.tx_id, address, a.pool_name, a.stake_units, amount_change_rune, amount_change_asset,
    CASE
    WHEN b.asset = 'THOR.RUNE' THEN asset_e8 / pow(10, 8)
    ELSE 0
    END AS rune_amount,
    CASE
    WHEN b.asset <> 'THOR.RUNE' THEN asset_e8 / pow(10, 8)
    ELSE 0
    Last run: 26 days ago
    DAY
    ASSET_NAME
    UNREALIZED_PL_RUNE
    TOTAL_UNREALIZED_PL_RUNE
    1
    2025-05-08 00:00:00.000BTC.BTC-1902707.27284544-517008.696090026
    2
    2025-05-08 00:00:00.000STABLECOIN543907.649644913-517008.696090026
    3
    2025-05-08 00:00:00.000Others841790.927110497-517008.696090026
    4
    2025-05-07 00:00:00.000STABLECOIN559251.829171541-720504.662868571
    5
    2025-05-07 00:00:00.000Others819733.023724412-720504.662868571
    6
    2025-05-07 00:00:00.000BTC.BTC-2099489.51576452-720504.662868571
    7
    2025-05-06 00:00:00.000Others822470.204684217-597011.235489139
    8
    2025-05-06 00:00:00.000STABLECOIN557504.319182217-597011.235489139
    9
    2025-05-06 00:00:00.000BTC.BTC-1976985.75935557-597011.235489139
    10
    2025-05-05 00:00:00.000Others817150.900158725-578891.369650905
    11
    2025-05-05 00:00:00.000STABLECOIN558076.624364067-578891.369650905
    12
    2025-05-05 00:00:00.000BTC.BTC-1954118.8941737-578891.369650905
    13
    2025-05-04 00:00:00.000BTC.BTC-1903387.71292203-519963.180411078
    14
    2025-05-04 00:00:00.000STABLECOIN557174.745143614-519963.180411078
    15
    2025-05-04 00:00:00.000Others826249.787367343-519963.180411078
    16
    2025-05-03 00:00:00.000Others833880.962888697-561685.849898471
    17
    2025-05-03 00:00:00.000STABLECOIN555760.004253649-561685.849898471
    18
    2025-05-03 00:00:00.000BTC.BTC-1951326.81704082-561685.849898471
    19
    2025-05-02 00:00:00.000BTC.BTC-1834815.00147046-440431.488715816
    20
    2025-05-02 00:00:00.000Others844137.327231596-440431.488715816
    ...
    2214
    151KB
    5s