NFTX
v3.0
Search
K

MarketplaceUniversalRouterZap

MarketplaceUniversalRouterZap.sol
This contract is a marketplace zap that uses the NFTX Universal Router.

Table of Contents

Owner Write Functions

Constants

WETH

function WETH() external view returns (address)
Address of WETH contract.

PERMIT2

function PERMIT2() external view returns (address)
Address of PERMIT2 contract.

nftxVaultFactory

function nftxVaultFactory() external view returns (address)
Address of NFTXVaultFactory contract.

inventoryStaking

function inventoryStaking() external view returns (address)
Address of NFTXInventoryStakingV3 contract.

BASE

uint256 constant BASE = 10 ** 18

Variables

universalRouter

function universalRouter() external view returns (address)
Address of NFTX's UniversalRouter contract.

paused

function paused() external view returns (bool)
Is the contract paused.

dustThreshold

function dustThreshold() external view returns (uint256)
The maximum vToken amount that constitutes "dust."

Events

Sell

event Sell(
uint256 vaultId,
uint256 count,
uint256 ethReceived,
address to,
uint256 netRoyaltyAmount,
uint256 wethFees
)
Emitted by sell721() and sell1155().
Parameters
Type
Description
vaultId
uint256
ID number of vault.
count
uint256
Total number of NFTs sold.
ethReceived
uint256
Amount of ETH received.
to
address
ETH proceeds receipient.
netRoyaltyAmount
uint256
Total royalty paid.
wethFees
uint256
WETH vault fees paid.

Swap (721)

event Swap(
uint256 vaultId,
uint256[] idsIn,
uint256[] idsOut,
uint256 ethSpent,
address to
)
Emitted by swap721().
Parameters
Type
Description
vaultId
uint256
ID of vault.
idsIn
uint256[]
NFT tokenIDs sent.
idsOut
uint256[]
NFT tokenIDs received.
ethSpent
uint256
Total ETH paid for swap.
to
address
Recipient that received NFT idsOut.

Swap (1155)

event Swap(
uint256 vaultId,
uint256[] idsIn,
uint256[] amounts,
uint256[] idsOut,
uint256 ethSpent,
address to
)
Emitted by swap1155().
Parameters
Type
Description
vaultId
uint256
ID number of vault.
idsIn
uint256[]
NFT tokenIDs sent.
amounts
uint256[]
Amounts of tokenIDs (sent and received).
idsOut
uint256[]
NFT tokenIDs received.
ethSpent
uint256
Amount of ETH paid for swap.
to
address
Recipient that received NFT idsOut.

Buy

event Buy(
uint256 vaultId,
uint256[] nftIds,
uint256 ethSpent,
address to,
uint256 netRoyaltyAmount
)
Emitted by buyNFTsWithETH(), buyNFTsWithERC20() and buyNFTsWithERC20WithPermit2().
Parameters
Type
Description
vaultId
uint256
ID of vault.
nftIds
uint256[]
NFT token IDs.
ethSpent
uint256
Total ETH paid for purchase.
to
address
Recipient of NFTs.
netRoyaltyAmount
uint256
Total royalty paid, in ETH.

DustReturned

event DustReturned(uint256 ethAmount, uint256 vTokenAmount, address to)
Emitted by buyNFTsWithETH(), buyNFTsWithERC20() and buyNFTsWithERC20WithPermit2().
Parameters
Type
Description
ethAmount
uint256
Amount of ETH dust returned.
vTokenAmount
uint256
Amount of vToken dust returned.
to
address
Recipient of dust.

Paused

event Paused(bool status)
Emitted by pause().
Parameters
Type
Description
status
bool
True if paused, false if un-paused.

NewUniversalRouter

event NewUniversalRouter(address universalRouter)
Emitted by setUniversalRouter().
Parameters
Type
Description
universalRouter
address
New NFTX UniversalRouter address.

NewDustThreshold

event NewDustThreshold(uint256 dustThreshold)
Emitted by setDustThreshold().
Parameters
Type
Description
dustThreshold
uint256
New dust threshold amount.

Write Functions

sell721

function sell721(
uint256 vaultId,
uint256[] calldata idsIn,
bytes calldata executeCallData,
address payable to,
bool deductRoyalty
) external
Sells one or more ERC721 NFTs for ETH.
Parameters
Type
Description
vaultId
uint256
ID of vault that NFTs are being sold into.
idsIn
uint256[]
IDs of NFTs being sold.
executeCallData
address
Encoded swap data.
to
address
Recipient of ETH proceeds.
deductRoyalty
bool
Whether a royalty is deducted.

swap721

