FixedPriceBatch
Inherits: BatchAuctionModule, IFixedPriceBatch
A module for creating fixed price batch auctions
State Variables
_auctionData
FPBA-specific auction data for a lot
Access via getAuctionData()
mapping(uint96 lotId => AuctionData) internal _auctionData;
_bids
General information about bids on a lot
Access via getBid()
mapping(uint96 lotId => mapping(uint64 bidId => Bid)) internal _bids;
_lotPartialFill
Partial fill data for a lot
Each FPBA can have at most one partial fill
Access via getPartialFill()
mapping(uint96 lotId => PartialFill) internal _lotPartialFill;
Functions
constructor
constructor(address auctionHouse_) AuctionModule(auctionHouse_);
VEECODE
7 byte, versioned identifier for the module. 2 characters from 0-9 that signify the version and 3-5 characters from A-Z.
function VEECODE() public pure override returns (Veecode);
_auction
Implementation-specific auction creation logic
This function assumes:
- The lot ID has been validated
- The start and duration of the lot have been validated
This function reverts if:
- The parameters cannot be decoded into the correct format
- The price is zero
- The minimum fill percentage is greater than
function _auction(uint96 lotId_, Lot memory lot_, bytes memory params_) internal override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
lot_ | Lot | The lot data |
params_ | bytes | ABI-encoded data of type AuctionDataParams |
_cancelAuction
Implementation-specific auction cancellation logic
This function assumes the following:
- The lot ID has been validated
- The caller has been authorized
- The auction has not concluded
This function performs the following:
- Sets the auction status to settled, and prevents claiming of proceeds
This function reverts if:
- The auction is active or has not concluded
function _cancelAuction(uint96 lotId_) internal override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
_calculatePartialFill
function _calculatePartialFill(
uint64 bidId_,
uint256 capacity_,
uint256 capacityExpended_,
uint96 bidAmount_,
uint256 baseScale_,
uint256 price_
) internal pure returns (PartialFill memory);
_bid
Implementation-specific bid logic
This function performs the following:
- Validates inputs
- Stores the bid
- Conditionally ends the auction if the bid fills the lot (bid may be partial fill)
- Returns the bid ID
This function assumes:
- The lot ID has been validated
- The caller has been authorized
- The auction is active
This function reverts if:
- Amount is zero
- Amount is greater than the maximum uint96
function _bid(
uint96 lotId_,
address bidder_,
address referrer_,
uint256 amount_,
bytes calldata
) internal override returns (uint64);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
bidder_ | address | The bidder of the purchased tokens |
referrer_ | address | The referrer of the bid |
amount_ | uint256 | The amount of quote tokens to bid |
<none> | bytes |
Returns
Name | Type | Description |
---|---|---|
<none> | uint64 | bidId The bid ID |
_refundBid
Implementation-specific bid refund logic
This function performs the following:
- Marks the bid as claimed
- Returns the amount to be refunded
This function assumes:
- The lot ID has been validated
- The bid ID has been validated
- The caller has been authorized
- The auction is active
- The bid has not been refunded
function _refundBid(
uint96 lotId_,
uint64 bidId_,
uint256,
address
) internal override returns (uint256 refund);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
bidId_ | uint64 | The bid ID |
<none> | uint256 | |
<none> | address |
Returns
Name | Type | Description |
---|---|---|
refund | uint256 | The amount of quote tokens to refund |
_claimBids
Implementation-specific bid claim logic
This function performs the following:
- Validates the bid
- Marks the bid as claimed
- Calculates the payout and refund
This function assumes:
- The lot ID has been validated
- The caller has been authorized
- The auction has concluded
- The auction is not settled
This function reverts if:
- The bid ID is invalid
- The bid has already been claimed
function _claimBids(
uint96 lotId_,
uint64[] calldata bidIds_
) internal override returns (BidClaim[] memory bidClaims, bytes memory auctionOutput);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
bidIds_ | uint64[] | The bid IDs |
Returns
Name | Type | Description |
---|---|---|
bidClaims | BidClaim[] | The bid claim data |
auctionOutput | bytes | The auction-specific output |
_settle
Implementation-specific lot settlement logic
This function performs the following:
- Sets the auction status to settled
- Calculates the filled capacity
- If the filled capacity is less than the minimum filled capacity, the auction does not clear
- If the filled capacity is greater than or equal to the minimum filled capacity, the auction clears
- Returns the total in, total out, and whether the auction is finished
This function assumes:
- The lot ID has been validated
- The auction has concluded
- The auction is not settled
This function reverts if:
- None
function _settle(
uint96 lotId_,
uint256
)
internal
override
returns (uint256 totalIn_, uint256 totalOut_, bool finished_, bytes memory auctionOutput_);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
totalIn_ | uint256 | totalIn The total amount of quote tokens that filled the auction |
totalOut_ | uint256 | totalOut The total amount of base tokens sold |
finished_ | bool | finished Whether the settlement is finished |
auctionOutput_ | bytes | auctionOutput The auction-type specific output to be used with a condenser |
_abort
Implementation-specific lot settlement logic
This function performs the following:
- Sets the auction status to Settled
This function assumes:
- The lot ID has been validated
- The auction is not settled
- The dedicated settle period has not passed
This function reverts if:
- None
function _abort(uint96 lotId_) internal override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
getBid
Returns the Bid
and EncryptedBid
data for a given lot and bid ID
This function reverts if:
- The lot ID is invalid
- The bid ID is invalid
function getBid(uint96 lotId_, uint64 bidId_) external view returns (Bid memory bid);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
bidId_ | uint64 | The bid ID |
Returns
Name | Type | Description |
---|---|---|
bid | Bid | The Bid data |
getAuctionData
Returns the AuctionData
data for an auction lot
This function reverts if:
- The lot ID is invalid
function getAuctionData(
uint96 lotId_
) external view override returns (AuctionData memory auctionData_);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
Returns
Name | Type | Description |
---|---|---|
auctionData_ | AuctionData | The AuctionData |
getPartialFill
Returns the PartialFill
data for an auction lot
For ease of use, this function determines if a partial fill exists.
This function reverts if:
- The lot ID is invalid
- The lot is not settled
function getPartialFill(
uint96 lotId_
) external view returns (bool hasPartialFill, PartialFill memory partialFill);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
Returns
Name | Type | Description |
---|---|---|
hasPartialFill | bool | True if a partial fill exists |
partialFill | PartialFill | The PartialFill data |
getNumBids
Get the number of bids for a lot
This function is not implemented in fixed price batch since bid IDs are not stored in an array A proxy is using the nextBidId to determine how many bids have been submitted, but this doesn't consider refunds
function getNumBids(uint96) external view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
<none> | uint96 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | numBids The number of bids |
getBidIds
Get the bid IDs from the given index
This function is not implemented in fixed price batch since bid IDs are not stored in an array
function getBidIds(uint96, uint256, uint256) external view override returns (uint64[] memory);
Parameters
Name | Type | Description |
---|---|---|
<none> | uint96 | |
<none> | uint256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint64[] | bidIds The bid IDs |
getBidIdAtIndex
Get the bid ID at the given index
This function is not implemented in fixed price batch since bid IDs are not stored in an array
function getBidIdAtIndex(uint96, uint256) external view override returns (uint64);
Parameters
Name | Type | Description |
---|---|---|
<none> | uint96 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint64 | bidId The bid ID |
getBidClaim
Get the claim data for a bid
This function reverts if:
- The lot ID is invalid
- The lot is not settled (since there would be no claim)
- The bid ID is invalid
function getBidClaim(
uint96 lotId_,
uint64 bidId_
) external view override returns (BidClaim memory bidClaim);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
bidId_ | uint64 | The bid ID |
Returns
Name | Type | Description |
---|---|---|
bidClaim | BidClaim | The bid claim data |
_getBidClaim
Returns the BidClaim
data for a given lot and bid ID
This function assumes:
- The lot ID has been validated
- The bid ID has been validated
function _getBidClaim(
uint96 lotId_,
uint64 bidId_
) internal view returns (BidClaim memory bidClaim);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
bidId_ | uint64 | The bid ID |
Returns
Name | Type | Description |
---|---|---|
bidClaim | BidClaim | The BidClaim data |
_revertIfLotActive
Checks that the lot represented by lotId_
is active
Should revert if the lot is active Inheriting contracts can override this to implement custom logic
function _revertIfLotActive(uint96 lotId_) internal view override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
_revertIfLotSettled
Checks that the lot represented by lotId_
is not settled
Should revert if the lot is settled Inheriting contracts must override this to implement custom logic
function _revertIfLotSettled(uint96 lotId_) internal view override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
_revertIfLotNotSettled
Checks that the lot represented by lotId_
is settled
Should revert if the lot is not settled Inheriting contracts must override this to implement custom logic
function _revertIfLotNotSettled(uint96 lotId_) internal view override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
_revertIfBidInvalid
Checks that the lot and bid combination is valid
Should revert if the bid is invalid Inheriting contracts must override this to implement custom logic
function _revertIfBidInvalid(uint96 lotId_, uint64 bidId_) internal view override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
bidId_ | uint64 | The bid ID |
_revertIfNotBidOwner
Checks that caller_
is the bid owner
Should revert if caller_
is not the bid owner
Inheriting contracts must override this to implement custom logic
function _revertIfNotBidOwner(
uint96 lotId_,
uint64 bidId_,
address caller_
) internal view override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
bidId_ | uint64 | The bid ID |
caller_ | address | The caller |
_revertIfBidClaimed
Checks that the bid is not claimed
Should revert if the bid is claimed Inheriting contracts must override this to implement custom logic
function _revertIfBidClaimed(uint96 lotId_, uint64 bidId_) internal view override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
bidId_ | uint64 | The bid ID |