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
deployVaultis not idempotent — it reverts withVaultAlreadyExists(user)(selector0x4293864f) if the wallet already has a vault. The platform deploys partner vaults automatically, so integration code should only readvaultOf(user)on the factory of the vault’s generation (or pollGET /api/me/vault) and never calldeployVaultitself.- At creation, the vault is initialised with
vaultOwner = userand max USDC + ERC-1155 approvals toCTFExchange,ConditionalTokens,NegRiskAdapterandNegRiskCtfExchange. - 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:
- Backend co-signature:
POST /api/vault/split-signaturewith{ marketId, amount }. Returns the signed operation payload withbackendSig: - Owner signature: Sign the same
SplitPositiontyped-data with the vault EIP-712 domain using the EOA key. - 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.
- Backend co-signature:
POST /api/vault/merge-signaturewith{ marketId, amount }. - Owner signature: Sign the
MergePositionstyped data. - On-chain submit: Call
vault.mergePositions(...).
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
MakerInEmergency).
Digest invalidation
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.