Skip to content
Lattice

WETHUnwrapper

Git Source

Title: WETHUnwrapper

Author: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80)

WETH → ETH relay for diamond-hosted adapters. Canonical WETH9 pays withdraw via msg.sender.transfer — a 2,300-gas stipend that cannot cover a diamond's zero-selector routing to the Receive facet (cold selector-map SLOAD + delegatecall). An adapter transfers its WETH here and calls unwrap: this contract absorbs the stipend send with a plain receive() and returns the ETH to the caller with FULL gas (call), which the diamond's Receive facet accepts.

Stateless and permissionless. It holds funds only within the unwrap transaction — anything parked here between transactions is claimable by the next unwrap caller, so ALWAYS transfer-then-unwrap atomically. Deployed lazily per diamond via CREATE2 (see LidoAdapterLib._wethUnwrapper).

Functions

unwrap

Unwraps this contract's entire WETH balance and sends the ETH to the caller.

function unwrap(IWETH9 _weth) external;

Parameters

NameTypeDescription
_wethIWETH9The WETH9 contract to withdraw from.

receive

Accepts WETH9's stipend-limited transfer payout.

receive() external payable;

Errors

WETHUnwrapper__EthReturnFailed

The full-gas ETH return to the caller failed.

error WETHUnwrapper__EthReturnFailed();