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