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//! - `python`: Enables Python bindings from [PyO3](https://pyo3.rs).
37//! - `extension-module`: Builds as a Python extension module.
38//!
39//! Python bindings for the Lighter adapter are intentionally scoped to configuration,
40//! enums, factory wiring, and integrator revocation. Data and execution
41//! clients are consumed directly through the Rust trait surface.
42//!
43//! [High-precision mode](https://nautilustrader.io/docs/nightly/getting_started/installation#precision-mode) (128-bit value types) is enabled by default.
44//!
45//! # Integrator attribution
46//!
47//! On Lighter Mainnet, submitted create and modify order transactions from Plus and Premium
48//! accounts carry the NautilusTrader integrator account index in Lighter's `L2TxAttributes`. This
49//! helps us gauge real usage of the integration and prioritize ongoing maintenance. Maker and taker
50//! integrator fees are set to zero, so attribution adds no trading cost. All other account tiers,
51//! sessions without an account snapshot, Lighter Testnet, and both Robinhood environments leave
52//! `L2TxAttributes` empty.
53//!
54//! Lighter requires an `ApproveIntegrator` approval before these attributes can be attached to
55//! Lighter Mainnet orders. During startup, the execution client submits the required zero-fee
56//! approval for a configured Plus or Premium L2 account. Other Lighter account tiers, sessions
57//! without an account snapshot, Lighter Testnet, and Robinhood clients do not submit an approval.
58//!
59//! Robinhood Mainnet instead applies the `NAUTILUS` referral to the account's public L1 address
60//! during execution-client startup. Application failures log a warning and do not block trading.
61//! Robinhood Testnet does not apply a referral. See the [Lighter integration guide](https://nautilustrader.io/docs/nightly/integrations/lighter.html#integrator-attribution)
62//! for attribution and revocation details.
63
64#![warn(rustc::all)]
65#![deny(unsafe_code)]
66#![deny(nonstandard_style)]
67#![deny(missing_debug_implementations)]
68#![deny(clippy::missing_panics_doc)]
69#![deny(rustdoc::broken_intra_doc_links)]
70// pyo3's `from_py_object` generates `.clone()` on `Copy` fields that clippy flags from the
71// macro expansion; an item-level `allow` cannot reach the expansion
72#![allow(clippy::clone_on_copy)]
73
74pub mod common;
75pub mod config;
76pub mod data;
77pub mod execution;
78pub mod factories;
79pub mod http;
80pub mod signing;
81pub mod websocket;
82
83#[cfg(feature = "python")]
84pub mod python;
85
86#[cfg(test)]
87mod tests;