Overview
The L1Unwrapper contract is an extension of the WETHOmnibridgeRouter that facilitates ETH deposits to the TornadoPool on L2 and handles withdrawals back to L1. It manages the wrapping/unwrapping of ETH to WETH for bridge compatibility and stores TornadoPool account registrations. Contract Location:contracts/bridge/L1Unwrapper.sol
State Variables
Address that receives L1 execution fees. If set to zero address, fees go to tx.origin. Can be changed by the multisig to implement fee sharing logic.
Constructor
OmniBridge contract address
Wrapped ETH (WETH) contract address
Owner address for contract governance
WETHOmnibridgeRouter(_bridge, _weth, _owner)
Source: contracts/bridge/L1Unwrapper.sol:37
Public Functions
register
Account structure containing owner address and public key bytes
- Account owner must be msg.sender
PublicKey(address indexed owner, bytes key)
Source: contracts/bridge/L1Unwrapper.sol:46
wrapAndRelayTokens
Receiver address on L2 (typically the TornadoPool contract)
Encoded data to pass to the receiver on L2 (contains Proof and ExtData)
TornadoPool account data for registration. If account.owner == msg.sender, registration will occur.
- Wraps msg.value ETH to WETH
- Calls bridge.relayTokensAndCall() to send WETH and data to L2
- If _account.owner matches msg.sender, registers the account
contracts/bridge/L1Unwrapper.sol:58
onTokenBridged
Bridged token address (must be WETH)
Amount of tokens bridged
Extra data containing recipient address and L1 fee (must be exactly 64 bytes)
- Token must be WETH
- Only callable by bridge contract
- Data length must be exactly 64 bytes
- Withdraws WETH to native ETH
- Decodes recipient address and l1Fee from _data
- Sends (value - l1Fee) to recipient
- Sends l1Fee to l1FeeReceiver or tx.origin if l1FeeReceiver is zero address
contracts/bridge/L1Unwrapper.sol:83
setL1FeeReceiver
Address of the new L1 fee receiver. Set to address(0) for native tx.origin receiver.
- Only callable by contract owner
contracts/bridge/L1Unwrapper.sol:109
Data Structures
Account
Ethereum address of the account owner
Public key bytes for encryption and receiving shielded transfers (64 bytes: 32 bytes pubkey + 32 bytes encryption key)
contracts/bridge/L1Unwrapper.sol:32
Events
PublicKey
Address of the account owner
Public key bytes registered
contracts/bridge/L1Unwrapper.sol:30
Usage Example
Inherited Functions
L1Unwrapper inherits fromWETHOmnibridgeRouter, which provides:
- Bridge wrapping/unwrapping utilities
- Owner access control via
onlyOwnermodifier - Safe ETH transfer helpers via
AddressHelper.safeSendValue