COCSwap: An Intelligent AMM powered by Convex Optimization and ZKPs
COCSwap (Convex Optimization Computation Swap) is an automated market maker (AMM) that leverages convex optimization techniques and zero-knowledge proofs to provide efficient and adaptive AMM pools.
Unlike Constant Function Market Makers that use simple formulas (e.g., constant product), COCSwap allows for complex calculations off-chain using convex optimization techniques. This allows for more sophisticated pricing models and capital efficiency.
Zero-Knowledge Proofs and Zero Knowledge Machine Learning allow for off-chain calculations to be verifiable onchain trustlessly without the need for oracles and economic consensus, allowing for better capital efficiency as well as correctness.
Given the expression of AMM as a convex optimization problem, we are able to expand the range of pricing models and objectives subject to expressive constraints. The use of convex optimization allows for a wide range of pricing models and constraints, which can be adjusted to suit different market conditions or asset characteristics. In addition, Convex Optimization allows for multi-asset pools beyond 2 assets alone.
This makes the AMM much smarter and adaptive allowing for different pricing strategies that may reduce risk on LPs and increase execution efficiency in swaps.
Summary on How it works:
When a user initiates a transaction (swap, add liquidity, or remove liquidity), the current state and proposed action are input into a convex optimization model off-chain.
The model, implemented using AI frameworks like PyTorch, optimizes the new state of the pool based on the defined objective function and constraints.
Using EZKL we are able to convert the AI model in to a corresponding ZK circuit. Allowing for a zk proof to be generated for the optimization model written in PyTorch.
EZKL generates an EVM compatible verifier. We can then implement a Smart Contract in solidity which incorporates the EVM compatible verifier. We used Foundry for our Smart Contracts. The smart contract receives the proposed new state along with the zero-knowledge proof. It verifies the proof to ensure the integrity of the off-chain computation.
If the proof is valid, the contract updates the pool state and executes the user's transaction.