A Dark pool for P2P trading of erc20 tokens which ensures zero slippage/price impact and complete privacy of orders.
Traders who deal with large token swaps on decentralized exchanges (DEXes) often face three major challenges:
Frontrunning and Sandwich Attacks: When traders execute large token swaps using public RPC endpoints, they risk getting front-run by MEV (Maximal Extractable Value) bots. These bots monitor public mempools for profitable opportunities and often exploit large trades for gains, leaving traders at a disadvantage.
Price Impact: Swapping large amounts of tokens in pools with low liquidity often results in significant price impact, meaning traders get worse rates as their trades affect the token's market price.
Slippage: In highly volatile market conditions, traders often face a difference between the price they expect and the price at which their order actually executes, leading to unexpected losses.
To solve these issues, we’ve built CipherPool, a dark pool for peer-to-peer (P2P) trading of ERC-20 tokens. Here's how it works:
The project leverages the Lit Protocol at its core to encrypt and manage order matching. Here's how it works:
Session Signatures for Encryption: Each trader or client connects to the Lit network and obtains session signatures (session sigs). These signatures are then used to encrypt their orders securely.
Defining Decryption Conditions: During encryption, specific conditions for decrypting the orders are set. In this case:
The orders can only be decrypted by the user who created them. Alternatively, the orders can be decrypted within a Lit Action associated with a specific IPFS CID. Encrypted Order Submission: Once encrypted on the client side, the orders are sent to CipherPool, which maintains an encrypted order book.
Matching Engine with PKP Ownership: CipherPool's matching engine includes a Programmable Key Pair (PKP), which also owns the vault contract. This PKP is responsible for signing all settlement transactions.
Order Matching and Settlement: The Lit Action decrypts pairs of orders and checks if they match. If a match is found, the Lit Action generates a signed settlement transaction. The matching engine then submits this transaction on-chain, finalizing the trade.