Factory
The CoinFactory
contract is an upgradeable contract which is the canonical factory for coins.
The contract is upgradable by the freee.fun team to update coin features, but any deployed coins are immutable and cannot be updated.
Overview
The CoinFactory
implements the ICoinFactory
interface and serves as the entry point for creating new coins in the freee.fun Coins Protocol. It handles the deployment of coin contracts, their associated Uniswap V3 pools, and the initial setup of liquidity.
Key Methods
deploy
This function creates a new coin contract with the specified parameters and its associated Uniswap V3 liquidity pool.
While the currency field can be set to any ERC20, only WETH/ETH pairs are supported by our user interface and indexer at this time.
Parameters:
payoutRecipient
: The recipient of creator reward payouts; this can be updated by any owner later onowners
: An array of addresses that will have permission to manage the coin's payout address and metadata URI. Owners can update the list of approved owners as well.name
: The name of the coin (e.g., "horse galloping").symbol
: The trading symbol for the coin (e.g., "HORSE")poolConfig
: The configuration parameters for the Uniswap V3 pool, encoded as abi.encode(uint8 version, address currency, int24 tickLower, int24 tickUpper, uint16 numDiscoveryPositions, uint256 maxDiscoverySupplyShare)platformReferrer
: The address of the platform referrer who will receive a portion of trading feesorderSize
: The order size for the first buy; must match msg.value for ETH/WETH pairs
Returns:
The address of the deployed coin contract
The amount of currency used for the initial purchase (if any)
Notes:
When creating a coin with ETH/WETH, you must send ETH with the transaction equal to the
orderSize
parameterFor other currencies, the factory will pull the specified amount from your wallet (requires approval)
While the currency field in poolConfig can be set to any ERC20, only WETH/ETH pairs are fully supported by the user interface and indexer at this time
Events
TokenCreated
Emitted when a new coin is created through the factory.
Event Parameters:
caller
: The address that called the deploy functionpayoutRecipient
: The address of the creator payout recipientplatformReferrer
: The address of the platform referrercurrency
: The address of the trading currencyuri
: The metadata URI of the coinname
: The name of the coinsymbol
: The symbol of the coincoin
: The address of the newly created coin contractpool
: The address of the associated Uniswap V3 poolversion
: The version string of the coin implementation
Error Handling
The factory defines custom errors to provide specific information about failed operations:
ERC20TransferAmountMismatch
: The amount of ERC20 tokens transferred does not match the expected amountEthTransferInvalid
: ETH is sent with a transaction but the currency is not WETH
Advanced Configuration
Currency Options
When creating a coin, you have two options for the trading currency:
ETH/WETH: Use
address(0)
for the currency parameter. This is the most common option, allowing users to buy and sell coins with ETH.ERC20 Token: Specify the address of an ERC20 token. This creates a coin that trades against that specific token.
Initial Purchase
The orderSize
parameter determines the initial purchase amount when creating a coin:
Setting this to a non-zero value creates initial liquidity in the pool
For ETH/WETH coins, this amount must be sent with the transaction
For ERC20 coins, the factory must be approved to spend this amount
Tick Configuration
The tickLower
parameter affects the price curve for the Uniswap V3 pool:
For ETH/WETH pairs, this is ignored and set to a default value
For other currencies, this can be customized to affect the price range of the liquidity position
Security Considerations
The factory is the only contract allowed to create official freee.fun protocol coins
Platform referrer addresses are permanently set at creation and cannot be changed
Owner addresses have some control over the coin (metadata, payout recipient)
Initial purchases are processed through Uniswap V3 pools, subject to their slippage and price impact mechanics
Last updated