LoanRepayer
Contract Overview
The LoanRepayer
contract is designed to facilitate the repayment of loans, including those involving flash-swaps. It interacts with various other contracts such as swappers, loans, and the registry to ensure the proper repayment and management of loans. The contract supports functionalities such as repaying multiple loans, repaying individual loans, and sourcing the principal for loans.
Read Methods
1. registry
Returns
Name | Type | Description |
---|---|---|
registry | address | The address of the registry contract. |
Returns the address of the registry contract used by the LoanRepayer
.
Write Methods
1. repayLoans
Parameters
Name | Type | Description |
---|---|---|
lrps | DataTypes.LoanRepayParams[] | An array of loan repayment parameters. |
Repays multiple loans based on the provided loan repayment parameters. Reverts if the array is empty.
Notice:
- Reason: To allow the repayment of multiple loans in a single transaction, improving efficiency.
2. repayLoan
Parameters
Name | Type | Description |
---|---|---|
lrp | DataTypes.LoanRepayParams | The loan repayment parameters. |
Repays a loan based on the provided loan repayment parameters. This function is used when the borrower wants to repay via a flash-swap.
Notice:
- Reason: To handle the repayment of a loan, including handling flash-swaps if necessary.
3. sourcePrincipal
Parameters
Name | Type | Description |
---|---|---|
repayAmt | uint256 | The amount to be repaid. |
reclaimedColl | uint256 | The collateral that is reclaimed. |
data | bytes | The data to be used. |
Sources the principal for the loan. This function is called by the loan contract after it has transferred the collateral to the borrower but before it has transferred the borrow token to the lender vault.
Notice:
- Reason: To handle the sourcing of the principal for loans, particularly in cases involving flash-swaps.
4. transferRemaining
Parameters
Name | Type | Description |
---|---|---|
token | address | The address of the token to be transferred. |
to | address | The address to which the tokens will be transferred. |
Helper function to transfer any remaining tokens back to the sender. It checks the balance of the token in this contract and transfers the tokens if the balance is greater than 0.
Notice:
- Reason: To ensure that any remaining tokens are returned to the sender, preventing them from being locked in the contract.
Constructor
Parameters
Name | Type | Description |
---|---|---|
_registry | address | The address of the registry contract. |
Initializes