ERC20Wrapper
Inherits: IERC20Wrapper
Title: ERC20Wrapper
Author: Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC20Wrapper.sol)
Stateless Diamond facet — wraps an underlying ERC-20 1:1. Pure delegator to ERC20WrapperLib.
recover() is intentionally NOT exposed here: exposing it requires access control, so a deriving facet
adds it. decimals() overrides the base 18 to mirror the underlying.
CUSTODY: the internal recover mints the diamond's WHOLE underlying balance above total supply, so a
facet that exposes it also mints any other module's escrow of the underlying (an ERC-4626 vault,
VestingWallet, BridgeERC20 or ShieldedPool). One custodian per asset per diamond (issue #240).
Notes:
- lattice-version: 0.1.0
- lattice-source: OpenZeppelin v5.6.1
Functions
decimals
The wrapper decimals, mirroring the underlying token (replaces the base 18).
function decimals() public view virtual returns (uint8);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint8 |
underlying
The address of the underlying ERC-20 token being wrapped.
function underlying() public view virtual returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
depositFor
Deposit value underlying tokens from the caller and mint the same number of wrapped tokens to
account.
function depositFor(address account, uint256 value) public virtual returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| account | address | |
| value | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
withdrawTo
Burn value wrapped tokens from the caller and send the same number of underlying tokens to
account.
function withdrawTo(address account, uint256 value) public virtual returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| account | address | |
| value | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
exportSelectors
ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).
Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches
forge inspect ERC20Wrapper methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
decimals() 0x313ce567
depositFor(address,uint256) 0x2f4f21e2
underlying() 0x6f307dc3
withdrawTo(address,uint256) 0x205c2878
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |