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:
| Contract | Description |
|---|---|
MockUmaAdapter | Owner-controlled oracle for market creation and resolution |
MockCollateral | Mintable ERC-20 test collateral |
DeterministicWallet | Signer-owned wallet implementation |
PolyProxyFactory | Deterministic proxy wallet factory |
PolySafeFactory | Deterministic safe wallet factory |
Deployment Scripts
All scripts live in packages/polymarket-mvp/script/:
| Script | Purpose |
|---|---|
DeployMvp.s.sol | Deploys or reuses CTF, collateral, adapter, factories, and exchange |
DeployDeterministicWallet.s.sol | Deploys signer-owned proxy or safe wallet |
SetupWalletApprovals.s.sol | Sets ERC-20 + ERC-1155 approvals through the wallet |
SeedTradingWallet.s.sol | Mints collateral and optionally splits positions |
RegisterMarket.s.sol | Creates a binary market and registers token pairs |
Further Reading
- ConditionalTokens (CTF) — condition lifecycle and position management
- CTFExchange — order matching and settlement
- Wallets — deterministic wallet deployment