Negative-VPI Clawback Excluded from HousePool LP Share Pricing Lets a Trader-LP Coalition Withdraw Other LPs' Principal
LP share pricing for Junior tranche deposits ignores the negative-VPI clawback reserve held in the trader's clearinghouse account, so equity is understated while a skew-reducing position is open. A trader and a Junior LP acting together can open just before an LP epoch boundary and close just after, letting the new Junior shares capture the returned clawback and leaving a passive Junior LP with less than its deposit.
Originally disclosed on Immunefi
- Disclosed after under an hour
#99424 [SC-Critical] Negative-VPI Clawback Excluded from HousePool LP Share Pricing Lets a Trader-LP Coalition Withdraw Other LPs' Principal
Submitted on Nov 13th 2026 at 16:10:28 UTC by @zer0luck_xint for Audit Competition | Plether
- Report ID: #99424
- Report Type: Smart Contract
- Report severity: Critical
- Target: https://github.com/immunefi-team/audit-comp-plether/blob/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src/HousePool.sol
- Impacts:
- Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
A skew-reducing open receives a negative virtual price impact (VPI) rebate paid from HousePool cash. The position owes an equal clawback, backed by a dedicated nonwithdrawable VPI reserve in the MarginClearinghouse. A close or liquidation recovers the outstanding amount by withholding price gain or consuming the reserve. LP share pricing counts neither the reserve nor the clawback, so between the open and the close the equity that prices Junior shares is lower by the cash the open paid out, the full rebate in every tested configuration.
A Junior deposit activated in that window buys shares at the lowered equity, and the clawback that returns at the close is shared with those new shares. A trader and a Junior LP acting together (the coalition) can open the skew-reducing position just before an LP epoch boundary and close it just after. A passive Junior LP's fully funded withdrawal can then fall below its deposit while the coalition exits with more USDG than it funded.
Vulnerability Details
The open pays the rebate from HousePool cash and locks an equal VPI reserve outside the pool. An open's trade cost is the signed sum of its VPI and execution fee (OpenAccountingLib.sol:135). When the VPI rebate exceeds the fee, the plan sets a HousePool payout of the net rebate to the trader's clearinghouse account, and the VPI reserve target becomes max(-vpiAccrued, 0) evaluated on the new lifetime VPI:
delta.poolRebatePayoutAssets = openState.tradeCostAssets < 0 ? uint256(-openState.tradeCostAssets) : 0;
...
delta.vpiRebateReserveAfterAssets =
_negativeVpiReserveTarget(effectiveSnap.position.vpiAccrued + openState.vpiAssets);
The settlement sidecar transfers that amount out of HousePool, funds the execution fee from free pool cash up to the cash available, and locks the reserve from the trader's free settlement or reclassifies it from the position's PnL pledge:
if (delta.poolRebatePayoutAssets > 0) {
IHousePool(host.pool()).payOut(host.clearinghouse(), delta.poolRebatePayoutAssets);
}
...
clearinghouse.lockVpiRebateReserve(delta.account, reserveFromFreeAssets);
HousePool pays the net rebate and then the execution fee, capped by free pool cash (CfdEnginePlanLib.sol:737-745). When free pool cash covers the fee, as in every tested configuration, HousePool cash falls by the full rebate r. The trader's clearinghouse account holds the reserve, equal to r, in reserved settlement that it cannot withdraw while the position is open (MarginClearinghouse.sol:843-852; packages/perps/SECURITY.md:866-867).
LP share pricing omits the reserve. The engine snapshot that HousePool uses for LP pricing takes physical assets from HousePool.totalAssets() and the terminal LP price delta from TerminalNavBookV2:
uint256 poolAssets = engineContract.pool().totalAssets();
snapshot.physicalAssets = poolAssets;
...
snapshot.terminalLpPriceDeltaAssets = terminalSnapshot.terminalLpPriceDeltaAssets;
The terminal book caps each account's LP receivable at its PnL pledge plus its trader claim, so the VPI reserve, which sits in the account's reserved settlement, does not enter the terminal delta:
uint256 candidateCapAssetAtoms =
clearinghouse.pnlPledgeAssets(account) + engine.traderClaimBalanceAssets(account);
HousePoolAccountingLib.buildReconcileSnapshot derives LP distributable equity from the physical pool assets, the terminal LP price delta and the trader claims only, with no term for the reserve or the clawback:
The protocol keeps both anticipated VPI and the VPI reserve out of terminal K and symmetric LP NAV (packages/perps/SECURITY.md:866-872; packages/perps/ACCOUNTING_SPEC.md:1057-1066). The exclusion keeps LPs from withdrawing the reserve as marked equity before the matching position obligation settles (packages/perps/WHITEPAPER.md:887-888). For solvency and redemption funding it is conservative: the reserved USDG is held in the trader's clearinghouse account and cannot pay LP redemptions until it is collected. For LP share pricing it is not conservative. Symmetric LP NAV prices entry and exit on the same terminal equity so that new LPs receive the same marked-liability discount borne by existing LPs and do not inherit old trader obligations at a higher deposit NAV (packages/perps/SECURITY.md:851-860). A marked price item carries market risk that the new LP then shares. The clawback does not move with the mark: its amount is fixed by the position's lifetime VPI, the dedicated reserve backs it, and the close and liquidation flows below collect it. Leaving it out of share pricing hands a reserve-backed receivable, paid for by the LPs present at the open, to any LP whose deposit is activated before it is collected.
A full close or a liquidation recovers the outstanding negative lifetime VPI. A close applies the lifetime clamp, which keeps accrued plus new VPI at or above zero, so closing a position with lifetime VPI of -r charges at least r:
if (state.proportionalAccrualAssets + state.vpiDeltaAssets < 0) {
state.vpiDeltaAssets = -state.proportionalAccrualAssets;
}
The close plan collects that clawback from withheld price gain or from the reserve, and the sidecar transfers the consumed reserve to HousePool. Liquidation assesses the full max(-vpiAccrued, 0) the same way:
uint256 vpiClawbackAssets =
_negativeVpiReserveTarget(snap.position.vpiAccrued) - delta.vpiRebateReserveAfterAssets;
vpiClawbackWithheldAssets = delta.actionChargeWithheldAssets < vpiClawbackAssets
? delta.actionChargeWithheldAssets
: vpiClawbackAssets;
delta.vpiRebateReserveConsumedAssets = vpiClawbackAssets - vpiClawbackWithheldAssets;
Deposits activated while the reserve is outstanding are priced on the lowered equity. LP epoch settlement reconciles the pool from the snapshot above and then prices Junior deposits on the resulting Junior principal and share supply:
DepositPhase memory juniorDepositPhase;
juniorDepositPhase.pricingAssets = juniorPrincipal;
juniorDepositPhase.pricingSupply = _juniorShareSupply();
Shares minted in that settlement are priced on equity lowered by that payout (r in the tests). When the position closes, the clawback returns as pool value and is shared pro rata across the enlarged Junior supply, so a new Junior LP holding a fraction alpha of Junior supply receives about alpha * r that the existing Junior LPs funded. Junior redemptions settled while the reserve is outstanding are priced on the same lowered equity (HousePool.sol:835-841).
Trigger. A Junior LP requests a deposit for the next LP epoch before the 5-minute request cutoff. About 1 minute before the epoch boundary, a trader opens a position that reduces the open skew and receives the rebate. At the boundary any address settles the LP epoch through OrderRouter.settleLpEpoch, which activates the deposit at the lowered equity. Seconds later the trader closes the position, and the close recovers the clawback for HousePool. After the 1-hour deposit cooldown, the Junior LP redeems at equity that again includes the clawback.
Impact Details
Severity: Critical, Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield.
The coalition takes principal from a passive Junior LP. The passive Junior LP makes no trade, its redemption is fully funded with no pending shares, and it withdraws less USDG than in the same history without the coalition trader's open and close. The coalition's Junior LP and trader withdraw their whole balances as USDG and, in the 3 profitable configurations, finish above the capital they funded. In the main configuration the passive Junior LP loses 5,880.57 USDG and withdraws 4,286.45 USDG less than its deposit.
In the release deployment and parameters, each configuration runs twice from one snapshot with the same LP deposits and redemptions, the same independent SHORT, and the same prices, timestamps and blocks; the second run adds only the coalition trader's open and close.
| Configuration | Coalition share of Junior supply | Passive Junior LP deposit | Passive withdrawal without the coalition trades | Passive withdrawal with them | Passive Junior LP loss | Coalition gain over the run without its trades |
|---|---|---|---|---|---|---|
| Junior 10M passive, 30M coalition, LONG 3.96M | 74.99% | 10,000,000.00 | 10,001,594.12 | 9,995,713.55 | 5,880.57 | +2,707.76 |
| Junior 10M passive, 5M coalition, LONG 1.56M | 33.32% | 10,000,000.00 | 10,001,596.32 | 9,999,943.05 | 1,653.27 | +403.78 |
| Junior 10M passive, 2M coalition, LONG 3.96M | 16.66% | 10,000,000.00 | 10,001,597.21 | 10,000,290.52 | 1,306.69 | -1,862.53 |
| Senior 7.5M, Junior 2.5M passive, 2.5M coalition, LONG 3.96M | 50.00% | 2,500,000.00 | 2,501,323.00 | 2,497,402.73 | 3,920.27 | +749.01 |
In the main configuration the rebate is 7,834.66 USDG, pending LP equity falls by exactly that amount at the open, and the close returns 7,834.76 USDG to HousePool. The coalition's Junior LP withdraws 30,005,876.07 USDG for its 30,000,000.00 USDG deposit; with the 1,000,000.00 USDG of trader funding, the coalition gets back 2,707.76 USDG more than it funded, after 3,168.00 USDG of execution fees paid to the protocol treasury. In every configuration the passive loss equals the coalition's Junior share times the rebate within 0.2%, and the USDG held by the custody contracts and actor wallets equals the token supply in both runs.
The loss does not depend on the coalition's profit. With a 2,000,000.00 USDG coalition deposit the coalition loses 1,862.53 USDG, and the passive Junior LP still loses 1,306.69 USDG.
Prerequisites:
- Open skew held by other traders that the coalition's open reduces. The tests use an independent SHORT of 3,960,000.00 USDG notional, 39.57% of the 10,007,842.80 USDG of HousePool assets, within the 40% maximum skew ratio of the release parameters (script/DeployPerpsArbitrumSepolia.s.sol:434-446). The VPI cost of a skew
Sis0.5 * k * S^2 / Dwithk= 1% and pool depthD(CfdMath.sol:134-139). A skew-reducing open of notionals<=Stherefore earnsr = 0.5 * k * (S^2 - (S - s)^2) / D, at most 8 bps ofDat the maximum skew ratio. Without third-party skew the coalition must first create the skew with its own skew-increasing open, which pays VPI and execution fees of its own. - A coalition share
alphaof Junior supply after activation that exceeds its trading cost. The coalition's net is aboutalpha * r - 2 * 4 bps * s(execution fee 4 bps per leg, CfdEngine.sol:147). For an open much smaller thanS,ris aboutk * S * s / D. The open is then profitable whenalpha > 2 * 4 bps * D / (k * S), about 20% of Junior supply at a skew of 39.57% of depth. The tests are profitable at 33.32%, 50.00% and 74.99%, and unprofitable at 16.66%. - Capital. The smallest profitable configuration above uses a 2,500,000.00 USDG Junior deposit next to 7,500,000.00 USDG of Senior and 2,500,000.00 USDG of passive Junior capital, plus trader margin; initial margin is 0.2% of notional in the release parameters.
- Timing inside 1 LP epoch. The coalition's Junior LP requests its deposit before the 5-minute cutoff (TrancheVault.sol:39, :545-556). A pending Junior deposit stays cancellable until its epoch is active (TrancheVault.sol:851-859), so the coalition can cancel it if the open does not fill before the boundary. In the tests the open fills 53 seconds before the boundary and the close 17 seconds after it.
- LP epoch settlement at the boundary. Settlement is permissionless through
OrderRouter.settleLpEpoch(OrderRouter.sol:479-481); while positions are open and the market is live, HousePool accepts only that call with a mark published at or after the boundary (HousePool.sol:808-819). An address with no role settles in the tests. Entry activation is deferred while the oracle is frozen (HousePool.sol:908-912, :1143; packages/perps/SECURITY.md:1387-1388), so the sequence runs during live market hours. - The 1-hour deposit cooldown (TrancheVault.sol:38) delays only the coalition's Junior exit; the clawback is already back in HousePool by then.
- With Senior capital present, the Junior covenant can limit Junior redemption funding (packages/perps/SECURITY.md:396). In the Senior-heavy configuration the Senior LP redeems in the same LP epoch as the passive Junior LP, both redemptions are fully funded, and the Senior withdrawal is identical in both runs.
- Transaction costs. The coalition result counts the execution fees, carry and every other charge on the trader's balance. It does not include Arbitrum gas or the Pyth update fee, which the local Pyth double does not charge. Fills use zero Pyth confidence. With a nonzero confidence the oracle shifts both coalition fills against the trader (PletherOracle.sol:940); the tests do not measure that case.
- Each configuration measures 1 open and close around a single LP epoch boundary.
- After the release deployment and its owner setup steps (seed positions and trading activation), no privileged role or unusual configuration is involved, and every call in the scenario is a public function. Prices come from the repository's
MockPythat the release Pyth address, with all 6 feeds at a fixed 1.20 basket.
Recommendation
Count the aggregate negative-VPI clawback of open positions, the sum of max(-vpiAccrued, 0), as an LP receivable in the equity that prices LP entry and exit, for example as a positive term in the terminal LP price delta that CfdEngineProtocolLens passes to HousePool. Maintain that aggregate in CfdEngine and update it in the same call that writes or deletes a position's lifetime VPI, so every open, increase, partial close, full close and liquidation that changes the reserve target changes the receivable atomically. Keep the reserve outside withdrawable liquidity, so redemption funding still uses only collected pool cash.
References
- Audit commit: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8
- Symmetric LP NAV and the negative-VPI reserve:
packages/perps/SECURITY.md:849-876,packages/perps/ACCOUNTING_SPEC.md:1057-1066 - VPI curve:
packages/perps/src/CfdMath.sol:96-139 - Release parameters:
packages/perps/DEPLOYMENT.md(Initial release parameters) andscript/DeployPerpsArbitrumSepolia.s.sol
Proof of Concept
Proof of Concept
The test deploys the release contracts with script/DeployPerpsArbitrumSepolia.s.sol inside Forge through ReleaseFixture.sol (source at the end of this section). In-scope contracts are unmodified. Only out-of-scope components are mocked:
- Pyth: the repository's
test/mocks/MockPyth.sol, etched at the release Pyth address. All 6 feeds stay at a 1.20 basket with zero confidence. - USDG: the release
MockUSDG. - The ArbSys block-number precompile.
The PoC file NegativeVpiReserveEntryPricing.t.sol contains 4 tests. Each test runs one history twice from the same snapshot: a comparison run without the coalition trader's open and close, and the attack run with them. All other LP and trader actions, prices, timestamps and blocks are identical in both runs. Steps in test_entrantCapturesClawbackFromPassiveJuniorLp, all through public entry points; orders are executed and LP epochs are settled by an address with no role:
- The passive Junior LP deposits 10,000,000 USDG and is activated. An independent trader opens a SHORT of 3,960,000 USDG notional, 39.6% of HousePool assets. The coalition trader funds 1,000,000 USDG of margin, and the coalition's Junior LP requests a 30,000,000 USDG deposit for the next LP epoch. The test takes a snapshot.
- 60 seconds before the LP epoch boundary the coalition trader commits a LONG of the same size, which executes 7 seconds later and receives the VPI rebate. The test reads the pending LP equity from
HousePool.getPendingTrancheStatebefore and after the open, and the VPI reserve fromMarginClearinghouse.vpiRebateReserveAssetsafter it. - At the boundary
OrderRouter.settleLpEpochruns with a price published at the boundary. The coalition's deposit is activated and claimed. - 10 seconds later the coalition trader commits the full close, which executes 7 seconds later. The coalition's deposit has deepened the pool, so the lifetime clamp sets the close's VPI charge to the rebate and the clawback returns to HousePool.
- After the 1-hour cooldown the coalition's Junior LP redeems all its shares at the next LP epoch. The independent trader closes its SHORT, and 1 hour later the passive Junior LP redeems all its shares. Both traders withdraw their whole clearinghouse balance.
- The test checks the exact rebate, a VPI reserve equal to the rebate, and a pending LP equity drop equal to the rebate (zero in the comparison run). It checks a zero reserve after the close with at least the rebate returned to HousePool, and a treasury gain equal to the 2 execution fees. It checks full funding of every LP redemption and zero pending shares for the passive Junior LP. It checks a passive loss equal to the coalition's Junior share times the rebate within 0.2%, the exact passive loss, coalition gain and passive shortfall below its deposit, and coalition withdrawals above the capital it funded. In both runs it checks that the USDG held by the custody contracts and actor wallets equals the token supply.
The other 3 tests repeat these steps with different sizes and check the passive loss within 0.2% of share times rebate and the sign of the coalition gain: test_oneThirdJuniorShareWithSmallerOpen (5,000,000 USDG coalition deposit, LONG of 1,560,000 USDG notional), test_passiveJuniorLpLosesWhenCoalitionDoesNotProfit (2,000,000 USDG coalition deposit), and test_seniorHeavyPoolHalfJuniorShare (7,500,000 USDG Senior LP, 2,500,000 USDG passive Junior LP, 2,500,000 USDG coalition deposit; the Senior LP redeems in the same LP epoch as the passive Junior LP).
On a fresh clone of the audit commit, run git submodule update --init --recursive. Create test/poc/ at the repository root, place ReleaseFixture.sol and NegativeVpiReserveEntryPricing.t.sol (sources at the end of this section) in it, then run from the repository root with Forge 1.5.1:
forge test --match-path test/poc/NegativeVpiReserveEntryPricing.t.sol -vv
Excerpt from the output of the command above for test_entrantCapturesClawbackFromPassiveJuniorLp (deployment lines omitted):
[PASS] test_entrantCapturesClawbackFromPassiveJuniorLp() (gas: 15743020)
Logs:
== passive Junior 10M, entrant Junior 30M, skew 39.6% of depth
passive Junior LP deposit 10000000.000000 USDG
coalition Junior LP deposit 30000000.000000 USDG
coalition trader funding 1000000.000000 USDG
HousePool assets before the open 10007842.798431 USDG
independent SHORT notional 3960000.000000 USDG
coalition LONG notional 3960000.000000 USDG
negative VPI rebate on the open (vpiAccrued) -7834.655437 USDG
coalition VPI reserve after the open 7834.655437 USDG
pending LP equity drop at the open 7834.655437 USDG
coalition share of Junior supply (bps) 7499
HousePool USDG change over the coalition close 7834.764313 USDG
coalition VPI reserve after the close 0.000000 USDG
passive Junior LP withdrawal, comparison 10001594.119565 USDG
passive Junior LP withdrawal, attack 9995713.554181 USDG
passive Junior LP loss 5880.565384 USDG
passive Junior LP result vs deposit, attack -4286.445819 USDG
coalition Junior LP withdrawal, comparison 29999999.999986 USDG
coalition Junior LP withdrawal, attack 30005876.072171 USDG
coalition trader withdrawal, comparison 1000000.000000 USDG
coalition trader withdrawal, attack 996831.691124 USDG
coalition cash gain over the comparison 2707.763309 USDG
coalition result vs funded capital, attack 2707.763295 USDG
treasury gain (coalition execution fees) 3168.000000 USDG
USDG in custody contracts + wallets = supply 42000002.000000 USDG
Excerpt from the same output for the other 3 tests (deployment lines and other values omitted) and the suite summary:
[PASS] test_oneThirdJuniorShareWithSmallerOpen() (gas: 15743436)
Logs:
== entrant Junior 5M, coalition LONG 1.56M notional
negative VPI rebate on the open (vpiAccrued) -4956.912393 USDG
coalition share of Junior supply (bps) 3332
passive Junior LP withdrawal, comparison 10001596.323830 USDG
passive Junior LP withdrawal, attack 9999943.051806 USDG
passive Junior LP loss 1653.272024 USDG
passive Junior LP result vs deposit, attack -56.948194 USDG
coalition cash gain over the comparison 403.778753 USDG
coalition result vs funded capital, attack 403.778747 USDG
[PASS] test_passiveJuniorLpLosesWhenCoalitionDoesNotProfit() (gas: 15740962)
Logs:
== entrant Junior 2M, coalition unprofitable
negative VPI rebate on the open (vpiAccrued) -7834.655437 USDG
coalition share of Junior supply (bps) 1666
passive Junior LP withdrawal, comparison 10001597.207013 USDG
passive Junior LP withdrawal, attack 10000290.516235 USDG
passive Junior LP loss 1306.690778 USDG
passive Junior LP result vs deposit, attack 290.516235 USDG
coalition cash gain over the comparison -1862.531327 USDG
coalition result vs funded capital, attack -1862.531330 USDG
[PASS] test_seniorHeavyPoolHalfJuniorShare() (gas: 17601333)
Logs:
== Senior 7.5M, passive Junior 2.5M, entrant Junior 2.5M
negative VPI rebate on the open (vpiAccrued) -7834.655437 USDG
coalition share of Junior supply (bps) 5000
passive Junior LP withdrawal, comparison 2501322.999748 USDG
passive Junior LP withdrawal, attack 2497402.728329 USDG
passive Junior LP loss 3920.271419 USDG
passive Junior LP result vs deposit, attack -2597.271671 USDG
coalition cash gain over the comparison 749.005290 USDG
coalition result vs funded capital, attack 680.617824 USDG
Senior LP withdrawal, comparison 7500342.470755 USDG
Senior LP withdrawal, attack 7500342.470755 USDG
Suite result: ok. 4 passed; 0 failed; 0 skipped; finished in 49.07ms (124.39ms CPU time)
Source files
ReleaseFixture.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.35;
// Deploys the release contracts with script/DeployPerpsArbitrumSepolia.s.sol inside Forge.
// Pyth, USDG and ArbSys are replaced by local test components; in-scope contracts are unmodified.
import {DeployPerpsArbitrumSepolia} from "../../script/DeployPerpsArbitrumSepolia.s.sol";
import {MockPyth} from "../mocks/MockPyth.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {PletherOracle} from "@plether/perps/PletherOracle.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {Test, console2} from "forge-std/Test.sol";
/// @dev Mirrors the Arbitrum precompile's block-number view inside the local test EVM.
contract ReleaseFixtureArbSys {
function arbBlockNumber() external view returns (uint256) {
return block.number;
}
}
abstract contract ReleaseFixture is Test {
address internal constant RELEASE_PYTH = 0x0B73614636C855Bf23F342F307FB981A3e47f42B;
uint256 internal constant DEPLOYER_KEY = 0xA11CE;
uint256 internal constant MONDAY_MORNING = 1_709_532_000; // Mon 2024-03-04 06:00 UTC (live market)
uint256 internal constant BASKET_1_20 = 120_000_000; // normalized basket mark 1.20 (8 decimals)
uint8 internal constant MODE_LIVE = 1;
uint8 internal constant MODE_FAD = 2;
uint8 internal constant MODE_FROZEN = 4;
uint8 internal constant MODE_ANY = 7;
DeployPerpsArbitrumSepolia.DeployedContracts internal d;
address internal owner;
address internal keeper = makeAddr("keeper");
uint256 internal clientNonce;
function setUp() public virtual {
vm.chainId(421_614);
vm.warp(MONDAY_MORNING);
ReleaseFixtureArbSys arbSys = new ReleaseFixtureArbSys();
vm.etch(address(100), address(arbSys).code);
MockPyth pyth = new MockPyth();
vm.etch(RELEASE_PYTH, address(pyth).code);
vm.setEnv("TEST_PRIVATE_KEY", vm.toString(DEPLOYER_KEY));
d = DeployPerpsArbitrumSepolia(deployCode("DeployPerpsArbitrumSepolia.s.sol:DeployPerpsArbitrumSepolia")).run();
owner = vm.addr(DEPLOYER_KEY);
// Permanent 1 USDG seeds per tranche (release values), then activation.
d.settlementToken.mint(owner, 2e6);
vm.startPrank(owner);
d.settlementToken.approve(address(d.housePool), 2e6);
d.housePool.initializeSeedPosition(false, 1e6, owner);
d.housePool.initializeSeedPosition(true, 1e6, owner);
d.housePool.activateTrading();
vm.stopPrank();
_setBasketPrices(BASKET_1_20);
d.router.updateMarkPrice(_updateData());
}
// ---------------------------------------------------------------- prices
function _oracle() internal view returns (PletherOracle) {
return PletherOracle(d.pletherOracle);
}
/// @dev Sets all six feeds so the normalized basket equals `basketPrice`, published at the current block time.
function _setBasketPrices(
uint256 basketPrice
) internal {
_setBasketPricesAt(basketPrice, vm.getBlockTimestamp());
}
function _setBasketPricesAt(
uint256 basketPrice,
uint256 publishTime
) internal {
for (uint256 i; i < 6; ++i) {
_setFeed(i, basketPrice, publishTime);
}
}
/// @dev Sets one component so that it alone would give normalized basket `basketPrice`, at `publishTime`.
function _setFeed(
uint256 i,
uint256 basketPrice,
uint256 publishTime
) internal {
PletherOracle oracle = _oracle();
uint256 normalizedPrice = oracle.basePrices(i) * basketPrice / 1e8;
uint256 feedPrice = oracle.inversions(i) ? 1e16 / normalizedPrice : normalizedPrice;
MockPyth(RELEASE_PYTH).setPrice(oracle.pythFeedIds(i), int64(uint64(feedPrice)), int32(-8), publishTime);
}
/// @dev Same as _setFeed with an explicit confidence (in feed units).
function _setFeedWithConf(
uint256 i,
uint256 basketPrice,
uint64 conf,
uint256 publishTime
) internal {
PletherOracle oracle = _oracle();
uint256 normalizedPrice = oracle.basePrices(i) * basketPrice / 1e8;
uint256 feedPrice = oracle.inversions(i) ? 1e16 / normalizedPrice : normalizedPrice;
MockPyth(RELEASE_PYTH).setPrice(oracle.pythFeedIds(i), int64(uint64(feedPrice)), conf, int32(-8),
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 LP equity snapshot used for share pricing omits the aggregate negative-VPI clawback receivable, counting only physical pool assets, terminal LP price delta and trader claims.
Impact
A passive Junior LP can withdraw less than its deposit while the coalition exits with more than it funded, though the coalition's gain depends on its share of Junior supply and it loses money at a 16.66% share.
What the attacker needed
Open skew from other traders; coalition Junior share above ~20%; millions in Junior and trader capital; deposit before 5-minute cutoff
The fix
The aggregate negative-VPI clawback of open positions should be counted as an LP receivable in the equity that prices LP entry and exit, updated atomically whenever a position's lifetime VPI changes, while keeping the reserve outside withdrawable liquidity.
How it was found
- A passive Junior LP deposits and is activated; an independent trader opens a SHORT creating skew; the coalition trader funds margin and the coalition Junior LP requests a large deposit for the next epoch.
- Shortly before the epoch boundary the coalition trader opens a skew-reducing LONG and receives the VPI rebate, lowering pending LP equity by the rebate.
- At the boundary the LP epoch is settled permissionlessly, activating the coalition deposit at the lowered equity.
- Seconds later the coalition trader closes the position, and the lifetime clamp returns the clawback to the pool.
- After the cooldown the coalition Junior LP redeems all shares, the independent trader closes, and later the passive Junior LP redeems.
- The test checks the rebate, the reserve, the equity drop, the returned clawback, full redemption funding and the passive LP's loss.
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.
The pool that backs traders prices its shares using the cash it currently holds. When a trader opens a trade that balances the book, the pool pays them a rebate, and the trader owes that money back later, held aside in a locked reserve. The pricing ignores that locked reserve, so shares look cheaper than they really are. Someone who buys shares at that moment gets a slice of the money that comes back when the trade closes, and that slice comes out of other people's deposits.
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.