bullet_rust_sdk/lib.rs
1mod client;
2mod keypair;
3mod metadata;
4mod trading;
5mod transaction_builder;
6
7pub use trading::NewOrderExt;
8
9/// Error types for the SDK.
10pub mod errors;
11
12// Re-export main types at crate root for ergonomic imports
13pub use client::{Client, Network};
14pub use errors::{SDKError, SDKResult, WSErrors};
15pub use generated::types::ApiErrorResponse;
16pub use keypair::Keypair;
17// Re-export WebSocket close code for pattern matching
18pub use reqwest_websocket::CloseCode;
19pub use transaction_builder::{Transaction, UnsignedTransaction};
20pub use types::CallMessage;
21
22// Re-export WebSocket module and types
23pub mod ws;
24pub use ws::client::{WebsocketConfig, WebsocketHandle};
25pub use ws::managed::{ManagedWebsocket, ManagedWsConfig, ManagedWsError, WsEvent};
26pub use ws::models::ServerMessage;
27pub use ws::topics::{KlineInterval, OrderbookDepth, Topic};
28
29/// Re-export the generated Progenitor client and types.
30///
31/// Use this module to access specific generated types if needed.
32/// Most users should just use `Client` which provides access
33/// to client methods via `Deref`.
34mod generated;
35pub mod codegen {
36 pub use crate::generated::*;
37}
38
39// Re-export generated response type returned by transaction submission.
40/// A decimal value that must be positive. Wraps `rust_decimal::Decimal`.
41///
42/// ```ignore
43/// use rust_decimal::Decimal;
44/// use bullet_rust_sdk::PositiveDecimal;
45///
46/// let price = PositiveDecimal::try_from(Decimal::from(50000))?;
47/// let qty = PositiveDecimal::try_from(Decimal::new(1, 3))?; // 0.001
48/// ```
49pub use bullet_exchange_interface::decimals::PositiveDecimal;
50/// User action discriminants for schema validation filtering.
51pub use bullet_exchange_interface::message::UserActionDiscriminants;
52// Order argument structs
53pub use bullet_exchange_interface::message::{
54 AmendOrderArgs, CancelOrderArgs, NewOrderArgs, NewTriggerOrderArgs, NewTwapOrderArgs,
55 PendingTpslPair, Tpsl, TpslPair,
56};
57/// Client-assigned order identifier. Wraps a `u64`.
58pub use bullet_exchange_interface::types::ClientOrderId;
59/// Numeric market identifier. Wraps a `u16`.
60///
61/// Resolve a symbol string to a `MarketId` via [`Client::market_id()`]:
62/// ```ignore
63/// let market_id = client.market_id("BTC-USD").expect("unknown symbol");
64/// ```
65pub use bullet_exchange_interface::types::MarketId;
66/// Exchange-assigned order identifier. Wraps a `u64`.
67pub use bullet_exchange_interface::types::OrderId;
68/// Order execution type.
69///
70/// - `Limit` — standard limit order
71/// - `PostOnly` — maker-only, rejected if it would cross the book
72/// - `ImmediateOrCancel` — **use this for market orders** (fill what you can, cancel the rest)
73/// - `FillOrKill` — fill entirely or cancel
74pub use bullet_exchange_interface::types::OrderType;
75// ── On-chain trading types ──────────────────────────────────────────────────
76//
77// These re-exports let users write `use bullet_rust_sdk::{Side, MarketId, ...}`
78// instead of reaching into `bullet_exchange_interface` directly.
79/// Order side. `Bid` = buy, `Ask` = sell.
80///
81/// Follows exchange-internal convention. When integrating:
82/// - `Side::Bid` corresponds to a **buy** order
83/// - `Side::Ask` corresponds to a **sell** order
84pub use bullet_exchange_interface::types::Side;
85pub use generated::types::SubmitTxResponse;
86// Re-export metadata types for symbol lookups.
87pub use metadata::SymbolInfo;
88
89/// Re-export bullet_rollup types commonly used with the SDK.
90pub mod types {
91 pub use bullet_exchange_interface;
92 pub type CallMessage = bullet_exchange_interface::message::CallMessage<
93 bullet_exchange_interface::address::Address,
94 >;
95
96 /// User-facing trading action (placing orders, withdrawals, etc.).
97 pub type UserAction =
98 bullet_exchange_interface::message::UserAction<bullet_exchange_interface::address::Address>;
99
100 /// Permissionless action anyone can call (e.g. `ApplyFunding`).
101 pub type PublicAction = bullet_exchange_interface::message::PublicAction<
102 bullet_exchange_interface::address::Address,
103 >;
104
105 pub use bullet_ws_interface::*;
106}
107
108pub use types::{PublicAction, UserAction};