Users can use this function to sell NFTs directly to buy pools (i.e., the buyer offer) for exchange of immediate liquidity. You can sell to multiple pools in one transaction

Request Parameters
ParameterTypeDescriptionExample
swapListRobustPairSwapSpecific[]Data Content: [[[Contract Address, [Token ID 1, Token ID 2, ...],[Amount 1, Amount 2]], Expected Payment Amount]][[['0x4485aD38f3fe1DA3856155496f7fEce05d4C3B56', 3104', [1,2,3], [1,2,3]], 1000000000000000000]]
tokenRecipientaddressUnused ETH recipient address, usually msg.sender0x0a9EE17c7B649dd30Db1450537576d313FF862C7
deadlineuint256Expiration timestamp1665208404

call router contract

Additional
// The specific structure of swapList
struct RobustPairSwapSpecificForToken {
        PairSwapSpecific swapInfo;
        uint256 minOutput;
}

struct PairSwapSpecific {
        LSSVMPair pair;
        uint256[] nftIds;
        uint256[] nftCounts;
}

ABI

function robustSwapNFTsForToken(tuple(tuple(address,uint256[],uint256[]),uint256)[],address,uint256) public returns (uint256)

Expected value and current price of an NFT

Refer to the calculation library for detail.

When selling an NFT, it is necessary to have a minimum expected amount of ETH to avoid sandwidge attack, and if this amount is not reached, the transaction will fail.
//Example: Scenario: User sells an NFT, the type of change in this pool is exponential
mathLib.Exponential.sell(1, 0.1, 0.003, 0.003, 1, 0, 'read')
//Returns: Total price (totalETH): priceData.userSellPrice, price displayed on the page for this NFT: currentPrice.userSellPrice
{
  priceData: {
    delta: 0.1,
    spotPrice: 1,
		userSellPrice: 0.994,
    poolBuyPrice: 0.997,
    poolBuyPriceFee: 0.003,
    userSellPriceFee: 0.006
  },
  currentPrice: { userSellPrice: 0.994 },   --current price
  nextPrice: { userSellPrice: 0.8945999999999998 }  --price of the next NFT
}

Code example

import { ethers, utils } from 'ethers';

const DEADLINE = Date.parse(new Date()) / 1000 + 60 * 3600;
const abi = ['function robustSwapNFTsForToken(tuple(tuple(address,uint256[],uint256[]),uint256)[],address,uint256) public returns (uint256)'];
const signer = new ethers.providers.Web3Provider(window?.ethereum).getSigner();
const contract = new ethers.Contract(routerAddress, abi, signer);
const txResult = await contract.robustSwapNFTsForToken(
	swapList,
  tokenRecipient,
  DEADLINE
);

Detailed and comprehensive demo: https://github.com/EZswap-Labs/api-demo