ERC-3386 A wrapper that wraps NFTs as ERC-20 (ERC-721 and ERC-1155 to ERC-20 Wrapper)

Stagnant · NFTs & multi-token · created 2021-03-12

A common interface for depositing ERC-721 or ERC-1155 tokens into a pool and issuing an ERC-20 derivative token in exchange, or burning the derivative token to redeem the base token.

Why it is needed

ERC-20 is the most widely used and liquid token standard, but ERC-721 and ERC-1155 tokens each have a unique identifier (id), so they can only be transferred as individual units. Because of this, NFTs cannot take advantage of ERC-20-only contracts, such as being pooled like ordinary tokens in an automated market maker (AMM), used as collateral, or traded in fractional amounts. Projects such as NFTX, WrappedKitties, NFT20, and MoonCatsWrapped have each already implemented their own way of wrapping NFTs as ERC-20, but because the function names and events all differ, wallets and other contracts find it difficult to recognize or integrate with them in a common way.

In depth

The relationship between Base, Pool, Derivative, and Wrapper

The original text distinguishes four roles. Base is the ERC-721 or ERC-1155 contract being pooled, Pool is the contract that holds the Base tokens, and Derivative is the ERC-20 contract that the Wrapper issues and burns. Wrapper refers to the contract that implements this interface itself. The specification states that all four of these can be the same contract. In other words, a single contract can serve as the ERC-20, the ERC-721/1155 receiver, and the pool custody logic all at once, or they can be split into separate contracts.

Unifying ERC-721 and ERC-1155 amount notation

ERC-1155 can hold one or more tokens of the same id, but ERC-721 only ever has one token per (address, id) pair. To unify this difference, the specification requires that when handling ERC-721, the _amount parameter must be 1, and the _amounts parameter must either be an empty list or a list of 1s with the same length as _ids. This allows both token standards to be handled with the same set of functions and events.

Minting methods: deposit-based and collateral-based

Minting is a method of transferring a Base token to the Pool and receiving a Derivative token in exchange. A Base token that has entered the pool this way must not be transferred again except through a burn function. This is to ensure that the value of the Derivative token always faithfully represents the value of the Base token. As an alternative, as proposed in the NFTX lightpaper, instead of moving the Base token into the Pool, it can be locked as collateral and a Derivative token borrowed against it in exchange, a pattern similar to a Maker vault.

Why the burn function is split into four variants

The burn functions differ depending on whether they specify which Base token to withdraw. burn and batchBurn withdraw an arbitrary Base token from the pool without specifying an id, while idBurn and batchIdBurn withdraw by specifying a particular id. Being able to specify an id means a more valuable token within the pool can be selected, and NFTX proposes charging an additional fee for this kind of targeted withdrawal to discourage the pool from being drained of its high-value tokens.

Diversity of pricing methods

The specification states that prices need not be fixed, and summarizes existing implementation cases into three types. The Equal method (NFTX, WrappedKitties) exchanges 1 Base token for 1 Derivative token. The Proportional method (NFT20) uses a fixed ratio, such as 100 Base tokens per 1 Derivative token. The Variable method has a ratio that changes depending on circumstances, such as NFT20's Dutch-auction-style minting or NFTX's id-specified withdrawal fee. Because of this diversity, the Mint* and Burn* events must include the amount of Derivative tokens issued or burned (_value).

Choice of inheritance structure

If the Wrapper inherits ERC-20, it can call super.mint and super.burn directly; otherwise, authority to change the Derivative contract's supply must be restricted to the Wrapper alone. Likewise, if it does not inherit ERC721Receiver or ERC1155Receiver, the Pool must be restricted to exchanging Base tokens only through the Wrapper's mint and burn functions. If the Wrapper directly inherits ERC-721 or ERC-1155, it is also possible to mint new Base tokens within the contract and distribute them immediately as Derivative tokens, as in an Initial NFT Offering.

How Approval Is Handled

All underlying transfer functions call the transfer functions of ERC-20, ERC-721, or ERC-1155 directly, not the Wrapper. Implementations must therefore either implement Derivative token approval for burning and Base token approval needed for minting themselves, or check IERC721/IERC1155 approval status outside the Wrapper before execution.

Proposal status notice

This ERC is marked Stagnant. That is, it is a draft whose discussion has stalled without being finalized as an official standard, and its content may change or may never be adopted.

Things to watch out for

Original ERC · ← ERCs