# In certain cases, users are unable to settle their orders with the PartialFill trade type.

ReduceOnly PartialFill orders fail on second settlement because _verifyOrder compares full openAmount against reduced position size, blocking remaining fills.

- Payout: Contest reward
- Severity: medium
- Program: Perpetual
- Credited: ether_sky
- Disclosed: 2024-02-19
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-02-perpetual-judging/issues/95
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-02-perpetual%3AM-2
- Tags: domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:business-logic vuln:dos

**Target:** OrderGatewayV2 order settlement (Solidity perp DEX)
**Root cause:** _verifyOrder's ReduceOnly check compares the full openAmount to the owner's current position size without subtracting totalFilledAmount, so after a partial fill the remaining amount appears larger than the reduced position.
**Steps:**
1. Create order with PartialFill trade type, ReduceOnly action, size S
2. Settle 50%: totalFilledAmount becomes S/2, position size drops to S/2
3. Attempt to settle remaining 50% via _fillTakerOrder
4. _verifyOrder computes openAmount (S) > ownerPositionSize.abs() (S/2) and reverts UnableToReduceOnly
5. Fix: compare `openAmount - totalFilledAmount` against position size
**How found:** Code reading of _verifyOrder: noticed totalFilledAmount is fetched and used in the ExceedOrderAmount check but not applied in the ReduceOnly openAmount comparison.
**Insight:** When a validation function reads totalFilledAmount for one bound check, audit every other comparison in the same function for the same partial-fill accounting; state-mutating fill counters must be subtracted from order size in all downstream checks.
