Skip to main content

Settlement

Order settlement contract for signed orders plus Holdings-native mint/burn/redeem/conversion flows.

Key changes in Settlement V2

Budget-native buys: Buy orders are now denominated in collateral budget and minimum output shares, not price/size. Single signed order type: No more separate MarketOrderIntent. Both limit and market orders use the same SignedOrder struct. Explicit order kinds: Replaces the old side + inventoryModeConstraint model with clear order families: BUY, SELL_INVENTORY, SELL_NO_INVENTORY. No sell-side ANY mode exists in V2. Consumption accounting: Orders track actual consumed amounts (collateral for buys, shares for sells) separately from fees.

Order settlement

settleFill / settleFillBatch

function settleFill(FillData calldata fill, bytes calldata fillSignature);
function settleFillBatch(FillData[] calldata fills, bytes[] calldata fillSignatures);
Settles one or many matched fills. The fill itself must be signed by an authorized fill signer.

Settlement V2 FillData struct

struct FillData {
    bytes32 marketId;
    address buyer;
    address seller;
    uint256 shareAmount;           // Shares being exchanged
    uint256 buyerCollateralAmount; // Collateral the buyer sends
    uint8 outcomeIndex;
    uint8 sellerOrderKind;         // SELL_INVENTORY or SELL_NO_INVENTORY
    bytes32 fillNonce;
    uint256 deadline;
    uint256 makerTotalConsumed;    // Cumulative consumed amount (not filled amount)
    uint256 takerTotalConsumed;
    uint256 makerTotalFees;        // Cumulative fees charged
    uint256 takerTotalFees;
    SignedOrder makerOrder;
    SignedOrder takerOrder;
    bytes makerSignature;
    bytes takerSignature;
}
V2 tracks actual asset movement (shareAmount, buyerCollateralAmount) and cumulative consumption per order, accounting for different consumption rules per order kind.

Settlement V2 SignedOrder struct

struct SignedOrder {
    bytes32 marketId;
    address trader;
    uint256 maxShares;          // Max shares to sell (sell) or max shares output (buy)
    uint256 minSharesOut;       // Min shares output (both buy and sell)
    uint256 maxCollateralIn;    // Max collateral to spend (buy) or receive (sell)
    uint256 minCollateralOut;   // Min collateral output (both buy and sell)
    uint8 outcomeIndex;
    uint8 orderKind;            // 0 = BUY, 1 = SELL_INVENTORY, 2 = SELL_NO_INVENTORY
    bytes32 nonce;
    uint256 expiry;
    uint256 maxFee;
    uint8 timeInForce;          // 0 = GTC, 1 = IOC, 2+ reserved
    uint8 makerRoleConstraint;  // 0 = ANY, 1 = MAKER_ONLY, 2 = TAKER_ONLY
}
Order kinds:
  • ORDER_KIND_BUY (0) — Budget-native buy: consume up to maxCollateralIn collateral, require at least minSharesOut shares
  • ORDER_KIND_SELL_INVENTORY (1) — Sell from existing outcome token inventory: sell up to maxShares, require at least minCollateralOut collateral
  • ORDER_KIND_SELL_NO_INVENTORY (2) — Sell by minting from budget: sell up to maxShares using maxCollateralIn budget, require at least minCollateralOut collateral
Consumption model:
  • BUY orders: consumed amount = buyerCollateralAmount + makerFee + takerFee
  • SELL orders: consumed amount = shareAmount
This per-kind consumption model enables proper budget enforcement for buys and share limits for sells. Order signatures are EIP-712 signatures over the Settlement domain.

Nonce cancellation

function cancelOwnNonce(bytes32 nonce)
Cancels the caller’s order nonce so orders using that nonce can no longer be filled.
function cancelNonce(address trader, bytes32 nonce, bytes calldata signature)
Cancels a trader nonce with their signature. Anyone can submit it. Signature type:
CancelNonce(address trader, bytes32 nonce)

Signature verification

function verifyOrderSignature(SignedOrder calldata order, bytes calldata signature) returns (bool);
Public helper method for validating trader signatures off-chain or from integration code. V2 uses a single order type for both limit and market orders.

Holdings-native operations

Mint complete sets

function mintCompleteSetsFromHoldings(bytes32 marketId, uint256 amount, address recipient, bool creditInternal);
function mintCompleteSetsFromHoldingsBySig(
    address user,
    bytes32 marketId,
    uint256 amount,
    address recipient,
    bool creditInternal,
    uint256 nonce,
    uint256 deadline,
    bytes calldata signature
);
Uses Holdings collateral balance to mint complete sets, then deposits all resulting outcome tokens into Holdings.
Settlement V2 removed mintAndDepositWithPermit(). Use Holdings.depositWithPermit() followed by Settlement.mintCompleteSetsFromHoldings() instead.

Burn complete sets

function burnCompleteSetsFromHoldings(bytes32 marketId, uint256 amount, address recipient, bool creditInternal);
function burnCompleteSetsFromHoldingsBySig(
    address user,
    bytes32 marketId,
    uint256 amount,
    address recipient,
    bool creditInternal,
    uint256 nonce,
    uint256 deadline,
    bytes calldata signature
);
Burns complete sets using Holdings balances instead of wallet balances. Outcome tokens are withdrawn from Holdings, burned via MarketFactory, and collateral is either sent externally to recipient or credited back into Holdings when creditInternal is true.

Negative-risk conversion

function convertMultiBinaryPositionsFromHoldings(
    bytes32 parentMarketId,
    uint256 indexSet,
    uint256 amount,
    uint256 expectedQuestionCount
);

function convertMultiBinaryPositionsFromHoldingsBySig(
    address user,
    bytes32 parentMarketId,
    uint256 indexSet,
    uint256 amount,
    uint256 expectedQuestionCount,
    uint256 nonce,
    uint256 deadline,
    bytes calldata signature
);
Performs negative-risk conversion using Holdings balances. NO positions are withdrawn from Holdings, converted through MarketFactory, and resulting YES tokens and released collateral are deposited back into Holdings.

Redeem outcomes

function redeemOutcomesToHoldings(bytes32 marketId, uint256[] calldata amounts);
function redeemOutcomesToHoldingsFor(address user, bytes32 marketId, uint256[] calldata amounts);
function batchRedeemOutcomesToHoldings(bytes32[] calldata marketIds, uint256[][] calldata amountsArray);
function batchRedeemOutcomesToHoldingsFor(
    address[] calldata users,
    bytes32[] calldata marketIds,
    uint256[][] calldata amountsArray
);
Redeems resolved outcome tokens from Holdings balances and credits resulting collateral back into Holdings.

Order helpers

function isOrderInvalid(address trader, SignedOrder calldata order) returns (bool invalid);
function getFilledAmount(bytes32 orderHash) returns (uint256 filledAmount);
Useful helper reads for order management and UI state.

Events

event NonceCanceled(address indexed trader, bytes32 indexed nonce);

event FillExecuted(
    bytes32 indexed marketId,
    address indexed maker,
    address indexed taker,
    bytes32 fillNonce,
    uint256 price,
    uint256 size,
    uint8 outcomeIndex,
    uint8 takerSide,
    address collateralToken,
    bool makerHasInventory,
    uint256 makerFee,
    uint256 takerFee,
    uint256 makerTotalFilled,
    uint256 takerTotalFilled,
    bytes32 makerOrderHash,
    bytes32 takerOrderHash
);

event CompleteSetsMintedForFill(
    bytes32 indexed marketId,
    bytes32 indexed fillNonce,
    address indexed maker,
    uint256 amount,
    address taker,
    uint8 outcomeIndex
);