nautilus_blockchain/events/
pool_created.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 alloy::primitives::Address;
17
18/// Represents a liquidity pool creation event from a decentralized exchange.
19///
20// This struct models the data structure of a pool creation event emitted by DEX factory contracts.
21#[derive(Debug, Clone)]
22pub struct PoolCreatedEvent {
23    /// The block number when the pool was created.
24    pub block_number: u64,
25    /// The blockchain address of the first token in the pair.
26    pub token0: Address,
27    /// The blockchain address of the second token in the pair.
28    pub token1: Address,
29    /// The fee tier of the pool, specified in basis points (e.g., 500 = 0.05%, 3000 = 0.3%).
30    pub fee: u32,
31    /// The tick spacing parameter that controls the granularity of price ranges.
32    pub tick_spacing: u32,
33    /// The blockchain address of the created liquidity pool contract.
34    pub pool_address: Address,
35}
36
37impl PoolCreatedEvent {
38    /// Creates a new [`PoolCreatedEvent`] instance with the specified parameters.
39    #[must_use]
40    pub const fn new(
41        block_number: u64,
42        token0: Address,
43        token1: Address,
44        fee: u32,
45        tick_spacing: u32,
46        pool_address: Address,
47    ) -> Self {
48        Self {
49            block_number,
50            token0,
51            token1,
52            fee,
53            tick_spacing,
54            pool_address,
55        }
56    }
57}