For the complete documentation index, see llms.txt. This page is also available as Markdown.

MagnifyCashV1

Git Source Inherits: IMagnifyCashV1, Ownable, Pausable, ERC721Holder, ERC1155Holder

State Variables

lendingDeskIdCounter

Unique identifier for lending desks

uint256 public lendingDeskIdCounter;

loanIdCounter

Unique identifier for loans

uint256 public loanIdCounter;

lendingDesks

Mapping to store lending desks

mapping(uint256 => LendingDesk) public lendingDesks;

lendingDeskLoanConfigs

Mapping to store loan configs of lending desks

mapping(uint256 => mapping(address => LoanConfig)) public lendingDeskLoanConfigs;

loans

Mapping to store loans

mapping(uint256 => Loan) public loans;

obligationNotes

The address of the ERC721 to generate obligation notes for borrowers

lendingKeys

The address of the lending desk ownership ERC721

loanOriginationFee

The basis points of fees that the borrower will pay for each loan

platformWallet

The address of the platform wallet

Functions

constructor

initializeNewLendingDesk

Creates a new lending desk

Emits an {NewLendingDeskInitialized} event.

Parameters

Name
Type
Description

_erc20

address

The ERC20 that will be accepted for loans in this lending desk

_depositAmount

uint256

The initial balance of this lending desk

_loanConfigs

LoanConfig[]

Loan config for each NFT collection this lending desk will support

setLendingDeskLoanConfigs

Creates a new lending configuration

Emits an {LendingDeskLoanConfigsSet} event.

Parameters

Name
Type
Description

_lendingDeskId

uint256

Identifier for the lending desk

_loanConfigs

LoanConfig[]

Loan config for each NFT collection this lending desk will support

_setLendingDeskLoanConfigs

removeLendingDeskLoanConfig

Removes a new lending configuration

Emits an {LendingDeskLoanConfigsSet} event.

Parameters

Name
Type
Description

_lendingDeskId

uint256

Identifier for the lending desk

_nftCollection

address

Address for the NFT collection to remove supported config for

depositLendingDeskLiquidity

This function is called to add liquidity to a lending desk

Emits an {LendingDeskLiquidityDeposited} event.

Parameters

Name
Type
Description

_lendingDeskId

uint256

The id of the lending desk

_amount

uint256

The balance to be transferred

_depositLendingDeskLiquidity

withdrawLendingDeskLiquidity

This function is called to cash out a lending desk

Emits an {LendingDeskLiquidityWithdrawn} event.

Parameters

Name
Type
Description

_lendingDeskId

uint256

The id of the lending desk to be cashout

_amount

uint256

Amount to withdraw from the lending desk

setLendingDeskState

This function can be called by the lending desk owner in order to freeze it

Emits an {LendingDeskStateSet} event.

Parameters

Name
Type
Description

_lendingDeskId

uint256

ID of the lending desk to be frozen

_freeze

bool

Whether to freeze or unfreeze

initializeNewLoan

This function can be called by a borrower to create a loan

Emits an {NewLoanInitialized} event

Parameters

Name
Type
Description

_lendingDeskId

uint64

ID of the lending desk related to this offer

_nftCollection

address

The NFT collection address to be used as collateral

_nftId

uint64

ID of the NFT to be used as collateral

_duration

uint32

Loan duration in hours

_amount

uint256

Amount to ask on this loan in ERC20

_maxInterestAllowed

uint32

getLoanAmountDue

This function can be called by anyone to get the remaining due amount of a loan

Parameters

Name
Type
Description

_loanId

uint256

ID of the loan

makeLoanPayment

This function can be called by the obligation note holder to pay a loan and get the collateral back

Emits an {LoanPaymentMade} event.

Parameters

Name
Type
Description

_loanId

uint256

ID of the loan

_amount

uint256

The amount to be paid, in erc20 tokens

_resolve

bool

Whether to resolve the loan or not. If true, _amount is ignored.

liquidateDefaultedLoan

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.

Parameters

Name
Type
Description

_loanId

uint256

ID of the loan

setLoanOriginationFee

Allows the admin of the contract to modify loan origination fee.

Emits an {LoanOriginationFeeSet} event.

Parameters

Name
Type
Description

_loanOriginationFee

uint256

Basis points fee the borrower will have to pay to the platform when borrowing loan

setPlatformWallet

Allows the admin of the contract to set the platform wallet where platform fees will be sent to

Emits an {PlatformWalletSet} event.

Parameters

Name
Type
Description

_platformWallet

address

Wallet where platform fees will be sent to

setPaused

Allows the admin of the contract to pause the contract as an emergency response.

Emits either a {Paused} or {Unpaused} event.

Parameters

Name
Type
Description

_paused

bool

Whether to pause or unpause

Events

NewLendingDeskInitialized

Event that will be emitted every time a lending desk is created

LendingDeskLoanConfigsSet

Event that will be emitted every time a lending desk config is created

LendingDeskLoanConfigRemoved

Event that will be emitted every time a lending desk config is removed

LendingDeskLiquidityDeposited

Event that will be emitted every time liquidity is added to a lending desk

LendingDeskLiquidityWithdrawn

Event that will be emitted every time there is a cash out on a lending desk

LendingDeskStateSet

Event that will be emitted every time a lending desk is frozen// unfrozen

NewLoanInitialized

Event that will be emitted every time a new offer is accepted

LoanPaymentMade

Event that will be emitted every time a borrower pays back a loan

DefaultedLoanLiquidated

Event that will be emitted every time a loan is liquidated when the obligation note holder did not pay it back in time

ProtocolInitialized

Event that will be when the contract is deployed

LoanOriginationFeeSet

Event that will be emitted every time an admin updates loan origination fee

PlatformWalletSet

Event that will be emitted every time an admin updates the platform wallet

Errors

ObligationNotesIsZeroAddr

LendingKeysIsZeroAddr

ERC20IsZeroAddr

InvalidLendingDeskId

CallerIsNotLendingDeskOwner

MinAmountIsZero

MaxAmountIsLessThanMin

MinInterestIsZero

MaxInterestIsLessThanMin

MinDurationIsZero

MaxDurationIsLessThanMin

InvalidInterest

InvalidNFTCollection

LendingDeskIsNotActive

InsufficientLendingDeskBalance

UnsupportedNFTCollection

AmountIsZero

LendingDeskIsNotFrozen

InvalidLoanId

LendingDeskIsNotEmpty

LoanAmountTooLow

LoanAmountTooHigh

LoanDurationTooLow

LoanDurationTooHigh

LoanIsNotActive

CallerIsNotBorrower

CallerIsNotLender

LoanHasNotDefaulted

LoanHasDefaulted

PlatformWalletIsZeroAddr

LoanMustBeActiveForMin1Hour

LoanPaymentExceedsDebt

InterestRateTooHigh

Last updated