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