NFT Market
Automated market maker for NFTs with bonding curves
NFT Market
NFT AMM with customizable bonding curves for instant NFT liquidity.
Overview
Unlike traditional NFT marketplaces that use order books, the NFT Market uses bonding curves to provide instant liquidity for buying and selling NFTs.
Pool Types
| Type | Description | Use Case |
|---|---|---|
TOKEN | Sell NFTs for tokens | Exit NFT position |
NFT | Buy NFTs with tokens | Accumulate NFTs |
TRADE | Two-way trading with spread | Market making |
Bonding Curves
Linear Curve
Price = spotPrice + delta * numItemsPrice increases/decreases linearly with each trade.
Exponential Curve
Price = spotPrice * (1 + delta)^numItemsPrice grows/shrinks exponentially.
XYK Curve
Price follows x * y = k constant product formulaClassic AMM curve for NFTs.
GDA Curve (Gradual Dutch Auction)
Prices decay over time, useful for NFT launches.
NFTPair
The core pair contract that holds NFTs and tokens.
State Variables
uint128 public spotPrice; // Current spot price
uint128 public delta; // Curve parameter
uint96 public fee; // Trade fee (for TRADE pools)
address payable assetRecipient; // Where assets goKey Functions
swapTokenForSpecificNFTs
function swapTokenForSpecificNFTs(
uint256[] calldata nftIds,
uint256 maxExpectedTokenInput,
address nftRecipient,
bool isRouter,
address routerCaller
) external payable returns (uint256 inputAmount)Buy specific NFTs from the pool.
swapNFTsForToken
function swapNFTsForToken(
uint256[] calldata nftIds,
uint256 minExpectedTokenOutput,
address payable tokenRecipient,
bool isRouter,
address routerCaller
) external returns (uint256 outputAmount)Sell NFTs to the pool.
getBuyNFTQuote
function getBuyNFTQuote(
uint256 assetId,
uint256 numItems
) external view returns (
CurveErrorCodes.Error error,
uint256 newSpotPrice,
uint256 newDelta,
uint256 inputAmount,
uint256 protocolFee,
uint256 royaltyAmount
)Get quote for buying NFTs.
NFTRouter
Aggregates swaps across multiple pools.
function swapLUXForSpecificNFTs(
PairSwapSpecific[] calldata swapList,
address payable luxRecipient,
address nftRecipient,
uint256 deadline
) external payable returns (uint256 remainingValue)Factory
function createPairERC721LUX(
IERC721 _nft,
ICurve _bondingCurve,
address payable _assetRecipient,
NFTPair.PoolType _poolType,
uint128 _delta,
uint96 _fee,
uint128 _spotPrice,
address _propertyChecker,
uint256[] calldata _initialNFTIDs
) external returns (NFTPairERC721LUX pair)NFT Lending
Borrow against NFTs held in liquidity pools.
function borrow(
address pair,
uint256[] calldata nftIds,
address swapPool,
uint256 minOutput
) external payableBorrow LUX against NFTs held in a pool.
Usage Example
import "@luxfi/standard/src/nft/NFTRouter.sol";
import "@luxfi/standard/src/nft/NFTPairFactory.sol";
// Create a TRADE pool for my NFT collection
NFTPairERC721LUX pair = factory.createPairERC721LUX(
myNFT,
linearCurve,
address(this),
NFTPair.PoolType.TRADE,
0.01 ether, // delta (price increment)
0.05e18, // 5% fee
0.1 ether, // starting price
address(0), // no property checker
initialNFTIds
);
// Buy NFTs through router
router.swapLUXForSpecificNFTs{value: 1 ether}(
swapList,
msg.sender, // LUX recipient (for refund)
msg.sender, // NFT recipient
block.timestamp + 1 hours
);Events
event SwapNFTInPair(uint256 amountOut, uint256[] ids);
event SwapNFTOutPair(uint256 amountIn, uint256[] ids);
event SpotPriceUpdate(uint128 newSpotPrice);
event DeltaUpdate(uint128 newDelta);
event FeeUpdate(uint96 newFee);