Skip to main content

Overview

Prophet’s on-chain logic is implemented in five Solidity contracts (^0.8.20), all deployed on 0G Chain. Each contract has a single responsibility. Together they implement a complete prediction market protocol with protocol-owned liquidity and AI-driven resolution. Repository path: contracts/src/ Build framework: Foundry (forge build, forge test) Libraries: OpenZeppelin Contracts ^5.0.0

ProphetFactory

File: contracts/src/ProphetFactory.sol Address: 0xEd51e3d6Ba8914875616bBcDd9aa9D4A00B27bD4 The factory is the entry point for market creation and the registry for all markets. It deploys each new MarketContract and wires it to the shared infrastructure (oracle agent, market-maker agent, PositionVault, PayoutDistributor).

Key Functions

Constructor Parameters


MarketContract

File: contracts/src/MarketContract.sol Deployed: One per market (by ProphetFactory) The core contract. Implements the binary YES/NO AMM, holds all market collateral (USDT), manages the complete market lifecycle, and enforces resolution rules.

Market Lifecycle

AMM Functions

Resolution Functions

View Functions

Security

  • ReentrancyGuard on all state-changing external functions
  • Checks-Effects-Interactions: all state updates happen before external token transfers
  • SafeERC20: all token operations use safeTransfer / safeTransferFrom
  • Non-zero checks: zero-amount trades revert with a descriptive error
  • Slippage protection: minSharesOut / minCollateralOut parameters on all trades

USDT Decimal Rule

USDT uses 6 decimal places throughout all Prophet contracts. 100 USDT = 100_000_000 in contract units. Never use parseEther. Always use parseUnits("100", 6).

LiquidityPool

File: contracts/src/LiquidityPool.sol Address: 0x13AbE644693DA19f9A895C8c82Cf53879580DA8e Holds protocol-owned USDT and provides it to markets on demand. The market-maker agent controls allocation. No human LP is required.

Key Functions

The LiquidityPool is the economic foundation of Prophet’s protocol-owned liquidity model. By keeping funds here rather than requiring per-market LPs, Prophet ensures every market has immediate liquidity at creation.

PositionVault

File: contracts/src/PositionVault.sol Address: 0x89FAcA46A2782b4751F697ddFe0A0b9124Eb794E Stores encrypted bet commitments and enforces atomic position reveal. Users commit positions here; the oracle reveals them after resolution.

Key Functions

TEE Attestation (MVP Status)

The function signature is in place. The full hardware TEE integration is the next step beyond MVP.

PayoutDistributor

File: contracts/src/PayoutDistributor.sol Address: 0x238D341Bb358AC7C8Ae0A22b35897bECE97b9740 Calculates winner payouts after position reveal. Handles fee splits and prevents double distribution.

Key Functions

Fee Distribution

When distributePayout is called:
  1. Total pool collateral is retrieved from MarketContract
  2. Winning positions are summed (from PositionVault reveal data)
  3. Fees are deducted: oracle fee + market-maker fee + protocol fee
  4. Remaining collateral is split proportionally among winning positions
  5. Each winner receives: (their position size / total winning positions) * (pool - fees)
Double distribution prevention: The hasDistributed mapping is set to true on the first call. Any subsequent call to distributePayout for the same market reverts. This is an absolute safety check — it cannot be bypassed.

Deployment Order

The contracts have circular dependencies that must be resolved at deploy time:
The deploy script at contracts/script/Deploy.s.sol handles all of this automatically.

OpenZeppelin Contracts Used


Forge Commands