Skip to main content

lightcone_sdk/api/types/
admin.rs

1//! Admin-related types for the Lightcone REST API.
2
3use serde::{Deserialize, Serialize};
4
5/// Response for GET /api/admin/test.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct AdminResponse {
8    /// Status (usually "success")
9    pub status: String,
10    /// Human-readable message
11    pub message: String,
12}
13
14/// Request for POST /api/admin/create-orderbook.
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct CreateOrderbookRequest {
17    /// Market address (Base58)
18    pub market_pubkey: String,
19    /// Base conditional token (Base58)
20    pub base_token: String,
21    /// Quote conditional token (Base58)
22    pub quote_token: String,
23    /// Price granularity (default: 1000)
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub tick_size: Option<u32>,
26}
27
28impl CreateOrderbookRequest {
29    /// Create a new request with required fields.
30    pub fn new(
31        market_pubkey: impl Into<String>,
32        base_token: impl Into<String>,
33        quote_token: impl Into<String>,
34    ) -> Self {
35        Self {
36            market_pubkey: market_pubkey.into(),
37            base_token: base_token.into(),
38            quote_token: quote_token.into(),
39            tick_size: None,
40        }
41    }
42
43    /// Set custom tick size.
44    pub fn with_tick_size(mut self, tick_size: u32) -> Self {
45        self.tick_size = Some(tick_size);
46        self
47    }
48}
49
50/// Response for POST /api/admin/create-orderbook.
51#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct CreateOrderbookResponse {
53    /// Status (usually "success")
54    pub status: String,
55    /// Created orderbook ID
56    pub orderbook_id: String,
57    /// Market pubkey
58    pub market_pubkey: String,
59    /// Base token address
60    pub base_token: String,
61    /// Quote token address
62    pub quote_token: String,
63    /// Tick size
64    pub tick_size: u32,
65    /// Human-readable message
66    pub message: String,
67}