const res: IResType<ISwapInfo>= await floorswap.swap.swapInfo({
collection: '...',
swapType: 1,
slippage?: 5,
count?: 1,
nftList?: ['5'],
}: ISwapInfoParams)
interface ISwapInfoParams {
collection: string;
swapType: number;
slippage?: number;
count?: number;
nftList?: string[];
}
interface IResType<T> {
code: string;
message: string;
success: boolean;
data: T;
}
interface ISwapInfo {
swapList: {
pairAddress: string;
nftList: string[];
}[];
signature: string;
tokenAmount: number;
protocolFee: number;
lpFee: number;
slippageAmount: number;
}
const response:ContractTransactionResponse = await floorswap.swap.swapTokenForNft({
signer: signer,
collection: "0x1234...",
count: 2,
slippage: 0.02,
}: ISwapTokenForNftParams & { signer: ethers.Signer });
interface ISwapTokenForNftParams {
collection: string;
slippage: number;
count: number;
}
const response:ContractTransactionResponse = await floorswap.swap.swapNftForToken({
signer: signer,
collection: "0x1234...",
nftIds: ["57", "68"],
slippage: 0.02,
}: ISwapNftForTokenParams & { signer: ethers.Signer });
interface ISwapNftForTokenParams {
collection: string;
slippage: number;
nftIds: string[];
}
Swap any NFTs for ETH.
const collection = "0x1234..."; // Collection contract address
const amount = 2;
const slippage = 0.02; //0.02 = 2%
await floorswapSDK.swap.swapAnyNftForToken({
signer: signer,
collection: nftAddress,
count: nftIds,
slippage: slippage,
}: ISwapAnyNftForTokenParams & { signer: ethers.Signer });
interface ISwapAnyNftForTokenParams {
collection: string;
slippage: number;
amount: number;
}