Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Guides

Launching a Confidential Liquidity Pool

A technical guide for developers to implement an Automated Market Maker (AMM) pool with private liquidity provider positions and transaction histories using zero-knowledge proofs.
Chainscore © 2026
introduction
PRACTICAL GUIDE

Launching a Confidential Liquidity Pool

A step-by-step tutorial for developers on deploying a privacy-preserving liquidity pool using zero-knowledge proofs.

A Confidential Liquidity Pool (CLP) is an Automated Market Maker (AMM) pool where the liquidity provider's deposits and trading activity are shielded using cryptographic techniques like zero-knowledge proofs (ZKPs). Unlike traditional pools on Uniswap or Curve, where all balances and trades are public on-chain, CLPs enable private liquidity provision and trading. This is achieved by representing pool shares and transaction amounts as cryptographic commitments, with validity proven via ZK-SNARKs or ZK-STARKs. Protocols like Aztec Network and Penumbra are pioneering this space, allowing users to earn fees while maintaining financial privacy.

To launch a CLP, you first need to choose a supporting protocol and framework. For this guide, we'll use a conceptual model based on Aztec's zk.money architecture. The core components are: a shielded pool contract that holds encrypted notes, a circuit (written in Noir or Circom) that validates pool mechanics, and a verifier contract that checks ZK proofs. You must define your pool's parameters: the asset pair (e.g., ETH/DAI), the fee structure (e.g., 0.3%), and the initial liquidity. The liquidity you provide is 'shielded' by depositing it into the pool's confidential note system, generating private proof of ownership.

The technical implementation involves writing the business logic circuit. This circuit proves, without revealing amounts, that a trade satisfies the constant product formula x * y = k. For a swap, it shows that the input and output commitments are valid, fees are correctly calculated, and the new pool reserves maintain the invariant. Here's a simplified Noir function signature:

noir
fn swap_private(
  input_note: Field,
  output_note: Field,
  pool_root: Field,
  fee_bps: u16
) -> Public {
  // ... circuit logic
}

After compiling the circuit, you deploy its verifier and the main pool contract, which manages note commitments and root updates.

Once deployed, liquidity providers interact with your CLP by calling a deposit_private function, which takes their public tokens, creates a shielded note representing their LP share, and submits a proof. Traders use a swap_private function, providing a ZK proof that they own an input note and are entitled to a calculated output. All on-chain transactions only show proof verifications and hash updates, not the actual amounts or user identities. Monitoring requires using the protocol's private viewing keys to decrypt your own portfolio balance and pool performance metrics.

Key considerations for launch include auditing your ZK circuits with firms like Trail of Bits, ensuring economic security for the shielded pool, and planning for upgradability via proxies or versioning. Unlike public pools, you cannot rely on external arbitrageurs to correct imbalances instantly, so initial liquidity is critical. Resources include Aztec's documentation, the Noir language playground, and example repositories like the zk-pool prototype. Launching a CLP merges DeFi innovation with strong privacy guarantees, creating new possibilities for institutional and retail liquidity.

prerequisites
PREREQUISITES AND SETUP

Launching a Confidential Liquidity Pool

This guide covers the essential technical requirements and initial configuration needed to deploy a private liquidity pool on a confidential computing network.

Before writing any code, you must establish a secure development environment. This requires installing a confidential virtual machine (CVM) SDK, such as Oasis Sapphire's @oasisprotocol/sapphire-paratime or Secret Network's secretjs. You'll also need Node.js (v18+), a package manager like npm or yarn, and a wallet with testnet tokens for the target chain. The core dependency is the confidential smart contract framework, which provides the trusted execution environment (TEE) or secure enclave runtime necessary for private computation.

