OrderRouter NatSpec says the oracle refunds excess ETH, but the Router refunds it into a ledger that emits no credit event
The OrderRouter's documentation states that the oracle refunds excess ETH, but the Router actually refunds it itself and, if the refund call fails, credits an internal ledger that emits no event. A keeper following the documentation would look in the wrong place and find no record of the deferred refund.
Originally disclosed on Immunefi
- Disclosed after under an hour
#97796 [SC-Insight] OrderRouter NatSpec says the oracle refunds excess ETH, but the Router refunds it into a ledger that emits no credit event
Submitted on Nov 3rd 2026 at 08:43:42 UTC by @W3B_SR_0xki for Audit Competition | Plether
- Report ID: #97796
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/immunefi-team/audit-comp-plether/tree/a82d4fefb02768e5b3bddcc97dee371eee24fea8/packages/perps/src
- Impacts:
Description
Target: packages/perps/src tree at a82d4fefb02768e5b3bddcc97dee371eee24fea8 (OrderRouter.sol, OrderRouterAdmin.sol, router/OrderLiquidationBatchLogic.sol)
Impact: Insight — Documentation improvements / Security best practices
Description
1. The NatSpec names the wrong refunder
OrderRouter.updateMarkPrice says: "The oracle handles the Pyth fee and normally refunds unused ETH to the caller" (OrderRouter.sol:424-425). executeLiquidation says: "The oracle handles Pyth fees and ETH refunds" (OrderRouter.sol:490).
In the code, the Router sends the oracle exactly the Pyth fee, so the oracle never sees the excess:
- The call is
oracle.updatePrice{value: pythFee}(...)(router/OrderLiquidationBatchLogic.sol:603-608). - The Router refunds
msg.value - pythFeeitself via_sendEth(router/OrderLiquidationBatchLogic.sol:621, :846-858). - If that 30,000-gas call fails,
_sendEthcredits the amount toOrderRouterAdmin.claimableEth(also router/OrderExecutionHandler.sol:30-43).
2. The Router's deferral ledger is silent
OrderRouterAdmin.creditClaimableEthincreasesclaimableEth[beneficiary]and emits nothing (OrderRouterAdmin.sol:264-275).claimBalance()emits nothing either (OrderRouterAdmin.sol:279-281, :293-306).- Only
claimBalanceToemits an event,EthRefundClaimedTo(OrderRouterAdmin.sol:290). - The oracle's ledger, by contrast, emits
EthRefundDeferredwhen it credits andEthRefundClaimed/EthRefundClaimedTowhen it pays out (interfaces/IPletherOracle.sol:231-240).
Impact
Consider a keeper whose fallback reverts or uses more than 30,000 gas. It follows the NatSpec and looks for its deferred refund in PletherOracle.claimableEth, or watches for EthRefundDeferred. Neither ever shows the refund. The ETH sits in OrderRouterAdmin.claimableEth with no event to reveal it.
Nothing is lost, because the beneficiary can still call claimBalance(). But the funds are hard to discover, and claims made through claimBalance() cannot be audited from logs.
Recommendation
- Update OrderRouter.sol:424-425 and :490 to say that the Router pays the oracle exactly the Pyth fee and refunds the rest, crediting
OrderRouterAdmin.claimableEthif the refund call fails. - Emit an event in
creditClaimableEth(for exampleEthRefundDeferred(beneficiary, amount)) and inclaimBalance()(for exampleEthRefundClaimed(msg.sender, amount)), mirroring the oracle's ledger.
Proof of Concept
Proof of Concept
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 Router's deferred-refund ledger functions were written without emitting events, and the NatSpec comments were not updated to match the actual refund flow.
Impact
Nothing is lost because the beneficiary can still claim, but the funds are hard to discover and claims made through `claimBalance()` cannot be audited from logs.
What the attacker needed
A keeper whose refund call fails; the refund call uses over 30,000 gas
The fix
The documentation should be corrected to describe the Router's own refund behaviour, and events should be emitted when crediting and claiming the deferred ETH.
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.
When someone sends more ETH than needed for a fee, the extra should be returned. Here the extra is kept in a list of amounts owed, but no notification is sent when that happens, so the person owed the money may not realise it is waiting for them.
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.