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

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.

UniChain Hook

Created At

ETHGlobal Brussels

Winner of

Blockscout - Best use of Blockscout Block Explorer

Prize Pool

Worldcoin - Pool Prize

Prize Pool

Project Description

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.

How it's Made

  1. Core Technology Stack:
  • Solidity for smart contract development
  • Uniswap v4 for the base AMM functionality
  • LayerZero for cross-chain interoperability
  • Worldcoin ID for identity verification
  • Dynamic Wallet for log in
  • Safe smart wallet for smart accounts
  • Blockscout
  1. Smart Contract Architecture:
  • Implemented a custom Uniswap v4 hook (SwapHook) to integrate cross-chain functionality and identity verification
  • Used the BaseHook contract from Uniswap v4 periphery as a foundation
  • Implemented beforeSwap and afterSwap functions to handle custom logic 3: Cross-Chain Functionality:
  • Integrated LayerZero's OFT (Omnichain Fungible Token) standard
  • Implemented cross-chain message passing using LayerZero's Ultra Light Nodes (ULNs)
  • Used LayerZero's send function to initiate cross-chain transfers
  1. Identity Verification:
  • Integrated Worldcoin's World ID protocol for proof of personhood
  • Implemented verification checks in the beforeSwap function
  • Used zero-knowledge proofs to maintain user privacy
  1. Token Handling:
  • Implemented a token locking mechanism for cross-chain transfers
  • Used ERC20 and OFT standard for token interactions
  1. Testing and Development:
  • Used Foundry for smart contract testing and deployment
  • Implemented comprehensive test cases covering various scenarios
  1. Notable 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 CrossChainTransferInitiated
  2. Challenges and Solutions:
  • Addressed the complexity of encoding and decoding hookData to include both Worldcoin and cross-chain information
  • Implemented careful error handling and logging to debug cross-chain interactions
background image mobile

Join the mailing list

Get the latest news and updates