Function: createOffer(uint256 tokenId, uint256 amount, uint256 askPrice)
The function allows a user to create a new offer by locking ERC-1155 tokens in the contract and setting an ask price.
Inputs
tokenIdControl: Arbitrary.
Constraints: None.
Impact: The parameter specifies the identifier of the ERC-1155 token to be locked in the offer.
amountControl: Arbitrary.
Constraints: Must be greater than or equal to
minimumOfferAmount.Impact: The parameter specifies the amount of tokens to lock in the offer.
askPriceControl: Arbitrary.
Constraints: Must be greater than zero and less than or equal to 1e6.
Impact: The parameter specifies the asking price for the offer in USDC equivalent.
Branches and code coverage
Intended branches
A new offer structure is created,
offerIdCounteris incremented, and the data is added tooffers.The tokens are transferred from the creator to the contract, and
offerIdis recorded in theuserOffersmapping.
Negative behavior
Revert if
amountis belowminimumOfferAmount.Revert if
askPriceis not within an acceptable range.