Donut Exchange

Donut Exchange

A decentralized exchange that leverages FHE for swaps with encrypted amounts, encrypted reserves and mitigates MEV as a result.

124
Built at ETHDenver 2024
First prize

The problem Donut Exchange solves

In the traditional finance world, users expect their transactions to remain private, think Veno, bank transfers, forex, etc. Our project introduces a new privacy primitive to the DeFi ecosystem. It allows users to swap tokens without revealing the transaction amounts. By encrypting these amounts, we also ensure that validators cannot profitably front-run transactions, preserving the integrity and fairness of the trading environment.

Challenges we ran into

Creating an exchange with private reserves presented unique challenges. A token's price is typically derived from the ratio of reserves between tokenA and tokenB, which means revealing the price could inadvertently disclose information about the reserves. To address this, we adopted a strategy that involves dealing with ratios when accessing reserve information. As a result, the only potential information leakage pertains to the ratio itself, rather than the actual reserve amounts. While its possible there still might be some data leakage about the reserves given certain circumstances, This method better ensures the confidentiality of reserve quantities.

The encryption library we uses introduced new Solidity data types specifically designed for encrypted integers and booleans. However, these new types come with computational limitations that become more pronounced as their size increases. The largest data type we could efficiently use was euint16, as euint32 proved to be computationally prohibitive and could exceed the block size limit, making some functions too large to execute within a single block. A more production-grade dex would require larger encrypted integer values to properly handle the math needed and mitigate underflow and overflow errors.

Tracks Applied (2)

Defi, NFTs & Gaming

A decentralized exchange is one of the most valuable primitives in the defi space. The utilization of an Automated Marke...Read More

Fhenix - Build Dapps on ETH L2 using FHE

In order to preserve the privcacy of the amounts, we needed a chain that would allow us to run computation on encrypted ...Read More

Fhenix

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