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::{Address, U160};
17use nautilus_model::defi::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 address of the smart contract which emitted the event.
28 pub pool_address: Address,
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(dex: SharedDex, pool_address: Address, sqrt_price_x96: U160, tick: i32) -> Self {
37 Self {
38 dex,
39 pool_address,
40 sqrt_price_x96,
41 tick,
42 }
43 }
44}