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//! NautilusTrader participates in [Lighter's partner program](https://apidocs.lighter.xyz/docs/partner-integration).
51//! On Lighter Mainnet and Robinhood Mainnet, create and modify order transactions carry the
52//! deployment-specific NautilusTrader integrator account index in `L2TxAttributes` across all
53//! account tiers, including Standard. Maker and taker integrator fees are zero. Both testnets omit
54//! integrator attributes.
55//!
56//! Lighter requires an `ApproveIntegrator` approval before these attributes can be attached to
57//! mainnet orders. During startup, each mainnet execution client submits the required zero-fee
58//! approval for a configured L2 account with a non-maker-only API key. Both testnets skip approval.
59//!
60//! During startup on either mainnet, when account details are available, the execution client
61//! attempts to apply the `NAUTILUS` referral code to the account's public L1 address using the
62//! configured L2 API key. The call is best effort with a 10-second timeout, and failures do not block
63//! trading.
64//! Selecting either mainnet opts the account into this attribution to support NautilusTrader
65//! development.
66//! Both testnets skip referral attribution.
67//!
68//! Lighter Mainnet's [referral program](https://docs.lighter.xyz/programs/referral-program) offers eligible
69//! referred users a 10% trading fee discount, paid as rebates. The venue determines referral acceptance
70//! and eligibility.
71//!
72//! See the [Lighter integration guide](https://nautilustrader.io/docs/nightly/integrations/lighter/#integrator-attribution)
73//! for attribution and revocation details.
74
75#![warn(rustc::all)]
76#![deny(unsafe_code)]
77#![deny(nonstandard_style)]
78#![deny(missing_debug_implementations)]
79#![deny(clippy::missing_panics_doc)]
80#![deny(rustdoc::broken_intra_doc_links)]
81// pyo3's `from_py_object` generates `.clone()` on `Copy` fields that clippy flags from the
82// macro expansion; an item-level `allow` cannot reach the expansion
83#![allow(clippy::clone_on_copy)]
84
85pub mod common;
86pub mod config;
87pub mod data;
88pub mod execution;
89pub mod factories;
90pub mod http;
91pub mod signing;
92pub mod websocket;
93
94pub(crate) mod book;
95
96#[cfg(feature = "python")]
97pub mod python;
98
99#[cfg(test)]
100mod tests;