# Incorrect LevETH Redeem Rate Due to BondETH Market Rate and LevETH Rate Comparison, Leading to Trader Losses

Pool.getRedeemAmount applies BondETH market rate cap to LevETH redemptions, causing LevETH redeemers to receive up to ~84% less than owed.

- Payout: Audit contest
- Severity: high
- Program: Plaza Finance
- Found by: 0x23r0
- Disclosed: 2024-12-16
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/190
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-12-plaza-finance%3AH-1
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error

**Target:** Pool.sol getRedeemAmount / simulateRedeem (LevETH redemption)
**Root cause:** getRedeemAmount unconditionally takes min(redeemRate, marketRate), but marketRate is the BondETH oracle price, not a LevETH rate; since it is always lower, LevETH redemptions are capped by the BondETH market rate.
**Steps:**
1. Deploy pool with 100 ETH reserves, 2500 BOND, 100 LEV supply and mock ETH price feed.
2. Mint 1 ETH of LEVERAGE tokens via pool.create(TokenType.LEVERAGE, 1 ether, 1).
3. Ensure BondOracleAdapter/marketRate returns a nonzero value (<=1e8).
4. Call pool.redeem(TokenType.LEVERAGE, lev.balanceOf(user), 1).
5. Observe redeemRate forced to marketRate instead of the computed LevETH rate (~6.25e8), returning ~0.16 ETH instead of ~1 ETH.
**How found:** Code review of getRedeemAmount: noticed the marketRate min() clamp is applied regardless of tokenType, and that marketRate is sourced from BondOracleAdapter (BondETH price) while redeemRate for LEVERAGE is derived from TVL/levSupply—an apples-to-oranges comparison.
**Exploitation:** Any LevETH holder redeeming while the BondETH market rate is nonzero and below the computed LevETH redeem rate receives the capped (lower) amount; the difference is a direct loss to the redeemer (up to ~84% in the PoC). No attacker capital needed—loss occurs on every LevETH withdrawal.
**Insight:** When a function branches on tokenType for rate computation, check whether downstream clamps/oracle comparisons are also tokenType-scoped; a shared min() with a single-asset oracle silently misprices the other asset class.

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

**Foundry PoC test redeeming LevETH with market rate**

```
function testMarketRateImbalance() public {
    vm.startPrank(governance);
     rToken = Token(params.reserveToken);

    // Mint reserve tokens
    rToken.mint(governance, 100 ether);
    rToken.approve(address(poolFactory), 100 ether);

    // Create pool and approve deposit amount
     pool = Pool(poolFactory.createPool(params, 100 ether, 2500 ether, 100 ether, "", "", "", "", false));
    bond = pool.bondToken();
    lev = pool.lToken();
    assertEq(2500 ether, BondToken(pool.bondToken()).totalSupply());
    assertEq(100 ether, LeverageToken(pool.lToken()).totalSupply());

   
    console.log("1st Iteration");
    createToken(user, 1 ether, Pool.TokenType.LEVERAGE);
    console.log("                ");


    // NOTE Make sure to mock MarketRate to return value.
     vm.startPrank(user);   
    console.log("3rd Iteration LEv Redeem");
    uint amount = pool.redeem(Pool.TokenType.LEVERAGE, lev.balanceOf(user), 1);
    console.log("Amount Redeemed", amount);
    console.log("                ");
    assertEq(amount, rToken.balanceOf(user));
    vm.stopPrank();
  
  }
```

**Vulnerable marketRate comparison in getRedeemAmount**

```
if (marketRate != 0 && marketRate < redeemRate) {
-   redeemRate = marketRate;


  function getRedeemAmount(
    TokenType tokenType,
    uint256 depositAmount,
    uint256 bondSupply,
    uint256 levSupply,
    uint256 poolReserves,
    uint256 ethPrice,
    uint8 oracleDecimals,
    uint256 marketRate
  ) public pure returns(uint256) {
    if (bondSupply == 0) {
      revert ZeroDebtSupply();
    }


    uint256 tvl = (ethPrice * poolReserves).toBaseUnit(oracleDecimals);
    uint256 assetSupply = bondSupply;
    uint256 multiplier = POINT_EIGHT;


    // Calculate the collateral level based on the token type
    uint256 collateralLevel;
    if (tokenType == TokenType.BOND) {
      collateralLevel = ((tvl - (depositAmount * BOND_TARGET_PRICE)) * PRECISION) / ((bondSupply - depositAmount) * BOND_TARGET_PRICE);
    } else {
      multiplier = POINT_TWO;
      assetSupply = levSupply;
      collateralLevel = (tvl * PRECISION) / (bondSupply * BOND_TARGET_PRICE);


      if (assetSupply == 0) {
        revert ZeroLeverageSupply();
      }
    }
    
    // Calculate the redeem rate based on the collateral level and token type
    uint256 redeemRate;
    if (collateralLevel <= COLLATERAL_THRESHOLD) {
      redeemRate = ((tvl * multiplier) / assetSupply);
    } else if (tokenType == TokenType.LEVERAGE) {
      redeemRate = ((tvl - (bondSupply * BOND_TARGET_PRICE)) / assetSupply) * PRECISION;
    } else {
      redeemRate = BOND_TARGET_PRICE * PRECISION;
    }


    if (marketRate != 0 && marketRate < redeemRate) {
      redeemRate = marketRate;
    }
```

