Refundable Bonding Curve

Purpose

The SuperMemeRefundableBondingCurve contract implements a bonding curve mechanism that allows users to buy tokens and request refunds under specific conditions. It ensures fair token distribution and provides the option to retrieve invested ETH when needed.


Core Functions

buyTokens(uint256 _amount)

Description: Enables users to purchase tokens using ETH. The cost is dynamically calculated based on the bonding curve mechanism.

Parameters:

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

Requirements:

  • _amount > 0.

  • msg.value must meet the minimum buy amount.

  • The bonding curve must not be completed.

  • The contract must not be in refund-only mode.

Behavior:

  1. Verifies user eligibility and calculates the token cost.

  2. Deducts a trade tax and mints tokens to the buyer.

  3. Tracks buyer-specific data, such as ETH contributions and buy points.

  4. If the bonding curve completes, triggers sendToDex.

Returns: None.


refund()

Description: Allows users to request a refund for their purchased tokens if the bonding curve is incomplete.

Requirements:

  • User must have a buy history and not have already requested a refund.

  • The bonding curve must not be completed.

Behavior:

  1. Calculates the refund amount based on the user’s balance and contributions.

  2. Deducts a trade tax and redistributes part of the tokens to other buyers.

  3. Returns the net ETH amount to the user.

  4. Updates user’s status to indicate a refund.

Returns: None.



View Functions

calculateCost(uint256 _amount)

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

Parameters:

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

Returns:

  • uint256: The calculated ETH cost for _amount tokens.


calculateTokensRefund()

Description: Determines the number of tokens to be refunded and redistributed based on the user’s contribution.

Returns:

  • uint256: The number of tokens refunded to the user.

  • uint256: The number of tokens redistributed to other buyers.


remainingTokens()

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

Returns:

  • uint256: The number of tokens remaining for sale.


The above functions enable seamless token transactions and dynamic pricing while ensuring user refunds are handled fairly. For more details, refer to the smart contract implementation or contact the development team.


Last updated