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 by slotSize.

    • Impact: None.

Branches and code coverage

Intended branches

  • Transfer sellCouponAmount of buyCouponToken from msg.sender to this contract.

  • Insert the new bid into the sorted linked list.

  • Update the currentCouponAmount and totalSellReserveAmount.

  • Remove the lowest bid if bidCount is greater than maxBids.

  • Remove and refund out of range bids if currentCouponAmount is greater than totalBuyCouponAmount.

Negative behavior

  • Revert if auction is not active.

  • Revert if sellCouponAmount is zero or greater than totalBuyCouponAmount.

  • Revert if sellCouponAmount is not divisible by slotSize.

  • Revert if buyReserveAmount is zero.

  • Revert if bidCount is greater than maxBids.

  • Revert if lowestBidIndex is the same as newBidIndex.

Zellic © 2025Back to top ↑