Skip to main content

hypercall_client/
lib.rs

1//! # Hypercall Client
2//!
3//! Rust SDK for trading on Hypercall public HTTP and websocket APIs.
4//!
5//! ## Quick Start: Place an Options Order
6//!
7//! ```rust,no_run
8//! use hypercall_client::{HypercallClient, HypercallWallet};
9//! use hypercall_sdk_types::{Side, TimeInForce};
10//! use rust_decimal::Decimal;
11//!
12//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
13//! let api = HypercallClient::new("https://api.hypercall.xyz");
14//! let wallet = HypercallWallet::from_private_key("0xYOUR_PRIVATE_KEY", 999)?;
15//!
16//! // Place a BTC call buy (options use typed args)
17//! let resp = api.place_order(&wallet, "BTC-20260501-76000-C", Side::Buy, Decimal::new(2000, 0), Decimal::new(5, 0), TimeInForce::IOC).await?;
18//! println!("Order ID: {:?}", resp);
19//! # Ok(())
20//! # }
21//! ```
22//!
23//! ## Crate Features
24//!
25pub mod account;
26pub mod api;
27pub mod error;
28pub mod funding;
29pub mod indicative;
30pub mod perp;
31pub mod qp_client;
32pub mod qp_scoped;
33pub mod rfq;
34#[cfg(feature = "rfq-v2")]
35pub mod rfq_v2;
36#[cfg(feature = "rfq-v2")]
37pub mod rfq_v2_recovery;
38#[cfg(feature = "rfq-v2")]
39pub mod rfq_v2_signing;
40pub mod tee_perp;
41pub mod wallet;
42pub mod websocket;
43
44#[cfg(test)]
45mod test_support;
46
47pub use account::{CreateAccountParams, CreateAccountResult};
48pub use api::{
49    BulkOrderParams, BulkReplaceOrderParams, HypercallClient, OrderDecimalInput, OrderOptions,
50    PlaceOrderParams, PublicLiquidationsQuery, ReplaceOrderParams, StandardMarginLiquidationParams,
51};
52pub use error::{ClientError, Result};
53pub use funding::{DepositUsdcParams, DepositUsdcResult, WithdrawUsdcParams};
54pub use hypercall_sdk_types::ws_protocol::WsMessage;
55pub use hypercall_sdk_types::{CursorPage, LiquidationHistoryEntry, PublicLiquidationsResponse};
56pub use hypercall_ws_protocol::{
57    WsDeliveryClass, WsPressureCause, WsRecoveryAction, WsSlowConsumerCloseReason,
58};
59pub use perp::{
60    PerpCancelByCloidParams, PerpCancelByOidParams, PerpLimitOrderParams,
61    SetAccountAbstractionParams, UpdateApiWalletParams,
62};
63pub use qp_client::{
64    NoopCallbacks, QpClientCallbacks, QpClientConfig, QpDisconnectReason, QpWriteFailure,
65    QpWriteOperation, RfqDropReason,
66};
67pub use tee_perp::{
68    build_perp_scale_order_legs, build_tee_perp_batch_modify, build_tee_perp_bracket_batch,
69    build_tee_perp_position_tpsl_batch, build_tee_perp_scale_batch, perp_market_limit_price,
70    perp_preview_batch_action, perp_preview_order, resolve_hypercall_builder_address,
71    round_perp_price_to_tick, tee_api_wallet_approval_progress, tee_perp_batch_cloid,
72    tee_perp_batch_modify_signing_hash, tee_perp_limit_order_wire, tee_perp_modify_signing_hash,
73    tee_perp_nonce_in_window, tee_perp_trigger_order_wire, tee_perp_twap_cancel_signing_hash,
74    tee_perp_twap_signing_hash, tee_perp_venue_expires_after_ms, ApproveHypercallBuilderParams,
75    HyperliquidInfoClient, HyperliquidLeverage, HyperliquidUserRole, PerpScaleLeg,
76    PerpScaleOrderSpec, TeeApiWalletApprovalChallenge, TeeApiWalletApprovalProgress,
77    TeeApiWalletApprovalSignature, TeeApiWalletEnrollment, TeeApiWalletEnrollmentPolling,
78    TeeApiWalletManagerSigner, TeePerpBatchModifyParams, TeePerpBatchModifySignature,
79    TeePerpBracketEntry, TeePerpBracketOrderParams, TeePerpExit, TeePerpLeverageParams,
80    TeePerpLeverageSignature, TeePerpMarketOrderParams, TeePerpModifyParams,
81    TeePerpModifySignature, TeePerpOrderBatchParams, TeePerpOrderBatchSignature,
82    TeePerpOrderReplacement, TeePerpPositionTpslParams, TeePerpScaleOrderParams, TeePerpSigner,
83    TeePerpTriggerExecution, TeePerpTriggerOrderParams, TeePerpTriggerOrderSignature,
84    TeePerpTwapCancelParams, TeePerpTwapCancelSignature, TeePerpTwapParams, TeePerpTwapSignature,
85    PERP_MARKET_SLIPPAGE_BPS,
86};
87pub use wallet::{
88    AccountAddress, ApiWalletDirectiveSigner, AtomicNonceProvider, CancelOrderSignature,
89    HypercallSigner, HypercallWallet, ManagerDirectiveSigner, NonceProvider,
90    PerpCancelByCloidSignature, PerpCancelByOidSignature, PerpDirectiveSigner,
91    PerpLimitOrderSignature, PlaceOrderSignature, PortfolioUsdcWithdrawalSignature,
92    ReplaceOrderSignature, SetAccountAbstractionSignature, StandardMarginLiquidationSignature,
93    StandardUsdcWithdrawalSignature, UpdateApiWalletSignature, UsdcWithdrawalSigner,
94};
95pub use websocket::{
96    WsClient, WsClientConfig, WsConnectionState, WsDisconnectReason, WsRecoveryPlan,
97};
98
99// Re-export commonly needed types from hypercall-sdk-types
100pub use hypercall_sdk_types::{
101    AcceptRfqRequest, ApiResponse, BulkCancelOrderResponse, BulkPlaceOrderResponse,
102    CancelOrderRequest, CanonicalOrdersResponse, DirectiveDeliveryStatus, DirectiveDomainStatus,
103    DirectiveStage, DirectiveStatusResponse, DirectiveSubmitRequest, DirectiveSubmitResponse,
104    ExchangeInfoResponse, Fill, FillApiResponse, FillsResponse, HcUpdateApiWalletAction,
105    HistoricalPnlInterval, HistoricalPnlPoint, HistoricalPnlResponse, HistoricalTheoInterval,
106    HistoricalTheoPoint, HistoricalTheoResponse, HlSetAbstractionAction,
107    HypercoreAccountAbstraction, InstrumentKind, InstrumentSpecResponse, MarginMode, MarginSummary,
108    Market, OptionType, Order, OrderInfo, OrderMessage, OrderStatus, OrdersApiResponse,
109    PerpCancelByCloidRequest, PerpCancelByOidRequest, PerpLimitOrderRequest, PerpTimeInForce,
110    PlaceOrderRequest, Portfolio, PortfolioPosition, PortfolioResponse,
111    PortfolioUsdcWithdrawalResponse, RfqLegRequest, SetAccountAbstractionRequest, Side,
112    SpanMarginSummary, StandardMarginLiquidationOrderResponse,
113    StandardMarginLiquidationPositionRequest, StandardUsdcWithdrawalResponse, SubmitRfqRequest,
114    TimeInForce, UsdcWithdrawalDomainStatus,
115};
116pub use hypercall_sdk_types::{
117    PerpLiquidationBinding, PerpPreviewAction, PerpPreviewDecision, PerpPreviewLeverageSetting,
118    PerpPreviewLimit, PerpPreviewMargin, PerpPreviewMaxSize, PerpPreviewOrder,
119    PerpPreviewOrderType, PerpPreviewRequest, PerpPreviewResponse, PerpPreviewTif,
120    PerpPreviewTrigger, PerpRejectionReasonCode, TeeApiWalletApprovalPackage,
121    TeePerpCancelResponse, TeePerpErrorCode, TeePerpLeverageAction, TeePerpLeverageResponse,
122    TeePerpMarketEntry, TeePerpMarketsResponse, TeePerpModifyVenueOrder, TeePerpOrderBatchAction,
123    TeePerpOrderBatchResponse, TeePerpOrderGrouping, TeePerpOrderResponse, TeePerpOrderStage,
124    TeePerpOrderType, TeePerpOrderWire, TeePerpTpsl, TeePerpVenueActionResponse,
125};
126pub use hypercall_sdk_types::{
127    TeePerpBatchModifyAction, TeePerpBatchModifyChildResponse, TeePerpBatchModifyResponse,
128    TeePerpModifyAction, TeePerpModifyResponse, TeePerpTwapAction, TeePerpTwapCancelAction,
129    TeePerpTwapResponse, DEFAULT_TEE_PERP_BATCH_MODIFY_MAX_CHILDREN,
130    MAX_TEE_PERP_BATCH_MODIFY_CHILDREN, TEE_PERP_TWAP_MAX_MINUTES, TEE_PERP_TWAP_MIN_MINUTES,
131};