Skip to main content
All shared type definitions live in Types.sol and are imported by every contract. This page is the canonical reference — individual contract pages link here rather than duplicating definitions.

Enums

Side

ValueOrdinalDescription
LONG0Trader profits when the base/quote rate rises
SHORT1Trader profits when the base/quote rate falls

Tenors (no enum)

There is no Tenor enum. Tenors are stored as raw uint32 tenorSeconds values in a dynamic registry on Config. New maturities are added permissionlessly via Config.registerTenor(tenorSeconds) and removed via Config.disableTenor(tenorSeconds). Currently registered on Sepolia:
LabelSeconds
1D86,400
1W604,800
1M2,592,000
3M7,776,000
6M15,552,000
1Y31,536,000
Read the live set with Config.getEnabledTenors(). The TypeScript and Rust SDKs ship a bundled cache (TENORS) sourced from the canonical defaults file, but consumers should prefer the on-chain getter for authoritative state.

PositionStatus

ValueOrdinalDescription
OPEN0Position is active
CLOSED1Position has been settled, liquidated, or early-terminated

CloseReason

ValueOrdinalDescription
NONE0Position is still open
MATURED1Settled at fixing price after maturity
LIQUIDATED2Closed by liquidation (equity below MM threshold)
EARLY_TERMINATION3Closed early by trader at forward price

Mode

ValueOrdinalOpensClosesSettlementsLiquidations
NORMAL0YesYesYesYes
DEGRADED1NoYesYesYes
REDUCE_ONLY2NoYesYesYes
PAUSED3NoNoNoNo

MarginMode

ValueOrdinalDescription
ISOLATED0Each position has its own locked margin (M2 default)
CROSS1Shared margin across positions (future)

FeeType

Used as the indexed feeType of SettlementEngine.FeesCollected. The subgraph indexes these into the FeeEvent entity.
ValueOrdinalDescription
LIQUIDATION_PENALTY0Penalty portion of a liquidation (separate from the trading-fee leg)
EARLY_TERMINATION1Reserved bucket for an early-termination surcharge (currently 0)
MATURITY2Reserved bucket for a maturity-settlement surcharge (currently 0)
TRADING3Trading fee charged at every position close (settlement, liquidation, early term, reduce)

Structs

Position

Every position is stored onchain as a Position struct:
struct Position {
    address account;                     // Owner address
    bytes32 pairId;                      // Currency pair identifier (e.g., keccak256("EUR/USD"))
    Side side;                           // LONG or SHORT
    uint256 notional;                    // Position size in USDC (6 decimals)
    uint32 tenorSeconds;                 // Tenor duration in seconds (dynamic registry)
    uint64 openTimestamp;                // Block timestamp when opened
    uint64 fixingTimestamp;              // Maturity date (business day adjusted)
    int256 entryStrike;                  // Forward price at open (18 decimals)
    uint64 entryOracleRoundId;           // Oracle round ID at open
    uint256 imLocked;                    // Locked initial margin (mutable via add/remove)
    uint256 mmThreshold;                 // Maintenance margin liquidation threshold
    PositionStatus status;               // OPEN or CLOSED
    CloseReason closeReason;             // Why it was closed (NONE while open)
    uint64 closeTimestamp;               // When closed (0 while open)
    int256 closePrice;                   // Settlement price at close (18 decimals)
    int256 realizedPnl;                  // Capped PnL used for accounting
    int256 marketPnl;                    // Uncapped true mathematical PnL
    uint16 snapshotImBps;                // IM factor at time of open
    uint16 snapshotMmBps;                // MM factor at time of open
    uint16 snapshotTradingFeeBps;        // Trading fee rate at time of open
    uint16 snapshotLiquidationPenaltyBps; // Liquidation penalty at time of open
    uint256 snapshotOracleFee;           // Oracle fee at time of open
    MarginMode marginMode;               // ISOLATED (M2 only)
}
The imLocked field is the only mutable economic field on an open position. It changes when the trader adds or removes margin. All snapshot* fields are immutable after position creation.

OpenPositionParams

struct OpenPositionParams {
    bytes32 pairId;        // Currency pair (e.g., EUR_USD_PAIR_ID)
    Side side;             // LONG or SHORT
    uint256 notional;      // Position size in USDC (6 decimals)
    uint32 tenorSeconds;   // Contract duration in seconds (must be enabled in Config)
    uint256 margin;        // Initial margin to lock (6 decimals)
}

MarginConfig

struct MarginConfig {
    uint16 imFactorBps;              // Initial margin factor (default: 200 = 2%)
    uint16 mmFactorBps;              // Maintenance margin factor (default: 100 = 1%)
    uint16 tradingFeeBps;            // Trading fee rate (default: 5 = 0.05%)
    uint16 liquidationPenaltyBps;    // Liquidation penalty (default: 30 = 0.3%)
}

FeeDestination

struct FeeDestination {
    address destination;  // Recipient address
    uint16 shareBps;      // Share of fees (must sum to 10000 across all destinations)
}

PricingConfig

struct PricingConfig {
    uint16 baseSpreadBps;            // Base spread (default: 5 = 0.05%)
    uint16 premiumDiscountAdjBps;    // Premium/discount adjustment (default: 5 = 0.05%)
}

FixingConfig

struct FixingConfig {
    uint8 fixingHourUtc;     // Hour of fixing time (0-23)
    uint8 fixingMinuteUtc;   // Minute of fixing time (0-59)
    uint8 fixingSecondUtc;   // Second of fixing time (0-59)
}

OracleConfig

struct OracleConfig {
    uint32 maxOracleAge;                // Max spot price age in seconds (default: 30)
    uint32 maxForwardAge;               // Max forward price age in seconds (default: 60)
    uint32 spotFixingWindowSeconds;     // Fixing window tolerance (default: 120 = ±2 min)
    uint32 minForwardUpdateSpacing;     // Min seconds between updates (default: 10)
    uint16 maxOracleMovePerUpdateBps;   // Max price move per update (default: 200 = 2%)
    uint16 maxDeviationVsPriorBps;      // Max deviation vs prior forward (default: 50 = 0.5%)
    uint16 maxAnchorDeviationBps;       // Max deviation vs Pyth-verified spot × IRP carry (default: 150 = 1.5%)
}

DegradedConfig

struct DegradedConfig {
    uint32 degradedDurationSeconds;  // Max time in DEGRADED before PAUSED (default: 3600 = 1h)
}

ForwardRound

struct ForwardRound {
    int256 forwardPrice;       // Forward price (18 decimal precision)
    uint64 publishTimestamp;   // When the price was published
    uint64 roundId;            // Sequential round identifier
    bool isValid;              // Whether this round is valid
}

Constants

ConstantValueDescription
PRICE_PRECISION1e18All prices use 18 decimal precision
BPS_DENOMINATOR10_000Basis points divisor (100% = 10,000 bps)
EUR_USD_PAIR_IDkeccak256("EUR/USD")Pair identifier for EUR/USD
USD_JPY_PAIR_IDkeccak256("USD/JPY")Pair identifier for USD/JPY

Contract Overview

Architecture diagram and contract summary.

Parameter Reference

Default parameter values and configuration.

Errors Reference

Custom errors by contract.