nautilus_lighter/lib.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3// https://nautechsystems.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! [NautilusTrader](https://nautilustrader.io) adapter for the [Lighter](https://lighter.xyz) DEX.
17//!
18//! The `nautilus-lighter` crate provides integration with the Lighter protocol for trading
19//! perpetual futures and spot markets on the Lighter and Robinhood Chain deployments.
20//!
21//! # NautilusTrader
22//!
23//! [NautilusTrader](https://nautilustrader.io) is an open-source, production-grade, Rust-native
24//! engine for multi-asset, multi-venue trading systems.
25//!
26//! The system spans research, deterministic simulation, and live execution within a single
27//! event-driven architecture, providing research-to-live semantic parity.
28//!
29//! # Feature Flags
30//!
31//! This crate provides feature flags to control source code inclusion during compilation,
32//! depending on the intended use case, i.e. whether to provide Python bindings
33//! for the [nautilus_trader](https://pypi.org/project/nautilus_trader) Python package,
34//! or as part of a Rust only build.
35//!
36//! - `examples`: Enables the crate's example binaries.
37//! - `extension-module`: Builds as a Python extension module.
38//! - `fuzz`: Enables libFuzzer integration for fuzz targets.
39//! - `high-precision` (default): Enables
40//! [high-precision mode](https://nautilustrader.io/docs/nightly/getting_started/installation/#precision-mode)
41//! to use 128-bit value types.
42//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
43//!
44//! Python bindings for the Lighter adapter are intentionally scoped to configuration,
45//! enums, factory wiring, and integrator revocation. Data and execution
46//! clients are consumed directly through the Rust trait surface.
47//!
48//! # Integrator attribution
49//!
50//! On Lighter Mainnet, submitted create and modify order transactions from Plus and Premium
51//! accounts carry the NautilusTrader integrator account index in Lighter's `L2TxAttributes`. This
52//! helps us gauge real usage of the integration and prioritize ongoing maintenance. Maker and taker
53//! integrator fees are set to zero, so attribution adds no trading cost. All other account tiers,
54//! sessions without an account snapshot, Lighter Testnet, and both Robinhood environments leave
55//! `L2TxAttributes` empty.
56//!
57//! Lighter requires an `ApproveIntegrator` approval before these attributes can be attached to
58//! Lighter Mainnet orders. During startup, the execution client submits the required zero-fee
59//! approval for a configured Plus or Premium L2 account. Other Lighter account tiers, sessions
60//! without an account snapshot, Lighter Testnet, and Robinhood clients do not submit an approval.
61//!
62//! Robinhood Mainnet instead applies the `NAUTILUS` referral to the account's public L1 address
63//! during execution-client startup. Application failures log a warning and do not block trading.
64//! Robinhood Testnet does not apply a referral. See the [Lighter integration guide](https://nautilustrader.io/docs/nightly/integrations/lighter/#integrator-attribution)
65//! for attribution and revocation details.
66
67#![warn(rustc::all)]
68#![deny(unsafe_code)]
69#![deny(nonstandard_style)]
70#![deny(missing_debug_implementations)]
71#![deny(clippy::missing_panics_doc)]
72#![deny(rustdoc::broken_intra_doc_links)]
73// pyo3's `from_py_object` generates `.clone()` on `Copy` fields that clippy flags from the
74// macro expansion; an item-level `allow` cannot reach the expansion
75#![allow(clippy::clone_on_copy)]
76
77pub mod common;
78pub mod config;
79pub mod data;
80pub mod execution;
81pub mod factories;
82pub mod http;
83pub mod signing;
84pub mod websocket;
85
86pub(crate) mod book;
87
88#[cfg(feature = "python")]
89pub mod python;
90
91#[cfg(test)]
92mod tests;