The next step is configuring your project and connecting to the network. Initialize a new project using the framework's template (e.g., cargo generate for CosmWasm on Secret, or a Hardhat plugin for Sapphire). You must then set up a .env file with your wallet's mnemonic seed phrase and the RPC endpoint for the network's testnet, like https://testnet.sapphire.oasis.io or https://lcd.testnet.secretsaturn.net. This allows your deployment scripts to authenticate transactions and pay gas fees.

A critical prerequisite is funding your deployment wallet with the network's native gas token. For testnets, you typically acquire these from a faucet. Without sufficient balance, you cannot deploy contracts or interact with them. Simultaneously, you should understand the basic architecture: your pool's logic (e.g., constant product formula) will run inside a confidential contract, while a frontend or bot will use a client library to send encrypted queries and transactions to this private backend.

Finally, verify your setup by deploying a simple 'Hello World' confidential contract. This tests the toolchain, network connection, and wallet configuration end-to-end. A successful deployment confirms you can compile code to the correct WASM target, sign a transaction, and receive a contract address from the blockchain. Only after this validation should you proceed to develop the actual pool contract, as debugging environment issues later is significantly more complex.

architecture-overview
SYSTEM ARCHITECTURE AND CORE COMPONENTS

Launching a Confidential Liquidity Pool

This guide details the architectural components and technical workflow for deploying a privacy-preserving liquidity pool using zero-knowledge proofs.

A confidential liquidity pool is a decentralized exchange (DEX) primitive where the state of the pool—specifically the reserve balances of assets—is kept private. Unlike traditional Automated Market Makers (AMMs) like Uniswap V3, where reserves are public on-chain, confidential pools use cryptographic commitments and zero-knowledge proofs (ZKPs) to obscure this data. The core components enabling this are a commitment scheme (e.g., Pedersen commitments) to represent encrypted balances, a zero-knowledge proof system (like zk-SNARKs via Circom or Halo2) to validate state transitions, and a verifier smart contract that checks proof validity without revealing underlying data.

The system architecture follows a state transition model. The pool's true state (reserves R_A, R_B) is represented by a public commitment C, stored on-chain. When a user submits a swap, they generate a ZKP that proves: 1) they know the pre-swap reserves, 2) the swap calculation (e.g., constant product formula x*y=k) is correct, and 3) the new, post-swap commitment C' is valid. This proof is submitted to the verifier contract alongside the public commitment update. The contract verifies the proof, ensuring the state transition is valid without learning R_A or R_B. This process maintains liquidity provider shares and pricing logic while hiding sensitive financial data.

To launch such a pool, developers must implement three key modules. First, the circuit logic defines the swap constraints in a ZKP framework. For example, a Circom circuit would take private inputs (old reserves, swap amount) and public inputs (commitments) to output a proof. Second, the prover client is an off-chain service (often written in JavaScript/TypeScript using libraries like snarkjs) that users run to generate proofs for their transactions. Third, the verifier contract, typically written in Solidity or Cairo, contains the verification key and logic to validate incoming proofs. Popular implementations can be studied in projects like Aztec Network's zk.money or the Mina Protocol.

Deployment involves several concrete steps. Begin by writing and testing the ZKP circuit for your AMM logic. Compile it to generate a verification key. Deploy the verifier contract with this key embedded. Then, deploy a manager contract that stores the public commitment and calls the verifier. Finally, build and host the client-side prover application that interacts with user wallets. Key security considerations include ensuring the circuit correctly enforces the AMM invariant, protecting the prover from front-running, and using a trusted setup ceremony if required by your ZKP system (e.g., Groth16).

Confidential pools enable novel use cases by mitigating MEV and protecting institutional trading strategies. However, they introduce complexity: transaction latency increases due to proof generation (often 5-15 seconds in-browser), and gas costs are higher for verification. Future architectural improvements focus on recursive proofs (like those in zkSync Era) to batch operations, and hardware acceleration for faster proving. By understanding this architecture—commitments, ZK circuits, and verifier contracts—developers can build the next generation of private DeFi infrastructure.

