Function: sellTokens(address token, uint256 amount)
The function allows the caller to sell tokens they own associated with a specific hashtag. The current sell price is calculated differently than the buy price, and it is the minimum of two prices: the first one depends on the current liquidity and full price of all tokens, and the second depends on viralityScore and supply. The function is available only whenNotPaused.
Inputs
tokenValidation:
onlyRegistered(token).Impact: The hashtag token address that the caller wants to sell.
amountValidation: If the balance of the caller
IERC20(token).balanceOf(msg.sender)is less than amount, the function will revert.Impact: The amount of token to buy.
Branches and code coverage (including function calls)
Intended branches
The caller received the expected amount of
paymentToken.
Negative behavior
The caller does not own enough hashtag tokens to sell.
The
tokenis not registered.The contract is paused.
Function call analysis
getSellPrice(token, amount)External/Internal? Internal.
Argument control?
tokenandamount.Impact: Calculates the current price for selling the specified amount of tokens.
IERC20(token).balanceOf(msg.sender)External/Internal? External.
Argument control?
tokenandamount.Impact: Returns the current hashtag token balance for the caller account to be sure that the caller owns enough tokens.
TrendingERC20(token).burn(msg.sender, amount)External/Internal? External.
Argument control?
tokenandamount.Impact: Burn the hashtag tokens from the caller account.
IERC20(paymentToken).safeTransfer(msg.sender, totalPrice);External/Internal? External.
Argument control? N/A.
Impact: Transfers the amount of
paymentTokenfor the token sale to the caller of the function.