Security review · November 2026
Morpho Liquidation Module for GMX
Guardian's review of Morpho Liquidation Module for GMX, published November 2026. The report records 3 findings, including 3 informational.
See how Guardian runs a perp DEX smart contract audit.
- Published
- Review window
- November 13 to 19, 2026
- Language
- Solidity
- Sector
- Perpetuals
- 0 Critical
- 0 High
- 0 Medium
- 0 Low
- 3 Informational
Scope
1 file in scope · 261 nSLOC
| File | nSLOC | Lines |
|---|---|---|
src/morpho/MorphoLiquidationModule.sol | 261 | 344 |
Findings 3
-
I-01 Informational Bad-debt repay fails for large positions Documentation Resolved
Description
repayBadDebtAndLiquidatelets the operator use Safe funds to pay part of an underwater borrower's bad debt, so lenders lose less. In one call, the Safe repays some of the borrower's USDG debt, then liquidates the position by seizing all of its GLV (MorphoLiquidationModule.sol:277). Seizing all the GLV is what makes Morpho write off the remaining bad debt.To seize all the GLV, the Safe must also repay USDG debt worth the GLV's value minus the liquidation bonus. That repayment is checked against
maxLiquidationRepayAssets, a USDG cap (MorphoLiquidationModule.sol:367). So when the cap is below what a full seizure costs, the call always reverts, even if the bad debt payment is small. For example, today's largest borrower has 310.5k USDG of debt; with a cap of, say, 50k USDG, it can never be helped in one call.The NatSpec of
repayBadDebtAndLiquidatedoes not mention this limit; onlyliquidatedocuments the cap (MorphoLiquidationModule.sol:243). An operator or bot built from the docs will hit this revert on the large positions, where bad debt matters most, and must first fall back to several partialliquidatecalls. While those run, the position stays open. If an external liquidator seizes all its GLV in the meantime, Morpho writes the whole bad debt off to lenders.Recommendation
Consider documenting in the NatSpec of
repayBadDebtAndLiquidatethat the full seizure counts againstmaxLiquidationRepayAssets, so large positions must first be reduced with partialliquidatecalls, ideally batched in one transaction.Resolution
GMX Team: Fixed in the NatSpec of repayBadDebtAndLiquidate. Batching the partial liquidations with the call is left to the operator, since the module has no batching function of its own.
-
I-02 Informational Bad-debt repay needs undocumented slack Documentation Resolved
Description
repayBadDebtAndLiquidatetakesrepayShares, a fixed number of borrow shares the operator computes off-chain. It repays them with Safe USDG, then seizes all of the borrower's GLV. As the NatSpec notes, the full seizure reverts on a borrow shares underflow if the repay leaves the position no longer underwater. So the repay must stay below the position's bad debt.Both that bad debt and the USDG cost are only set at execution. Morpho accrues interest and converts the shares to USDG, rounding up, inside the call (
MorphoLiquidationModule.sol:271), so the payment can exceed the operator's estimate. An upward GLV oracle update in between lowers the bad debt. In a 7-day sample this market's oracle moved up to 0.1% per hour: about 290 USDG on a position whose full seizure repays 290k USDG. If the operator aimed at the full bad debt, the call reverts.So the operator must leave slack below its estimate, and Morpho writes that slack off to lenders. The function cannot reliably clear a position's full bad debt in one call.
Recommendation
Consider documenting in the NatSpec of
repayBadDebtAndLiquidatethatrepaySharesshould leave slack below the estimated bad debt, to absorb interest accrual and oracle updates before execution.Resolution
GMX Team: Fixed in the NatSpec of repayBadDebtAndLiquidate.
-
I-03 Informational Bad-debt repay has no minimum GLV seized Suggestion Acknowledged
Description
repayBadDebtAndLiquidaterepays part of an underwater position's bad debt with Safe USDG, then seizes all of its GLV. The full seizure also earns the Safe the liquidation bonus, which on large positions is bigger than the bad debt payment. The function re-reads the collateral at execution and only rejects zero (MorphoLiquidationModule.sol:266). There is no minimum amount of GLV to seize.If another liquidator seizes all but a few wei of GLV before the operator's transaction, the call still succeeds: the Safe makes the full bad debt payment and gets almost no GLV. On an Arbitrum fork with the largest borrower, a third party seized all but 1 wei, and the Safe then paid 19,429 USDG for 1 wei of GLV. Without the third party, the same call would have earned the Safe about 36.8k USDG of liquidation bonus, more than covering the payment.
Lenders lose the same amount in both cases. But if the operator only means to pay bad debt as part of a full liquidation, it cannot enforce that, and nothing documents that the payment may come with no GLV.
Recommendation
Consider adding a
minSeizedargument torepayBadDebtAndLiquidateand reverting when the GLV seized is below it.Resolution
GMX Team: This is by design. The repay is meant to lower the bad debt lenders take, which it does however little GLV the Safe gets, and maxBadDebtRepayAssets bounds the repay in each call.
No findings match.
More from GMX
All 49 reports-
RewardRouterV3 & RewardRouterUtils
20 findings1 high 20 findings: 1 high, 8 low, 11 informational -
V2.2.1 Review
102 findings8 high 102 findings: 8 high, 37 medium, 49 low, 8 informational -
Incentives Contracts
17 findings 17 findings: 3 medium, 3 low, 11 informational -
Donation Contracts
25 findings 25 findings: 1 medium, 6 low, 18 informational
Put your code through the same review.
This review started with a conversation about scope. Tell us what you are building and we will plan yours with you.