key-concepts
PRIVACY ENGINE

Key Cryptographic Concepts

Confidential liquidity pools use advanced cryptography to hide sensitive trading data while maintaining full functionality. These are the core concepts that make private DeFi possible.

03

Commitment Schemes

Cryptographic primitives that allow a user to commit to a chosen value while keeping it hidden, with the ability to reveal it later. The commitment is binding (cannot change the value) and hiding (cannot deduce the value).

  • Pedersen Commitments are commonly used in confidential transactions for their additive homomorphic properties.
  • In private AMMs, they are used to commit to deposit amounts and trade values before they are revealed for settlement.
  • This creates a blinded order flow, preventing front-running and information leakage.
06

Differential Privacy

A system for publicly sharing information about a dataset by describing patterns of groups within the dataset while withholding information about individuals.

  • Adds calibrated statistical noise to query results (e.g., total pool volume, fee accrual) to prevent the deduction of any single user's activity.
  • Used by analytics platforms to provide aggregate insights without compromising user privacy.
  • For a confidential pool, it allows for the publication of useful metrics (like APY) without leaking sensitive trading data that could be exploited.
step-1-shielded-deposit
CONFIDENTIAL LIQUIDITY POOL

Step 1: Designing the Shielded Deposit Mechanism

The foundation of a confidential pool is a deposit mechanism that accepts standard tokens and mints a private, non-transferable proof of deposit. This step focuses on implementing this core privacy primitive using zero-knowledge proofs.

A shielded deposit mechanism allows users to contribute liquidity—like ETH or USDC—without publicly linking their wallet address to the pool's activity. The core technical components are a commitment scheme and a zero-knowledge proof (ZKP) circuit. When a user deposits, the contract generates a cryptographic commitment (e.g., a Pedersen hash) to a secret nullifier and the deposit amount. This commitment is published on-chain, but the values inside remain hidden. The user retains the secret nullifier, which will later allow them to privately withdraw their funds.

The privacy guarantee is enforced by a ZKP, such as a Groth16 or PLONK proof. The user's client (wallet) runs a circuit that proves, without revealing the secrets, that: 1) a valid ERC-20 transfer was signed, 2) the public commitment is correctly computed from the secret nullifier and amount, and 3) the amount is within allowed limits. Only this proof and the public commitment are submitted to the smart contract. Popular frameworks for building this include Circom with snarkjs or Halo2 libraries. The contract's deposit function verifies the ZKP and the token transfer, then stores the commitment in a Merkle tree of deposits.

This Merkle tree, often implemented with incremental Merkle tree libraries like those from the Tornado Cash circuit or Semaphore, is crucial for future anonymity. Each new deposit commitment is inserted as a leaf. The root of this tree is stored on-chain and is updated with each deposit. When a user later wants to withdraw, they will prove membership of their commitment in this tree without revealing which leaf is theirs. The contract must also securely handle the deposited tokens, typically by escrowing them in the contract itself or a dedicated vault.

A critical design choice is selecting the nullifier scheme. A simple nullifier is a hash of a user's secret. To prevent double-spending, the contract maintains a spent nullifier set. When withdrawing, the user reveals a nullifier derived from their secret; if it's already in the set, the transaction fails. For enhanced privacy across multiple pools, consider using a unified nullifier system like that in Aztec Protocol, where a nullifier can be proven to be valid for one of many assets without revealing which one.

Finally, the deposit interface must be gas-efficient and user-friendly. Batch deposits via a relayer can help users avoid paying gas directly, improving privacy. The contract should emit minimal events—perhaps only the new Merkle root and the commitment—to reduce on-chain data leakage. By completing this step, you establish the private entry point for liquidity, setting the stage for the confidential pool logic that operates on these shielded commitments.

step-2-private-swap-circuit
IMPLEMENTATION

Step 2: Building the Private Swap Circuit

