Skip to main content
Every user gets their own Vault contract, deployed by VaultFactory. The platform deploys it for you (see Backend auto-deploy); a deposit does not create it, because depositERC20 is called directly on the vault itself. Each vault is a standalone contract (in Generation 1), not a generic multi-tenant contract. Its address is assigned at deploy time via plain CREATE, so read it from vaultOf(user) or GET /api/me/vault rather than computing it off-chain.

VaultFactory

  • deployVault is not idempotent — it reverts with VaultAlreadyExists(user) (selector 0x4293864f) if the wallet already has a vault. The platform deploys partner vaults automatically, so integration code should only read vaultOf(user) on the factory of the vault’s generation (or poll GET /api/me/vault) and never call deployVault itself.
  • At creation, the vault is initialised with vaultOwner = user and max USDC + ERC-1155 approvals to CTFExchange, ConditionalTokens, NegRiskAdapter and NegRiskCtfExchange.
  • The factory acts as the central event bus for all vaults (DepositedERC20, WithdrawnERC20, EmergencyInitiated, EmergencyExecuted, etc.), emitting monotonic sequence numbers (seq).

Bootstrap: vault → deposit

Per-EOA deposit limits in DepositLimitRegistry are managed by the platform. Until the platform has assigned your EOA a deposit tier, depositERC20 reverts with KycRequired() (selector 0x709ea86e). Before making the first deposit, poll GET /api/me/deposit-limits until restrictions.depositBlocked is false.

Vault entry points

Dual-signed operations

The calls below require two EIP-712 signatures: the vault owner’s signature plus a platform backend co-signature. msg.sender is unconstrained.

Single-auth / system operations

Splitting USDC into YES + NO inside the vault

SELL orders require the outcome ERC-1155 to reside in the maker vault: at settlement, the exchange debits the tokens directly from the maker vault. The flow:
  1. Backend co-signature: POST /api/vault/split-signature with { marketId, amount }. Returns the signed operation payload with backendSig:
  2. Owner signature: Sign the same SplitPosition typed-data with the vault EIP-712 domain using the EOA key.
  3. On-chain submit: Call vault.splitPosition(kind, collateral, conditionId, partition, amount, salt, deadline, ownerSig, backendSig).

Merging YES + NO back into USDC

mergePositions is the exact inverse of splitPosition: it burns equal amounts of YES and NO tokens inside the vault and credits USDC to the vault balance.
  1. Backend co-signature: POST /api/vault/merge-signature with { marketId, amount }.
  2. Owner signature: Sign the MergePositions typed data.
  3. On-chain submit: Call vault.mergePositions(...).
Both SplitPosition and MergePositions share the same EIP-712 type definition:
partition is always [1, 2] (representing YES + NO). kind is 0 for binary markets and 1 for neg-risk markets.

Emergency withdraw

These functions are strictly callable by the vault-owner EOA without backend co-signatures. The emergency state is unilateral and cannot be cancelled by the platform. While in emergency mode, the exchange rejects new orders from the maker vault (MakerInEmergency).

Digest invalidation

Invalidates a dual-signed operation before on-chain execution by recording its digest in usedDigests. Either the vault owner or the platform backend may call it; any other caller reverts with NotOwner().

Generation 1 vs. Generation 2 architecture

  • Generation 1: Each user vault is a full standalone contract deployed from bytecode pinned in the factory’s SSTORE2 pointer (vaultInitCodePointer). No admin or platform upgrade can modify deployed vault logic.
  • Generation 2: Separate vaults from VaultFactoryGen2, upgradeable only behind a timelock. Positions are not moved from the generation-1 vault. See Vault generation 2.
See Emergency exit and upgradeability for Generation 2 details.

EIP-712 domain

verifyingContract is always the specific user vault address, not the factory.