Function: investWithToken(InvestQuoteData quoteData)
Allows users to invest reserveToken or approved ERC-20 tokens. If the global variable allowAll is true, the msg.sender is not validated. Otherwise, if the address is not a contract, the allowedAccounts should contain the msg.sender address. In exchange, msg.sender will receive the Origami investment tokens.
Inputs
quoteData.fromTokenConstraints: It can be
reserveTokenor approved ERC-20 token to invest toreserveTokencontract.Impact: If
quoteData.fromToken == reserveToken, thenreserveTokenis enough to just transferfromTokenAmountto this contract frommsg.sender. Otherwise,fromTokenwill be transferred to this contract, and after that, invested to thereserveTokencontract.
quoteData.fromTokenAmountConstraints: Cannot be equal to zero.
Impact: The amount of tokens to invest.
quoteData.underlyingInvestmentQuoteDataConstraints: N/A.
Impact: Extra quote parameters that will be provided to the
reserveToken.investWithToken()function for investingfromTokentokens to thereserveTokencontract.
Branches and code coverage
Negative behavior
Non-whitelisted caller
quoteData.fromTokenis not an approved token address.The caller does not own enough
fromTokentokens.investmentAmountis less thanquoteData.minInvestmentAmount.quoteData.fromTokenandquoteData.underlyingInvestmentQuoteData.fromTokenare different.quoteData.fromTokenAmountis less thanquoteData.underlyingInvestmentQuoteData.fromTokenAmount.
Function call analysis
SafeERC20.safeTransferFrom(IERC20(this.reserveToken), msg.sender, address(this), reservesAmount)What is controllable?
reservesAmount.If the return value is controllable, how is it used and how can it go wrong? No return value.
What happens if it reverts, reenters or does other unusual control flow? Can revert if
msg.senderdoes not have enoughreserveTokento transfer. The functioninvestWithTokenhas non-reentrant modifier.
SafeERC20.safeTransferFrom(IERC20(quoteData.fromToken), msg.sender, address(this), quoteData.fromTokenAmount)What is controllable?
quoteData.fromTokenandquoteData.fromTokenAmount.If the return value is controllable, how is it used and how can it go wrong? No return value.
What happens if it reverts, reenters or does other unusual control flow? Can revert if
msg.senderdoes not have enoughfromTokento transfer. The functioninvestWithTokenhas non-reentrant modifier.
IOrigamiInvestment(this.reserveToken).investWithToken(underlyingQuoteData)What is controllable?
underlyingQuoteData.If the return value is controllable, how is it used and how can it go wrong? Return amount of received tokens in exchange of invested tokens.
What happens if it reverts, reenters or does other unusual control flow? Can revert if
quoteData.underlyingInvestmentQuoteData.fromTokenis not an approved token address. Also revert ifquoteData.underlyingInvestmentQuoteData.fromTokenAmountis more thanquoteData.fromTokenAmount.
this._issueSharesFromReserves(reservesAmount, msg.sender, quoteData.minInvestmentAmount)What is controllable?
reservesAmountandquoteData.minInvestmentAmount.If the return value is controllable, how is it used and how can it go wrong? Return the minted shares amount — in case it is less than
minSharesAmount, the function will revert.What happens if it reverts, reenters or does other unusual control flow? N/A.