Skip to main content

nautilus_common/messages/defi/
subscribe.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 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 nautilus_core::{Params, UUID4, UnixNanos};
17use nautilus_model::{
18    defi::chain::Blockchain,
19    identifiers::{ClientId, InstrumentId},
20};
21
22#[derive(Debug, Clone)]
23pub struct SubscribeBlocks {
24    pub chain: Blockchain,
25    pub client_id: Option<ClientId>,
26    pub command_id: UUID4,
27    pub ts_init: UnixNanos,
28    pub params: Option<Params>,
29}
30
31impl SubscribeBlocks {
32    /// Creates a new [`SubscribeBlocks`] instance.
33    #[must_use]
34    pub fn new(
35        chain: Blockchain,
36        client_id: Option<ClientId>,
37        command_id: UUID4,
38        ts_init: UnixNanos,
39        params: Option<Params>,
40    ) -> Self {
41        Self {
42            chain,
43            client_id,
44            command_id,
45            ts_init,
46            params,
47        }
48    }
49}
50
51/// Represents a command to subscribe to definition updates for a specific AMM pool.
52#[derive(Debug, Clone)]
53pub struct SubscribePool {
54    pub instrument_id: InstrumentId,
55    pub client_id: Option<ClientId>,
56    pub command_id: UUID4,
57    pub ts_init: UnixNanos,
58    pub params: Option<Params>,
59}
60
61impl SubscribePool {
62    /// Creates a new [`SubscribePool`] instance.
63    #[must_use]
64    pub fn new(
65        instrument_id: InstrumentId,
66        client_id: Option<ClientId>,
67        command_id: UUID4,
68        ts_init: UnixNanos,
69        params: Option<Params>,
70    ) -> Self {
71        Self {
72            instrument_id,
73            client_id,
74            command_id,
75            ts_init,
76            params,
77        }
78    }
79}
80
81#[derive(Debug, Clone)]
82pub struct SubscribePoolSwaps {
83    pub instrument_id: InstrumentId,
84    pub client_id: Option<ClientId>,
85    pub command_id: UUID4,
86    pub ts_init: UnixNanos,
87    pub params: Option<Params>,
88}
89
90impl SubscribePoolSwaps {
91    /// Creates a new [`SubscribePoolSwaps`] instance.
92    #[must_use]
93    pub fn new(
94        instrument_id: InstrumentId,
95        client_id: Option<ClientId>,
96        command_id: UUID4,
97        ts_init: UnixNanos,
98        params: Option<Params>,
99    ) -> Self {
100        Self {
101            instrument_id,
102            client_id,
103            command_id,
104            ts_init,
105            params,
106        }
107    }
108}
109
110/// Represents a command to subscribe to liquidity updates for a specific AMM pool.
111#[derive(Debug, Clone)]
112pub struct SubscribePoolLiquidityUpdates {
113    pub instrument_id: InstrumentId,
114    pub client_id: Option<ClientId>,
115    pub command_id: UUID4,
116    pub ts_init: UnixNanos,
117    pub params: Option<Params>,
118}
119
120impl SubscribePoolLiquidityUpdates {
121    /// Creates a new [`SubscribePoolLiquidityUpdates`] instance.
122    #[must_use]
123    pub fn new(
124        instrument_id: InstrumentId,
125        client_id: Option<ClientId>,
126        command_id: UUID4,
127        ts_init: UnixNanos,
128        params: Option<Params>,
129    ) -> Self {
130        Self {
131            instrument_id,
132            client_id,
133            command_id,
134            ts_init,
135            params,
136        }
137    }
138}
139
140/// Represents a command to subscribe to fee-collect events for a specific AMM pool.
141#[derive(Debug, Clone)]
142pub struct SubscribePoolFeeCollects {
143    pub instrument_id: InstrumentId,
144    pub client_id: Option<ClientId>,
145    pub command_id: UUID4,
146    pub ts_init: UnixNanos,
147    pub params: Option<Params>,
148}
149
150impl SubscribePoolFeeCollects {
151    /// Creates a new [`SubscribePoolFeeCollects`] instance.
152    #[must_use]
153    pub fn new(
154        instrument_id: InstrumentId,
155        client_id: Option<ClientId>,
156        command_id: UUID4,
157        ts_init: UnixNanos,
158        params: Option<Params>,
159    ) -> Self {
160        Self {
161            instrument_id,
162            client_id,
163            command_id,
164            ts_init,
165            params,
166        }
167    }
168}
169
170/// Represents a command to subscribe to flash-loan events for a specific AMM pool.
171#[derive(Debug, Clone)]
172pub struct SubscribePoolFlashEvents {
173    pub instrument_id: InstrumentId,
174    pub client_id: Option<ClientId>,
175    pub command_id: UUID4,
176    pub ts_init: UnixNanos,
177    pub params: Option<Params>,
178}
179
180impl SubscribePoolFlashEvents {
181    /// Creates a new [`SubscribePoolFlashEvents`] instance.
182    #[must_use]
183    pub fn new(
184        instrument_id: InstrumentId,
185        client_id: Option<ClientId>,
186        command_id: UUID4,
187        ts_init: UnixNanos,
188        params: Option<Params>,
189    ) -> Self {
190        Self {
191            instrument_id,
192            client_id,
193            command_id,
194            ts_init,
195            params,
196        }
197    }
198}