Skip to content
Confidex

Confidex

TEE private order book DEX with FHE

Created on 7th May 2025

Confidex

Confidex

TEE private order book DEX with FHE

The problem Confidex solves

Confidex is a fully confidential, MEV-resistant decentralized exchange that integrates secure computing, confidential ERC20, and blockchain-based attestation logic to deliver a seamless and private trading experience. Built using Inco’s Fully Homomorphic Encryption (FHE) stack and deployed on Base Sepolia, Confidex enables fair and tamper-proof swaps without revealing user balances or trading intents.

Confidex addresses front-running and MEV extraction in decentralized exchanges by enabling confidential off-chain order matching within a Trusted Execution Environment (TEE). By integrating confidential ERC-20 tokens (e.g., using zero-knowledge proofs or homomorphic encryption), it also protects user balances and transaction amounts from public exposure. This dual approach prevents adversaries from gaining informational or temporal advantages, thereby preserving both execution integrity and data privacy in on-chain trading.

Users can swap any token while keeping their balances and trade intents private through a cERC-20 contract. This allows users not only to mitigate MEV attacks but also to prevent disclosure of their token balances to other traders within the Base ecosystem. The Trusted Execution Environment accesses encrypted values from the cERC-20 contract to decrypt the deposit amount and update the user’s off-chain balance. Once processed, the matching engine pairs intents from two users and updates their balances. This triggers the withdraw function, which encrypts the post-swap amount and sends it back to the user's wallet.

TEE & Confidential Matching
🔹 Marlin TEE + NestJS – The backend runs inside a Trusted Execution Environment (TEE), implemented in NestJS, which ensures all order processing and matching occurs confidentially and tamper-proof. TEE reads encrypted deposit logs, decrypts them using @inco/js, and re-encrypts amounts for withdrawals.
Marlin configurations:
The Job ID: 0x0000000000000000000000000000000000000000000000000000000000000bca
IP address: 43.204.7.162

Smart Contracts (Base Sepolia)
🔹 Solidity on Base Sepolia – Confidex smart contracts are deployed on Base Sepolia and use the Inco ConfidentialERC20 standard to enable encrypted on-chain balances and FHE-compliant operations.
Confidex: https://sepolia.basescan.org/address/0x571f608851abf768f332233a43b6d54240cda01e#code

Confidential Tokens
cUSDC: https://sepolia.basescan.org/address/0x1bc80bcc4fbb107fcf65d09e84d4c6ff5e0b9e7b#code

cCMF: https://sepolia.basescan.org/address/0xeb1f4fd5b3a49ea9569eddd3f12cfabbfaeb42bc#code

🔹 @inco/lightning – Used in contracts to handle fully homomorphic computations for ConfidentialERC20 token operations.

🔹 OpenZeppelin Libraries – Integrated ERC20, ECDSA, and MessageHashUtils for token infrastructure and cryptographic verifications.

Frontend & User Interaction
🔹 Next.js + Wagmi + Viem + ShadCN + TailwindCSS – A modern frontend stack for smooth dApp interaction.
🔹 @inco/js – Used in the browser for encrypting token amounts before deposit and decrypting confidential balances client-side. Ensures end-to-end confidentiality without exposing data to frontend, backend, or blockchain.

Confidentiality & MEV Resistance:
🛡️ FHE Encrypted Balances – User holdings remain hidden even from indexers and sequencers
🛡️ Encrypted Trade Intents – Prevents sandwiching and front-running
🛡️ TEE Matching – Ensures fairness and prevents tampering
🛡️ Public Attestations – Verifiable but privacy-preserving execution proofs

Challenges we ran into

Integrating Inco’s FHE and cERC-20 tokens was challenging due to the complexity of handling encrypted balances and operations within smart contracts. Performing token transfers and state updates without decrypting the data required a deep understanding of Inco’s tooling and encryption model. Additionally, combining the FHE logic with the use of a Trusted Execution Environment introduced difficulties in managing decryption permissions and ensuring correct state updates for user balances. Similar challenges arose when submitting intents directly from the user’s wallet to the Trusted Execution Environment, as these intents also needed to be decrypted.

Tracks Applied (2)

DeFi

Confidex redefines DeFi by introducing confidential trading using FHE and TEE. While traditional DEXs expose user data t...Read More

Showcase

Confidex fits the Showcase track as an evolution of our existing project, SoloPatty—a trust-minimized, MEV-resistant DEX...Read More

Cheer Project

Cheering for a project means supporting a project you like with as little as 0.0025 ETH. Right now, you can Cheer using ETH on Arbitrum, Optimism and Base.

Discussion

Builders also viewed

See more projects on Devfolio