# Low TVL and high Leverage Supply will DoS the redeem of Leverage tokens

In Plaza Finance Pool.getRedeemAmount, division-before-multiplication truncates redeemRate to zero when leverage supply exceeds tvl*PRECISION, blocking leverage token redemption.

- Payout: Audit contest
- Severity: medium
- Program: Plaza Finance
- Found by: 0xc0ffEE
- Disclosed: 2024-12-16
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/1039
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-12-plaza-finance%3AM-19
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:dos vuln:precision-loss

**Target:** Pool.sol getRedeemAmount / redeem()
**Root cause:** In getRedeemAmount, redeemRate = ((tvl - bondSupply*BOND_TARGET_PRICE) / assetSupply) * PRECISION divides before multiplying, so when assetSupply > tvl*PRECISION the intermediate division truncates to 0, yielding redeemAmount 0 and reverting with ZeroAmount.
**Steps:**
1. Deploy pool with high leverage supply relative to TVL (e.g. 1000e18 lev, 13 ether reserve) and bond supply such that collateral level > 1.2.
2. Transfer leverage tokens to a user.
3. Call `pool.redeem(Pool.TokenType.LEVERAGE, amountLev, 0)`.
4. Observe revert `Pool.ZeroAmount` because redeemRate computed as 0 due to division-before-multiplication truncation.
**How found:** Code review of getRedeemAmount spotted multiplication after division in the leverage branch, then reasoned that high assetSupply relative to TVL causes the intermediate division to truncate to zero; confirmed with a Foundry PoC.
**Exploitation:** Not an attack; a user simply cannot redeem leverage tokens when assetSupply exceeds tvl*PRECISION because the computed redeemRate truncates to zero and redeem reverts.
**Insight:** In share/rate math, always check the order of division vs multiplication: any `(a/b)*c` where b can exceed a*precision silently truncates to zero and can brick redeem paths when supply is large relative to TVL.

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

**Foundry PoC test for leverage redeem DoS**

```
function testLowTvlAndLowBondTokenSupplyWillBlockLevTokenRedemption() public {
        // The Bond and Leverage tokens are minted to the governance, because the pool is deployed by this address
        // Using governance we bypass the need to have PreDeposit contract, which deploys the pool
        // The tokens from governance are sent to the user, simulating the PreDeposit claim functionality
        console.log("Governance lev balance: ", lev.balanceOf(governance));

        vm.startPrank(governance);
        lev.transfer(user, lev.balanceOf(governance));
        vm.stopPrank();

        console.log("User lev balance: ", lev.balanceOf(user));
        console.log("Governance lev balance: ", lev.balanceOf(governance));

        vm.startPrank(user);
        uint256 amountLev = lev.balanceOf(user);
        vm.expectRevert(Pool.ZeroAmount.selector);
        pool.redeem(Pool.TokenType.LEVERAGE, amountLev, 0);
        console.log("User lev balance after redeem: ", lev.balanceOf(user));
        console.log("Pool reserve tokens: ", reserve.balanceOf(address(pool)));

        vm.stopPrank();
    }
}
```