function swap721(
uint256 vaultId,
uint256[] calldata idsIn,
uint256[] calldata idsOut,
uint256 vTokenPremiumLimit,
address payable to
) external payable
Swaps one or more ERC721 NFTs for one or more other ERC721 NFTs.
Parameters
Type
Description
vaultId
uint256
ID of vault that NFTs are being swapped out of.
idsIn
uint256[]
IDs of NFTs being sent to vault.
idsOut
uint256[]
IDs of NFTs exiting vault.
vTokenPremiumLimit
uint256
Max premium fee to be paid (in vToken).
to
address
Address that NFTs from vault are sent to.
msg.value
uint256
Amount of ETH to send.

buyNFTsWithETH

function buyNFTsWithETH(
uint256 vaultId,
uint256[] calldata idsOut,
bytes calldata executeCallData,
address payable to,
uint256 vTokenPremiumLimit,
bool deductRoyalty
) external payable
Buys one or more NFTs with ETH.
Parameters
Type
Description
vaultId
uint256
ID of vault holding desired NFTs.
idsOut
uint256[]
IDs of desired NFTs.
executeCallData
bytes
Encoded swap data.
to
address
Address that NFTs are sent to.
vTokenPremiumLimit
uint256
Max premium fee to be paid (measured in vToken despite payment being in ETH).
deductRoyalty
bool
Whether a royalty is deducted.
msg.value
uint256
Amount of ETH to send.

buyNFTsWithERC20

function buyNFTsWithERC20(
BuyNFTsWithERC20Params calldata params
) external
Purchases NFTs via NFTX's UniversalRouter and pay with any ERC20 supported by the NFTX AMM.
Parameters
Type
Description
params
BuyNFTsWithERC20Params
See table below.
BuyNFTsWithERC20Params
Type
Description
tokenIn
IERC20
Address of input token.
amountIn
uint256
Amount of input token.
vaultId
uint256
Vault ID of vToken holding desired NFTs.
idsOut
uint256
NFT token IDs to buy.
vTokenPremiumLimit
uint256
Max premium fee to be paid (measured in vToken).
executeToWETHCallData
bytes
Encoded call data for "ERC20 to WETH swap" for NFTX UniversalRouter's execute function.
executeToVTokenCallData
bytes
Encoded call data for "WETH to vToken swap" for NFTX Universal Router's execute function.
to
address
Recipient of purchased NFT IDs.
deductRoyalty
bool
Whether a royalty is deducted.

buyNFTsWithERC20WithPermit2

function buyNFTsWithERC20WithPermit2(
BuyNFTsWithERC20Params calldata params,
bytes calldata encodedPermit2
) external
Buys one or more NFTs with ERC20, using Permit2 for token approval.
Parameters
Type
Description
params
BuyNFTsWithERC20Params
See table above.
encodedPermit2
bytes
Encoded Permit2 data:
address owner,
IPermitAllowanceTransfer.PermitSingle,
bytes memory signature

sell1155

function sell1155(
uint256 vaultId,
uint256[] calldata idsIn,
uint256[] calldata amounts,
bytes calldata executeCallData,
address payable to,
bool deductRoyalty
) external
Sells one or more ERC1155 NFTs.
Parameters
Type
Description
vaultId
uint256
ID of vault to sell into.
idsIn
uint256[]
IDs of NFTs to sell.
amounts
uint256[]
Quantities of each NFT token ID to send.
executeCallData
bytes
Encoded swap data.
to
address
Address to receive ETH from sale.
deductRoyalty
bool
Whether a royalty is deducted.

swap1155

function swap1155(
uint256 vaultId,
uint256[] calldata idsIn,
uint256[] calldata amounts,
uint256[] calldata idsOut,
uint256 vTokenPremiumLimit,
address payable to
) external payable
Swaps one or more ERC1155 NFTs for one or more other ERC1155 NFTs.
Parameters
Type
Description
vaultId
uint256
ID of vault being swapped into.
idsIn
uint256[]
IDs of NFTs being sent to vault.
amounts
uint256[]
Quantities of each NFT being sent.
idsOut
uint256[]
IDs of NFTs exiting the vault.
vTokenPremiumLimit
uint256
Max premium fee to be paid (in vToken).
to
address
Address that receives NFTs leaving the vault.
msg.value
uint256
Amount of ETH to send.

Owner Functions

pause

function pause(bool paused_) external
Pauses this contract.
Parameters
Type
Description
paused_
bool
True to pause, false to un-pause.

setUniversalRouter

function setUniversalRouter(address universalRouter_) external
Sets address of NFTX Universal Router.
Parameters
Type
Description
universalRouter_
address
New NFTX universal router address.

setDustThreshold

function setDustThreshold(uint256 dustThreshold_) external
Sets (max) threshold for what is considered token dust.
Name
Type
Description
dustThreshold_
uint256
Max threshold for dust.