hicommonwealth / commonwealth

A platform for decentralized communities
https://commonwealth.im
GNU General Public License v3.0
68 stars 44 forks source link

🪣 Launchpad Platform Bucket #9393

Open Rotorsoft opened 2 months ago

Rotorsoft commented 2 months ago

Description

Bucket ticket with issues associated to Launchpad platform work

Project Owner

@rotorsoft

PRD

#9360

Tasks

Design Links

No response

Design Screenshots

No response

Additional Context

Here is the prior Miro Board

As part of the ERC20 Launchpad, users may create coins. Coins are similar to stake.

they have a short name (ticker) launchpad address (not optional) UniV3 pool address (optional) may be associated with a community Coins may be bought and sold. They exist in two phases 1) launchpad 2) launched.

In the launchpad phase, the goal is for coins to reach a target fund amount raised. Which is hardcoded. Therefore, we should leverage similar infrastructure to track price, amt bought and sold.

In the launched phase, coins are added to Uniswap, where they may be exchanged permissionlessly.


Link to Github

/**
 * @title Launchpad
 * @notice This contract orchestrates the creation of new tokens and their initial distribution and liquidity setup.
 *         It utilizes the LPBondingCurve for managing liquidity and CurveManager for pricing mechanisms.
 */
contract Launchpad {
    LPBondingCurve public bondingCurve;     // External contract references for functionalities.
    ICurveActionHook public curveActionHook; 

    address public defaultLPHook;        // The default liquidity hook contract address
    address public protocolVault;        // The address protocol commision fees will sent to
    address public bondingCurveAddress;  // The address of the Launchpad Bonding Curve enabler (LPBondingCurve) contract
    uint256 public protocolFee;          // The protocol fee percentage

    event LaunchpadCreated( address launchpad);

    event NewTokenCreated( address token );

    event TokenRegistered( address token, uint256 curveId );
contract LPBondingCurve { 

    struct Token {
        uint256 launchpadLiquidity;  // Liquidity reserved for launchpad activities
        uint256 poolLiquidity;       // Liquidity reserved for pooling purposes
        address[] unlockHolders;     // Addresses that tokens will be unlocked for over time
        uint256[] amounts;           // Corresponding shares for each unlockHolders
        uint256 curveId;             // ID of the curve used for pricing
        uint256 scalar;              // Scalar used for adjusting pricing calculations
        uint32 reserveRatio;         // ratio determining the shape of the bonding curve
        address LPhook;              // Hook address for liquidity pool operations
        bool funded;                 // Flag to check if the token setup is complete and funded
    }

    /**
    * @notice Struct to hold the parameters required to register a new token with the bonding curve.
    *         This struct is used to pass the necessary information from the launchpad contract to the bonding curve.
    */

    struct RegisterTokenParams {
        address _tokenAddress; // Address of the token to be registered.
        uint256 _curveId;      // ID of the curve used for pricing.
        uint256 _scalar;       // Scalar used for adjusting pricing calculations.
        uint32 _reserveRatio;  // reserve ratio determining the shape of the curve
        uint256 totalSupply;   // Total supply of the token.
        address[] holders;     // Addresses that tokens will be unlocked for over time.
        uint256[] shares;      // Corresponding shares for each unlockHolder.
        address LPHook;        // Hook address for liquidity pool operations.
    }

    uint256 constant PRECISION = 1e14;            // Precision factor for floating point calculations
    address public launchpad;                     // Address of the launchpad contract
    address public protocolFeeDestination;        // Destination address for protocol fees
    address public LPCurveManager;                // Address of the CurveManager for price calculations
    ICurveActionHook public curveActionHook;      // Interface for calling pre/post-transaction hooks
    uint256 immutable public protocolFeePercent;  // Percentage of each transaction taken as a fee
    mapping(address => Token) public tokens;      // Mapping of token addresses to main Token struct information
    mapping(address => uint256) public liquidity; // Mapping of token addresses to liquidity amounts

    //Custom Reentrancy guard settings 
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;
    uint256 private _status;

    event Trade(
        address trader, 
        address namespace, 
        bool isBuy, 
        uint256 communityTokenAmount, 
        uint256 ethAmount, 
        uint256 protocolEthAmount, 
        uint256 supply
    );

    event TokenRegistered(
        address token, 
        uint256 curveId,
        uint256 totalSupply    
    );

    modifier launchpadOnly() {
        require(msg.sender == launchpad);
        _;
    }
dillchen commented 1 week ago

I believe this bucket is technically done, cc: @timolegros for confirmation