Withdraw
The withdrawal flow enables users to take out already supplied collateral. The following sections will explain what you need to do to withdraw successfully.
Transactional Function Sequence
withdrawCollateral
updateLoan
Step 1: Withdraw
function withdraw(bytes withdrawData, uint256 value, address onBehalf, string lenderName, uint256 loanId)
withdrawData
The withdrawal data for the lender -
bytes memory _withdrawBytesData =
abi.encode(_lenderProviderAddress, _collateralToken, _collateralAmount, _userAddress);
value
Ether value
onBehalf
The users eth address
lenderName
The name of the lender
loanId
The users loan Id
Step 2: Update Loan Info
function updateLoan(bytes loanInfo, address user, uint256 loanId, UpdateField)
loanInfo
The new loan Info for the user
New collateral amount = Old - New
bytes memory loanInfo = abi.encode(new collateral amount)
user
The users eth address
loanId
The users loan Id
UpdateField
This will by default be set to 0
End of withdraw
Last updated