LoanCreator
Contract Overview
The LoanCreator
contract is designed to facilitate the creation of loans, including those involving flash-swaps. It interacts with various other contracts such as vaults, swappers, and the registry to ensure the proper creation and management of loans. The contract supports functionalities such as executing multiple loans, creating individual loans, and sourcing collateral 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 LoanCreator
.
Write Methods
1. executeLoans
Parameters
Name | Type | Description |
---|---|---|
leps | DataTypes.LoanExecParams[] | An array of loan execution parameters. |
Returns
Name | Type | Description |
---|---|---|
loans | ILoan[] | An array of created loan contracts. |
Executes multiple loans based on the provided loan execution parameters. Reverts if the array is empty.
Notice:
- Reason: To allow the creation of multiple loans in a single transaction, improvin gas efficiency.
2. createLoan
Parameters
Name | Type | Description |
---|---|---|
lep | DataTypes.LoanExecParams | The loan execution parameters. |
Returns
Name | Type | Description |
---|---|---|
createdLoan | ILoan | The address of the created loan. |
Creates a loan based on the provided loan execution parameters. This is an internal function called by executeLoans
.
Notice:
- Reason: To encapsulate the logic of creating a loan, including handling flash-swaps if necessary.
3. sourceCollateral
Parameters
Name | Type | Description |
---|---|---|
loanContract | address | The address of the loan contract. |
data | bytes | The encoded data containing the vault, swapper, and swapperData. |
Sources collateral for a loan. This function should only be called by the LendersVault
contract after a loan is created.
Notice:
- Reason: To handle the sourcing of collateral 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:
Ensures 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 the contract with the provided registry address. Reverts if the address is zero.