UniChain Hook
This project enables sybil free cross-chain atomic swaps using Uniswap V4s before and after swap hooks and layer zero's OFT contracts.
Screenshots






Problem Statement
This project implements a custom Uniswap v4 hook that integrates cross-chain token swaps using LayerZero and incorporates Worldcoin ID verification. The main features and components are:1: Uniswap v4 Integration:Implements a custom hook (SwapHook) that interacts with Uniswap v4 pools.Uses the BaseHook contract from Uniswap v4 periphery. -Implements beforeSwap and afterSwap functions to execute custom logic during swaps. 2: Worldcoin ID Verification:Integrates with WorldIDVerifiedNFT to ensure users are verified before performing swaps.Checks if the user has a World ID Verified NFT in the beforeSwap function. 3: Cross-Chain Functionality:Utilizes LayerZero's OFT (Omnichain Fungible Token) standard for cross-chain token transfers.Implements functions to initiate cross-chain transfers after successful swaps. 4: Token Locking Mechanism: -Locks tokens for cross-chain transfers using a mapping to track locked token amounts per user. 5: Event Emission:Emits events for cross-chain transfers, token locking, and LayerZero operations. 6: Custom Logic:Implements custom debit and credit functions to handle token transfers across chains.Overrides LayerZero's _lzReceive function to handle incoming cross-chain messages.In summary, this project creates an advanced AMM (Automated Market Maker) system that combines Uniswap v4's flexibility, LayerZero's cross-chain capabilities, and Worldcoin's identity verification to enable secure, cross-chain token swaps with user verification. This integration aims to enhance liquidity, improve security, and provide a seamless cross-chain trading experience for users.
Solution
Core Technology Stack:Solidity for smart contract developmentUniswap v4 for the base AMM functionalityLayerZero for cross-chain interoperabilityWorldcoin ID for identity verificationDynamic Wallet for log inSafe smart wallet for smart accountsBlockscoutSmart Contract Architecture:Implemented a custom Uniswap v4 hook (SwapHook) to integrate cross-chain functionality and identity verificationUsed the BaseHook contract from Uniswap v4 periphery as a foundationImplemented beforeSwap and afterSwap functions to handle custom logic 3: Cross-Chain Functionality:Integrated LayerZero's OFT (Omnichain Fungible Token) standardImplemented cross-chain message passing using LayerZero's Ultra Light Nodes (ULNs)Used LayerZero's send function to initiate cross-chain transfersIdentity Verification:Integrated Worldcoin's World ID protocol for proof of personhoodImplemented verification checks in the beforeSwap functionUsed zero-knowledge proofs to maintain user privacyToken Handling:Implemented a token locking mechanism for cross-chain transfersUsed ERC20 and OFT standard for token interactionsTesting and Development:Used Foundry for smart contract testing and deploymentImplemented comprehensive test cases covering various scenariosNotable Implementation Details: Combined Worldcoin verification data and cross-chain transfer data in a single hookData parameter Implemented a custom CrossChainTransferData struct to handle transfer-specific information Used events to log important actions like CrossChainTransferInitiatedChallenges and Solutions:Addressed the complexity of encoding and decoding hookData to include both Worldcoin and cross-chain informationImplemented careful error handling and logging to debug cross-chain interactions
Hackathon
ETHGlobal Brussels
2024
Prizes
- 🏆
Best use of Blockscout Block Explorer
Blockscout
- 🏆
Pool Prize
Worldcoin
Contributors
- matthew1809
44 contributions
- krisoshea-eth
38 contributions
- francescocirulli
13 contributions
- limone-eth
7 contributions
- andreaswierm
2 contributions
- 0xRAG
2 contributions