Shared enums (Side, Tenor, Mode, CloseReason, MarginMode), structs (Position, MarginConfig, OracleConfig, ForwardRound), and constants (PRICE_PRECISION, BPS_DENOMINATOR, EUR_USD_PAIR_ID) used across all protocol contracts
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.
Tenor durations are configurable via Config.setTimeConfig(). The values above are defaults. Tenors must be explicitly enabled via Config.setTenorEnabled() after deployment.
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) Tenor tenor; // Maturity tenor (ONE_DAY, ONE_WEEK, ONE_MONTH) uint32 tenorSeconds; // Tenor duration in seconds 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.
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)}