Skip to content

Smart Contracts

The AK Market platform is built on a set of composable smart contracts for conditional token creation, exchange, and wallet management.

Contract Architecture

┌──────────────────────────────────────────────────┐
│                  CTFExchange                       │
│  (order validation, signature verification,       │
│   fill settlement, operator management)           │
├──────────────┬───────────────┬────────────────────┤
│ ConditionalTokens (CTF)  │  ERC-20 Collateral    │
│ (conditions, positions,  │  (funding token)       │
│  split/merge/redeem)     │                        │
├──────────────────────────┴────────────────────────┤
│              Oracle / Resolution Adapter           │
│  (market creation, payout reporting)               │
├───────────────────────────────────────────────────┤
│         Wallet Factories (Proxy / Safe)            │
│  (deterministic wallet deployment)                 │
└───────────────────────────────────────────────────┘

Packages

packages/ctf-upstream

Vendor package containing the upstream ConditionalTokens contract. This is the core engine for conditional token logic — creating conditions, splitting positions, merging, and redeeming payouts.

packages/exchange-upstream

Vendor package containing the upstream CTFExchange contract. Handles signed order validation and fill settlement. Supports multiple signature types: EOA, POLY_PROXY, POLY_GNOSIS_SAFE, and POLY_1271.

packages/polymarket-mvp

Platform-specific contracts and deployment scripts:

ContractDescription
MockUmaAdapterOwner-controlled oracle for market creation and resolution
MockCollateralMintable ERC-20 test collateral
DeterministicWalletSigner-owned wallet implementation
PolyProxyFactoryDeterministic proxy wallet factory
PolySafeFactoryDeterministic safe wallet factory

Deployment Scripts

All scripts live in packages/polymarket-mvp/script/:

ScriptPurpose
DeployMvp.s.solDeploys or reuses CTF, collateral, adapter, factories, and exchange
DeployDeterministicWallet.s.solDeploys signer-owned proxy or safe wallet
SetupWalletApprovals.s.solSets ERC-20 + ERC-1155 approvals through the wallet
SeedTradingWallet.s.solMints collateral and optionally splits positions
RegisterMarket.s.solCreates a binary market and registers token pairs

Further Reading