Skip to main content

IERC6909Wrappable

Git Source

Title: IERC6909Wrappable

Declares interface for an ERC6909 implementation that allows for wrapping and unwrapping ERC6909 tokens to and from ERC20 tokens

Functions

wrap

Wraps an ERC6909 token to an ERC20 token

function wrap(uint256 tokenId_, uint256 amount_) external returns (address wrappedToken);

Parameters

NameTypeDescription
tokenId_uint256The ID of the ERC6909 token
amount_uint256The amount of tokens to wrap

Returns

NameTypeDescription
wrappedTokenaddressThe address of the wrapped ERC20 token

unwrap

Unwraps an ERC20 token to an ERC6909 token

function unwrap(uint256 tokenId_, uint256 amount_) external;

Parameters

NameTypeDescription
tokenId_uint256The ID of the ERC6909 token
amount_uint256The amount of tokens to unwrap

getWrappedToken

Returns the address of the wrapped ERC20 token for a given token ID

function getWrappedToken(uint256 tokenId_) external view returns (address wrappedToken);

Parameters

NameTypeDescription
tokenId_uint256The ID of the ERC6909 token

Returns

NameTypeDescription
wrappedTokenaddressThe address of the wrapped ERC20 token (or zero address)

isValidTokenId

Returns whether a token ID is valid

function isValidTokenId(uint256 tokenId_) external view returns (bool isValid);

Parameters

NameTypeDescription
tokenId_uint256The ID of the ERC6909 token

Returns

NameTypeDescription
isValidboolWhether the token ID is valid

getWrappableTokens

Returns the token IDs and wrapped token addresses of all tokens

function getWrappableTokens() external view returns (uint256[] memory tokenIds, address[] memory wrappedTokens);

Returns

NameTypeDescription
tokenIdsuint256[]The IDs of all tokens
wrappedTokensaddress[]The wrapped token addresses of all tokens

Events

Wrapped

event Wrapped(uint256 indexed tokenId, address indexed wrappedToken, address indexed account, uint256 amount);

Unwrapped

event Unwrapped(uint256 indexed tokenId, address indexed wrappedToken, address indexed account, uint256 amount);

Errors

ERC6909Wrappable_TokenIdAlreadyExists

error ERC6909Wrappable_TokenIdAlreadyExists(uint256 tokenId);

ERC6909Wrappable_InvalidTokenId

error ERC6909Wrappable_InvalidTokenId(uint256 tokenId);

ERC6909Wrappable_InvalidERC20Implementation

error ERC6909Wrappable_InvalidERC20Implementation(address erc20Implementation);

ERC6909Wrappable_ZeroAmount

error ERC6909Wrappable_ZeroAmount();