This section details the construction of the core zero-knowledge circuit that enforces the logic for a confidential liquidity pool swap.

The private swap circuit is the cryptographic engine of the pool. It is a zero-knowledge proof program written in a domain-specific language like Circom or Noir. Its primary function is to verify, without revealing the underlying values, that a proposed swap adheres to the pool's constant product formula x * y = k. The circuit takes private inputs—the user's secret token amounts and the new pool reserves—and public inputs—the pool's public commitment and the swap's output—to generate a proof of a valid state transition.

A minimal circuit must enforce several constraints. First, it verifies that the input commitment matches the current public state of the pool. Second, it calculates the expected new reserve amounts after the swap, ensuring the product new_x * new_y equals the original constant k. Third, it validates that the user is depositing the correct input amount and is entitled to the declared output amount. Any deviation from these rules causes the proof generation to fail, preventing invalid swaps.

Here is a conceptual outline of the circuit's public and private inputs:

  • Public Inputs (Revealed): Pool commitment (hash of reserves), output token amount to user, new pool commitment.
  • Private Inputs (Hidden): Current reserves (x, y), user's input token amount, computed new reserves (x', y'). The circuit logic ensures x * y == x' * y' and that the delta between x and x' equals the user's secret input.

Developing this circuit requires careful attention to numeric precision and overflow, as ZK circuits operate over finite fields. Using libraries for safe arithmetic is critical. Once implemented and compiled, the circuit produces a proving key and a verification key. The proving key is used by the pool client to generate proofs for each swap, while the verification key is embedded in the pool's smart contract to validate those proofs on-chain.

The final step is integrating this circuit with the client-side SDK. The SDK will handle fetching the pool's public state, calculating the swap parameters off-chain, executing the circuit with the private inputs to generate a ZK proof, and finally submitting the public inputs and proof to the blockchain for verification and execution. This completes the core confidential swap mechanism.

step-3-withdrawal-verification
PRIVACY ENGINE

Step 3: Enabling Confidential Withdrawals

Implement the cryptographic logic that allows users to withdraw their assets from the pool without revealing their position size or transaction history on-chain.

Confidential withdrawals are the final, critical component of a private liquidity pool. Unlike a standard AMM where withdrawal amounts are public on-chain, this step uses zero-knowledge proofs (ZKPs) to allow a user to prove they own a valid liquidity position and calculate their fair share of the pool's reserves, all without revealing the size of their stake or the specific withdrawal transaction. The core mechanism involves the user generating a zk-SNARK proof that attests to: the validity of their original deposit note (a cryptographic commitment), the current state of the pool reserves, and the correctness of the computed withdrawal amount based on their share.

To initiate a withdrawal, the user's client (wallet) must fetch the latest public state of the pool, including the total reserve commitments. It then uses this data, along with the user's private viewing key, to scan for their unspent deposit notes. For each note, the client locally computes the prover function for the withdrawal circuit. This circuit, typically written in a ZK domain-specific language like Circom or Noir, encodes the business logic: (Valid Note ∧ Current Pool State) → (Correct Withdrawal Amount ∧ Updated Note Nullifier). The output is a succinct proof and the new public outputs for the transaction.

The user submits the proof and public outputs to the pool's smart contract. The contract, which contains a verifier for the withdrawal circuit, checks the proof against the current public pool state. Key on-chain checks include: verifying the proof is valid, ensuring the submitted nullifier (a unique hash of the spent note) hasn't been used before (preventing double-spends), and updating the public pool reserve commitments to reflect the withdrawn amounts. Only the net change in reserves is revealed, not which user caused it.

Here is a simplified conceptual outline of the withdrawal circuit logic, often implemented in a ZK framework:

code
// Pseudo-Circuit for Confidential Withdrawal
signal input privateNoteSecret; // User's secret key for the note
signal input publicPoolRoot;    // Merkle root of pool reserves
signal input privateNoteAmount; // The amount in the note (private)

