project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5

inco-swap

IncoSwap: Confidential Token Swaps Powered by Fully Homomorphic Encryption

inco-swap

Created At

ETHGlobal Bangkok

Winner of

Inco Network - Best use of confidentiality for DeFi

Project Description

What It Does: This project enables users to swap cryptocurrencies while keeping their transaction details completely private, unlike traditional DEXs, where all trade data is publicly visible on the blockchain.

How It Works: Leveraging FHE, the project ensures that the amounts, and prices, remain encrypted during the entire process. The encryption allows the system to perform computations on encrypted data while maintaining the integrity and accuracy of the trades.

Why It’s Important: By ensuring transaction privacy, this project safeguards users from exploitation by malicious actors, such as sandwich attacks, which manipulate public trade information for profit. It provides a secure and confidential environment for decentralized trading, addressing critical privacy and security concerns in the DeFi space. Also it unlocks the ability for users to trade tokens completely in private

How it's Made

Due to the limitation of the TFHE’s div function of which it only allows division by plaintext, a naive implementation of AMM’s bonding curve algorithm cannot be implemented directly.

As such, we take a novel approach in providing an alternative solution at implementing the swap function.

We take a three step approach instead of the traditional single step swap approach in traditional AMMs of which a single swap function is splitted into preswap ,triggerSwap and finally executeSwap

The idea of our approach to swap will be to batch multiple swap transactions and to only perform the AMM calculation once. By doing so, we are able to ‘mix’ the inputs and outputs of a swap across a few transactions. ie. Should Alice and Bob swapped for 1usdc and 5usdc for Eth respectively, we will take the grand sum of inputs which is 6usdc to be the token in into the AMM calculation. Let’s say the token out in this case be 18eth for example, this 18eth can be shared by Alice and Bob in correspondent to their token in. As a result, Alice will receive 3eth and Bob will receive 15Eth

The preSwap stage will attempt to gather user’s swap intent. Storing the tokenIn as maps to the users address as euint64 which is an encrypted value. At this stage, No one is able to know how much token the user is intending to swap

Once a certain batch threshold is reached, the triggerSwap function can be called. triggerSwap will request for a global decrypt on the reserves of token0 and token1 of the pool. This value will be used as the denominator of our bonding curve calculation.

Once the calculation is done by Inco’s MPC network, a callback will be initiate to the executeSwap function. executeSwap will contain the bonding curve calculation and finally distribute the tokenOuts to each users in corresponding to the user’s tokenIns value

background image mobile

Join the mailing list

Get the latest news and updates