nautilus_model/defi/mod.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 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 decentralised
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 helpers used by on-chain adapters.
27
28pub mod amm;
29pub mod chain;
30pub mod data;
31pub mod dex;
32pub mod hex;
33pub mod pool_analysis;
34pub mod pool_identifier;
35pub mod reporting;
36pub mod rpc;
37pub mod tick_map;
38pub mod token;
39pub mod types;
40pub mod validation;
41pub mod wallet;
42
43#[cfg(test)]
44pub mod stubs;
45
46// Re-exports
47pub use amm::{Pool, SharedPool};
48pub use chain::{Blockchain, Chain, SharedChain};
49pub use data::{
50 DefiData,
51 block::Block,
52 collect::PoolFeeCollect,
53 flash::PoolFlash,
54 liquidity::{PoolLiquidityUpdate, PoolLiquidityUpdateType},
55 swap::PoolSwap,
56 transaction::Transaction,
57};
58pub use dex::{AmmType, Dex, DexType, SharedDex};
59pub use pool_analysis::PoolProfiler;
60pub use pool_identifier::PoolIdentifier;
61pub use token::{SharedToken, Token};
62
63/// Number of decimal places used by the native Ether denomination.
64///
65/// On the EVM all ERC-20 balances are expressed in **wei** – the
66/// smallest indivisible unit of Ether, named after cryptographer
67/// Wei Dai. One ether equals `10^18` wei, so using 18 decimal
68/// places is sufficient to represent any value expressible on-chain.
69///
70/// Tokens that choose a smaller precision (e.g. USDC’s 6, WBTC’s 8)
71/// still fall below this upper bound.
72pub static WEI_PRECISION: u8 = 18;