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 theBorrowerGateway
contract with the address of theAddressRegistry
contract.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 theReentrancyGuard
library from the OpenZeppelin library to prevent reentrancy attacks.SafeERC20
: The contract imports theSafeERC20
library from the OpenZeppelin library to safely perform ERC20 token transfers.
Interfaces:
IAddressRegistry
: The contract imports theIAddressRegistry
interface to interact with theAddressRegistry
contract.IBorrowerGateway
: The contract imports theIBorrowerGateway
interface to define the functions required for theBorrowerGateway
contract.ILenderVaultImpl
: The contract imports theILenderVaultImpl
interface to access the loan and vault information in the lender vault.IVaultCallback
: The contract imports theIVaultCallback
interface to interact with callback contracts for additional processing.
Dependencies:
Constants
: The contract imports theConstants
contract to access predefined constants used in calculations.DataTypesPeerToPeer
: The contract imports theDataTypesPeerToPeer
contract to access the data structures used for borrowing and repayment instructions.Errors
: The contract imports theErrors
library, which provides custom error messages for different exceptional scenarios.IERC20Metadata
: The contract imports theIERC20Metadata
interface from the OpenZeppelin library to interact with ERC20 tokens.
Last updated