CopyX: Encrypted DeFi, copy trading & yield with Uniswap V4 + ZAMA FHE.
CopyX is a privacy-first copy-trading and yield generation protocol built as a Vault-as-Hook on Uniswap v4. It uses ZAMA FHEVM to keep user balances and trade intents encrypted end-to-end, and an EigenLayer-style AVS to privately decrypt, simulate, match, and batch trades off-chain—so only the net, aggregated flow ever touches the AMM. Core outcome: Alpha stays private, retail can safely copy it, and idle capital earns yield.
{target, selector, args}) so even a malicious AVS can’t push arbitrary calls.Alpha Generators (two roles):
Copy Traders (retail/pros): subscribe to preferred alpha generators; get proportional encrypted fills with per-user sizes hidden.
LPs / Depositors: capture yield from DeFi deployments + lower AMM churn thanks to internal matching.
Deposit & Shielding: Users deposit ERC-20s; the hook mints encrypted balances (eTokens) using ZAMA FHEVM types.
Encrypted Intents: Traders encrypt amounts (and optional minOut) locally and submit intents to the hook; only ciphertext handles land on-chain.
Batching Window: The hook collects intents for a short window (e.g., ~5 blocks) and emits a TaskCreated header (batchId, snapshot, TTL, decryptor address).
AVS Decrypt → Simulate → Net:
(batchId, bounds, snapshotCommit), and an aggregator posts it on-chain.Merkle-Gated Execution: The Uniswap v4 hook acts as a gate. On executeBatch, it checks quorum, TTL, and Merkle proofs for sanitized calldata, then performs only the net AMM swap via PoolManager (private inclusion to reduce MEV).
Encrypted Settlement & Copy: Per-user balance deltas are applied as encrypted adds/subs (no plaintext amounts revealed). When a trader’s execution is validated/profitable, CopyX proportionally mirrors the fill to subscribers’ encrypted balances.
Withdraw (optional): Users can redeem to any recipient to further break linkage.
Privacy surface:
Live inside the hook vault:
Why this matters: steady baseline yield when trading is quiet; rebalancing pulls funds back when utilization rises.
Separation of concerns:
On-chain
{target, selector, args} leaves.Off-chain
Frontend
snapshotCommit.In one sentence: CopyX delivers private, verifiable copy trading and capital-efficient yield on Uniswap v4 by combining ZAMA FHEVM encryption with an AVS that nets flows off-chain and executes only the aggregate on-chain.
We built CopyX by integrating three powerful templates that gave us a massive head start - the Zama FHEVM template, EigenLayer's Hello World AVS template, and Uniswap V4 Hooks template. These templates eliminated weeks of boilerplate setup and let us focus purely on the integration magic.
The Tech Stack & Architecture
Core Technologies:
The Nitty-Gritty Integration
Hybrid Token SystemWe created HybridFHERC20 tokens that maintain dual balances - public and encrypted. Users deposit regular USDC/USDT and receive encrypted versions (eUSDC/eUSDT) that only they can decrypt.
Intent Batching & Matching (The Hacky Part)Instead of processing swaps individually, we batch intents every 5 blocks. Our AVS operators:
The 90/10 Capital SplitHere's where it gets interesting - when LPs add liquidity, we only send 10% to the Uniswap pool and mark 90% for deployment to Aave/Compound. This maintains sufficient liquidity while generating extra yield on idle funds.
Merkle Verification for SafetyAVS operators generate Merkle proofs for profitable trades. The contract only executes trades with valid proofs, preventing any malicious operations.
Copy Trading ArchitectureSubscribers can follow alpha traders. When a trade proves profitable (verified by AVS), it's automatically replicated proportionally for all subscribers - completely encrypted end-to-end.
Partner Technology Benefits
Zama FHEVM gave us:
EigenLayer AVS enabled:
Uniswap V4 Hooks provided:
Notable Hacks
The Double Token System: We deploy parallel encrypted tokens for each regular token. When users deposit, they get encrypted versions that trade in a shadow pool, maintaining privacy while staying compatible with Uniswap V4.
Batch Netting Algorithm: By matching opposite intents before hitting the AMM, we reduce actual swaps by ~45%, saving gas and improving privacy (smaller on-chain footprint).
Frontend Encryption: Using Zama's SDK, we encrypt amounts client-side before they ever touch the blockchain - even the mempool never sees plaintext amounts.
The beauty is that the templates handled all the heavy lifting of FHE setup, AVS infrastructure, and hook scaffolding. We just had to wire them together and add our secret sauce - the batching logic, intent matching, and capital efficiency mechanisms. Without these templates, we'd still be debugging basic FHE operations instead of building advanced DeFi features!

