feat: allow to undo repayments for fully repaid loans #69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Main changes
undoRepaymentFor()
function can now accept unroundedrepaymentAmount
parameter values. This change has been introduce to properly undo final repayments of loans. The final repayment is one that caused closing of a loan.B
.B
block:BT
.BTZ
. E.g. forAmerica/Sao_Paulo
timezone:BTZ = BT - 3 * 60 * 60
.getLoanPreview()
function at theB-1
block with theBTZ
timestamp:getLoanPreview(loanId, BTZ)
.trackedBalance
field of the returned structure as therepaymentAmount
parameter of theundoRepaymentFor()
function to undo the final repayment.repaymentAmount
of functionundoRepaymentFor()
:onBeforeLoanReopened()
hook function has been added to the credit line smart contract. It is called when a final repayment is being undone to check the loan can be reopened according to the current borrowing policy. If the loan cannot be reopened (e.g. themaxBorrowedAmount
limit of all loans of the borrower is reached) the function will be returned with an appropriate error and the whole blockchain transaction will be reverted as well.Versioning
The smart contracts version has been updated to
v1.12.0
.Test Coverage
The new changes have been fully covered by tests.
Test coverage details