<!-- canonical: https://0xsimao.com/findings/ostium-lock-discount-revert-division -->

# OstiumVault::lockDiscount() may revert due to division by 0

Medium · Three Sigma · RWA perpetuals DEX · 19th February, 2024

Finding 3S-OS-L05 of the Ostium security review.

- Protocol: https://www.ostium.com/
- Report: /reports/ostium
- Source: https://cdn.sanity.io/files/qoqld077/production/a95b9c69e0f65d1d6b0e649f0d62a362358ca8ce.pdf

---

### Description

[OstiumVault::lockDiscount()](https://github.com/0xOstium/smart-contracts-threeSigma/blob/audit-feedback/src/OstiumVault.sol#L83) reverts if maxDiscountThresholdP == uint16(100) *
PRECISION_2, but the constructor and updateMaxDiscountThresholdP() allow setting it
to this value.

### Recommendation

Also check for equality by using <= instead of <.

### Status

Addressed in [#32af17a](https://github.com/0xOstium/smart-contracts-threeSigma/pull/58/commits/32af17a5919c8e5c6fcc4f04b0e49eb5d0521459).

---

Related findings:

- [BorrowingVault, if the debt/assets ratio falls too much, liquidators could choose to repay debt equal to the assets at a discount](https://0xsimao.com/findings/fuji-finance-debt-falls-choose-repay): Fuji Finance
- [BasicVault::getRedeemRequestOf() will revert as the redeem requests are filled with the wrong indexes](https://0xsimao.com/findings/mitosis-redeem-revert-filled-indexes): Mitosis
