NFTXRouter
NFTXRouter.sol
This contract interacts with the NFTX AMM for adding & removing liquidity, and facilitating buys & sells. It also handles minting and burning vTokens when necessary.
Table of Contents
Constants
WETH
Contract address of WETH
.
PERMIT2
Contract address of PERMIT2.
positionManager
Contract address of the AMM's NonfungiblePositionManager
.
router
Contract address of the AMM's SwapRouter
.
quoter
Contract address of the AMM's QuoterV2
.
nftxVaultFactory
Contract address of the NFTX vault factory.
inventoryStaking
Address of inventory staking contract.
Variables
lpTimelock
The timelock duration to apply to new positions.
earlyWithdrawPenaltyInWei
Early withdrawal fee. 1e16 = 1%.
vTokenDustThreshold
Threshold amount for vToken dust to be returned.
Events
AddLiquidity
Emitted by addLiquidity()
and addLiquidityWithPermit2()
.
RemoveLiquidity
Emitted by removeLiquidity()
.
IncreaseLiquidity
Emitted by increaseLiquidity()
and increaseLiquidityWithPermit2()
.
SellNFTs
Emitted by sellNFTs()
.
BuyNFTs
Emitted by buyNFTs()
.
Write Functions
addLiquidity
Adds liquidity to an AMM pool (specified by a vToken address and a trading fee). Returns the token ID of the newly minted liquidity NFT. There can be at most one pool for each vToken/WETH pair and fee. If a pool with the specified fee and vToken does not already exist then one is created.
addLiquidityWithPermit2
Adds liquidity using Permit2 contract.
increaseLiquidity
Increase the size of a liquidity position.
increaseLiquidityWithPermit2
Increase the size of a liquidity position, using permit2 for vTokens instead of regular approvals.
removeLiquidity
Removes liquidity from an AMM pool and claims any available fees.
sellNFTs
Takes NFTs from caller and returns ETH. First, the NFTs are converted to vToken, and then the vToken is swapped for WETH through a single pool determined by the fee
param.
buyNFTs
Takes ETH from caller in return for NFTs. First, the ETH is swapped for vToken, and then the vToken is used to redeem the NFTs. The swap is routed through a single pool, determined by the fee
param.
Owner Functions
rescueTokens
Sends balance of an ERC20 token to caller. Also works for ETH.
setLpTimelock
Sets the LP timelock duration.
setVTokenDustThreshold
Sets the vToken dust threshold (minimum amount required to be returned to sender).
setEarlyWithdrawPenalty
Sets the early withdrawal penalty. 1e16 = 1%.
Read Functions
quoteBuyNFTs
Computes the cost in ETH to purchase one or more NFTs.
getPoolExists
Checks for the existence of a pool.
getPool
Retrieves the address of the pool (if it exists) for a vToken and fee setting.
computePool
Computes the deterministically generated pool address.
isVToken0
Checks if a vToken is token0 when paired with WETH.
Last updated