Unique identifier for lending desks
uint256 public lendingDeskIdCounter;
Unique identifier for loans
uint256 public loanIdCounter;
Mapping to store lending desks
mapping(uint256 => LendingDesk) public lendingDesks;
Mapping to store loan configs of lending desks
mapping(uint256 => mapping(address => LoanConfig)) public lendingDeskLoanConfigs;
Mapping to store loans
mapping(uint256 => Loan) public loans;
The address of the ERC721 to generate obligation notes for borrowers
address public immutable obligationNotes;
The address of the lending desk ownership ERC721
address public immutable lendingKeys;
The basis points of fees that the borrower will pay for each loan
uint256 public loanOriginationFee;
The address of the platform wallet
address public platformWallet;
constructor(
address _obligationNotes,
address _lendingKeys,
uint256 _loanOriginationFee,
address _platformWallet,
address _initialOwner
);
Creates a new lending desk
Emits an {NewLendingDeskInitialized} event.
function initializeNewLendingDesk(address _erc20, uint256 _depositAmount, LoanConfig[] calldata _loanConfigs)
external
whenNotPaused;
Parameters
Creates a new lending configuration
Emits an {LendingDeskLoanConfigsSet} event.
function setLendingDeskLoanConfigs(uint256 _lendingDeskId, LoanConfig[] calldata _loanConfigs) public whenNotPaused;
Parameters
function _setLendingDeskLoanConfigs(uint256 _lendingDeskId, LoanConfig[] calldata _loanConfigs) internal;
Removes a new lending configuration
Emits an {LendingDeskLoanConfigsSet} event.
function removeLendingDeskLoanConfig(uint256 _lendingDeskId, address _nftCollection) external whenNotPaused;
Parameters
This function is called to add liquidity to a lending desk
Emits an {LendingDeskLiquidityDeposited} event.
function depositLendingDeskLiquidity(uint256 _lendingDeskId, uint256 _amount) public whenNotPaused;
Parameters
function _depositLendingDeskLiquidity(uint256 _lendingDeskId, uint256 _amount) internal;
This function is called to cash out a lending desk
Emits an {LendingDeskLiquidityWithdrawn} event.
function withdrawLendingDeskLiquidity(uint256 _lendingDeskId, uint256 _amount) external;
Parameters
This function can be called by the lending desk owner in order to freeze it
Emits an {LendingDeskStateSet} event.
function setLendingDeskState(uint256 _lendingDeskId, bool _freeze) external whenNotPaused;
Parameters
This function can be called by a borrower to create a loan
Emits an {NewLoanInitialized} event
function initializeNewLoan(
uint64 _lendingDeskId,
address _nftCollection,
uint64 _nftId,
uint32 _duration,
uint256 _amount,
uint32 _maxInterestAllowed
) external whenNotPaused;
Parameters
This function can be called by anyone to get the remaining due amount of a loan
function getLoanAmountDue(uint256 _loanId) public view returns (uint256 amount);
Parameters
This function can be called by the obligation note holder to pay a loan and get the collateral back
Emits an {LoanPaymentMade} event.
function makeLoanPayment(uint256 _loanId, uint256 _amount, bool _resolve) external;
Parameters
This function is called by the lending desk key owner in order to liquidate a loan and claim the NFT collateral
Emits an {LiquidatedOverdueLoan} event.
function liquidateDefaultedLoan(uint256 _loanId) external;
Parameters
Allows the admin of the contract to modify loan origination fee.
Emits an {LoanOriginationFeeSet} event.
function setLoanOriginationFee(uint256 _loanOriginationFee) public onlyOwner;
Parameters
Allows the admin of the contract to set the platform wallet where platform fees will be sent to
Emits an {PlatformWalletSet} event.
function setPlatformWallet(address _platformWallet) public onlyOwner;
Parameters
Allows the admin of the contract to pause the contract as an emergency response.
Emits either a {Paused} or {Unpaused} event.
function setPaused(bool _paused) external onlyOwner;
Parameters
Event that will be emitted every time a lending desk is created
event NewLendingDeskInitialized(
uint256 lendingDeskId, address owner, address erc20, uint256 initialBalance, LoanConfig[] loanConfigs
);
Event that will be emitted every time a lending desk config is created
event LendingDeskLoanConfigsSet(uint256 lendingDeskId, LoanConfig[] loanConfigs);
Event that will be emitted every time a lending desk config is removed
event LendingDeskLoanConfigRemoved(uint256 lendingDeskId, address nftCollection);
Event that will be emitted every time liquidity is added to a lending desk
event LendingDeskLiquidityDeposited(uint256 lendingDeskId, uint256 amountDeposited);
Event that will be emitted every time there is a cash out on a lending desk
event LendingDeskLiquidityWithdrawn(uint256 lendingDeskId, uint256 amountWithdrawn);
Event that will be emitted every time a lending desk is frozen// unfrozen
event LendingDeskStateSet(uint256 lendingDeskId, bool freeze);
Event that will be emitted every time a new offer is accepted
event NewLoanInitialized(
uint256 lendingDeskId,
uint256 loanId,
address borrower,
address nftCollection,
uint256 nftId,
uint256 amount,
uint256 duration,
uint256 interest,
uint256 platformFee
);
Event that will be emitted every time a borrower pays back a loan
event LoanPaymentMade(uint256 loanId, uint256 amountPaid, bool resolved);
Event that will be emitted every time a loan is liquidated when the obligation note holder did not pay it back in time
event DefaultedLoanLiquidated(uint256 loanId);
Event that will be when the contract is deployed
event ProtocolInitialized(address obligationNotes, address lendingKeys);
Event that will be emitted every time an admin updates loan origination fee
event LoanOriginationFeeSet(uint256 loanOriginationFee);
Event that will be emitted every time an admin updates the platform wallet
event PlatformWalletSet(address platformWallet);
error ObligationNotesIsZeroAddr();
error LendingKeysIsZeroAddr();
error ERC20IsZeroAddr();
error InvalidLendingDeskId();
error CallerIsNotLendingDeskOwner();
error MinAmountIsZero();
error MaxAmountIsLessThanMin();
error MinInterestIsZero();
error MaxInterestIsLessThanMin();
error MinDurationIsZero();
error MaxDurationIsLessThanMin();
error InvalidInterest();
error InvalidNFTCollection();
error LendingDeskIsNotActive();
error InsufficientLendingDeskBalance();
error UnsupportedNFTCollection();
error AmountIsZero();
error LendingDeskIsNotFrozen();
error InvalidLoanId();
error LendingDeskIsNotEmpty();
error LoanAmountTooLow();
error LoanAmountTooHigh();
error LoanDurationTooLow();
error LoanDurationTooHigh();
error LoanIsNotActive();
error CallerIsNotBorrower();
error CallerIsNotLender();
error LoanHasNotDefaulted();
error LoanHasDefaulted();
error PlatformWalletIsZeroAddr();
error LoanMustBeActiveForMin1Hour();
error LoanPaymentExceedsDebt();
error InterestRateTooHigh();