initialize(address,address,uint128,uint96,uint128) :
This function is used to initialize a pool. It sets the owner, asset recipient, delta, fee, and spot price of the pool. The pool type is determined by the poolType() function, and the bonding curve is determined by the bondingCurve() function. If the pool type is TOKEN or NFT, the fee must be set to 0. If the pool type is TRADE, the asset recipient must be set to 0 and the fee must be less than 90%. The delta and spot price must be valid for the bonding curve. (autogenerated documentation)
swapTokenForAnyNFTs(uint256,uint256,address,bool,address) :
This function allows a user to swap a given amount of tokens for a specified number of Non-Fungible Tokens (NFTs). It first checks that the pool type is either NFT or TRADE, and that the number of NFTs requested is greater than 0 and less than or equal to the balance of NFTs held by the contract. It then calculates the protocol fee and the amount of token input required, pulls the token input and pays the protocol fee, sends the requested NFTs to the recipient, and refunds the token input to the sender. Finally, it emits an event to signal that the swap has been completed. (autogenerated documentation)
swapTokenForSpecificNFTs(uint256[],uint256,address,bool,address) :
This function allows a user to swap a specific amount of tokens for a set of Non-Fungible Tokens (NFTs). It first calculates the protocol fee and the amount of tokens to be inputted, then pulls the token input and pays the protocol fee. It then sends the specific NFTs to the recipient, refunds the token to the sender, and emits an event to signal the completion of the swap. (autogenerated documentation)
swapNFTsForToken(uint256[],uint256,address,bool,address) :
This function allows users to swap NFTs for tokens. It takes an array of NFT IDs, a minimum expected token output, a token recipient address, a boolean value to indicate if the caller is a router, and a router caller address as parameters. It then calculates the protocol fee and the token output amount, sends the token output to the recipient, pays the protocol fee from the factory, takes the NFTs from the sender, and emits a SwapNFTInPair event. (autogenerated documentation)
getBuyNFTQuote(uint256) :
This function allows a user to get a quote for buying a certain number of NFTs from the bonding curve. It takes in the number of NFTs as an argument and returns an error code, the new spot price, the new delta, the input amount, and the protocol fee. The function works by calling the getBuyInfo function from the bonding curve contract, which calculates the new spot price, delta, input amount, and protocol fee based on the number of NFTs requested and the current spot price and delta. (autogenerated documentation)
getSellNFTQuote(uint256) :
This function allows a user to get a quote for selling a given number of NFTs on the bonding curve. It takes in the number of NFTs to be sold as an argument and returns the CurveErrorCodes.Error, the new spot price, the new delta, the output amount, and the protocol fee. The function works by calling the getSellInfo function from the bonding curve contract, which calculates the new spot price, delta, output amount, and protocol fee based on the number of NFTs to be sold. (autogenerated documentation)
getAllHeldIds() :
This function retrieves the ILSSVMPairFactoryLike instance from the contract's calldata. It does this by first calculating the length of the immutable parameters in the calldata, then shifting the last parameter (which is the factory instance) to the left by 0x60 bytes. The result is then returned as the _factory variable. (autogenerated documentation)
pairVariant() :
This function is part of an interface for a factory contract that creates a pair variant. It returns an instance of the ILSSVMPairFactoryLike.PairVariant type. The function works by retrieving the factory address from the end of the call data, and then shifting the address to the right by 96 bits to get the instance of the PairVariant type. (autogenerated documentation)
factory() :
This function returns an ILSSVMPairFactoryLike object, which is used to create a new instance of an ILSSVMPair contract. It does this by retrieving the address of the factory from the end of the call data, and then shifting it to the right by 60 bits. (autogenerated documentation)
bondingCurve() :
This function retrieves the address of the bonding curve contract from the calldata. It does this by subtracting the length of the immutable parameters from the calldata size, adding 20, and then loading the data from that position. The data is then shifted right by 96 bits to get the address of the bonding curve contract. (autogenerated documentation)
nft() :
This function is used to retrieve the IERC721 address from a transaction. It does this by shifting the last 40 bytes of the calldata right by 96 bits (0x60). This is necessary because the IERC721 address is stored in the last 40 bytes of the calldata, and is preceded by the immutable parameters. The function first calculates the length of the immutable parameters, then subtracts this from the total calldata size to get the start of the IERC721 address. It then shifts the address right by 96 bits to get the IERC721 address. (autogenerated documentation)
poolType() :
This function returns the type of pool associated with the contract. It does this by using the assembly language to shift the bits of the data stored in the contract's memory by 8 bits to the right. This data is stored in the last 60 bytes of the contract's memory, after the immutable parameters. (autogenerated documentation)
getAssetRecipient() :
This function gets the address of the recipient of the asset. If the pool type is set to trade, the address of the recipient is set to the address of the contract. Otherwise, the address of the recipient is set to the address stored in the assetRecipient variable. If the assetRecipient variable is set to 0, the address of the recipient is set to the address of the contract. (autogenerated documentation)
_calculateBuyInfoAndUpdatePoolParams(uint256,uint256) :
This function is used to calculate the buy information and update the pool parameters for a given number of NFTs. It takes in the number of NFTs, the maximum expected token input, a bonding curve, and a factory-like object as parameters. It then uses the bonding curve to calculate the spot price, delta, input amount, and protocol fee associated with the purchase. It then checks to make sure that the input amount is not greater than the maximum expected token input. If the spot price or delta has changed, it emits an event to update the spot price or delta. Finally, it returns the protocol fee and input amount. (autogenerated documentation)
_calculateSellInfoAndUpdatePoolParams(uint256,uint256) :
This function is used to calculate the sell information and update the pool parameters for a given number of NFTs. It takes in the number of NFTs, the minimum expected token output, a bonding curve, and a factory as parameters. It then calculates the current spot price and delta, and uses the bonding curve to calculate the new spot price, delta, output amount, and protocol fee. It then checks that the output amount is greater than the minimum expected token output, and if the spot price or delta has changed, it emits an event to update the spot price or delta. Finally, it returns the protocol fee and output amount. (autogenerated documentation)
_pullTokenInputAndPayProtocolFee(uint256,bool,address,uint256) :
This function is used to take NFTs from the sender and transfer them to the asset recipient. If the transaction is being routed through a router, the router is used to transfer the NFTs from the sender to the asset recipient. If the transaction is not being routed, the NFTs are transferred directly from the sender to the asset recipient. In either case, the function checks that the NFTs have been successfully transferred before returning. (autogenerated documentation)
_refundTokenToSender(uint256) :
This function is used to take NFTs from the sender and transfer them to the asset recipient. It takes in an IERC721 contract, an array of NFT IDs, an ILSSVMPairFactoryLike contract, a boolean value to indicate if the sender is a router, and the address of the router caller. If the sender is a router, the function uses the router's pairTransferNFTFrom function to transfer the NFTs from the sender to the asset recipient. If the sender is not a router, the function uses the safeTransferFrom function to transfer the NFTs from the sender to the asset recipient. (autogenerated documentation)
_payProtocolFeeFromPair(uint256) :
This function is used to take NFTs from a sender and transfer them to the asset recipient. It takes in an IERC721 contract, an array of NFT IDs, an ILSSVMPairFactoryLike contract, a boolean value to indicate if the sender is a router, and the address of the router caller. If the sender is a router, the function calls the pairTransferNFTFrom function on the router to transfer the NFTs from the sender to the asset recipient. If the sender is not a router, the function calls the safeTransferFrom function on the IERC721 contract to transfer the NFTs from the sender to the asset recipient. (autogenerated documentation)
_sendTokenOutput(address,uint256) :
This function is used to transfer Non-Fungible Tokens (NFTs) from a sender to a recipient. It takes in an IERC721 contract, the address of the recipient, and an array of NFT IDs as parameters. It first checks if the sender is a router, and if so, it uses the router's pairTransferNFTFrom function to transfer the NFTs. If the sender is not a router, it uses the safeTransferFrom function to transfer the NFTs. In either case, it requires that the NFTs are successfully transferred before returning. (autogenerated documentation)
_sendAnyNFTsToRecipient(address,uint256) :
This function is used to transfer Non-Fungible Tokens (NFTs) from one address to another. It takes in an IERC721 contract, the address of the recipient, and an array of NFT IDs as parameters. It first checks if the sender is a router, and if so, it uses the router's pairTransferNFTFrom function to transfer the NFTs. If the sender is not a router, it uses the safeTransferFrom function to transfer the NFTs. In either case, it requires that the NFTs are successfully transferred before returning. (autogenerated documentation)
_sendSpecificNFTsToRecipient(address,uint256[]) :
This function is used to transfer specific Non-Fungible Tokens (NFTs) from a sender to a recipient. It takes in the IERC721 contract, the address of the recipient, and an array of NFT IDs as parameters. It first checks if the sender is a router, and if so, it uses the LSSVMRouter contract to transfer the NFTs from the sender to the recipient. If the sender is not a router, it uses the safeTransferFrom function to transfer the NFTs from the sender to the recipient. (autogenerated documentation)
_takeNFTsFromSender(uint256[],bool,address) :
This function is used to transfer Non-Fungible Tokens (NFTs) from a sender to a recipient. It takes in the IERC721 contract, an array of NFT IDs, an ILSSVMPairFactoryLike contract, a boolean value to indicate if the transfer is being done through a router, and the address of the router caller. If the transfer is being done through a router, the function first checks if the router is allowed to perform the transfer. It then loops through the array of NFT IDs and calls the pairTransferNFTFrom function on the router to transfer the NFTs from the sender to the recipient. If the transfer is not being done through a router, the (autogenerated documentation)
_immutableParamsLength() :
This function allows the owner of the contract to withdraw ERC1155 tokens from the contract. It takes in an IERC1155 interface, an array of ids, and an array of amounts as parameters. It then calls the safeBatchTransferFrom function on the IERC1155 interface, transferring the specified tokens from the contract to the msg.sender. (autogenerated documentation)
withdrawERC721(uint256[]) :
This function withdraws ERC1155 tokens from the contract to the msg.sender. It does this by calling the safeBatchTransferFrom() function on the IERC1155 interface, passing in the address of the contract, the address of the msg.sender, an array of ids of the tokens to be transferred, an array of amounts of the tokens to be transferred, and an empty string as the data parameter. The function then transfers the specified tokens from the contract to the msg.sender. (autogenerated documentation)
withdrawERC20(uint256) :
This function allows the owner of the contract to withdraw ERC1155 tokens from the contract. It takes in an IERC1155 interface, an array of ids, and an array of amounts as parameters. It then calls the safeBatchTransferFrom function on the IERC1155 interface, transferring the specified tokens from the contract to the msg.sender. (autogenerated documentation)
withdrawERC1155(uint256[],uint256[]) :
This function allows the owner of the contract to withdraw ERC1155 tokens from the contract. It takes two parameters, an IERC1155 interface and two arrays of uint256 values. The first array contains the ids of the tokens to be withdrawn, and the second array contains the amounts of each token to be withdrawn. The function then calls the safeBatchTransferFrom function of the IERC1155 interface, transferring the tokens from the contract to the msg.sender. (autogenerated documentation)
changeSpotPrice(uint128) :
This function allows the owner of the contract to change the spot price of the curve. It first checks that the new spot price is valid for the curve, and then sets the spot price to the new value. It then emits an event to notify other contracts of the change. (autogenerated documentation)
changeDelta(uint128) :
This function allows the owner of the contract to update the delta value of the bonding curve. The delta value is used to calculate the price of a token when buying or selling. The function first checks that the new delta value is valid for the curve, and then updates the delta value and emits an event to notify of the change. (autogenerated documentation)
changeFee(uint96) :
This function allows the owner of the contract to change the fee associated with a trade pool. It requires that the pool type is set to 'Trade' and that the new fee is less than 90%. If the fee is successfully changed, an event is emitted to notify the users of the new fee. (autogenerated documentation)
changeAssetRecipient(address) :
This function allows the owner of the contract to change the recipient of the asset associated with the pool. It first checks that the pool is not a trade pool, and then sets the assetRecipient variable to the new address provided as an argument. Finally, it emits an event to signal that the asset recipient has been changed. (autogenerated documentation)
call(address) :
This function is used to call a target address with a given data payload. It is only accessible to the owner of the contract and requires that the target address is whitelisted in the factory contract. The function calls the target address with a value of 0 and checks the result of the call to ensure that it was successful. If the call is successful, the function returns true, otherwise it returns false. (autogenerated documentation)
multicall(bool) :
This function is a multi-call function that allows a contract owner to execute multiple calls in a single transaction. It takes an array of calldata and a boolean value as parameters. It then iterates through the array of calldata and executes each call. If the boolean value is set to true, the function will revert if any of the calls fail. Finally, it requires that the owner of the contract remains the same after the transaction is complete. (autogenerated documentation)
_getRevertMsg() :
This function is used to retrieve the revert message from a transaction that has been reverted. It takes in a byte array as an argument and returns a string containing the revert message. It does this by adding 4 bytes to the byte array and then decoding it using the ABI library. (autogenerated documentation)