signal output withdrawAmount;   // Amount to withdraw (public)
signal output nullifier;        // Unique hash to spend note (public)

// 1. Verify note commitment is valid and exists in the pool state
constraint noteValid = verifyNoteCommitment(privateNoteSecret, privateNoteAmount);
constraint noteInPool = verifyMerkleInclusion(publicPoolRoot, noteValid);

// 2. Compute pro-rata share based on note amount vs total reserves
constraint withdrawAmount = (privateNoteAmount / totalReserves) * poolLiquidity;

// 3. Generate nullifier to prevent replay
constraint nullifier = hash(privateNoteSecret, noteUniqueId);

The actual withdrawal amount is derived from the user's private share and the pool's total liquidity, a calculation kept off-chain.

After a successful verification, the contract releases the assets to a specified public address. From the blockchain's perspective, the transaction is a valid state transition with verified cryptographic guarantees, but the link between the withdrawing address and the original depositor is broken. This final step completes the privacy loop: deposits, swaps, and withdrawals all occur without exposing individual user activity, while maintaining the cryptographic integrity and solvency of the pool. Developers must rigorously audit the withdrawal circuit and nullifier logic, as flaws here could lead to loss of funds or privacy leaks.

step-4-impermanent-loss
CONFIDENTIAL LIQUIDITY POOLS

Step 4: Calculating Impermanent Loss in Private State

This step explains how to compute impermanent loss (IL) for a confidential liquidity pool, where asset prices and reserves are hidden, using zero-knowledge proofs to verify the calculation.

In a traditional Automated Market Maker (AMM) like Uniswap V2, impermanent loss is the opportunity cost a liquidity provider (LP) experiences when the price of their deposited assets changes compared to simply holding them. The formula is public and calculated as IL = 2 * sqrt(price_ratio) / (1 + price_ratio) - 1. However, in a confidential liquidity pool built with technologies like Aztec or ZK-SNARKs, the pool's reserves and the external market price are private states, making direct calculation impossible without revealing sensitive data.

To calculate IL privately, you must perform the computation within a zero-knowledge circuit. The circuit takes confidential inputs—the initial deposit amounts (reserveA0, reserveB0), the current hidden reserves (reserveA1, reserveB1), and the current market price ratio—and outputs a cryptographic proof that the IL was computed correctly. The key is that the actual numeric value of the loss can remain encrypted or be revealed only to the LP, while the proof assures the protocol of its validity. This maintains the privacy guarantees of the entire system.

Here is a conceptual outline of the ZK circuit logic for this calculation:

code
// Private inputs: initial and final reserves, external price ratio
signal input reserveA0, reserveB0, reserveA1, reserveB1, priceRatio;
// Calculate value if held vs. value in pool
signal heldValue = reserveA0 * priceRatio + reserveB0;
signal poolValue = reserveA1 * priceRatio + reserveB1;
// Compute impermanent loss ratio (private)
signal ilRatio = poolValue / heldValue - 1;
// Output the IL result (can be public or private)
signal output ilResult <== ilRatio;

The circuit enforces the mathematical relationship without leaking the individual reserve amounts.

After generating the ZK proof, the LP submits it to the pool's smart contract. The contract verifies the proof against a public verification key. Successful verification confirms that the impermanent loss was calculated honestly according to the pool's bonding curve (e.g., Constant Product Formula), even though the verifier never sees the underlying data. This allows for features like private fee statements or risk-adjusted APR calculations without compromising user privacy.

Implementing this requires a ZK-DSL like Noir or Circom. Developers must carefully design the circuit to handle fixed-point arithmetic for precision and include range checks to prevent overflows. The trusted setup and proof generation cost are non-trivial, so this method is best suited for scenarios where privacy is a premium feature. For public testnets, you can experiment with frameworks like the Aztec Sandbox to prototype these confidential DeFi mechanics.

