Skip to main content
PolyShield
POLYGON MAINNET · BETA
Docs menu · Architecture
Getting started
OverviewThe basicsQuickstartFAQ
Core concepts
The privacy modelZero-knowledge proofsSpending notesThe Merkle tree & nullifiers
Architecture
System overviewVault contractZK circuitsOff-chain services
Security
Threat modelTrust assumptionsBackup & recoveryFees
Reference
Glossary
ARCHITECTURE

Vault contract

Vault.sol on Polygon mainnet is the trust anchor — a UUPS-upgradeable contract behind an ERC-1967 proxy. It custodies funds and enforces every rule.

The Vault:

  • Maintains the append-only Poseidon Merkle tree (depth 32) of note commitments.
  • Records spent nullifiers to prevent double-spend, checks-effects-interactions throughout.
  • Verifies 9 proof types: DEPOSIT, BET_AUTH, SETTLEMENT_CREDIT, WITHDRAWAL, BET_CANCEL, CANCEL_CREDIT, POSITION_CLOSE, PARTIAL_CREDIT, CONSOLIDATE.
  • Derives settlement payouts on-chain from the real Gnosis CTF and injects them into proofs — users never supply a payout value, so they can't inflate a credit.
  • Enforces a $50,000 per-address cumulative deposit cap in the MVP.
  • Holds a governance-mutable fee config (bet fee, withdrawal fee, relay-gas reimbursement).

Injected values: the anti-forgery pattern

For anything a user shouldn't control — the fee, the payout-per-share, the cancellation amount — the Vault supplies the value as a public input to the proof. Because that value feeds the new commitment, a proof built with any other number simply fails verification. The user proves the math; the Vault dictates the sensitive terms.

Under the size limit
A Solidity contract can't exceed 24 KB. The Vault stays under it by delegatecall-linking two libraries — VaultInputs (public-input assembly) and VaultLogic (spend-path bodies) — which run in the Vault's own storage context.