Borrow

The borrow flow enables users to take out a position on a third-party lender. The following sections will explain what you need to do to borrow successfully.

Transactional Function Sequence

Make sure to run each function in order from top to bottom. Please Click the links inside the module column for further information on the function's output.

Module
Function

Step 1: setBorrowData

function setBorrowData(bytes borrowData, bytes loanUpdateInfo, address user, uint256 loanId,bytes loanInfo uint256 portfolioId, UpdateField)

Parameters
Descriptions

BorrowData

The borrow data for the loan -

bytes memory _borrowData = abi.encode(_loanToken, _loanAmount(This is in USD 8 decmials), _rateMode, _decimals, _foreclosureFee);

user

The users eth address

loanId

The users loan Id

portfolioId

The users portfolio Id

loanUpdateInfo

The update information set for the user -

bytes memory _loanUpdateInfo =
            abi.encode(_portfolioId, _collateralBalance(This is in USD 8 decimals), _loanToken, _loanAmount(This is in USD 8 decimals), ILoan.LoanStatus.UNCOVERED(2));

UpdateField

This will by default be set to 1

loanInfo

The loan info represents the users loan amount -

bytes memory _loanInfo = abi.encode(_loanAmount(This is in USD 8 decimals));

Step 2: borrow

function borrow(bytes borrowData, uint256 value, address onBehalf, string lenderName, uint256 loanId, bool isUnprotected)

Parameters
Descriptions

borrowData

The borrow data for the lender -

bytes memory _borrowBytesData =
            abi.encode(lenderProviderAddress_, loanToken_, loanAmount_(This is in wei), rateMode_, userAddress_);

value

ether value

onBehalf

The users eth address

lenderName

The name of the lender

loanId

The users loan Id

isUnprotected

The indication we are working with a forecloseable but unprotected asset

Step 3: Update Loan Info

function updateLoan(bytes loanInfo, address user, uint256 loanId, UpdateField)

Parameters
Descriptions

loanInfo

The amount that was just borrowed - bytes memory loanInfo( borrowAmount) in USD 8 decimals

user

The users eth address

loanId

The users loan Id

UpdateField

This will be be set to 1

Step 4: Update Loan Info

function updateLoan(bytes loanInfo, address user, uint256 loanId, UpdateField)

Parameters
Descriptions

loanInfo

The collateral amount bytes memory loanInfo( collateral Amount) in USD 8 decimals

user

The users eth address

loanId

The users loan Id

UpdateField

This will be be set to 0

End of Borrow

Last updated