NFT20Pair

NFT20Pair is an ERC20 token contract representing a pool of ERC721/ERC1155 NFT tokens. It allows users to deposit their ERC721/ERC1155 tokens in exchange for corresponding ERC20 tokens, and vice versa. Users may also use this contract to trade their ERC721/ERC1155 tokens for other tokens in the pool.

The currently deployed base (logic) contract can be found at 0x7824948612d5F6d3dBC54d1c1173715B997403a1 on mainnet Ethereum.

When creating new pairs NFT20Factory will instantiate a new instance of this contract (via a BeaconProxy) to represent the pair.

You should never interact with this base contract directly, and should instead use NFT20Factory.nftToToken() to find the deployed contract for the pair you wish to use.

General Deposit Behavior

This contract conforms to IERC721Receiver and IERC1155Receiver in order to mint ERC20 pair tokens in exchange for ERC721/ERC1155 NFTs.

Sending ERC721/ERC1155 tokens directly to a pair address will result in the transfer of the corresponding ERC20 pair tokens to the sender upon receipt.

In general, you must approve the pair contract address to transfer the relevant tokens on your behalf before calling these methods.

Methods

withdraw()

function withdraw(uint256[] calldata _tokenIds,uint256[] calldata amounts,address receipient) external

Burns ERC20 tokens to redeem ERC721/ERC1155 tokens from the pool.

Parameters

Parameter NameTypeDescription

_tokenIds

uint256[]

An array of tokenIds to withdraw.

amounts

uint256[]

The amount of each token in _tokenIds to withdraw.

receipient

address

Address where ERC721/ERC1155 tokens should be transfered to.

multi721Deposit()

function multi721Deposit(uint256[] memory _ids, address _referral) public;

Deposits multiple ERC721 tokens in exchange for the pair’s ERC20 token in one transaction.

Parameters

Parameter NameTypeDescription

_ids

uint256[]

An array of tokenIds to deposit.

_referral

address

Referring address to recieve 40% of the fee.

swap721()

function swap721(uint256 _in, uint256 _out) external;

Swaps an ERC721 token for a different ERC721 token in the pool.

Parameters

Parameter NameTypeDescription

_in

uint256

tokenId to deposit.

_out

uint256

tokenId to withdraw.

swap1155()

function swap1155(uint256[] calldata in_ids,uint256[] calldata in_amounts,uint256[] calldata out_ids,uint256[] calldata out_amounts) external;

Swaps ERC1155 token(s) for different ERC115 token(s) in the pool.

Parameters

Parameter NameTypeDescription

_in_ids

uint256[]

An array of tokenIds to deposit.

_in_amounts

uint256[]

An array of amounts of tokens to deposit.

_out_ids

uint256[]

An array of tokenIds to withdraw.

_out_amounts

uint256[]

An array of amounts of tokens to withdraw.

View Methods

factory()

address public factory;

Returns the factory contract that created this pair.

Return values

TypeDescription

address

Factory contract address.

nftAddress()

address public nftAddress;

Returns the address of the ERC721/ERC1155 token held in this pair.

Return values

TypeDescription

address

ERC721/ERC1155 contract address.

nftType()

uint256 public nftType;

Returns the type of NFT held in this pair, 721 for ERC721 or 1155 for ERC1155.

Return values

TypeDescription

uint256

721 for ERC721 or 1155 for ERC1155.

nftValue()

uint256 public nftValue;

Returns the amount of ERC20 tokens to be issued per ERC721/ERC1155 deposit.

Return values

TypeDescription

uint256

amount of ERC20 tokens issued on deposit

Last updated