nautilus_common/messages/defi/
unsubscribe.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 UnsubscribeBlocks {
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 UnsubscribeBlocks {
33    /// Creates a new [`UnsubscribeBlocks`] 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 an unsubscription command for pool definition updates from a specific AMM pool.
53#[derive(Debug, Clone)]
54pub struct UnsubscribePool {
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 UnsubscribePool {
63    /// Creates a new [`UnsubscribePool`] 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 UnsubscribePoolSwaps {
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 UnsubscribePoolSwaps {
92    /// Creates a new [`UnsubscribePoolSwaps`] 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        params: Option<IndexMap<String, String>>,
100    ) -> Self {
101        Self {
102            instrument_id,
103            client_id,
104            command_id,
105            ts_init,
106            params,
107        }
108    }
109}
110
111/// Represents an unsubscription command for pool liquidity updates from a specific AMM pool.
112#[derive(Debug, Clone)]
113pub struct UnsubscribePoolLiquidityUpdates {
114    pub instrument_id: InstrumentId,
115    pub client_id: Option<ClientId>,
116    pub command_id: UUID4,
117    pub ts_init: UnixNanos,
118    pub params: Option<IndexMap<String, String>>,
119}
120
121impl UnsubscribePoolLiquidityUpdates {
122    /// Creates a new [`UnsubscribePoolLiquidityUpdates`] instance.
123    #[must_use]
124    pub const fn new(
125        instrument_id: InstrumentId,
126        client_id: Option<ClientId>,
127        command_id: UUID4,
128        ts_init: UnixNanos,
129        params: Option<IndexMap<String, String>>,
130    ) -> Self {
131        Self {
132            instrument_id,
133            client_id,
134            command_id,
135            ts_init,
136            params,
137        }
138    }
139}