Function: recall(uint256 _value)
This allows a user to close a position (e.g., deleverage the value of what was deposited).
Inputs
_value
Control: Fully controlled by the caller.
Constraints: Checked to be a valid amount of collateral to be recalled.
Impact: Amount of collateral to be recalled.
Branches and code coverage (including function calls)
Intended branches
Verify that the collateral amount is valid.
If the collateral amount is valid, then deleverage the value of what was deposited.
If what was deposited is more than what can be repaid, then repay all the debt and send the surplus back to the sender.
Otherwise, repay what is possible and make sure user is still within correct collateralization limits.
Receive the swapped collateral as a result of the deleverage (essentially
max_deposit
).Ensure that debt is zero after a full recall.
Negative behavior
If the collateral amount is invalid, then revert.
Should not allow user to recall more than what they have deposited.
Should not allow recalling on behalf of another user.
Should not allow calling if debt is zero.