<!-- canonical: https://0xsimao.com/findings/mento-ratio-scalar-lesser-expected -->

# _getReserveRatioScalar() will give a lesser value than expected

Medium · Sherlock · Stablecoin · 24th October 2024

Finding M-5 of the Mento competition.

- Protocol: https://audits.sherlock.xyz/contests/598
- Report: /reports/mento
- Codebase: https://github.com/0xsimao/2024-10-mento-update/tree/098b17fb32d294145a7f000d96917d13db8756cc
- Source: https://github.com/sherlock-audit/2024-10-mento-update-judging/issues/50

---

### Summary

[numberOfExpansions = (block.timestamp - config.lastExpansion) / config.expansionFrequency](https://github.com/sherlock-audit/2024-10-mento-update/blob/main/mento-core/contracts/goodDollar/GoodDollarExpansionController.sol#L232)

The calculation divides it by the expansionFrequency, but this will cause significant rounding issues.

If the expansionFrequency is 1 day (as specified in the docs), time may pass without anybody calling the function and the following scenario will be present.

Let's say 30 hours since last expansion and someone decides then to call it, it will be rounded due to the division to be 1 day, producing a smaller value than the hours that've passed.

### Root Cause

The root cause is the potential of **rounding down** `numberOfExpansions`, which will give a significantly smaller value, depending on how big will be remainder of the division. (6 for 30 hours, 3 for 27 hours, etc)

### Internal pre-conditions

`mintUBIFromExpansion()` need to be callable.



### External pre-conditions

_No response_

### Attack Path

1. Alice calls `mintUBIFromExpansion()` to create an expansion
2. 30 hours pass and nobody calls the function, Bob sees that he can call `mintUBIFromExpansion()`
3. Due to the rounding down of the calculation, it will a value equivalent of 24 hours passing.

### Impact

The protocol will expand **slower than intended**, thus less $G will be minted, which will **become significant** overtime.



### PoC

_No response_

### Mitigation

_No response_

---

Related findings:

- [cds owners can withdraw more than expected via manipulating excessProfitCumulativeValue](https://0xsimao.com/findings/autonomint-owners-withdraw-manipulating-excess): Autonomint
