Skip to main content

FixedPriceBatch

Git Source

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

NameTypeDescription
lotId_uint96The lot ID
lot_LotThe lot data
params_bytesABI-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

NameTypeDescription
lotId_uint96The 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

NameTypeDescription
lotId_uint96The lot ID
bidder_addressThe bidder of the purchased tokens
referrer_addressThe referrer of the bid
amount_uint256The amount of quote tokens to bid
<none>bytes

Returns

NameTypeDescription
<none>uint64bidId 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

NameTypeDescription
lotId_uint96The lot ID
bidId_uint64The bid ID
<none>uint256
<none>address

Returns

NameTypeDescription
refunduint256The 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

NameTypeDescription
lotId_uint96The lot ID
bidIds_uint64[]The bid IDs

Returns

NameTypeDescription
bidClaimsBidClaim[]The bid claim data
auctionOutputbytesThe 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

NameTypeDescription
lotId_uint96The lot ID
<none>uint256

Returns

NameTypeDescription
totalIn_uint256totalIn The total amount of quote tokens that filled the auction
totalOut_uint256totalOut The total amount of base tokens sold
finished_boolfinished Whether the settlement is finished
auctionOutput_bytesauctionOutput 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

NameTypeDescription
lotId_uint96The 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

NameTypeDescription
lotId_uint96The lot ID
bidId_uint64The bid ID

Returns

NameTypeDescription
bidBidThe 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

NameTypeDescription
lotId_uint96The lot ID

Returns

NameTypeDescription
auctionData_AuctionDataThe 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

NameTypeDescription
lotId_uint96The lot ID

Returns

NameTypeDescription
hasPartialFillboolTrue if a partial fill exists
partialFillPartialFillThe 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

NameTypeDescription
<none>uint96

Returns

NameTypeDescription
<none>uint256numBids 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

NameTypeDescription
<none>uint96
<none>uint256
<none>uint256

Returns

NameTypeDescription
<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

NameTypeDescription
<none>uint96
<none>uint256

Returns

NameTypeDescription
<none>uint64bidId 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

NameTypeDescription
lotId_uint96The lot ID
bidId_uint64The bid ID

Returns

NameTypeDescription
bidClaimBidClaimThe 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

NameTypeDescription
lotId_uint96The lot ID
bidId_uint64The bid ID

Returns

NameTypeDescription
bidClaimBidClaimThe 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

NameTypeDescription
lotId_uint96The 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

NameTypeDescription
lotId_uint96The 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

NameTypeDescription
lotId_uint96The 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

NameTypeDescription
lotId_uint96The lot ID
bidId_uint64The 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

NameTypeDescription
lotId_uint96The lot ID
bidId_uint64The bid ID
caller_addressThe 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

NameTypeDescription
lotId_uint96The lot ID
bidId_uint64The bid ID