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
tokenId
Control: Arbitrary.
Constraints: None.
Impact: The parameter specifies the identifier of the ERC-1155 token to be locked in the offer.
amount
Control: Arbitrary.
Constraints: Must be greater than or equal to
minimumOfferAmount
.Impact: The parameter specifies the amount of tokens to lock in the offer.
askPrice
Control: 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,
offerIdCounter
is incremented, and the data is added tooffers
.The tokens are transferred from the creator to the contract, and
offerId
is recorded in theuserOffers
mapping.
Negative behavior
Revert if
amount
is belowminimumOfferAmount
.Revert if
askPrice
is not within an acceptable range.