Users can list NFTs (create Sell Pool), make offer (create Buy Pool) and liquidity mining (create Trade Pool) with this function
Similar to NFT 721, but with the following differences:
- An additional parameter _initialNFTCount needs to be passed.
- The ABI has some changes due to point 1.
- Each pool can only be restricted to one tokenId to ensure that cheap NFTs do not contaminate expensive NFT pools.
Request Parameters
Note: The outermost layer is an object, and the following parameters need to be enclosed in []
Parameter | Type | Description | Example |
---|---|---|---|
_nft | address | The address of the ERC721 NFT contract. | 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 |
_bondingCurve | address | The address of the AMM mechanism. Linear: 0x0f776A85F842b605E0771B6a244DF2a2505Fa7A1 Exponential: 0x0F16Be0e961AD87f47A5e2a8177e0c2299C7849c | 0x0f776A85F842b605E0771B6a244DF2a2505Fa7A1 |
_assetRecipient | address | The address to receive the assets. Since the assets for buy pools and sell pools are directly transferred to assetRecipient, and the assets for trade pools remain in the pool, when _poolType is 0 or 1, pass the asset recipient address, such as the creator address; when _poolType is 2, pass the 0 address. | msgsender or 0 address |
_poolType | enum | Buy: 0; Sell: 1; Trade: 2 | 0 or 1 or 2 |
_delta | uint128 | The change in price in the pool after each transaction. For example, if the current price in the linear pool is 1, and delta is 0.1, then after buying an NFT, the pool price will be 1.1 (rough calculation). If delta is 0, then the pool price will not change after buying an NFT. Unit: wei. | 0.1 * 10 ** 18 wei |
_fee | uint96 | The transaction fee for each transaction. Buy and sell pools do not have this option, and it defaults to 0. Trade pools allow users to set their own transaction fees. Unit: wei. | The transaction fee is a percentage, so the actual fee is (fee / 1 10 18). The contract stipulates that the fee cannot be greater than 10%, so the value cannot exceed 0.1 _ 10 18 wei. |
_spotPsporice | uint128 | The initial price of the NFT in the pool, which needs to be calculated using a calculation library. Unit: wei. | 1000000000000 wei |
_initialNFTIDs | uint256[] | The tokenId passed into the pool when it was first created. Since no NFT is passed into the buy pool, pass [] when _poolType is 0. | [1003, 1005] |
_initialNFTCount | uint256 | The number of NFTs to buy or sell. | 23 |
{ value: totalAmount } | obj | Native token sent to the contract is required for buy and trade pools, in wei unit | { value: 1000000000000000000} |
call factory contract
Additional Information
// Data structure
function createPair1155ETH(
CreatePair1155ETHParams calldata params
) external payable returns (LSSVMPair1155ETH pair)
struct CreatePair1155ETHParams {
IERC1155 nft;
ICurve bondingCurve;
address payable assetRecipient;
LSSVMPair1155.PoolType poolType;
uint128 delta;
uint96 fee;
uint128 spotPrice;
uint256 nftId;
uint256 initialNFTCount;
}
Return Parameters
Parameters | Type | Description | Example |
---|---|---|---|
pair | address | Pool address | 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 |
Calculation of spotPrice & totalAmount
When purchasing NFT, there is a maximum expected cost, which if exceeded, the transaction will not be completed.
//Example: Scenario: User purchases NFT, the pool change type is linear
const price = mathLib?.[curve]?.[this.createPoolType](
//Starting price set
startPrice,
//delta value set
delta,
//Transaction fee set by trade.
fee,
//The following two are fixed and pass 0.
0,
0,
//Purchase quantity
buyOrSellCount,
//Fixed pass create.
'create'
)
//Return value
{
"priceData":{
"spotPrice":0.021941176470588235,
"poolBuyPrice":0.02150235294117647,
"poolSellPrice":0.0234,
......
}
}
//Values taken when creating the pool
spotPrice=priceData.spotPrice
//Create a buy pool
totalAmount=priceData.poolBuyPrice
//Create a sell pool 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.createPair1155ETH([
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
'0x0f776A85F842b605E0771B6a244DF2a2505Fa7A1',
'0x39Ef50bd29Ae125FE10C6a909E42e1C6a94Dde29',
0,
100000000000000000,
0,
0
[1,2,3],
23],
{ value: totalAmount },
);