Skip to main content

AuctionModule

Git Source

Inherits: IAuction, Module

State Variables

_ONE_HUNDRED_PERCENT

Constant for percentages, in basis points

1% = 1_00 or 1e2. 100% = 100_00 or 100e2 or 1e4.

uint48 internal constant _ONE_HUNDRED_PERCENT = 100e2;

minAuctionDuration

Minimum auction duration in seconds

uint48 public minAuctionDuration;

lotData

General information pertaining to auction lots

See the Lot struct for more information on the return values

mapping(uint96 id => Lot lot) public lotData;

Functions

constructor

constructor(address auctionHouse_) Module(auctionHouse_);

TYPE

2 byte identifier for the module type

This enables the parent contract to check that the module Keycode specified

function TYPE() public pure override returns (Type);

auction

Create an auction lot

If the start time is zero, the auction will have a start time of the current block timestamp.

This function handles the following:

  • Validates the lot parameters
  • Stores the auction lot
  • Calls the implementation-specific function

This function reverts if:

  • The caller is not the parent of the module
  • The start time is in the past
  • The duration is less than the minimum
function auction(
uint96 lotId_,
AuctionParams memory params_,
uint8 quoteTokenDecimals_,
uint8 baseTokenDecimals_
) external virtual override onlyInternal;

Parameters

NameTypeDescription
lotId_uint96The lot id
params_AuctionParamsThe auction parameters
quoteTokenDecimals_uint8The quote token decimals
baseTokenDecimals_uint8The base token decimals

_auction

Implementation-specific auction creation logic

Auction modules should override this to perform any additional logic

function _auction(uint96 lotId_, Lot memory lot_, bytes memory params_) internal virtual;

Parameters

NameTypeDescription
lotId_uint96The lot ID
lot_LotThe lot data
params_bytesAdditional auction parameters

cancelAuction

Cancel an auction lot

Assumptions:

  • The parent will refund the seller the remaining capacity
  • The parent will verify that the caller is the seller

This function handles the following:

  • Calls the implementation-specific function
  • Updates the lot data

This function reverts if:

  • the caller is not the parent of the module
  • the lot id is invalid
  • the lot has concluded
function cancelAuction(uint96 lotId_) external virtual override onlyInternal;

Parameters

NameTypeDescription
lotId_uint96The lot id

_cancelAuction

Implementation-specific auction cancellation logic

Auction modules should override this to perform any additional logic

function _cancelAuction(uint96 lotId_) internal virtual;

Parameters

NameTypeDescription
lotId_uint96The lot ID

isLive

Returns whether the auction is currently accepting bids or purchases

A lot is active if:

  • The lot has not concluded
  • The lot has started
  • The lot has not sold out or been cancelled (capacity > 0)
function isLive(uint96 lotId_) public view override returns (bool);

Parameters

NameTypeDescription
lotId_uint96The lot ID

Returns

NameTypeDescription
<none>boolbool Whether or not the lot is active

isUpcoming

Returns whether the auction is upcoming

The implementing function should handle the following:

  • Return true if the lot has not started yet AND has not been cancelled
  • Return false if the lot is active, has ended, or was cancelled
function isUpcoming(uint96 lotId_) public view override returns (bool);

Parameters

NameTypeDescription
lotId_uint96The lot id

Returns

NameTypeDescription
<none>boolbool Whether or not the lot is upcoming

hasEnded

Returns whether the auction has ended

The implementing function should handle the following:

  • Return true if the lot is not accepting bids/purchases and will not at any point
  • Return false if the lot hasn't started or is actively accepting bids/purchases
function hasEnded(uint96 lotId_) public view override returns (bool);

Parameters

NameTypeDescription
lotId_uint96The lot id

Returns

NameTypeDescription
<none>boolbool Whether or not the lot is active

remainingCapacity

Get the remaining capacity of a lot

The implementing function should handle the following:

  • Return the remaining capacity of the lot
function remainingCapacity(uint96 lotId_) external view override returns (uint256);

Parameters

NameTypeDescription
lotId_uint96The lot id

Returns

NameTypeDescription
<none>uint256uint96 The remaining capacity of the lot

capacityInQuote

Get whether or not the capacity is in quote tokens

The implementing function should handle the following:

  • Return true if the capacity is in quote tokens
  • Return false if the capacity is in base tokens
function capacityInQuote(uint96 lotId_) external view override returns (bool);

Parameters

NameTypeDescription
lotId_uint96The lot id

Returns

NameTypeDescription
<none>boolbool Whether or not the capacity is in quote tokens

getLot

Get the lot data for a given lot ID

function getLot(uint96 lotId_) external view override returns (Lot memory);

Parameters

NameTypeDescription
lotId_uint96The lot ID

setMinAuctionDuration

Set the minimum auction duration

This function must be called by the parent AuctionHouse, and can be called by governance using execOnModule.

function setMinAuctionDuration(uint48 duration_) external onlyParent;

_revertIfLotInvalid

Checks that lotId_ is valid

Should revert if the lot ID is invalid Inheriting contracts can override this to implement custom logic

function _revertIfLotInvalid(uint96 lotId_) internal view virtual;

Parameters

NameTypeDescription
lotId_uint96The lot ID

_revertIfBeforeLotStart

Checks that the lot represented by lotId_ has not started

Should revert if the lot has not started

function _revertIfBeforeLotStart(uint96 lotId_) internal view virtual;

_revertIfLotStarted

Checks that the lot represented by lotId_ has started

Should revert if the lot has started

function _revertIfLotStarted(uint96 lotId_) internal view virtual;

_revertIfBeforeLotConcluded

Checks that the lot represented by lotId_ has not concluded

Should revert if the lot has not concluded

function _revertIfBeforeLotConcluded(uint96 lotId_) internal view virtual;

_revertIfLotConcluded

Checks that the lot represented by lotId_ has not concluded

Should revert if the lot has concluded

function _revertIfLotConcluded(uint96 lotId_) internal view virtual;

_revertIfLotInactive

Checks that the lot represented by lotId_ is active

Should revert if the lot is not active Inheriting contracts can override this to implement custom logic

function _revertIfLotInactive(uint96 lotId_) internal view virtual;

Parameters

NameTypeDescription
lotId_uint96The lot ID

_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 virtual;

Parameters

NameTypeDescription
lotId_uint96The lot ID