Submitted by Koolex
The protocol allows the lender to change the interest rate anytime. However, since the new interest rate is stored on trading pool level, the lender could front-run a borrowing transaction thats yet to be processed, updating the interest rate too high (up to 99). This is harmful to the borrower even if the borrower repays the SOL immediately.
Thats because the minimum elapsed days on repay is set to be one
src/processor/swapback.rs#L145
Update interest rate on pool level:
src/processor/lending.rs#L38-L51
Minimum elapsed days is 1:
src/processor/swapback.rs#L145
Allow the borrower to pass maximum interest rate, this protects the borrower from any change of the interest rate that occur after they send their TX.
Another suggestion: store the interest rate on position level instead.
piske-alex (Lavarage) confirmed and commented:
Koolex (warden) commented:
alcueca (judge) commented:
Note: For full discussion, see here.
