API Reference

Users can list NFTs (create Sell Pool), make offer (create Buy Pool) and liquidity mining (create Trade Pool) with this function

Request Parameters

Note: The outermost layer is an object, and the following parameters need to be enclosed in []

ParameterTypeDescription
_nftaddressThe address of the ERC721 NFT contract.0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
_bondingCurveaddressThe address of the AMM mechanism.
Linear: 0x0f776A85F842b605E0771B6a244DF2a2505Fa7A1
Exponential: 0x0F16Be0e961AD87f47A5e2a8177e0c2299C7849c
0x0f776A85F842b605E0771B6a244DF2a2505Fa7A1
_assetRecipientaddressThe recipient address of the asset, as the asset of buy pool and sell pool will be directly sent to the assetRecipient, and the asset of trade pool will remain in the pool. Therefore, when _poolType is 0 or 1, pass the address of the asset recipient, such as the creator address, when _poolType is 2, pass the 0 address.msgsender or 0 address
_poolTypeenumBuy: 0; Sell: 1; Trade: 20 or 1 or 2
_deltauint128The amplitude of the price change in the pool after each transaction. For example, if the current linear pool price is 1 and delta is 0.1, the pool price will be 1.1 after buying an NFT (roughly calculated). If delta is 0, the pool price will remain unchanged after buying an NFT. Units: wei.0.1 * 10 ** 18 wei
_feeuint96The transaction fee for each transaction. Buy and sell pools do not have this option and are set to 0 by default. Trade pools allow users to customize the transaction fee. Units: wei.The transaction fee is a percentage, the fee is (fee / 1 10 18), and the contract specifies that the transaction fee cannot be greater than 10%, so the value cannot exceed 0.1 _ 10 18 wei.
_spotPsporiceuint128The initial price of the NFT in the pool, which needs to be calculated using a calculation library. Units: wei.1000000000000 wei
_initialNFTIDsuint256[]The TokenIDs passed into the pool when it is first created. Because there is no NFT passed into the buyPool, pass [] when _poolType is 0.[1003, 1005]
{ value: totalAmount }objFor buy pool and trade pool, the contract needs to be sent the native token, Units: wei.{ value: 1000000000000000000}

call factory contract

Note
// Data structure
function createPairETH(
    CreatePairETHParams calldata params
) external payable returns (LSSVMPairETH pair)
    
struct CreatePairETHParams {
    IERC721 nft;
    ICurve bondingCurve;
    address payable assetRecipient;
    LSSVMPair.PoolType poolType;
    uint128 delta;
    uint96 fee;
    uint128 spotPrice;
    uint256[] initialNFTIDs;
}
Return Parameters
ParameterTypeDescriptionExample
pairaddressAddress of the pool0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

Calculation of spotPrice & totalAmount

When buying an NFT, there is a maximum expected cost, and if it exceeds this value, the transaction will not occur.
//Example: A user purchases an NFT, and the pool's change type is linear.
const price = mathLib?.[curve]?.[this.createPoolType](
  				//start price set
          startPrice,
  				//delta value set
          delta,
  				//trade transaction fee set
          fee,
  				//the following two are fixed at 0
          0,
          0,
  				//number of purchases
          buyOrSellCount,
  				//create is fixed
          'create'
        )
//Return value
{
    "priceData":{
        "spotPrice":0.021941176470588235,
        "poolBuyPrice":0.02150235294117647,
        "poolSellPrice":0.0234,
        ......
    }
}
//Values taken when creating a pool
spotPrice = priceData.spotPrice
//Creating a buy pool
totalAmount = priceData.poolBuyPrice
//Creating a sell or trade pool
totalAmount = priceData.poolSellPrice

Code Example

import { ethers, utils } from 'ethers';

const signer = new ethers.providers.Web3Provider(window?.ethereum).getSigner();
const contract = new ethers.Contract(factoryAddress, abi, signer);
const txResult = await contract.createPairETH([
	'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
  '0x0f776A85F842b605E0771B6a244DF2a2505Fa7A1',
  '0x39Ef50bd29Ae125FE10C6a909E42e1C6a94Dde29',
  0,
  100000000000000000,
  0,
  0
  [1,2,3]
  { value: totalAmount }]
);