Degen Bonding Curve
Purpose
The SuperMemeDegenBondingCurve
contract facilitates the creation and trading of tokens based on a bonding curve mechanism. The contract enables users to buy and sell tokens, while also managing liquidity provision to decentralized exchanges (DEXs).
Core Functions
buyTokens(uint256 _amount)
Description: Allows users to purchase tokens based on the bonding curve. The cost is dynamically calculated based on the current supply.
Parameters:
_amount
(uint256): The amount of tokens the user wants to purchase.
Requirements:
_amount > 0
The bonding curve should not be completed.
The user must send sufficient ETH to cover the token cost and applicable tax.
Behavior:
Calculates the cost of
_amount
using the bonding curve.Adds a trade tax to the total cost.
Transfers excess ETH back to the buyer if overpaid.
Mints tokens to the buyer's address.
Emits the
tokensBought
andPrice
events.Calls
sendToDex
if the bonding curve completes.
sellTokens(uint256 _amount, uint256 _minimumEthRequired)
Description: Allows users to sell tokens back to the contract for ETH. The refund amount is dynamically calculated based on the current supply.
Parameters:
_amount
(uint256): The amount of tokens the user wants to sell._minimumEthRequired
(uint256): The minimum ETH the user expects to receive.
Requirements:
The bonding curve should not be completed.
The user must hold enough tokens.
The ETH balance of the contract must be sufficient to cover the refund.
The refund amount must be greater than or equal to
_minimumEthRequired
.
Behavior:
Calculates the refund amount based on
_amount
.Deducts a trade tax from the refund.
Transfers the net refund to the seller.
Burns the sold tokens.
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 of purchasing the tokens.
calculateRefund(uint256 _amount)
Description: Calculates the refund amount for selling _amount
tokens back to the contract based on the bonding curve.
Parameters:
_amount
(uint256): The number of tokens to calculate the refund for.
Returns:
uint256
: The ETH refund for selling the tokens.
remainingTokens()
Description: Returns the number of tokens still available for purchase before the bonding curve completes.
Returns:
uint256
: The number of tokens available for sale.
Last updated