ApexDorkon/Fair-Launch-Bonding-Curve
Mathematical token launchpad featuring quadratic bonding curves, oracle-managed lifecycles, and automated graduation.
README
๐ Fair Launch Protocol: Mathematical Bonding Curve
A decentralized, autonomous token launchpad protocol inspired by the "fair launch" model. This protocol leverages a Quadratic Bonding Curve to ensure continuous liquidity, organic price discovery, and a bot-resistant graduation phase.
Designed for the Moca Network, the system automates the transition from a bonding curve to a secondary market (DEX) once a specific funding goal is met.
๐ System Architecture
The protocol is split into two primary layers to maximize security and modularity:
| Layer | Contract | Responsibility |
|---|---|---|
| Factory | TokenLaunchFactory.sol |
Deployer and registry. Manages the deployment of unique curve instances for every new token. |
| Engine | FairLaunchCurve.sol |
The mathematical core. Handles all buy/sell logic, integral math for pricing, and the final graduation event. |
๐งฎ The Mathematical Model
Unlike basic linear models, this protocol implements a Quadratic Bonding Curve. The price increases as a function of the supply squared, rewarding early adopters while preventing late-stage price stagnation.
1. Price Function
The marginal price
2. The Integral (Cost to Buy)
To ensure fairness for large transactions, the protocol calculates the Area Under the Curve (the integral) rather than using the spot price. This prevents price manipulation within a single block.
The amount of tokens received (
Where:
-
$T_0$ = Initial token supply in the curve. -
$t_1$ = Current tokens already sold. -
$\Delta m$ = MOCA amount sent to the contract.
๐ Key Features
- Fair Launch Mechanics: 100% of tokens are placed in the curve. No team allocation, no pre-sale, no "insider" advantage.
- Automated Graduation: Once the curve collects 10 MOCA (target goal), the sale is finalized. The collected liquidity is automatically transferred to a Liquidity Vault.
- Slippage Protection: Built-in slippage parameters for every
buyandselltransaction. - Native MOCA Integration: Handles native MOCA by auto-wrapping into WMOCA for consistent internal accounting.
- Oracle Lifecycle Management: High-security "Start" and "Pause" controls managed by a dedicated Oracle wallet.
๐ Execution Flow
1. Deployment
The Factory deploys a new FairLaunchCurve. The total supply is deposited into this contract, creating the initial reserve.
2. Trading Phase
Users interact with the buy() and sell() functions. As tokens are purchased, the contract stores the native MOCA in the reserve, and the price moves along the quadratic curve.
3. Graduation
When the Graduation Threshold (default 90%) is reached:
- Trading is paused via the
finalizedflag. - Collected MOCA is moved to the
vaultReceiveraddress. - The token is ready to be paired with the graduated MOCA on a secondary DEX.
๐ Setup & Deployment
Compile
npx hardhat compiletest
npx hardhat test๐ License
Released under the MIT License.