Factory Contract
PredictionMarketFactory Contract
The PredictionMarketFactory
is the entry point for creating new prediction markets on VORTX. It handles market deployment, fee collection, and registration with the trading system.
Core Functionality
Primary Purpose
Deploy new markets: Creates individual
PredictionMarket
contractsCollect creation fees: Charges $50 worth of VORTX tokens
Validate parameters: Ensures markets are properly configured
Register with OrderBook: Makes markets available for trading
Key State Variables
Main Functions
createMarket()
The core function that creates new prediction markets.
Parameters:
title
: Market question (max 200 characters)description
: Detailed explanation and contextendTime
: Unix timestamp when trading endsresolutionCriteria
: How the outcome will be determinedinitialLiquidity
: USDT amount (minimum 100)
Process:
Validate inputs: Check title length, end time, liquidity amount
Collect VORTX fee: Transfer $50 worth of VORTX from creator
Deploy market contract: Create new PredictionMarket instance
Transfer initial liquidity: Move USDT from creator to market
Mint initial tokens: Market creates YES/NO tokens for creator
Register with OrderBook: Enable trading for the new market
Emit events: Log market creation for indexing
Returns:
marketId
: Unique identifier for the marketmarketAddress
: Address of the deployed market contract
getMarketInfo()
Retrieve information about any market.
updateMarketCreationFee()
Admin function to adjust creation fee based on VORTX price.
Why this exists: As VORTX token price changes, the fee in tokens needs adjustment to maintain ~$50 USD equivalent.
Market Deployment Process
Step-by-Step Breakdown
1. Fee Collection
2. Market Contract Deployment
3. Initial Liquidity Processing
4. OrderBook Registration
Events
MarketCreated
FeeUpdated
Access Control
Admin Functions
updateMarketCreationFee()
: Adjust fee based on VORTX pricesetOrderBook()
: Update OrderBook address if neededemergencyPause()
: Pause market creation in emergencies
Public Functions
createMarket()
: Anyone can create marketsgetMarketInfo()
: Read market datagetAllMarkets()
: List all created markets
Integration Points
With OrderBook
With PredictionMarket
With VORTX Treasury
Error Handling
Common Revert Reasons
"Title too long"
: Market title exceeds 200 characters"End time too soon"
: Market ends within 1 hour"Insufficient liquidity"
: Less than 100 USDT provided"Fee payment failed"
: Not enough VORTX tokens approved"Market already exists"
: Duplicate market detection
Validation Logic
Gas Optimization
Efficient Deployment
CREATE2 for deterministic addresses: Enables off-chain address calculation
Minimal constructor parameters: Reduces deployment gas costs
Batch operations: Multiple setup steps in single transaction
Storage Optimization
Packed structs: Multiple values in single storage slot
Mapping over arrays: O(1) lookups for market data
Event-based indexing: Reduce on-chain storage needs
Usage Examples
Creating a Market (Frontend Integration)
The PredictionMarketFactory serves as the secure, validated entry point for all market creation on VORTX, ensuring consistent deployment while collecting necessary fees to fund platform development.
Last updated