nautilus_blockchain/events/
initialize.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
16use alloy::primitives::U160;
17use nautilus_model::defi::{PoolIdentifier, SharedDex};
18
19/// Event emitted when a liquidity pool is initialized on a DEX.
20///
21/// This event typically occurs when a new pool is created and
22/// the initial price and tick are set.
23#[derive(Debug, Clone)]
24pub struct InitializeEvent {
25    /// The decentralized exchange where the event happened.
26    pub dex: SharedDex,
27    /// The unique identifier for the pool.
28    pub pool_identifier: PoolIdentifier,
29    /// The square root of the price ratio encoded as a fixed point number with 96 fractional bits.
30    pub sqrt_price_x96: U160,
31    /// The current tick of the pool.
32    pub tick: i32,
33}
34
35impl InitializeEvent {
36    pub fn new(
37        dex: SharedDex,
38        pool_identifier: PoolIdentifier,
39        sqrt_price_x96: U160,
40        tick: i32,
41    ) -> Self {
42        Self {
43            dex,
44            pool_identifier,
45            sqrt_price_x96,
46            tick,
47        }
48    }
49}