Loan Proposal Implementation

LoanProposalImpl: Contract for managing loan proposals, including creation, negotiation, and handling of subscriptions, conversions, collateral transfers, rollbacks, and defaults.

Summary:

LoanProposalImpl.sol is a key contract that maintains and manages loan proposals in the lending system. The contract provides functionalities for the creation, negotiation, acceptance, finalization, and rollback of loan terms. Furthermore, the contract keeps track of the subscriptions and conversions related to each loan proposal.

Key Features:

  • Stores dynamic and static data related to loan proposals.

  • Maps and tracks total converted subscriptions, and whether lenders have exercised conversion or claimed repayment.

  • Allows the proposal of loan terms, acceptance of loan terms, and finalization of loan terms and collateral transfer.

  • Provides a function to rollback a proposal if conditions are not met.

  • Handles cases of default, detailing the total subscriptions that have claimed on default.

Key Functions:

  • initialize(): Initializes the LoanProposalImpl contract with necessary parameters such as factory, arranger, funding pool, collToken, whitelistAuthority, and grace periods.

  • proposeLoanTerms(): Allows an arranger to propose terms for a new loan.

  • acceptLoanTerms(): Allows a borrower to accept the proposed loan terms.

  • finalizeLoanTermsAndTransferColl(): Finalizes the loan terms and handles the transfer of collateral from the borrower.

  • rollback(): Allows to rollback a proposal if conditions are not met.

Libraries:

  • SafeERC20: The contract uses the OpenZeppelin's SafeERC20 library for safe operations with ERC20 tokens.

  • SafeCast: The contract uses OpenZeppelin's SafeCast for safe type casting.

Interfaces:

  • IERC20Metadata: The contract imports the IERC20Metadata interface, which is an extension of IERC20 providing methods for getting the token's name, symbol, and decimals.

  • IFactory: The contract imports the IFactory interface which defines the functions of the factory contract.

  • IFundingPoolImpl: The contract imports the IFundingPoolImpl interface outlining the main functionalities of the FundingPoolImpl.

Inheritance:

  • Initializable: The contract inherits from Initializable, providing a mechanism to initialize state in a contract at creation time in a controlled manner.

  • ReentrancyGuard: The contract inherits from ReentrancyGuard, providing a mechanism to prevent reentrant calls.

Dependencies:

  • Constants: The contract imports Constants for defining constants such as BASE and MIN_WAIT_UNTIL_EARLIEST_UNSUBSCRIBE.

  • DataTypesPeerToPool: The contract imports DataTypesPeerToPool to access the LoanTerms struct used for managing loan terms.

  • Errors: The contract imports the Errors library, which provides custom error messages for different exceptional scenarios.

Last updated