FHE-enabled privacy preserving Limit Order 'iceberg' hook built on top of Uniswap V4. It allows users to place encrypted limit orders without revealing trade details such as trade size, price and trade direction. This is done using the FHE capabilities from Fhenix Protocol.
- User places a new encrypted limit order order using the iceberg hook.
- The encrypted tokens are transferred to the hook
- An encrypted receipt is minted to the user.
- The order remains in the Iceberg hook until the price crosses the limit price.
- Once the price crosses, the funds are unwrapped and swapped at the market rate in the liquidity pool.
- The outstanding balances are then settled with the liquidity pool.
- The tokens are re-encrypted once received by the Iceberg hook.
- Once the user claims the tokens using the receipt they receive an encrypted transfer of the trade output.
This all happens WITHOUT REVEALING TRADE DETAILS!!!
requires foundry
forge install
bun install
forge test -vvvv --via-ir
/src/Iceberg.sol - Iceberg Hook
/src/FHERC20.sol - Custom FHE-enabled ERC20 impl
/src/FHERC6909.sol - Custom FHE-enabled ERC6909 impl
/script/Bridge.s.sol - Fhenix Bridge Run Script
/test/Iceberg.t.sol - Iceberg Hook Test Suite
/test/utils/... - Test Utilities
Additional resources:
v4-periphery contains advanced hook implementations that serve as a great reference
