Function: investWithToken(InvestQuoteData quoteData)
Allows users to invest in accepted ERC-20 tokens and receive lovToken in return.
Inputs
quoteData.fromTokenConstraints: There are no constraints here. But the address is validated inside the
_depositIntoReservesfunction of the OrigamiLovTokenManager contract (_manager.investWithToken(msg.sender, quoteData)->_depositIntoReserves). IffromTokenis equal to thedepositAsset, thendepositAssetwill be deposited to the_reserveToken. IffromTokenis equal to the_reserveToken, then its tokens are already deposited for the_managercontract; otherwise, the function will revert.Impact: The token that will be invested.
quoteData.fromTokenAmountConstraints: Cannot be zero.
Impact: The caller transfers the
fromTokenAmountof approved ERC-20 tokens to the OrigamiLovTokenManager contract.
quoteData.maxSlippageBpsConstraints: Is not used and is not validated.
Impact: The maximum allowed slippage of the
expectedInvestmentAmount.
quoteData.deadlineConstraints: Is not used and is not validated.
Impact: The maximum deadline to execute the transaction.
quoteData.expectedInvestmentAmountConstraints: Is not used and is not validated.
Impact: The expected amount of this lovToken token to receive in return.
quoteData.minInvestmentAmountConstraints: There is a check inside
_manager.investWithToken(msg.sender, quoteData)thatinvestmentAmountis not less thanquoteData.minInvestmentAmount.Impact: The minimum amount of lovTokens to receive.
quoteData.underlyingInvestmentQuoteDataConstraints: Is not used and is not validated.
Impact: Extra quote parameters.
Branches and code coverage
Intended branches
The expected amount of lovTokens was minted for the
msg.sender.
Negative behavior
quoteData.fromTokenis not a trusted contract.The caller does not own enough
fromTokentokens.quoteData.fromTokenAmountis zero
Function call analysis
SafeERC20.safeTransferFrom(IERC20(quoteData.fromToken), msg.sender, address(_manager), 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 a nonreentrant modifier.
_manager.investWithToken(msg.sender, quoteData)What is controllable?
quoteData.If the return value is controllable, how is it used and how can it go wrong? The function returns the number of lovTokens that will be minted for the caller. The
investmentAmountis not less thanquoteData.minInvestmentAmount.What happens if it reverts, reenters or does other unusual control flow? The
_manageris a trusted contract that is not controlled by the caller.