Structs & Enums

ConfigParams

struct ConfigParams {
    uint256 quoteLotSizeInAtoms;
    uint256 baseLotSizeInAtoms;
    uint256 tickSizeInQuoteLotsPerBaseUnit;
    uint256 minLimitOrderAmountInBaseLots;
    FeeTier feeTier;
}
  • quoteLotSizeInAtoms: The smallest tradeable unit of the quote token, measured in atoms.
  • baseLotSizeInAtoms: The smallest tradeable unit of the base token, measured in atoms.
  • tickSizeInQuoteLotsPerBaseUnit: The minimum price increment for trading, expressed as a number of quote lots per base unit.
  • minLimitOrderAmountInBaseLots: Minimum allowable size for a limit order, measured in base lots.
  • feeTier: Defined in the FeeTier enum.

FeeTier

enum FeeTier {
    LOW,
    MEDIUM,
    HIGH
}

Events

MarketCreated

// Emitted when a new market is successfully created.
event MarketCreated(
    address indexed creator,
    address indexed quoteToken,
    address indexed baseToken,
    address marketAddress,
    uint256 quoteDecimals,
    uint256 baseDecimals,
    uint256 quoteLotSizeInAtoms,
    uint256 baseLotSizeInAtoms,
    uint256 tickSizeInQuoteLotsPerBaseUnit,
    uint256 minLimitOrderAmountInBaseLots,
    uint256 feeAmountInBps
);
  • creator: The address of the account that created the market.
  • quoteToken: The address of the quote token.
  • baseToken: The address of the base token.
  • marketAddress: The address of the deployed CLOB market contract.
  • quoteDecimals: The number of decimals for the quote token.
  • baseDecimals: The number of decimals for the base token.
  • quoteLotSizeInAtoms: The smallest tradeable unit of the quote token, measured in atoms.
  • baseLotSizeInAtoms: The smallest tradeable unit of the base token, measured in atoms.
  • tickSizeInQuoteLotsPerBaseUnit: The minimum price increment for trading, expressed as a number of quote lots per base unit.
  • minLimitOrderAmountInBaseLots: Minimum allowable size for a limit order, measured in base lots.
  • feeAmountInBps: The fee amount in basis points (1/100th of a percent).

Functions

createMarket

createMarket
function createMarket(
    address quoteToken, 
    address baseToken, 
    ConfigParams memory params
) external returns (address)

Creates a CLOB market for the given token pair. ConfigParams specifies the market fee tier, lot sizes, and tick sizes.

The call will revert if the market already exists, or if the ConfigParams are invalid.

Parameters

TypeNameDescription
addressquoteTokenThe quote token of the market.
addressbaseTokenThe base token of the market.
ConfigParams memoryparamsCustom ConfigParams structure, which specifies the market fee tier, lot sizes, and tick sizes.

Return Values

TypeDescription
addressThe deployment address of the CLOB market contract.

Events

Reverts

  • MarketAlreadyExists: If the market already exists for the given token pair and configuration.
  • InvalidConfigParams: If the provided configuration parameters are invalid.
  • TokensMustBeDifferent: If the quote and base tokens are the same.

getMarketAddress

getMarketAddress
function getMarketAddress(
    address quoteToken,
    address baseToken,
    ConfigParams memory params
) external view returns (address)

Returns the address of the CLOB market for the given token pair and configuration parameters. Markets are identified by the keccak256 hash of the unique combination of quoteToken address, baseToken address, and ConfigParams.

Parameters

TypeNameDescription
addressquoteTokenThe quote token of the market.
addressbaseTokenThe base token of the market.
ConfigParams memoryparamsCustom ConfigParams structure, which specifies the market fee tier, lot sizes, and tick sizes.

Return Values

TypeDescription
addressThe address of the CLOB market.

Reverts

  • MarketDoesNotExist: If the market does not exist for the given token pair and configuration.

getMarketCount

getMarketCount
function getMarketCount(
    address quoteToken, 
    address baseToken
) external view returns (uint256)

Given a certain token pair (sensitive to the order of quoteToken and baseToken), returns the number of markets created for that token pair, each being distinct via different ConfigParams.

Parameters

TypeNameDescription
addressquoteTokenThe quote token of the market.
addressbaseTokenThe base token of the market.

Return Values

TypeDescription
uint256The number of markets created for the given token pair.

getConfigParams

getConfigParams
function getConfigParams(
    address quoteToken, 
    address baseToken, 
    uint256 startIndex, 
    uint256 numParams
) external view returns (ConfigParams[] memory params, uint256 returnedParams)

Returns a subset of ConfigParams for the specified token pair, granted that a token pair may have multiple different markets distinguished by their ConfigParams. Returns a list of ConfigParams starting from a specified startIndex up to a specified number of parameters. The function reverts if the indices are invalid.

Parameters

TypeNameDescription
addressquoteTokenThe quote token of the market.
addressbaseTokenThe base token of the market.
uint256startIndexThe index which specifies where to start in the array of all ConfigParams for the given token pairs.
uint256numParamsThe number of ConfigParams to retrieve for the return value, starting iteration from the startIndex

Return Values

TypeNameDescription
ConfigParams[] memoryparamsAn array of ConfigParams structs.
uint256returnedParamsThe number of ConfigParams returned.

Reverts

  • InvalidIndices: If the specified indices are out of bounds for the available ConfigParams.