Borrower - Repay a loan

Borrower: repay a loan

Repay a loan including lender's yield and protocol fee.

Flow

  • Check repay TX is sent by borrower.

  • Repay timestamp consistency:

    • If the loan is not called you may repay "slightly late".

    • If the loan is called repayment must be exactly at call time.

  • Compute amounts:

    • Compute loanDuration = _repayTimestamp - loan.startTime.

    • Compute amountOwed using getAmountOwed function.

    • Compute fee - fee is a percentage of lender’s yield, not of principal.

    • lenderAmount = amountOwed - fee.

  • Transfers:

    • Transfer lenderAmount = amountOwed - fee USDC from borrower to lender.

    • Transfer fee from borrower to protocol fee recipient.

    • Transfer collateral from PolyLend Smart Contract to borrower.

  • Cancel the loan by zeroing loan.borrower.

  • Emit LoanRepaid.

Last updated