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
_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 sell.
_amountOutMin
Validation: 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.
_address
Validation: Checked to be a valid token address by the
tokenExists
modifier.Impact: The token address to sell.
_isWETH
Validation: 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.