A complete Rust integration path for Morpho Midnight offers.
SDK Guide | API Docs | Examples | CLI Guide
Nocturne is a Rust SDK for integrating with the Morpho Midnight protocol. It builds and signs offers, constructs Merkle trees, simulates execution, reads the public order book, manages lending and borrowing positions, and produces transactions that Rust wallet clients can submit.
Nocturne is an early v0.1.0 release and has not been independently security-audited. See SECURITY.md before using it with real value.
The crates.io package and Rust import intentionally have different names:
| Context | Name |
|---|---|
| crates.io SDK package | nocturne-midnight |
| Rust import | nocturne |
Add the SDK to a Rust application:
[dependencies]
nocturne = { package = "nocturne-midnight", version = "0.1.0" }Install the CLI:
cargo install nocturne-verifyflowchart LR
A[Offer terms] --> B[Build and validate]
B --> C[Group and build tree]
C --> D[Sign or ratify]
D --> E[Encode payload]
E --> F[Publish with Rust wallet]
G[Midnight API] --> H[Book or quote]
H --> I[Size and simulate]
I --> J[Encode take calldata]
J --> K[Submit with Rust wallet]
D -. inspect .-> V[Offline review]
E -. inspect .-> V
J -. inspect .-> V
- Maker: build β validate β group β sign or ratify β encode β publish.
- Taker: fetch β quote β size β simulate β encode β submit.
- Reviewer: receive bytes or typed data β decode β reproduce root and digest β verify.
Start with the SDK quickstart and complete workflows. Every example and its exact Cargo command are listed in the examples index. CLI commands are documented in the CLI guide.
The minimum supported Rust version is 1.90. Run the repository checks with:
cargo test --workspace --all-targetsProtocol-critical outputs have contract and TypeScript SDK parity coverage. The maintainer-only live Anvil harness exercises complete maker, taker, authorization, cancel-and-replace, state-decoding, and market-making lifecycles against deployed Midnight contracts.
Nocturne emphasizes deterministic offchain construction, validation, and simulation wherever possible. Most SDK behavior can be developed and tested locally without funding a wallet; Anvil and live-chain tests are reserved for the integration boundaries that require them.
Contributions are welcome. See CONTRIBUTING.md for the development workflow, testing expectations, and pull request guidelines.
- Join the Telegram chat for questions and discussion.
- Open a GitHub issue for bugs and features.
- Report vulnerabilities privately using SECURITY.md.
- Morpho SDKs and Morpho Midnight β protocol behavior, compatibility vectors, and selected algorithms were developed with reference to these public projects.
- ruint / alloy β Ethereum primitives and optional wallet integration.
- RustCrypto
k256β secp256k1 signing and recovery. tiny-keccak,rayon, and Foundry.
Independent, personal open source projectβnot created, endorsed, or supported by Morpho. Provided "AS IS" with no warranty and no liability, and it is not financial, investment, or legal advice. Interacting with blockchain protocols and automated trading carries significant risk, including total loss of funds. See DISCLAIMER.md for the full text.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
