# PrismaConnector can mint a position below the desired health factor

PrismaConnector.adjustTrove used getNominalICR (always <1.5e18) instead of getCurrentICR, so trove adjustments always reverted, bricking borrow/repay.

- Payout: Audit contest
- Severity: high
- Program: NOYA
- Found by: KYP
- Disclosed: 2025-02-17
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-04-noya-findings/issues/925
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-noya%3AH-17
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** PrismaConnector.adjustTrove in NOYA vault connector
**Root cause:** Health factor check calls ITroveManager.getNominalICR(address) which returns a nominal value always below minimumHealthFactor (1.5e18), instead of getCurrentICR with a price.
**Steps:**
1. Open trove via connector.openTrove with 2 WETH collateral minting 2000e18 ULTRA
2. Compute actual ICR via tm.getCurrentICR(connector, wethPrice*1e10); it exceeds 1.5e18
3. Call connector.adjustTrove(..., 0, 1e18, false) to repay 1 ULTRA
4. Call reverts because getNominalICR(address(this)) < minimumHealthFactor
**How found:** Code review of the health-factor check in adjustTrove; noticed getNominalICR takes no price argument and returns a value always below the 1.5e18 threshold, then confirmed with a Foundry PoC.
**Exploitation:** Not an attacker-driven exploit; the bug bricks adjustTrove so a trove can only be closed. If insufficient ULTRA was minted initially, collateral cannot be recovered.
**Insight:** When a connector wraps a lending protocol, verify the health-factor getter matches the protocol's actual ICR semantics (price-dependent getCurrentICR) rather than a nominal/no-price variant; a wrong getter silently bricks all adjust paths.

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

**Foundry test proving adjustTrove reverts despite healthy trove**

```
function testTroveHealthFactor() public {
    uint256 amount = 2e18;                   // collateral
    uint256 ultraToMint = 2000e18;
    _dealERC20(WETH, address(connector), amount);

    uint256 wethPrice = chainlinkOracle.getValue(address(WETH), address(840), 1 ether);
    console.log("wethPrice   :", wethPrice); // 3037$ per WETH

    vm.startPrank(owner);

    connector.approveZap(IStakeNTroveZap(ULTRA_StakeNTroveZap), ULTRA_weeth_troveManager, true);
    connector.openTrove(
        IStakeNTroveZap(ULTRA_StakeNTroveZap), ULTRA_weeth_troveManager, 
        125e14,     // max fee
        amount,     // collateral
        ultraToMint // ULTRA to mint
    );

    ITroveManager tm = ITroveManager(ULTRA_weeth_troveManager);
    (uint256 coll1, uint256 debt1) = tm.getTroveCollAndDebt(address(connector));
    console.log("coll1       :", coll1);
    console.log("debt1       :", debt1);
    console.log("minHF       :", connector.minimumHealthFactor()); // 1.5
    
    uint256 connectorMinHF = connector.minimumHealthFactor();
    uint256 troveHF = tm.getCurrentICR(address(connector), wethPrice * 1e10);  // or coll1 * (wethPrice * 1e10) / debt1;
    console.log("troveHF     :", troveHF);

    assertGt(troveHF, connector.minimumHealthFactor()); // 2000 ULTRA is backed up by 2 WETH, so troveHF is well above 1.5

    // Next call fails, when it shouldn't; health factor of the trove is above connector.minimumHealthFactor()
    vm.expectRevert();
    // repay 1 ULTRA
    connector.adjustTrove( 
        IStakeNTroveZap(ULTRA_StakeNTroveZap), 
        ULTRA_weeth_troveManager, 
        125e14, // max fee
        0,      // collateral to withdraw
        1e18,   // repay amount
        false   // is repay 
    );

    // There should be enough collateral to borrow 1 ULTRA, but call fails
    vm.expectRevert();
    // borrow 1 ULTRA
    connector.adjustTrove( 
        IStakeNTroveZap(ULTRA_StakeNTroveZap), 
        ULTRA_weeth_troveManager, 
        125e14, // max fee
        0,      // collateral to withdraw
        1e18,   // borrow amount
        true   // is borrow 
    );
}
```

**Interface addition for getCurrentICR**

```
function getCurrentICR(address _borrower, uint256 _price) external view returns (uint256);
```

