Vortx
WebsiteDiscordTwitter/XLaunch App
  • Background
    • 👋Welcome to VORTX
    • ⁉️What is VORTX?
  • Platform Overview
    • 🚀Getting Started with VORTX
    • 🔎How Prediction Markets Work
    • 🆕Create New Markets
    • 🗒️How Market Resolutions Work
    • 💰Oracle Rewards
    • 💸Fees and Economics
  • Technical Details
    • 🔧Technical Overview
    • 🏭Factory Contract
  • 🔮Prediction Market Contract
  • 📘OrderBook Contract
  • About VORTX
    • 💵Tokenomics
Powered by GitBook

© 2025 VORTX. All rights reserved.

On this page
  • PredictionMarketFactory Contract
  • Core Functionality
  • Main Functions
  • Market Deployment Process
  • Events
  • Access Control
  • Integration Points
  • Error Handling
  • Gas Optimization
  • Usage Examples
  1. Technical Details

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 contracts

  • Collect 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

IERC20 public vortxToken;           // VORTX token for fees
IERC20 public usdt0Token;           // USDT for liquidity
IOrderBook public orderBook;        // Central trading engine
address public admin;               // Admin address for oversight
uint256 public marketCreationFee;   // Fee in VORTX tokens ($50 worth)
uint256 public minimumLiquidity;    // 100 USDT minimum
mapping(uint256 => address) public markets; // marketId => market address
uint256 public nextMarketId;        // Auto-incrementing market IDs

Main Functions

createMarket()

The core function that creates new prediction markets.

function createMarket(
    string memory title,
    string memory description,
    uint256 endTime,
    string memory resolutionCriteria,
    uint256 initialLiquidity
) external returns (uint256 marketId, address marketAddress)

Parameters:

  • title: Market question (max 200 characters)

  • description: Detailed explanation and context

  • endTime: Unix timestamp when trading ends

  • resolutionCriteria: How the outcome will be determined

  • initialLiquidity: USDT amount (minimum 100)

Process:

  1. Validate inputs: Check title length, end time, liquidity amount

  2. Collect VORTX fee: Transfer $50 worth of VORTX from creator

  3. Deploy market contract: Create new PredictionMarket instance

  4. Transfer initial liquidity: Move USDT from creator to market

  5. Mint initial tokens: Market creates YES/NO tokens for creator

  6. Register with OrderBook: Enable trading for the new market

  7. Emit events: Log market creation for indexing

Returns:

  • marketId: Unique identifier for the market

  • marketAddress: Address of the deployed market contract

getMarketInfo()

Retrieve information about any market.

function getMarketInfo(uint256 marketId) external view returns (
    address marketAddress,
    string memory title,
    uint256 endTime,
    bool isResolved,
    uint256 totalVolume
)

updateMarketCreationFee()

Admin function to adjust creation fee based on VORTX price.

function updateMarketCreationFee(uint256 newFeeInVORTX) external onlyAdmin

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

// Calculate current fee in VORTX tokens
uint256 feeAmount = marketCreationFee; // Updated by admin based on VORTX price
require(vortxToken.transferFrom(msg.sender, address(this), feeAmount), "Fee payment failed");

2. Market Contract Deployment

// Deploy new market using CREATE2 for deterministic addresses
bytes32 salt = keccak256(abi.encodePacked(nextMarketId, msg.sender, block.timestamp));
PredictionMarket newMarket = new PredictionMarket{salt: salt}(
    title,
    description,
    endTime,
    resolutionCriteria,
    address(usdt0Token),
    msg.sender // market creator
);

3. Initial Liquidity Processing

// Transfer USDT from creator to market
require(usdt0Token.transferFrom(msg.sender, address(newMarket), initialLiquidity), "Liquidity transfer failed");

// Market automatically mints YES/NO tokens to creator
newMarket.processInitialLiquidity(msg.sender, initialLiquidity);

4. OrderBook Registration

// Register market with central trading engine
orderBook.registerMarket(
    nextMarketId,
    address(newMarket),
    newMarket.yesToken(),
    newMarket.noToken()
);

Events

MarketCreated

event MarketCreated(
    uint256 indexed marketId,
    address indexed creator,
    address marketAddress,
    string title,
    uint256 endTime,
    uint256 initialLiquidity
);

FeeUpdated

event FeeUpdated(uint256 oldFee, uint256 newFee, uint256 timestamp);

Access Control

Admin Functions

  • updateMarketCreationFee(): Adjust fee based on VORTX price

  • setOrderBook(): Update OrderBook address if needed

  • emergencyPause(): Pause market creation in emergencies

Public Functions

  • createMarket(): Anyone can create markets

  • getMarketInfo(): Read market data

  • getAllMarkets(): List all created markets

Integration Points

With OrderBook

// Factory tells OrderBook about new market
orderBook.registerMarket(marketId, marketAddress, yesToken, noToken);

With PredictionMarket

// Factory deploys market with required parameters
PredictionMarket market = new PredictionMarket(params...);

With VORTX Treasury

// Collected fees go to treasury
vortxToken.transfer(treasury, collectedFees);

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

require(bytes(title).length <= 200, "Title too long");
require(endTime > block.timestamp + 1 hours, "End time too soon");
require(initialLiquidity >= minimumLiquidity, "Insufficient liquidity");
require(vortxToken.allowance(msg.sender, address(this)) >= marketCreationFee, "Insufficient VORTX allowance");

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)

// 1. Approve VORTX tokens for fee
await vortxToken.approve(factoryAddress, feeAmount);

// 2. Approve USDT for initial liquidity
await usdtToken.approve(factoryAddress, liquidityAmount);

// 3. Create the market
const tx = await factory.createMarket(
    "Will Bitcoin reach $150,000 by December 31, 2025?",
    "Market resolves to YES if Bitcoin (BTC) closes above $150,000 on any major exchange (Coinbase, Binance, Kraken) on December 31, 2025 at 11:59 PM UTC.",
    1735689599, // Dec 31, 2025 timestamp
    "Price data from CoinGecko API at market close time",
    ethers.utils.parseEther("100") // 100 USDT initial liquidity
);

const receipt = await tx.wait();
const marketId = receipt.events.find(e => e.event === 'MarketCreated').args.marketId;

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.

PreviousTechnical OverviewNextPrediction Market Contract

Last updated 1 day ago

🏭