Close
How to close a margin tarde.
Close a position by swapping the collateral back to loan tokens, paying back the loan to the lender and withdrawing the remainder either in the loan or the collateral currency.
Arguments
loanId
bytes32
The id of the loan.
receiver
address
The receiver of the remainder (unused collateral + profit).
swapAmount
uint256
Defines how much of the position should be closed and is denominated in collateral tokens. If swapAmount >= collateral, the complete position will be closed.
returnTokenIsCollateral
bool
Defines if the remainder should be paid out in the loan or the collateral currency.
bytes
loanId The id of the loan.
Returns
The amount of the loan which was closed, the amount of tokens sent to the receiver, the address of the tokens sent to the receiver (loan or collateral)
Last updated