Function: exitToToken(ExitQuoteData quoteData, address recipient)
Allows users to withdraw investment funds from the Origami investment vault.
### Inputs
quoteData.investmentTokenAmountConstraints: Cannot be zero, and the caller must own a sufficient amount.
Impact: The amount of shares to sell. Shares will be burned from the caller account.
quoteData.toTokenConstraints: Can be equal to the
reserveTokenor approved ERC-20.Impact: The
recipientwill receive these tokens in return —toTokenshould be an accepted ERC-20 token orreserveToken.
quoteData.underlyingInvestmentQuoteDataConstraints: No constraints.
Impact: Extra quote parameters that will be provided to the
reserveToken.exitToToken().
recipientConstraints: Cannot be zero address.
Impact: The receiver of the
toToken.
Branches and code coverage
Negative behavior
Verify that result does not depend on user's
underlyingQuoteData.underlyingExitQuoteData.investmentTokenAmount(the user controls this field, but it will be overwritten by the function thus, the user's value should not affect the result).toTokenis not approved.The caller owns fewer than
quoteData.investmentTokenAmountshares tokens.
Function call analysis
this._redeemReservesFromShares(quoteData.investmentTokenAmount, msg.sender, quoteData.minToTokenAmount, recipient)What is controllable?
quoteData.investmentTokenAmount,quoteData.minToTokenAmount, andrecipient.If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? The function converts user's shares amount to reserve tokens and burns this
sharesAmountfrom the user balance. IfquoteData.toToken == reserveToken, this contract will transferreserveTokento receiver. Also, the function performs a slippage check thatreserveTokenAmountis not less than expectedminReserveTokenAmount.
IOrigamiInvestment(this.reserveToken).exitToToken(underlyingQuoteData.underlyingExitQuoteData, recipient)What is controllable?
underlyingQuoteData.underlyingExitQuoteDataandrecipient.If the return value is controllable, how is it used and how can it go wrong? Returns the number of tokens received by the recipient. If
toTokenAmount < quoteData.minToTokenAmount, the function will revert.What happens if it reverts, reenters or does other unusual control flow? The function can revert if
underlyingQuoteData.underlyingExitQuoteData.toTokenis not accepted by thereserveTokencontract.