Further Information & Resources
How can we add more debt to a user at their request?
If a user has already supplied and borrowed and wishes to borrow again we can recall the borrow functions. The specific function that would called would be borrow which would call the third-party lender and then update loan info to reflect the users' debt that has been added.
Step 1: borrow
function borrow(bytes borrowData, uint256 value, address onBehalf, string lenderName, uint256 loanId, bool isUnprotected)
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 2: Update Loan Info
function updateLoan(bytes loanInfo, address user, uint256 loanId, UpdateField)
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
How can we add more collateral to a user at their request?
If a user has already supplied and wishes to supply more collateral we will call the following function, note this function is not the initiate supply function as that is to be called ONLY on the first supply. After you call supply successfully please run the update loan info function to reflect the new collateral amount.
Step 1: Supply
function supply(uint256 value, address onBehalf, string lenderName, bytes supplyData, uint256 uniqueId, bool isUnprotected)
value
Ether Value
onBehalf
The users eth address
lenderName
The name of the lender
supplyData
The supply data for the lender. Note inside the data the lender provider address will be based on the network please check (here) for lender provider addresses. The supply data that will be needed is the following -
bytes memory _supplyBytesData =
abi.encode(collateralToken_, collateralAmount_, lenderProviderAddress_, onBehalf_);
uniqueId
The unique id that points to a users loan id
isUnprotected
The indication we are working with a forecloseable but unprotected asset
Step 2: Update Loan Info
function updateLoan(bytes loanInfo, address user, uint256 loanId, UpdateField)
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
How can an unprotected user become protected?
For a user who is not protected in the life cycle of their position we can call the function that we called to set the protection for the protected user please check here for the function you need to call. This will be the only function the user needs to call in order for protection to be added to their loan.
How can a user cancel their protection?
There are currently 2 ways a user can cancel their protection directly and indirectly. The direct approach is the following. The in-direct approach would be if a user calls to repay while under active protection. Please check here for the in-direct cancelation aswell note you need to approve the repay amount and the cancelation fee amount.
cancelProtection
Step 1: Cancel Protection
function cancelProtection(uint256 loanId,address onBehalf)
loanId
The users loan token Id
onBehalf
The users eth address
Resources
Lender Provider Addresses
Lender Token Addresses
Last updated