Types

SpotPool / OrderBook Types

OrderId (type)

solidity
type OrderId is uint128;

An OrderId is unique only within a single market. The same value can refer to different orders across markets, and resting and pending/stop orders are numbered independently. Always pair an OrderId with its market to identify an order.

Order (struct)

solidity
struct Order {
    OrderId orderId;
    bool isBid;
    address owner;
    uint64 userData;
    uint256 price;
    uint256 fullQuantity;
    uint256 quantityRemaining;
    uint64 expireTimestampNs;
}

OrderBookLevel (struct)

solidity
struct OrderBookLevel {
    uint256 price;
    uint256 quantity;
}

OrderType (enum)

ValueDescription
NormalOrderOrder will be filled or placed into the book depending on current state
FillOrKillOrder will only execute if it can be fully filled immediately, otherwise rejected
ImmediateOrCancelOrder will fill as much as possible immediately, remaining quantity is cancelled
PostOnlyOrder will be rejected if any portion would fill immediately (maker-only)

SelfMatchingOption (enum)

ValueDescription
CancelTakerCancel the taker order if it would match against own maker order
CancelMakerCancel the maker order if taker would match against it, then continue matching

PlaceOrderRequest (struct)

One order in a batch placement. Mirrors the per-order arguments of placeOrder; the order owner is supplied once by the batch entrypoint — the caller for placeOrders, the owner argument for placeOrdersFor — rather than per request.

solidity
struct PlaceOrderRequest {
    bool isBid;
    uint64 userData;
    uint256 price;
    uint256 quantity;
    uint64 expireTimestampNs;
    OrderType orderType;
    SelfMatchingOption selfMatchingOption;
    address builder;
    uint96 builderFeeBpsTimes1k;
}
FieldTypeDescription
isBidboolTrue for a buy (bid) order, false for a sell (ask) order
userDatauint64Arbitrary 64-bit user data attached to the order
priceuint256Limit price; must be a multiple of tickSize
quantityuint256Order quantity; must be >= minQuantity and a multiple of lotSize
expireTimestampNsuint64Expiration timestamp in nanoseconds (must be a future value)
orderTypeOrderTypeExecution type: NormalOrder, FillOrKill, ImmediateOrCancel, or PostOnly
selfMatchingOptionSelfMatchingOptionBehavior when the order would match against the owner's own orders
builderaddressOptional builder address that earns a fee on this order's fills. address(0) for none.
builderFeeBpsTimes1kuint96Per-order builder fee rate in BPS_TIMES_1K units. Must be 0 when builder is address(0).

ReduceOrderRequest (struct)

One reduction in a batch reduce (reduceOrders / reduceOrdersFor).

solidity
struct ReduceOrderRequest {
    OrderId orderId;
    uint256 newQuantityRemaining;
}
FieldTypeDescription
orderIdOrderIdThe order to reduce
newQuantityRemaininguint256The new remaining quantity; must be >= minQuantity and lot-aligned

AmendOrderRequest (struct)

One amend — the order to cancel plus the replacement to place. Shared by amendOrder / amendOrderFor (one request) and amendOrders / amendOrdersFor (an array of requests).

solidity
struct AmendOrderRequest {
    OrderId oldOrderId;
    bool alwaysPlace;
    PlaceOrderRequest newOrder;
}
FieldTypeDescription
oldOrderIdOrderIdThe resting order to cancel, then replace
alwaysPlaceboolRace handling for an oldOrderId already filled/cancelled by the time the tx lands. false (default) reverts AmendOldOrderGone and places nothing; true skips the (impossible) cancel and places newOrder anyway (opt-in upsert).
newOrderPlaceOrderRequestThe replacement order to place; owned by the amend caller (or the operator-declared owner on the ...For paths)

OrderBookParameters (struct)

solidity
struct OrderBookParameters {
    uint256 tickSize;
    uint256 minQuantity;
    uint256 lotSize;
}
FieldTypeDescription
tickSizeuint256Minimum price increment in quote token units
minQuantityuint256Minimum order quantity in base token units
lotSizeuint256Minimum quantity increment in base token units

SpotPoolParameters (struct)

