Skip to content

Shisa-Fosho/contracts

Repository files navigation

Predictions — Contracts

Smart contracts for our prediction market platform built on top of the Polymarket/Gnosis CTF infrastructure.

Architecture

Unmodified Polymarket contracts:

  • ConditionalTokens (CTF) — ERC-1155 outcome tokens, condition lifecycle (Solidity 0.5.1)
  • CTFExchange — CLOB for binary market trading via EIP-712 signed orders (0.8.15)
  • NegRiskCtfExchange — CLOB for multi-outcome event trading (0.8.15)
  • NegRiskAdapter + Vault + WrappedCollateral — neg-risk token wrapping (0.8.19)

Our contracts:

  • MarketFactory — creates conditions on CTF, supports binary/categorical/scalar markets
  • AdminOracle — resolves conditions via reportPayouts, two-step admin transfer (upgradeable to UMA)

Prerequisites

  • Foundry
  • Node.js 18+ (for CTF Hardhat deployment)
  • Funded deployer wallet on target chain

Build & Test

forge build
forge test

Deployment

Deployment is a 3-step process due to Solidity version differences across contracts.

Step 1 — ConditionalTokens (Hardhat, Solidity 0.5.1)

cd ctf-legacy
npm install
PRIVATE_KEY=0x... npx hardhat run scripts/deploy.ts --network <network>

Outputs: CTF_ADDRESS

Supported networks: sepolia, polygon, localhost (see hardhat.config.ts).

Step 2 — Vault + NegRiskAdapter (Foundry, Solidity 0.8.19)

CTF_ADDRESS=<from step 1> \
COLLATERAL_TOKEN=<USDC address> \
PRIVATE_KEY=0x... \
forge script script/DeployNegRiskAdapter.s.sol \
  --rpc-url <rpc_url> --broadcast

Outputs: Vault, NegRiskAdapter, WrappedCollateral

Step 3 — Exchanges + Oracle + Factory (Foundry, Solidity 0.8.15)

CTF_ADDRESS=<from step 1> \
COLLATERAL_TOKEN=<USDC address> \
NEG_RISK_ADAPTER=<from step 2> \
PRIVATE_KEY=0x... \
forge script script/Deploy.s.sol \
  --rpc-url <rpc_url> --broadcast

Outputs: CTFExchange, NegRiskCtfExchange, AdminOracle, MarketFactory

This script also:

  • Adds the deployer as operator on both exchanges (required for trade settlement)
  • Adds NegRiskCtfExchange as admin on the NegRiskAdapter

Deployment — Polygon (137)

Contract Address
ConditionalTokens 0xa2E381988F264A01C0Ec75820482b8E2F2Ed256C
Vault 0x292Ab0E0AEFa1245306e49b81F47436D6C200130
NegRiskAdapter 0xD7bfaa4b9B15d91ef9c872745E791cdF35adAe62
WrappedCollateral 0x7F10687A14B9B4318d04B46D278e6366E8d27418
CTFExchange 0x588a236D311a3232cE39B003Ab8b54891dBe48A4
NegRiskCtfExchange 0x7e8Aa6B70F90d17F31DC8CBA11d1a4bC529B8fb7
AdminOracle 0x8CeaD4a442a4eaD637d6bA5e9C2fAf8807c3382F
MarketFactory 0xBD4B4F722b9b7aEF1aFbDFd8a6d4C96D609Be4bD
Collateral (USDC) 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359

Directory Structure

├── src/
│   ├── MarketFactory.sol      # Market creation (binary, categorical, scalar)
│   └── AdminOracle.sol        # Resolution oracle
├── script/
│   ├── Deploy.s.sol           # Exchanges + Oracle + Factory (0.8.15)
│   └── DeployNegRiskAdapter.s.sol  # Vault + Adapter (0.8.19)
├── ctf-legacy/                # ConditionalTokens Hardhat project (0.5.1)
├── lib/                       # Git submodules (ctf-exchange, neg-risk-adapter, OZ, etc.)
└── test/

License

MIT

About

Foundry project — forked Polymarket contracts and deployment scripts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors