# User may not be able to borrow even if they provide sufficient collaterals

CoreRouter.supply never calls enterMarkets, so supplied collateral isn't in accountAssets and borrowAllowed returns INSUFFICIENT_LIQUIDITY, blocking borrows despite sufficient collateral.

- Payout: Audit contest
- Severity: medium
- Program: Lend Audit Contest
- Found by: h2134
- Disclosed: 2025-05-22
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-05-lend-audit-contest-judging/issues/456
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-05-lend-audit-contest%3AM-2
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic

**Target:** CoreRouter / Lendtroller borrow accounting
**Root cause:** CoreRouter.supply mints lTokens but never calls enterMarkets, so the collateral market is not added to accountAssets in Lendtroller; borrowAllowed's liquidity loop skips it and returns INSUFFICIENT_LIQUIDITY.
**Steps:**
1. Deploy Lendtroller, Lend, oracle, lTokens, LendStorage, CoreRouter, CrossChainRouter; support markets and set collateral factors.
2. Alice supplies 1 WETH via `coreRouter.supply(1e18, weth)` (no enterMarkets).
3. Bob supplies 3000 DAI via `coreRouter.supply(3000e18, dai)` (no enterMarkets).
4. Bob calls `coreRouter.borrow(1e18, weth)`; expect revert `BorrowLendtrollerRejection(INSUFFICIENT_LIQUIDITY)`.
**How found:** Code reading: noticed supply() lacks enterMarkets while borrow() calls it, then traced borrowAllowed -> getHypotheticalAccountLiquidityInternal iterating accountAssets, which excludes the supplied collateral.
**Insight:** In Compound-fork lending, collateral only counts if the market is entered; check that every supply/deposit path calls enterMarkets, not just borrow, since accountAssets membership gates liquidity checks.

## Proof of concept (copied exactly from the original report)

**Forge PoC test showing borrow reverts despite collateral**

```
function testPOC_CannotBorrowWithSufficientCollaterals() public {
        address alice = makeAddr("Alice");
        deal(address(weth), alice, 1e18);
        
        // Alice supplies 1 WETH
        {
            vm.startPrank(alice);
            weth.safeApprove(address(coreRouter), 1e18);
            coreRouter.supply(1e18, address(weth));
            vm.stopPrank();
        }

        address bob = makeAddr("Bob");
        deal(address(dai), bob, 3000e18);

        // Bob supplies 3000 DAI
        {
            vm.startPrank(bob);
            dai.safeApprove(address(coreRouter), 3000e18);
            coreRouter.supply(3000e18, address(dai));
            vm.stopPrank();
        }

        // Bob borrows 1 WETH but then transaction will revert
        vm.prank(bob);
        vm.expectRevert(abi.encodeWithSelector(TokenErrorReporter.BorrowLendtrollerRejection.selector, LendtrollerErrorReporter.Error.INSUFFICIENT_LIQUIDITY));
        coreRouter.borrow(1e18, address(weth));
    }
```

