Borrower Gateway
BorrowerGateway: Interface for borrowers to interact with lender vaults. Manages borrowing, repayment, collateral and loan token transfers
Summary:
BorrowerGateway.sol is a contract that serves as an interface between borrowers and lender vaults in the Peer-to-Peer DeFi framework. It handles the borrowing and repayment processes, including transfers of collateral and loan tokens.
Key Features:
Allows borrowers to borrow funds using on-chain and off-chain quotes.
Facilitates collateral and loan token transfers between borrowers and lender vaults.
Manages protocol fees charged during borrowing.
Supports loan repayments and updates the lender vault's storage state.
Key Functions:
constructor(address _addressRegistry): Initializes theBorrowerGatewaycontract with the address of theAddressRegistrycontract.borrowWithOffChainQuote(): Borrows funds using an off-chain quote and initiates the necessary transfers.borrowWithOnChainQuote(): Borrows funds using an on-chain quote and initiates the necessary transfers.repay(): Repays a loan and updates the lender vault's storage state.setProtocolFee(): Sets the protocol fee for borrowing transactions.processTransfers(): Processes collateral and loan token transfers during borrowing.processRepayTransfers(): Processes collateral and loan token transfers during loan repayment.checkDeadlineAndRegisteredVault(): Checks the deadline and verifies the existence of a registered lender vault.
Libraries:
ReentrancyGuard: The contract imports theReentrancyGuardlibrary from the OpenZeppelin library to prevent reentrancy attacks.SafeERC20: The contract imports theSafeERC20library from the OpenZeppelin library to safely perform ERC20 token transfers.
Interfaces:
IAddressRegistry: The contract imports theIAddressRegistryinterface to interact with theAddressRegistrycontract.IBorrowerGateway: The contract imports theIBorrowerGatewayinterface to define the functions required for theBorrowerGatewaycontract.ILenderVaultImpl: The contract imports theILenderVaultImplinterface to access the loan and vault information in the lender vault.IVaultCallback: The contract imports theIVaultCallbackinterface to interact with callback contracts for additional processing.
Dependencies:
Constants: The contract imports theConstantscontract to access predefined constants used in calculations.DataTypesPeerToPeer: The contract imports theDataTypesPeerToPeercontract to access the data structures used for borrowing and repayment instructions.Errors: The contract imports theErrorslibrary, which provides custom error messages for different exceptional scenarios.IERC20Metadata: The contract imports theIERC20Metadatainterface from the OpenZeppelin library to interact with ERC20 tokens.
Last updated