nautilus_common/messages/defi/
subscribe.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 SubscribeBlocks {
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 SubscribeBlocks {
31    /// Creates a new [`SubscribeBlocks`] 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 a subscription command for pool definition updates from a specific AMM pool.
51#[derive(Debug, Clone)]
52pub struct SubscribePool {
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 SubscribePool {
61    /// Creates a new [`SubscribePool`] 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 SubscribePoolSwaps {
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 SubscribePoolSwaps {
90    /// Creates a new [`SubscribePoolSwaps`] 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
98        params: Option<IndexMap<String, String>>,
99    ) -> Self {
100        Self {
101            address,
102            client_id,
103            command_id,
104            ts_init,
105            params,
106        }
107    }
108}
109
110/// Represents a subscription command for pool liquidity updates from a specific AMM pool.
111#[derive(Debug, Clone)]
112pub struct SubscribePoolLiquidityUpdates {
113    pub address: Address,
114    pub client_id: Option<ClientId>,
115    pub command_id: UUID4,
116    pub ts_init: UnixNanos,
117    pub params: Option<IndexMap<String, String>>,
118}
119
120impl SubscribePoolLiquidityUpdates {
121    /// Creates a new [`SubscribePoolLiquidityUpdates`] instance.
122    #[must_use]
123    pub const fn new(
124        address: Address,
125        client_id: Option<ClientId>,
126        command_id: UUID4,
127        ts_init: UnixNanos,
128        params: Option<IndexMap<String, String>>,
129    ) -> Self {
130        Self {
131            address,
132            client_id,
133            command_id,
134            ts_init,
135            params,
136        }
137    }
138}