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