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