Governance fee charged without market-order placement
Description
A market order can be cancelled in the callback for various reasons, including if useBackupOnly
is true, so the value of a.price
is zero, the execution price is outside slippage parameters, or the trade is not within exposure limits. In this case, the USDC is transferred back to the user after the dev and governance fees are deducted.
Charging the user governance fees in case the backup oracle is used does not seem fair to the users of the protocol. Additionally, a front-runner can sandwich a market open on the mempool with a large trade that consumes all of the open interest, causing the market order to be cancelled. If the back-run side of the sandwich closes the same trade, the price does not change, so there is no risk to the front-runner — but the fees add to the LP returns.
Impact
Users are charged an unfair fee amount.
Recommendations
We recommend removing this fee when a market order is cancelled and instead return to the trader all the USDC or revert.
Remediation
This issue has been acknowledged by Avantis Labs, Inc., and a fix was implemented in commit 36126985↗.