Skip to main content
M2 is deployed on Ethereum Sepolia testnet only. This is not a production system. All tokens are test tokens with no monetary value. Do not use real funds. Contract addresses, parameters, and behaviors may change between deployments.

Deployment Overview

PropertyValue
NetworkEthereum Sepolia testnet
Versionv0.3.0
MilestoneM2 (External Testnet)
CollateralMockUSDC (test ERC-20, 6 decimals)
Supported PairEUR/USD
OraclePyth Network (Sepolia)
M2 is the first externally accessible deployment of the Open Nile Protocol. It includes the full protocol feature set deployed on Ethereum Sepolia with real Pyth oracle prices and automated keeper operations.

Smart Contracts

Eight core contracts plus a Protocol registry are deployed on Sepolia:

Shared Infrastructure

  • Protocol — Root registry and access control
  • Config — All configurable parameters (fees, margins, caps)
  • OracleModule — Pyth spot prices + publisher-pushed forward prices
  • ModeController — 4-mode operating state machine
  • RiskManager — Position, account, and pool-level risk caps

Pool Contracts

  • MarginAccounts — Collateral deposits, margin locking, fee collection
  • PoolVault — ERC-4626 liquidity pool for LP deposits
  • PositionManager — Position lifecycle (open, increase, close, reduce)
  • SettlementEngine — Batch settlement, liquidation, early termination
All contracts are immutable (no proxy upgrades). Protocol parameters are adjustable via the Config contract by the admin role. Contract source is verified on Sepolia Etherscan.

Supported Features

  • EUR/USD NDF trading — LONG or SHORT positions
  • 3 tenors: 1 Day (86,400s), 1 Week (604,800s), 1 Month (2,592,000s)
  • Isolated margin model — each position’s risk is contained to its own locked margin
  • Variable leverage up to 50x (2% initial margin requirement)
  • Position operations: open, increase, close early, reduce, add/remove margin
  • Permissionless settlement — anyone can settle matured positions or liquidate

Off-Chain Services

1

Publisher (Rust)

Fetches real EUR/USD spot prices from Pyth Hermes API, computes forward prices using interest rate parity, and publishes them onchain via the OracleModule. Runs on a configurable interval (default: every 30 seconds).
2

Keeper (Rust)

Monitors for matured and liquidatable positions. Executes batch settlement and liquidation transactions. Fully automated with configurable scan intervals.
3

Frontend (Next.js)

Trading UI built with Next.js, wagmi, viem, and shadcn/ui. Supports wallet connection via RainbowKit, real-time position monitoring, LP deposit/withdraw, and protocol state display.
4

Subgraph (The Graph)

Indexes all onchain protocol events into a queryable GraphQL API. Provides historical data, position lifecycle tracking, fee accounting, and pool state history.

Integration Paths

M2 supports multiple ways to interact with the protocol:
IntegrationDescriptionStatus
TypeScript SDKType-safe ABIs, enums, and constants (@nile-markets/sdk)Available
Subgraph APIGraphQL queries for positions, accounts, pool state, historyAvailable
CLI ToolCommand-line interface (nile) for all protocol operationsAvailable
MCP ServerModel Context Protocol server for AI agentsAvailable
x402 APIPay-per-call HTTP API using x402 payment protocolAvailable
llms.txtMachine-readable protocol summary for LLM consumptionAvailable

Known Limitations

The following limitations apply to the M2 deployment and are planned for resolution in future milestones:
Only EUR/USD is supported. The contract architecture supports multi-pair registration via OracleModule.registerPair(), but additional pairs (GBP/USD, USD/JPY) are deferred to M3.
All positions use isolated margin (MarginMode.ISOLATED). Cross-margin support (MarginMode.CROSS) is defined in the enum but not implemented. Planned for M3.
Fixing dates do not account for FX market holidays. Only weekends are excluded from the tenor duration calculation. A proper holiday calendar is planned for M3.
Mode changes (Normal, Degraded, Reduce-Only, Paused) are triggered by the admin role. Automated mode escalation based on oracle health or pool metrics is planned for M3.
The M2 contracts have not undergone a professional security audit. A professional audit with 1-2 independent firms is planned for M3. The test suite includes 550 Foundry tests with 95%+ line coverage.
M2 uses a test ERC-20 (MockUSDC) rather than canonical USDC. Integration with canonical USDC on mainnet is planned for M3.
The keeper service operates without onchain economic incentives (no liquidation rewards or gas reimbursement). Keeper incentive design is planned for M3.
Forward prices are published by a single authorized publisher. There is no publisher redundancy or decentralized publisher network. Multi-publisher support is planned for M3.

M3 Plan

What is planned for the mainnet-ready milestone.

Contract Addresses

Current Sepolia deployment addresses.

Quick Start

Get started interacting with the M2 deployment.