BatchAuctionHouse
Inherits: IBatchAuctionHouse, AuctionHouse
As its name implies, the BatchAuctionHouse is where batch auctions are created, bid on, and settled. The core protocol logic is implemented here.
Functions
constructor
constructor(
address owner_,
address protocol_,
address permit2_
) AuctionHouse(owner_, protocol_, permit2_);
_auction
Implementation-specific logic for auction creation
Handles auction creation for a batch auction.
This function performs the following:
- Performs additional validation
- Collects the payout token from the seller (prefunding)
- Calls the onCreate callback, if configured
This function reverts if:
- The specified auction module is not for batch auctions
- The capacity is in quote tokens
function _auction(
uint96 lotId_,
RoutingParams calldata routing_,
IAuction.AuctionParams calldata params_
) internal override returns (bool performedCallback);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The auction lot ID |
routing_ | RoutingParams | RoutingParams |
params_ | IAuction.AuctionParams | AuctionParams |
Returns
Name | Type | Description |
---|---|---|
performedCallback | bool | true if the implementing function calls the onCreate callback |
_cancel
Implementation-specific logic for auction cancellation
Handles cancellation of a batch auction lot.
This function performs the following:
- Refunds the base token to the seller (or callback)
- Calls the onCancel callback, if configured
function _cancel(
uint96 lotId_,
bytes calldata callbackData_
) internal override returns (bool performedCallback);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The auction lot ID |
callbackData_ | bytes | Calldata for the callback |
Returns
Name | Type | Description |
---|---|---|
performedCallback | bool | true if the implementing function calls the onCancel callback |
_curate
Implementation-specific logic for curation
Handles curation approval for a batch auction lot.
This function performs the following:
- Transfers the required base tokens from the seller (or callback)
- Calls the onCurate callback, if configured
function _curate(
uint96 lotId_,
uint256 curatorFeePayout_,
bytes calldata callbackData_
) internal override returns (bool performedCallback);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The auction lot ID |
curatorFeePayout_ | uint256 | The amount to pay the curator |
callbackData_ | bytes | Calldata for the callback |
Returns
Name | Type | Description |
---|---|---|
performedCallback | bool | true if the implementing function calls the onCurate callback |
bid
Bid on a lot in a batch auction
This function performs the following:
- Validates the lot ID
- Records the bid on the auction module
- Transfers the quote token from the caller
- Calls the onBid callback
This function reverts if:
params_.lotId
is invalid- The auction module reverts when creating a bid
- The quote token transfer fails
- Re-entrancy is detected
function bid(
BidParams memory params_,
bytes calldata callbackData_
) external override nonReentrant returns (uint64 bidId);
Parameters
Name | Type | Description |
---|---|---|
params_ | BidParams | Bid parameters |
callbackData_ | bytes | Custom data provided to the onBid callback |
Returns
Name | Type | Description |
---|---|---|
bidId | uint64 | Bid ID |
refundBid
Refund a bid on a lot in a batch auction
This function performs the following:
- Validates the lot ID
- Refunds the bid on the auction module
- Transfers the quote token to the bidder
This function reverts if:
- The lot ID is invalid
- The auction module reverts when cancelling the bid
- Re-entrancy is detected
function refundBid(uint96 lotId_, uint64 bidId_, uint256 index_) external override nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | Lot ID |
bidId_ | uint64 | Bid ID |
index_ | uint256 | Index of the bid in the auction's bid list |
claimBids
Claim bid payouts and/or refunds after a batch auction has settled
This function performs the following:
- Validates the lot ID
- Claims the bids on the auction module
- Allocates the fees for each successful bid
- Transfers the payout and/or refund to each bidder
This function reverts if:
- The lot ID is invalid
- The auction module reverts when claiming the bids
- Re-entrancy is detected
function claimBids(uint96 lotId_, uint64[] calldata bidIds_) external override nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | Lot ID |
bidIds_ | uint64[] | Bid IDs |
settle
Settle a batch auction
This function handles the following:
- Settles the auction on the auction module
- Sends proceeds and/or refund to the seller
- Executes the onSettle callback
- Allocates the curator fee to the curator
This function reverts if:
- The lot ID is invalid
- The auction module reverts when settling the auction
- Re-entrancy is detected
function settle(
uint96 lotId_,
uint256 num_,
bytes calldata callbackData_
)
external
override
nonReentrant
returns (uint256 totalIn, uint256 totalOut, bool finished, bytes memory auctionOutput);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | Lot ID |
num_ | uint256 | Number of bids to settle in this pass (capped at the remaining number if more is provided) |
callbackData_ | bytes | Custom data provided to the onSettle callback |
Returns
Name | Type | Description |
---|---|---|
totalIn | uint256 | Total amount of quote tokens from bids that were filled |
totalOut | uint256 | Total amount of base tokens paid out to winning bids |
finished | bool | Boolean indicating if the settlement was completed |
auctionOutput | bytes | Custom data returned by the auction module |
abort
Abort a batch auction that cannot be settled, refunding the seller and allowing bidders to claim refunds
This function handles the following:
- Validates the lot id
- Aborts the auction on the auction module
- Refunds prefunding (in base tokens) to the seller
- Calls the onCancel callback
This function reverts if:
- The lot ID is invalid
- The auction module reverts when aborting the auction
- The refund amount is zero
Note that this function will not revert if the onCancel
callback reverts.
function abort(uint96 lotId_) external override nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID to abort |
getBatchModuleForId
function getBatchModuleForId(uint96 lotId_) public view returns (BatchAuctionModule);
Events
Bid
event Bid(uint96 indexed lotId, uint96 indexed bidId, address indexed bidder, uint256 amount);
RefundBid
event RefundBid(uint96 indexed lotId, uint96 indexed bidId, address indexed bidder);
ClaimBid
event ClaimBid(uint96 indexed lotId, uint96 indexed bidId, address indexed bidder);
Settle
event Settle(uint96 indexed lotId);
Abort
event Abort(uint96 indexed lotId);
Errors
AmountLessThanMinimum
error AmountLessThanMinimum();
InsufficientFunding
error InsufficientFunding();