Submitted by ABAIKUNANBAEV
In Controller smart contract, due to mistake in multiplication of i_gain, its miscalculated and the error occurs. This can lead to a multiplier reflecting an incorrect value and therefore affect yin borrowing rate.
According to the multiplier formula, first we calculate p_term. The formula for p_term is following:
p_term = p_gain * error
And thats done right using the get_p_term_internal() function:
https://github.com/code-423n4/2024-01-opus/blob/main/src/core/controller.cairo#L243-245
Then we add right and go to integral term calculation. Its almost the same as p_term, only the time scale factor is added:
https://github.com/code-423n4/2024-01-opus/blob/main/src/core/controller.cairo#L256-258
The problem is that when we add this formula to the multiplier, we multiply it additionally by i_gain:
https://github.com/code-423n4/2024-01-opus/blob/main/src/core/controller.cairo#L166-167
And, according to the formula, only this part should be multiplied by i_gain:
But old_term also ends up multiplied.
https://github.com/code-423n4/2024-01-opus/blob/main/src/core/controller.cairo#L256-258
https://github.com/code-423n4/2024-01-opus/blob/main/src/core/controller.cairo#L167
0xsomeone (judge) commented:
milancermak (Opus) confirmed
