Function: bid(uint256 buyReserveAmount, uint256 sellCouponAmount)
This function is used to place a bid on an auction. A user could put sellCouponAmount of coupon tokens to get buyReserveAmount of reserve tokens. If the bid is successful, the user will get the reserve tokens back, but if the bid is unsuccessful, the user will get the coupon tokens back.
Inputs
buyReserveAmountControl: Arbitrary.
Constraints: Nonzero.
Impact: None.
sellCouponAmountControl: Arbitrary.
Constraints: Nonzero, less than or equal to
totalBuyCouponAmount, and divisible byslotSize.Impact: None.
Branches and code coverage
Intended branches
Transfer
sellCouponAmountofbuyCouponTokenfrommsg.senderto this contract.Insert the new bid into the sorted linked list.
Update the
currentCouponAmountandtotalSellReserveAmount.Remove the lowest bid if
bidCountis greater thanmaxBids.Remove and refund out of range bids if
currentCouponAmountis greater thantotalBuyCouponAmount.
Negative behavior
Revert if auction is not active.
Revert if
sellCouponAmountis zero or greater thantotalBuyCouponAmount.Revert if
sellCouponAmountis not divisible byslotSize.Revert if
buyReserveAmountis zero.Revert if
bidCountis greater thanmaxBids.Revert if
lowestBidIndexis the same asnewBidIndex.