Function: swapTokenForETH()
The function is used to sell 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
_amountInValidation: The amount is checked to be bigger than the message value in case ETH amount is used.
Impact: The amount of tokens to sell.
_amountOutMinValidation: The quoted amount is checked to be greater than or equal to
_amountOutMin; otherwise, it reverts.Impact: The minimum amount of ETH to get when tokens are sold.
_addressValidation: Checked to be a valid token address by the
tokenExistsmodifier.Impact: The token address to sell.
_isWETHValidation: No validation.
Impact: Decides if ETH or wETH is used to sell the token.
Branches and code coverage (including function calls)
Intended branches
Swap tokens for ETH with sufficient balance.
Swap tokens for wETH with sufficient balance.
Swap tokens for ETH and reach the DEX threshold.
Negative behaviour
Swap tokens for ETH with insufficient balance.
Swap tokens for wETH with insufficient balance.
Swap tokens already deployed for ETH.