@@ -85,10 +85,12 @@ contract SealedBidAuction is ISealedBidAuction, AbstractBlocklockReceiver, Reent
85
85
seller = msg .sender ;
86
86
}
87
87
88
- // BID PHASES
89
-
90
- // Phase 1. Bidding Phase
91
- // Submit a sealed bid
88
+ /// BID PHASES
89
+
90
+ /// @dev Phase 1. Bidding Phase
91
+ /// @notice Submit a sealed bid to participate in the auction.
92
+ /// @param sealedBid The encrypted bid amount to submit to the auction.
93
+ /// @return bidID The unique identifier for the submitted bid.
92
94
function placeSealedBid (TypesLib.Ciphertext calldata sealedBid )
93
95
external
94
96
payable
@@ -118,8 +120,10 @@ contract SealedBidAuction is ISealedBidAuction, AbstractBlocklockReceiver, Reent
118
120
return bidID;
119
121
}
120
122
121
- // Phase 2. Reveal Phase
122
- // Unseal sealed bid
123
+ /// @dev Phase 2. Reveal Phase
124
+ /// @notice Unseals the sealed bid after the bidding phase has ended.
125
+ /// @param requestID The unique identifier for the bid to unseal.
126
+ /// @param decryptionKey The key used to decrypt the sealed bid.
123
127
function receiveBlocklock (uint256 requestID , bytes calldata decryptionKey )
124
128
external
125
129
override
@@ -145,6 +149,9 @@ contract SealedBidAuction is ISealedBidAuction, AbstractBlocklockReceiver, Reent
145
149
emit BidUnsealed (bid.bidID, bid.bidder, bid.unsealedBid);
146
150
}
147
151
152
+ /// @dev Updates the highest bid during the reveal phase.
153
+ /// @param bidID The unique identifier of the bid being evaluated.
154
+ /// @param unsealedBid The decrypted bid amount.
148
155
function updateHighestBid (uint256 bidID , uint256 unsealedBid ) internal {
149
156
Bid storage bid = bidsById[bidID];
150
157
@@ -160,8 +167,9 @@ contract SealedBidAuction is ISealedBidAuction, AbstractBlocklockReceiver, Reent
160
167
emit BidUnsealed (bidID, bid.bidder, unsealedBid);
161
168
}
162
169
163
- // Phase 3. Auction Finalization
164
- // Withdraw refundable reserve amounts paid during bidding
170
+ /// @dev Phase 3. Auction Finalization
171
+ /// @notice Allows bidders (except the highest bidder) to withdraw refundable reserve amounts.
172
+ /// @return The amount to withdraw as a refund.
165
173
function withdrawRefund () external onlyAfter (biddingEndBlock) onlyAfterBidsUnsealed nonReentrant {
166
174
require (msg .sender != highestBidder, "Highest bidder cannot withdraw refund. " );
167
175
Bid memory bid = bids[msg .sender ];
@@ -172,7 +180,9 @@ contract SealedBidAuction is ISealedBidAuction, AbstractBlocklockReceiver, Reent
172
180
emit ReservePriceClaimed (bid.bidID, msg .sender , amount);
173
181
}
174
182
175
- // Fulfil highest bid
183
+ /// @dev Fulfill the highest bid after the bidding ends and bids are unsealed.
184
+ /// @notice Only the highest bidder can fulfill the bid and pay the difference.
185
+ /// @param msg.value The value sent in the transaction must equal the highest bid minus the reserve price.
176
186
function fulfillHighestBid () external payable onlyAfter (biddingEndBlock) onlyAfterBidsUnsealed {
177
187
require (highestBid > 0 , "Highest bid is zero. " );
178
188
require (msg .sender == highestBidder, "Only the highest bidder can fulfil. " );
@@ -186,16 +196,23 @@ contract SealedBidAuction is ISealedBidAuction, AbstractBlocklockReceiver, Reent
186
196
emit HighestBidFulfilled (msg .sender , msg .value + RESERVE_PRICE);
187
197
}
188
198
189
- // Finalize auction
199
+ /// @dev Finalizes the auction and declares the winner.
200
+ /// @notice Marks the auction as ended and emits an event with the winning bid and bidder.
190
201
function finalizeAuction () external onlyAfterBidsUnsealed {
191
202
require (! auctionEnded, "Auction already finalised. " );
192
203
auctionEnded = true ;
193
204
emit AuctionEnded (highestBidder, highestBid);
194
205
}
195
206
196
- /**
197
- * Getters
198
- */
207
+ /// GETTERS
208
+
209
+ /// @dev Retrieves bid details using the bid ID.
210
+ /// @param bidID The unique identifier for the bid.
211
+ /// @return sealedBid The encrypted sealed bid.
212
+ /// @return decryptionKey The decryption key used for revealing the bid.
213
+ /// @return unsealedBid The decrypted bid amount.
214
+ /// @return bidder The address of the bidder.
215
+ /// @return revealed Whether the bid has been revealed.
199
216
function getBidWithBidID (uint256 bidID )
200
217
external
201
218
view
@@ -214,6 +231,13 @@ contract SealedBidAuction is ISealedBidAuction, AbstractBlocklockReceiver, Reent
214
231
revealed = bidsById[bidID].revealed;
215
232
}
216
233
234
+ /// @dev Retrieves bid details using the bidder's address.
235
+ /// @param bidder The address of the bidder.
236
+ /// @return sealedBid The encrypted sealed bid.
237
+ /// @return decryptionKey The decryption key used for revealing the bid.
238
+ /// @return unsealedBid The decrypted bid amount.
239
+ /// @return _bidder The address of the bidder.
240
+ /// @return revealed Whether the bid has been revealed.
217
241
function getBidWithBidder (address bidder )
218
242
external
219
243
view
@@ -232,6 +256,9 @@ contract SealedBidAuction is ISealedBidAuction, AbstractBlocklockReceiver, Reent
232
256
revealed = bidsById[bidderToBidID[bidder]].revealed;
233
257
}
234
258
259
+ /// @dev Retrieves the current highest bid and bidder's address.
260
+ /// @return highestBidAmount The amount of the highest bid.
261
+ /// @return highestBidderAddress The address of the highest bidder.
235
262
function getHighestBid () external view returns (uint256 highestBidAmount , address highestBidderAddress ) {
236
263
highestBidAmount = highestBid;
237
264
highestBidderAddress = highestBidder;
0 commit comments