nautilus_model/defi/amm.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
16use crate::defi::{chain::SharedChain, dex::Dex, token::Token};
17
18/// Represents a liquidity pool in a decentralized exchange.
19#[derive(Debug, Clone)]
20pub struct Pool {
21 /// The blockchain network where this pool exists.
22 pub chain: SharedChain,
23 /// The decentralized exchange protocol that created and manages this pool.
24 pub dex: Dex,
25 /// The blockchain address of the pool smart contract.
26 pub address: String,
27 /// The block number when this pool was created on the blockchain.
28 pub creation_block: u64,
29 /// The first token in the trading pair.
30 pub token0: Token,
31 /// The second token in the trading pair.
32 pub token1: Token,
33 /// The trading fee charged by the pool, denominated in basis points.
34 pub fee: u32,
35 /// The minimum tick spacing for positions in concentrated liquidity AMMs.
36 pub tick_spacing: u32,
37}
38
39impl Pool {
40 /// Creates a new [`Pool`] instance with the specified properties.
41 #[must_use]
42 #[allow(clippy::too_many_arguments)]
43 pub fn new(
44 chain: SharedChain,
45 dex: Dex,
46 address: String,
47 creation_block: u64,
48 token0: Token,
49 token1: Token,
50 fee: u32,
51 tick_spacing: u32,
52 ) -> Self {
53 Self {
54 chain,
55 dex,
56 address,
57 creation_block,
58 token0,
59 token1,
60 fee,
61 tick_spacing,
62 }
63 }
64}