Function: buyTokens(address token, uint256 amount)
The function allows the caller to buy tokens associated with a specific hashtag. The current buy price depends on the current viralityScore and supply of the token, which may change over time, and the unchangeable initialPrice, exponent, and initialSupply values. The function is available only whenNotPaused.
Inputs
tokenValidation:
onlyRegistered(token).Impact: The hashtag-token address that the caller wants to buy.
amountValidation: The
amountof tokens is not directly validated, but the user must have enough funds to buy this amount of tokens.Impact: The amount of token to buy.
Branches and code coverage (including function calls)
Intended branches
The caller received the expected amount of tokens in exchange for the expected amount of
paymentTokentokens.
Negative behavior
The caller does not own enough
paymentTokentokens to buy theamountof hashtag tokens.The
tokenis not registered.The contract is paused.
Function call analysis
getBuyPrice(token, amount)External/Internal? Internal.
Argument control?
tokenandamount.Impact: Calculates the current price of the the requested
amountof tokens.
IERC20(paymentToken).safeTransferFrom(msg.sender, address(this), totalPrice)External/Internal? External.
Argument control? N/A.
Impact: Transfers of payment for the requested
amountof tokens.
TrendingERC20(token).mint(msg.sender, amount)External/Internal? External.
Argument control?
amount.Impact: Mints the requested amount of hashtag tokens for the caller of the function.