Function: swapETHForToken()
The function is used to buy tokens. If the real ETH reserve reaches a certain threshold, the tokens and the ETH reserve are sent in a DEX pool through a router.
Inputs
_amountIn
Validation: The amount is checked to be bigger than the message value in case ETH amount is used.
Impact: The amount of tokens to buy.
_amountOutMin
Validation: The quoted amount is checked to be greater than or equal to
_amountOutMin
; otherwise, it reverts.Impact: The minimum amount of tokens to buy.
_address
Validation: Checked to be a valid token address by the
tokenExists
modifier.Impact: The token address to buy.
_isWETH
Validation: No validation.
Impact: Decides if ETH or wETH is used to buy the token.
Branches and code coverage (including function calls)
Intended branches
Swap ETH for tokens with sufficient balance.
Swap wETH for tokens with sufficient balance.
Swap ETH for tokens and reach the DEX threshold.
Negative behaviour
Swap ETH for tokens with insufficient balance.
Swap wETH for tokens with insufficient balance.
Swap ETH for tokens already deployed.