morpho-org / morpho-blue-irm

Morpho Blue Interest Rate Models
https://morpho.org
MIT License
26 stars 17 forks source link

IRM #1

Closed MathisGD closed 1 year ago

MerlinEgalite commented 1 year ago

For the naming we could write pidIrm or something like that?

peyha commented 1 year ago

Can you break the IRM by borrowing a low amount of token (1 wei for instance) many times in the same block ?

Feel like it is possible because in this case the borrow rate will be $\text{borrow rate last block}*\text{jump multiplier}^N$ which probably grows pretty quickly to infinity

MathisGD commented 1 year ago

Can you break the IRM by borrowing a low amount of token (1 wei for instance) many times in a block ?

Feel like it is possible because in this case the borrow rate will be borrow rate last block∗jump multiplierN which probably grows pretty quickly to infinity

It is not possible because the formula is:

uint256 jumpMultiplier = IrmMathLib.wExp(int256(LN_JUMP_FACTOR), errDelta);

And in your example errDelta is near zero. In general going from u1 to u2 in one step or breaking it into smaller steps does not change the overall jump that will be made.

pakim249CAL commented 1 year ago

Can you break the IRM by borrowing a low amount of token (1 wei for instance) many times in a block ?

Feel like it is possible because in this case the borrow rate will be borrow rate last block∗jump multiplierN which probably grows pretty quickly to infinity

This shouldn't work because the IRM can only be called once per block. This may not be clear here as the logic to only call this contract once per block is contained in the Morpho contract and not here.

MathisGD commented 1 year ago

This shouldn't work because the IRM can only be called once per block. This may not be clear here as the logic to only call this contract once per block is contained in the Morpho contract and not here.

This is an other point, but it's not even required to prevent the problem

peyha commented 1 year ago

Can you break the IRM by borrowing a low amount of token (1 wei for instance) many times in a block ? Feel like it is possible because in this case the borrow rate will be borrow rate last block∗jump multiplierN which probably grows pretty quickly to infinity

It is not possible because the formula is:

uint256 jumpMultiplier = IrmMathLib.wExp(int256(LN_JUMP_FACTOR), errDelta);

And in your example errDelta is near zero. In general going from u1 to u2 in one step or breaking it into smaller steps does not change the overall jump that will be made.

errDelta is near zero but still constant ($\Delta(e)=u(t*)-u(t*)=\frac{b+1}{s}-\frac{b}{s}=\frac{1}{s}$) so you still get $r=r_{previous}J^{\frac{N}{s}}$ which diverges (unless I'm missing something in my computation)

Can you break the IRM by borrowing a low amount of token (1 wei for instance) many times in a block ? Feel like it is possible because in this case the borrow rate will be borrow rate last block∗jump multiplierN which probably grows pretty quickly to infinity

This shouldn't work because the IRM can only be called once per block. This may not be clear here as the logic to only call this contract once per block is contained in the Morpho contract and not here.

You are right