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
buyReserveAmount
Control: Arbitrary.
Constraints: Nonzero.
Impact: None.
sellCouponAmount
Control: Arbitrary.
Constraints: Nonzero, less than or equal to
totalBuyCouponAmount
, and divisible byslotSize
.Impact: None.
Branches and code coverage
Intended branches
Transfer
sellCouponAmount
ofbuyCouponToken
frommsg.sender
to this contract.Insert the new bid into the sorted linked list.
Update the
currentCouponAmount
andtotalSellReserveAmount
.Remove the lowest bid if
bidCount
is greater thanmaxBids
.Remove and refund out of range bids if
currentCouponAmount
is greater thantotalBuyCouponAmount
.
Negative behavior
Revert if auction is not active.
Revert if
sellCouponAmount
is zero or greater thantotalBuyCouponAmount
.Revert if
sellCouponAmount
is not divisible byslotSize
.Revert if
buyReserveAmount
is zero.Revert if
bidCount
is greater thanmaxBids
.Revert if
lowestBidIndex
is the same asnewBidIndex
.