TECHNOLOGY OVERVIEW

Comparison of Privacy-Preserving AMM Approaches

A technical comparison of cryptographic methods for implementing confidential liquidity pools, focusing on trade-offs between privacy, performance, and composability.

Cryptographic MethodAztec Connect (zk-zkRollup)Penumbra (Threshold Encryption)Railgun (zk-SNARKs on L1)

Privacy Guarantee

Full transaction privacy

Shielded pool privacy

Asset & amount privacy

Settlement Layer

Ethereum L1 (via rollup)

Cosmos app-chain

Ethereum L1

Finality Time

~20 minutes

< 6 seconds

~5 minutes

Gas Cost per Swap (approx.)

$8-15

$0.01-0.05

$25-40

MEV Resistance

Cross-Chain Composability

Smart Contract Support

Limited (circuits)

Full CosmWasm

Limited (verified contracts)

Audit Status

Multiple major audits

Formal verification ongoing

Multiple major audits

CONFIDENTIAL LIQUIDITY POOLS

Frequently Asked Questions

Common technical questions and troubleshooting for developers building with confidential liquidity pools using protocols like Penumbra, Aztec, or Fhenix.

A confidential liquidity pool is an Automated Market Maker (AMM) where key financial states—like individual user balances, pending trades, and sometimes even the pool's total reserves—are kept private using zero-knowledge proofs (ZKPs) or fully homomorphic encryption (FHE).

Key differences from standard AMMs:

  • Privacy of trades: The amounts, directions, and wallet addresses involved in a swap are hidden from the public ledger.
  • Shielded liquidity: LPs can deposit and withdraw funds without revealing their position size or profit/loss to the network.
  • MEV resistance: Front-running and sandwich attacks are mitigated because transaction details are not visible in the public mempool.

Protocols like Penumbra implement this by using ZK-SNARKs to prove the validity of swaps and liquidity changes without revealing the underlying data, while Fhenix uses FHE to compute directly on encrypted data.

conclusion-next-steps
IMPLEMENTATION SUMMARY

Conclusion and Next Steps

You have successfully launched a confidential liquidity pool using FHE technology. This guide has covered the core concepts, from understanding the cryptographic primitives to deploying a functional pool on a testnet.

Your deployed pool now operates on the principle of encrypted state. All critical parameters—user balances, swap amounts, and liquidity provider shares—are homomorphically encrypted. This ensures that while the pool's logic (compute_swap, add_liquidity) is executed correctly on-chain, the underlying financial data remains confidential. The next step is to rigorously test your implementation. Use the testnet faucet to fund wallets, simulate multiple swap and liquidity provision events, and verify that the encrypted outputs match expected results when decrypted with the appropriate private key.

For production readiness, you must address key operational considerations. Key management is paramount; the private decryption key must be securely generated and stored off-chain by a trusted entity or a decentralized key management network. You should also implement a front-running mitigation strategy, such as commit-reveal schemes, as the encrypted mempool can still leak timing information. Furthermore, audit your compute_swap function for potential FHE-specific vulnerabilities, like precision loss from fixed-point arithmetic or unintentional information leakage through ciphertext metadata.

To extend your pool's functionality, consider integrating with existing DeFi primitives. You could create a confidential veTokenomics model where voting power is encrypted, or develop a shielded bridge that privately transfers liquidity between your pool and a public AMM like Uniswap V3. Explore frameworks like Zama's fhEVM or Fhenix for more advanced tooling and standardized libraries that can simplify complex confidential smart contract development.

The landscape of confidential DeFi is rapidly evolving. Stay updated on the latest research in FHE schemes (like CKKS for approximate arithmetic) and ZK-proof systems that can be combined with FHE for verifiable confidential computation. Participating in testnet incentive programs from networks like Inco, Fhenix, or Aztec can provide real-world feedback and potential grant opportunities. Your implementation is a foundational step toward a more private and secure financial system.