Incorrect interest calculation
The interest calculation in the stablecoin factory's InterestModel contract incorrectly divides the exponential decay portion of the integral by 1e18, causing interest to be drastically undercharged when the rate decays from above the minimum rate. An attacker could exploit this to pay far less interest than owed, as demonstrated by a scenario where correct interest is about 13,880 coins but the code charges only about 185 coins.
Source: https://github.com/sherlock-audit/2025-12-monolith-stablecoin-factory-judging/issues/1185
Found by
00001111, 0xShoonya, 0xeix, 0xl33, 0xnija, 0xodus, Albert_Mei, Audittens, BroRUok, ChainProof, ChaosSR, Edoscoba, Harry-Elite, Himanshu772005, JeRRy0422, Le_Rems, M1troV, Matin, Sparrow_Jac, Varun_05, X0sauce, ZeroEx, algiz, axelot, bbl4de, blockace, cholakovvv, coin2own, d33p, dantehrani, dic0de, emmanuel_ewah, gabkov, ibrahimatix0x01, itsgreg, jayjoshix, m3dython, neeloy, rubencrxz, securehash1, tedox, touristS, v_2110, xiaoming90, xxiv, zcai
Summary
N/A
Root Cause
N/A
Internal Pre-conditions
N/A
External Pre-conditions
N/A
Attack Path
It was observed that the piecewise integral formula in Line 49 below is incorrect when _lastRate > MIN_RATE.
File: InterestModel.sol
20: function calculateInterest(
..SNIP..
40: if (currBorrowRate < MIN_RATE) {
41: currBorrowRate = MIN_RATE;
42: // calculate integral
43: if (_lastRate <= MIN_RATE) {
44: // Already at min rate, just use flat rate for entire period
45: interest = _totalPaidDebt * MIN_RATE * _timeElapsed / 365 days / 1e18;
46: } else {
47: uint timeToMin = uint(-wadLn(int(MIN_RATE * 1e18 / _lastRate))) / _expRate;
48: // Decaying integral up to min rate, then add flat rate portion
49: interest = _totalPaidDebt * ((_lastRate - MIN_RATE) / _expRate +
50: MIN_RATE * (_timeElapsed - timeToMin)) / 365 days / 1e18;
51: }
..SNIP..
The formula for Line 49 is as follows:
I=D \cdot(\underbrace{\frac{r_{\text {old }}-r_{\min }}{k}}_{\text {exp segment }}+\underbrace{r_{\min }\left(d t-t_{\min }\right)}_{\text {flat segment }}) / 365 d
Where:
- $r_{old}$ is
_lastRate(in WAD/1e18) - $r_{min}$ is
MIN_RATE(in WAD/1e18) - $k$ is
_expRate(in WAD/1e18) - $t_{min}$ is in seconds
- $D$ is
_totalPaidDebt, and $I$ isinterest
The first term of the code gives:
A = (_lastRate - MIN_RATE) / _expRate;
A=\frac{\left(1 e 18r_{o l d}-1 e 18r_{\min }\right)}{1 e 18 k} =\frac{1 e 18\left(r_{o l d}-r_{\min }\right)}{1 e 18 k}=\frac{\left(r_{o l d}-r_{\min }\right)}{k} \text { seconds}
The second term of the code gives:
B = MIN_RATE * (_timeElapsed - timeToMin);
B=1 e 18 r_{\min }\left(d t-t_{\min }\right) .
The correct integral (in terms of these) is:
- Exp part:
A - Flat part:
B / 1e18
So:
\int_0^{d t}{APR}(t) d t=A+\frac{B}{1 e 18}
Hence interest should be:
interest = _totalPaidDebt * (A + B / 1e18) / 365 days;
But the code does:
interest = _totalPaidDebt * (A + B) / 365 days / 1e18;
Which equals:
I_{\text {code }}=\frac{D}{365 d \cdot 1 e 18}(A+B)=\underbrace{\frac{D A}{365 d \cdot 1 e 18}}_{\text {exp part }}+\underbrace{\frac{D B}{365 d \cdot 1 e 18}}_{\text {flat part }} .
Compare to the target:
I_{\mathrm{true}}=\frac{D A}{365 d}+\frac{D B}{365 d \cdot 1 e 18}
- The flat part
Bis correct (both haveB/(365d*1e18)) - The exponential part (
A) is off by a factor of1e18(DA/(365d*1e18)vsDA/(365d))
So when the rate decays from _lastRate down to MIN_RATE, the entire exponential segment’s contribution to interest is effectively divided by 1e18 (almost completely lost). In other words, the code is effectively doing is dropping (or near-zeroing) the exponential-decay integral and only charging the floor portion after crossing $r_{\min}$.
Assume that:
lastRate = 50% APR,MIN_RATE = 0.5% APR,halfLife = 7 days,timeElapsed = 60 days(so we cross the floor),totalPaidDebt = 1,000,000
Result:
- Correct math interest ≈ 13,880 Coin.
- Current code interest ≈ 185 Coin (≈1.3% of the correct amount).
Impact
High. Loss of interests/yields as the interest is undercalculated.
PoC
No response
Mitigation
No response
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a unit mismatch in the interest formula: the exponential decay term is divided by 1e18 along with the flat term, but only the flat term should be scaled that way.
Impact
High; interest is undercalculated, leading to loss of yields for the protocol, though the text does not state whether this was fixed or whether any defence limited it.
What the attacker needed
Borrower with debt in the protocol; interest rate above MIN_RATE; time elapses so rate decays to MIN_RATE
The fix
The interest formula should be corrected so that the exponential decay term is not divided by 1e18, matching the derived correct integral.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a smart contract bug in how interest is calculated over time. When the interest rate is falling towards a minimum, the code makes a maths mistake that divides part of the interest by a huge number, so borrowers pay almost nothing for that period. Someone could borrow a large sum and repay much less interest than they should.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.