1use async_trait::async_trait;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct DeribitConfig {
9 pub client_id: String,
10 pub client_secret: String,
11 pub test_net: bool,
12 pub timeout_seconds: u64,
13}
14
15impl Default for DeribitConfig {
16 fn default() -> Self {
17 Self {
18 client_id: String::new(),
19 client_secret: String::new(),
20 test_net: true,
21 timeout_seconds: 30,
22 }
23 }
24}
25
26pub struct DeribitUrls;
28
29impl DeribitUrls {
30 pub const PROD_BASE_URL: &'static str = "https://www.deribit.com";
31 pub const TEST_BASE_URL: &'static str = "https://test.deribit.com";
32
33 pub const PROD_WS_URL: &'static str = "wss://www.deribit.com/ws/api/v2";
34 pub const TEST_WS_URL: &'static str = "wss://test.deribit.com/ws/api/v2";
35
36 pub fn get_base_url(test_net: bool) -> &'static str {
37 if test_net {
38 Self::TEST_BASE_URL
39 } else {
40 Self::PROD_BASE_URL
41 }
42 }
43
44 pub fn get_ws_url(test_net: bool) -> &'static str {
45 if test_net {
46 Self::TEST_WS_URL
47 } else {
48 Self::PROD_WS_URL
49 }
50 }
51}
52
53#[async_trait]
55pub trait DeribitClient {
56 type Error;
57
58 async fn connect(&mut self) -> Result<(), Self::Error>;
60
61 async fn disconnect(&mut self) -> Result<(), Self::Error>;
63
64 fn is_connected(&self) -> bool;
66}