nautilus_common/messages/defi/
subscribe.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 indexmap::IndexMap;
17use nautilus_core::{UUID4, UnixNanos};
18use nautilus_model::{
19    defi::chain::Blockchain,
20    identifiers::{ClientId, InstrumentId},
21};
22
23#[derive(Debug, Clone)]
24pub struct SubscribeBlocks {
25    pub chain: Blockchain,
26    pub client_id: Option<ClientId>,
27    pub command_id: UUID4,
28    pub ts_init: UnixNanos,
29    pub params: Option<IndexMap<String, String>>,
30}
31
32impl SubscribeBlocks {
33    /// Creates a new [`SubscribeBlocks`] instance.
34    #[must_use]
35    pub const fn new(
36        chain: Blockchain,
37        client_id: Option<ClientId>,
38        command_id: UUID4,
39        ts_init: UnixNanos,
40        params: Option<IndexMap<String, String>>,
41    ) -> Self {
42        Self {
43            chain,
44            client_id,
45            command_id,
46            ts_init,
47            params,
48        }
49    }
50}
51
52/// Represents a subscription command for pool definition updates from a specific AMM pool.
53#[derive(Debug, Clone)]
54pub struct SubscribePool {
55    pub instrument_id: InstrumentId,
56    pub client_id: Option<ClientId>,
57    pub command_id: UUID4,
58    pub ts_init: UnixNanos,
59    pub params: Option<IndexMap<String, String>>,
60}
61
62impl SubscribePool {
63    /// Creates a new [`SubscribePool`] instance.
64    #[must_use]
65    pub const fn new(
66        instrument_id: InstrumentId,
67        client_id: Option<ClientId>,
68        command_id: UUID4,
69        ts_init: UnixNanos,
70        params: Option<IndexMap<String, String>>,
71    ) -> Self {
72        Self {
73            instrument_id,
74            client_id,
75            command_id,
76            ts_init,
77            params,
78        }
79    }
80}
81
82#[derive(Debug, Clone)]
83pub struct SubscribePoolSwaps {
84    pub instrument_id: InstrumentId,
85    pub client_id: Option<ClientId>,
86    pub command_id: UUID4,
87    pub ts_init: UnixNanos,
88    pub params: Option<IndexMap<String, String>>,
89}
90
91impl SubscribePoolSwaps {
92    /// Creates a new [`SubscribePoolSwaps`] instance.
93    #[must_use]
94    pub const fn new(
95        instrument_id: InstrumentId,
96        client_id: Option<ClientId>,
97        command_id: UUID4,
98        ts_init: UnixNanos,
99
100        params: Option<IndexMap<String, String>>,
101    ) -> Self {
102        Self {
103            instrument_id,
104            client_id,
105            command_id,
106            ts_init,
107            params,
108        }
109    }
110}
111
112/// Represents a subscription command for pool liquidity updates from a specific AMM pool.
113#[derive(Debug, Clone)]
114pub struct SubscribePoolLiquidityUpdates {
115    pub instrument_id: InstrumentId,
116    pub client_id: Option<ClientId>,
117    pub command_id: UUID4,
118    pub ts_init: UnixNanos,
119    pub params: Option<IndexMap<String, String>>,
120}
121
122impl SubscribePoolLiquidityUpdates {
123    /// Creates a new [`SubscribePoolLiquidityUpdates`] instance.
124    #[must_use]
125    pub const fn new(
126        instrument_id: InstrumentId,
127        client_id: Option<ClientId>,
128        command_id: UUID4,
129        ts_init: UnixNanos,
130        params: Option<IndexMap<String, String>>,
131    ) -> Self {
132        Self {
133            instrument_id,
134            client_id,
135            command_id,
136            ts_init,
137            params,
138        }
139    }
140}