solidity
struct SpotPoolParameters {
    uint256 takerFeeBpsTimes1k;
    uint256 makerFeeBpsTimes1k;
    address feeRecipient;
    uint256 maxBuilderFeeBpsTimes1k;
}
FieldTypeDescription
takerFeeBpsTimes1kuint256Taker fee rate in basis points x 1000 (1 BPS = 1000)
makerFeeBpsTimes1kuint256Maker fee rate in basis points x 1000 (1 BPS = 1000)
feeRecipientaddressAddress that receives collected trading fees
maxBuilderFeeBpsTimes1kuint256Protocol-wide cap on per-user→builder approvals (BPS_TIMES_1K). 0 disables Builder Codes.

TokenLockBreakdown (struct)

Returned per token by getLockedTokenBreakdown. The three fields are exhaustive and disjoint — their sum equals the pool's on-chain balance of the token.

solidity
struct TokenLockBreakdown {
    uint256 principalLocked;
    uint256 lockedSurplus;
    uint256 leftover;
}
FieldTypeDescription
principalLockeduint256Principal locked by resting orders — the tradeable amount they would pay out if fully filled, before fees.
lockedSurplusuint256Everything locked above principal: the maker + builder fee reserve, price-improvement over-lock (refunded to the owner on cancel/removal), and rounding dust. Not purely protocol revenue.
leftoveruint256Token held by the pool but not locked on the book: free (withdrawable) vault balances, fees already accrued to the fee recipient, and any direct transfers.

MidpointEmaParameters (struct)

Configuration for the EMA-smoothed midpoint trigger feed emitted on MarkPriceUpdated. The smoothing factor is the load-bearing protection against single-block midpoint manipulation — an attacker would need to sustain a manipulated raw midpoint across multiple intervals to drag the EMA past a stop's trigger band.

solidity
struct MidpointEmaParameters {
    uint256 updateIntervalSec;
    uint256 emaSmoothingAlpha;
}
FieldTypeDescription
updateIntervalSecuint256How often the EMA advances by one step, in seconds. Must be > 0 and <= 86400 (one day).
emaSmoothingAlphauint256EMA smoothing factor scaled by 1e18. Must be in (0, 1e18]. Higher = less smoothing.

Stop Order Types

PendingOrderType (enum)

ValueDescription
LIMITTriggered order uses a user-specified limit price
MARKETTriggered order uses a slippage-adjusted limit price computed from the mark price

Operator (enum)

ValueDescription
GTETriggers when mark price is greater than or equal to trigger price
LTETriggers when mark price is less than or equal to trigger price

PendingOrder (struct)

solidity
struct PendingOrder {
    bool isBid;
    address owner;
    uint64 userData;
    uint256 quantity;
}

PendingOrderWithTrigger (struct)

solidity
struct PendingOrderWithTrigger {
    PendingOrder order;
    PendingOrderType orderType;
    uint256 triggerPrice;
    Operator triggerOperator;
    uint256 limitPrice;
    address builder;
    uint96 builderFeeBpsTimes1k;
}
FieldTypeDescription
orderPendingOrderCore order parameters (side, owner, userData, quantity)
orderTypePendingOrderTypeWhether this is a LIMIT or MARKET order
triggerPriceuint256The EMA midpoint threshold that activates this order
triggerOperatorOperatorGTE or LTE comparison against the mark price
limitPriceuint256Limit price for LIMIT orders. Must be exactly 0 for MARKET orders.
builderaddressOptional builder address that earns a fee on the triggered IOC order's fills. address(0) for none. See Builder Codes.
builderFeeBpsTimes1kuint96Per-order builder fee rate in BPS_TIMES_1K units. Must be 0 when builder is address(0).

StoredPendingOrder (struct)

The on-chain representation of a pending order. Returned by registry view functions.

solidity
struct StoredPendingOrder {
    PendingOrderWithTrigger orderWithTrigger;
    OrderId orderId;
    uint256 somiPaid;
}
FieldTypeDescription
orderWithTriggerPendingOrderWithTriggerThe original order specification
orderIdOrderIdGlobally unique pending-order identifier
somiPaiduint256SOMI paid at creation. Refunded on cancel, consumed on trigger.