# User unable to migrate under certain edge case

Migration of a debt-free position reverts because assetToRepay=max resolves to 0 shares and 0 assets, failing Morpho's exactlyOneZero check.

- Payout: Audit contest
- Severity: medium
- Program: Notional
- Found by: Bigsam
- Disclosed: 2025-06-27
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-06-notional-exponent-judging/issues/674
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-06-notional-exponent%3AM-17
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic vuln:dos

**Target:** AbstractLendingRouter/MorphoLendingRouter migration path
**Root cause:** _enterOrMigrate always passes type(uint256).max as assetToRepay; _exitWithRepay converts that to borrowShares (0 when no debt) and sets assetToRepay=0, so Morpho.repay is called with both assets and shares zero.
**Steps:**
1. User has collateral but zero debt on old lending router.
2. Call migration entrypoint triggering `_enterOrMigrate(onBehalf, vault, asset, assetAmount, depositData, migrateFrom)`.
3. `_enterOrMigrate` calls `ILendingRouter(migrateFrom).exitPosition(onBehalf, vault, address(this), sharesReceived, type(uint256).max, "")`.
4. `_exitWithRepay` sees `assetToRepay == type(uint256).max`, sets `sharesToRepay = MORPHO.position(...).borrowShares` (0) and `assetToRepay = 0`.
5. `MORPHO.repay(m, 0, 0, onBehalf, repayData)` reverts on `UtilsLib.exactlyOneZero(assets, shares)`.
**How found:** Code-reading of the migration path: noticed assetToRepay is hardcoded to type(uint256).max, traced the max-handling branch in _exitWithRepay, and reasoned that a debt-free position yields zero borrowShares, producing a (0,0) repay call rejected by Morpho.
**Insight:** When a router hardcodes a sentinel like type(uint256).max to mean 'repay full debt', trace the zero-debt case: the sentinel resolves to zero shares and zero assets, which strict external protocols (Morpho's exactlyOneZero) reject. Check migration/exit paths for positions with no borrow.

