Locking Curve

The SuperMemeLockingCurve contract implements a bonding curve mechanism where tokens are locked for a specific duration based on the price at the time of purchase. It ensures fair token distribution, locking periods, and dynamic pricing based on demand.


Core Functions

buyTokens(uint256 _amount)

Description: Allows users to purchase tokens with ETH. Tokens are locked for a specific duration determined by the bonding curve mechanism.

Parameters:

  • _amount (uint256): The number of tokens the user wishes to purchase.

Requirements:

  • _amount > 0.

  • The bonding curve must not be completed.

  • The user must not have tokens already locked.

  • The user must send sufficient ETH to cover the cost and trade tax.

Behavior:

  1. Verifies user eligibility and calculates the cost of _amount tokens.

  2. Deducts a trade tax and calculates the lock duration for the purchased tokens.

  3. Mints tokens to the user and locks them for the calculated duration.

  4. Updates the contract's state, including scaled supply and total ETH collected.

  5. Returns any excess ETH sent by the user.

Returns: None.


sendToDex()

Description: Transfers liquidity (ETH and tokens) to a decentralized exchange (DEX) after the bonding curve is completed or scaled bonding threshold is reached.

Requirements:

  • The bonding curve must be completed or scaled bonding threshold reached.

  • At least 5 users must vote to send liquidity to the DEX.

Behavior:

  1. Verifies voting eligibility and transfers a small reward to voters.

  2. Uses UniswapV2Router to add liquidity.

  3. Finalizes the DEX stage.

Returns: None.


sellTokens(uint256 _amount, uint256 _minimumEthRequired)

Description: Allows users to sell their tokens back to the contract for ETH.

Parameters:

  • _amount (uint256): The number of tokens the user wishes to sell.

  • _minimumEthRequired (uint256): The minimum ETH the user expects to receive (slippage protection).

Requirements:

  • _amount > 0.

  • The bonding curve must not be completed.

  • Tokens must not be locked.

  • The contract must have sufficient ETH to refund the user.

Behavior:

  1. Calculates the refund amount based on _amount.

  2. Deducts a trade tax from the refund.

  3. Transfers the net ETH to the user and burns the sold tokens.

  4. Updates the contract's state, including scaled supply and total ETH collected.

Returns: None.


View Functions

calculateCost(uint256 _amount)

Description: Calculates the cost of purchasing _amount tokens based on the bonding curve.

Parameters:

  • _amount (uint256): The number of tokens to calculate the cost for.

Returns:

  • uint256: The ETH cost for _amount tokens.


calculateRefund(uint256 _amount)

Description: Calculates the refund amount for selling _amount tokens based on the bonding curve.

Parameters:

  • _amount (uint256): The number of tokens to calculate the refund for.

Returns:

  • uint256: The ETH refund for _amount tokens.


remainingTokens()

Description: Returns the number of tokens available for purchase before the bonding curve completes.

Returns:

  • uint256: The number of tokens remaining for sale.


checkRemainingLockTime(address _address)

Description: Checks the remaining lock duration for a specific address.

Parameters:

  • _address (address): The address of the user to check.

Returns:

  • uint256: The remaining lock time in seconds. Returns 0 if the lock has expired.


calculateNextLockTime()

Description: Predicts the lock duration for the next user based on current supply and locking logic.

Returns:

  • uint256: The predicted lock time in seconds.


Last updated