nautilus_model/defi/mod.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//! DeFi (Decentralized Finance) domain model.
17//!
18//! This module gathers all constructs required to model on-chain markets and decentralized
19//! exchange (DEX) activity.
20//!
21//! • `chain` - Blockchain networks supported by Nautilus (Ethereum, Arbitrum, …).
22//! • `token` - ERC-20 and other fungible token metadata.
23//! • `dex` - DEX protocol definitions (Uniswap V3, PancakeSwap, …).
24//! • `data` - Domain events & state snapshots that flow through the system (Block, `PoolSwap`).
25//! • `types` - Numeric value types (Money, Quantity, Price) shared across the DeFi layer.
26//! • `rpc` - Lightweight JSON-RPC types and parsers used by on-chain adapters.
27
28pub mod amm;
29pub mod chain;
30pub mod currency;
31pub mod data;
32pub mod dex;
33pub mod hex;
34pub mod pool_analysis;
35pub mod pool_identifier;
36pub mod reporting;
37pub mod rpc;
38pub mod tick_map;
39pub mod token;
40pub mod types;
41pub mod validation;
42pub mod wallet;
43
44pub(crate) mod orderbook;
45
46#[cfg(test)]
47pub mod stubs;
48
49// Re-exports
50pub use amm::{Pool, SharedPool};
51pub use chain::{Blockchain, Chain, SharedChain};
52pub use data::{
53 DefiData,
54 block::Block,
55 collect::PoolFeeCollect,
56 fee_protocol_collect::PoolFeeProtocolCollect,
57 fee_protocol_update::PoolFeeProtocolUpdate,
58 flash::PoolFlash,
59 liquidity::{PoolLiquidityUpdate, PoolLiquidityUpdateType},
60 swap::PoolSwap,
61 transaction::Transaction,
62};
63pub use dex::{AmmType, Dex, DexType, SharedDex};
64pub use pool_analysis::PoolProfiler;
65pub use pool_identifier::PoolIdentifier;
66pub use token::{SharedToken, Token};
67
68/// Number of decimal places used by the native Ether denomination.
69///
70/// On the EVM all ERC-20 balances are expressed in **wei** - the
71/// smallest indivisible unit of Ether, named after cryptographer
72/// Wei Dai. One ether equals `10^18` wei, so using 18 decimal
73/// places is sufficient to represent any value expressible on-chain.
74///
75/// Tokens that choose a smaller precision (e.g. USDC's 6, WBTC's 8)
76/// still fall below this upper bound.
77pub static WEI_PRECISION: u8 = 18;