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 the BorrowerGateway contract with the address of the AddressRegistry 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 the ReentrancyGuard library from the OpenZeppelin library to prevent reentrancy attacks.

  • SafeERC20: The contract imports the SafeERC20 library from the OpenZeppelin library to safely perform ERC20 token transfers.

Interfaces:

  • IAddressRegistry: The contract imports the IAddressRegistry interface to interact with the AddressRegistry contract.

  • IBorrowerGateway: The contract imports the IBorrowerGateway interface to define the functions required for the BorrowerGateway contract.

  • ILenderVaultImpl: The contract imports the ILenderVaultImpl interface to access the loan and vault information in the lender vault.

  • IVaultCallback: The contract imports the IVaultCallback interface to interact with callback contracts for additional processing.

Dependencies:

  • Constants: The contract imports the Constants contract to access predefined constants used in calculations.

  • DataTypesPeerToPeer: The contract imports the DataTypesPeerToPeer contract to access the data structures used for borrowing and repayment instructions.

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

  • IERC20Metadata: The contract imports the IERC20Metadata interface from the OpenZeppelin library to interact with ERC20 tokens.

Last updated