Zylith is a proof-driven, shielded concentrated liquidity market maker on Starknet. It preserves a public CLMM state machine while hiding ownership of notes and positions.
Public AMMs provide deterministic pricing and composability but expose per-user balances and positions. A shielded AMM should preserve the public price process while minimizing disclosure of ownership. Zylith separates ownership privacy (off-chain notes + ZK proofs) from on-chain pool state (public).
Zylith uses Groth16 proofs generated off-chain to prove correctness of private inputs and CLMM transitions. The pool contract verifies proofs and applies the resulting state deltas to a public CLMM core via an adapter. The chain verifies membership and nullifier freshness, it does not recompute swap math.
ShieldedNotesmaintains commitment trees for token0, token1, and positions.- Commitments are Poseidon(Poseidon(secret, nullifier), amount) over BN254.
- Nullifiers are recorded on-chain to prevent double spends.
- Merkle roots are stored on-chain, full trees are maintained off-chain.
- Membership verification uses on-chain Starknet Poseidon and historical root windows.
ZylithPoolis the entrypoint for swaps and liquidity operations.PoolAdapterapplies verified state transitions to the CLMM core.- The CLMM core tracks sqrt price (Q128.128), tick, active liquidity, fee growth, and tick bitmap similar to Ekubo.
- Pool state is public, correctness derives from proof-verified transitions.
- Implementation provenance: only the CLMM core and math layer under
contracts/clmm/are adapted from Ekubo.
- Groth16 over BN254, verified on Starknet via Garaga.
- Circuits:
private_depositandprivate_withdraw.private_swapandprivate_swap_exact_out.private_liquidityfor add/remove/claim.
- Circuits prove swap and liquidity math off-chain; the chain does not recompute swap math.
Private:
- Ownership of token notes and position notes.
- Note secrets and nullifier seeds.
Public:
- Commitments, nullifiers, and Merkle roots.
- Pool state: sqrt price, tick, liquidity, fee growth, protocol fee accounting.
- Deposit and withdraw amounts and recipients.
- Tick bounds for positions (MVP).
Limitations (MVP):
- Amount privacy is not provided. Swap and liquidity amounts are public or derivable from public state transitions.
- Position ranges are public.
- Pool initialization parameters are public.
- User constructs a token note off-chain.
- Prover generates a Groth16 proof (
private_deposit) of note correctness. ShieldedNotesverifies the proof, inserts the commitment, transfers ERC20 into custody, and updates the Merkle root.
- User fetches membership paths from the ASP.
- Prover generates a swap proof (
private_swaporprivate_swap_exact_out). ZylithPoolverifies the proof, checks:- membership path validity against on-chain roots,
- nullifier freshness,
- pool state consistency for the verified transition.
PoolAdapterapplies swap deltas to the CLMM core.- Output commitments are inserted into
ShieldedNotes.
- User proves liquidity math in
private_liquidity. ZylithPoolverifies the proof and applies liquidity deltas viaPoolAdapter.- Position and change commitments are inserted into
ShieldedNotes.
- User proves note opening and nullifier in
private_withdraw. ShieldedNotesverifies membership on-chain, marks the nullifier, and transfers ERC20 to the recipient.
- Generates witnesses and proofs with
snarkjs. - Converts proofs to Starknet calldata via
garaga. - Trust: correctness depends on circuit and verifier; the backend is not trusted for correctness but is required for liveness.
- Reconstructs Merkle trees from on-chain events.
- Serves membership paths and insertion paths.
- Trust: integrity is enforced on-chain by root verification. Incorrect paths cause proof or on-chain verification to fail; ASP is a liveness dependency.
- Stores encrypted notes in browser IndexedDB.
- Vault key is derived from wallet signatures; losing the key loses notes.
- Trust: user must back up notes; the protocol cannot recover them.
- Circuit correctness is a primary assumption; bugs can create invalid but verifiable proofs.
- Groth16 requires a trusted setup; if toxic waste is compromised, an attacker can forge proofs for false statements and bypass circuit constraints.
- Garaga and on-chain verifiers are assumed correct.
- Vault storage is a single point of user recovery; losing the vault key loses access to funds.
contracts/: Cairo contracts for pool, notes, adapter, verifier, interfaces.contracts/clmm/: Ekubo-derived CLMM core and math modules.circuits/: Circom circuits and constants.rust/: prover, backend API, ASP indexer, and client helpers.frontend/: React UI and encrypted vault.scripts/: deployment and setup utilities.docs/: runbook and security model references.
Zylith is an MVP. The system is unaudited and experimental. Expect breaking changes and incomplete privacy properties as described above.
The repository is licensed under AGPL-3.0, except for contracts/clmm/ which is licensed under the Ekubo DAO Shared Revenue License 1.0 (ekubo-license-v1.eth).