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 pm_financing;
32pub mod qp_client;
33pub mod qp_scoped;
34pub mod rfq;
35#[cfg(feature = "rfq-v2")]
36pub mod rfq_v2;
37#[cfg(feature = "rfq-v2")]
38pub mod rfq_v2_recovery;
39#[cfg(feature = "rfq-v2")]
40pub mod rfq_v2_signing;
41pub mod tee_perp;
42pub mod tee_spot;
43pub mod vaults;
44pub mod wallet;
45pub mod websocket;
46
47#[cfg(test)]
48mod test_support;
49
50pub use account::{CreateAccountParams, CreateAccountResult};
51pub use api::{
52    BulkOrderParams, BulkReplaceOrderParams, HypercallClient, OrderDecimalInput, OrderOptions,
53    PlaceOrderParams, PublicLiquidationsQuery, ReplaceOrderParams, StandardMarginLiquidationParams,
54};
55pub use error::{ClientError, Result};
56pub use funding::{DepositUsdcParams, DepositUsdcResult, WithdrawUsdcParams};
57pub use hypercall_sdk_types::ws_protocol::WsMessage;
58pub use hypercall_sdk_types::{CursorPage, LiquidationHistoryEntry, PublicLiquidationsResponse};
59pub use hypercall_ws_protocol::{
60    WsDeliveryClass, WsPressureCause, WsRecoveryAction, WsSlowConsumerCloseReason,
61};
62pub use perp::{
63    PerpCancelByCloidParams, PerpCancelByOidParams, PerpLimitOrderParams,
64    SetAccountAbstractionParams, UpdateApiWalletParams,
65};
66pub use pm_financing::{
67    PmFinancingItem, PmFinancingItemKind, PmFinancingItemStatus, PmFinancingMargin,
68    PmFinancingRepayment, PmFinancingResponse, PmFinancingTotals, PmLoanRepayResponse,
69    PmLoanRepaymentRequest, PmRepayRejection, PmRepaymentBlockedReason, PmRepaymentStatus,
70    RepayAmount, RepayPmLoanParams,
71};
72pub use qp_client::{
73    NoopCallbacks, QpClientCallbacks, QpClientConfig, QpDisconnectReason, QpWriteFailure,
74    QpWriteOperation, RfqDropReason,
75};
76pub use tee_perp::{
77    build_perp_scale_order_legs, build_tee_perp_batch_modify, build_tee_perp_bracket_batch,
78    build_tee_perp_position_tpsl_batch, build_tee_perp_scale_batch, perp_market_limit_price,
79    perp_preview_batch_action, perp_preview_order, resolve_hypercall_builder_address,
80    round_perp_price_to_tick, tee_api_wallet_approval_progress, tee_perp_batch_cloid,
81    tee_perp_batch_modify_signing_hash, tee_perp_limit_order_wire, tee_perp_modify_signing_hash,
82    tee_perp_nonce_in_window, tee_perp_trigger_order_wire, tee_perp_twap_cancel_signing_hash,
83    tee_perp_twap_signing_hash, tee_perp_venue_expires_after_ms, ApproveHypercallBuilderParams,
84    HyperliquidInfoClient, HyperliquidLeverage, HyperliquidUserRole, PerpScaleLeg,
85    PerpScaleOrderSpec, TeeApiWalletApprovalChallenge, TeeApiWalletApprovalProgress,
86    TeeApiWalletApprovalSignature, TeeApiWalletEnrollment, TeeApiWalletEnrollmentPolling,
87    TeeApiWalletManagerSigner, TeePerpBatchModifyParams, TeePerpBatchModifySignature,
88    TeePerpBracketEntry, TeePerpBracketOrderParams, TeePerpExit, TeePerpLeverageParams,
89    TeePerpLeverageSignature, TeePerpMarketOrderParams, TeePerpModifyParams,
90    TeePerpModifySignature, TeePerpOrderBatchParams, TeePerpOrderBatchSignature,
91    TeePerpOrderReplacement, TeePerpPositionTpslParams, TeePerpScaleOrderParams, TeePerpSigner,
92    TeePerpTriggerExecution, TeePerpTriggerOrderParams, TeePerpTriggerOrderSignature,
93    TeePerpTwapCancelParams, TeePerpTwapCancelSignature, TeePerpTwapParams, TeePerpTwapSignature,
94    PERP_MARKET_SLIPPAGE_BPS,
95};
96pub use tee_spot::{
97    tee_spot_cancel_signing_hash, tee_spot_order_signing_hash, TeeSpotCancelParams,
98    TeeSpotCancelSignature, TeeSpotOrderParams, TeeSpotOrderSignature, TeeSpotSigner,
99};
100pub use vaults::{
101    CreateVaultResponse, Vault, VaultConfigParams, VaultFill, VaultHistoryPage, VaultHolder,
102    VaultMetadata, VaultPage, VaultQueuedRequest, VaultRequestResponse, VaultSettlement,
103    VaultSettlementsPage, VaultStatusChange, VaultStatusChangesPage,
104};
105pub use wallet::{
106    AccountAddress, ApiWalletDirectiveSigner, AtomicNonceProvider, CancelOrderSignature,
107    HypercallSigner, HypercallWallet, ManagerDirectiveSigner, NonceProvider,
108    PerpCancelByCloidSignature, PerpCancelByOidSignature, PerpDirectiveSigner,
109    PerpLimitOrderSignature, PlaceOrderSignature, PortfolioUsdcWithdrawalSignature,
110    ReplaceOrderSignature, SetAccountAbstractionSignature, StandardMarginLiquidationSignature,
111    StandardUsdcWithdrawalSignature, UpdateApiWalletSignature, UsdcWithdrawalSigner,
112};
113pub use websocket::{
114    WsClient, WsClientConfig, WsConnectionState, WsDisconnectReason, WsRecoveryPlan,
115};
116
117// Re-export commonly needed types from hypercall-sdk-types
118pub use hypercall_sdk_types::{
119    AcceptRfqRequest, ApiResponse, BulkCancelOrderResponse, BulkPlaceOrderResponse,
120    CancelOrderRequest, CanonicalOrdersResponse, DirectiveDeliveryStatus, DirectiveDomainStatus,
121    DirectiveStage, DirectiveStatusResponse, DirectiveSubmitRequest, DirectiveSubmitResponse,
122    ExchangeInfoResponse, Fill, FillApiResponse, FillsResponse, HcUpdateApiWalletAction,
123    HistoricalPnlInterval, HistoricalPnlPoint, HistoricalPnlResponse, HistoricalTheoInterval,
124    HistoricalTheoPoint, HistoricalTheoResponse, HlSetAbstractionAction,
125    HypercoreAccountAbstraction, InstrumentKind, InstrumentSpecResponse, MarginMode, MarginSummary,
126    Market, OptionType, Order, OrderInfo, OrderMessage, OrderStatus, OrdersApiResponse,
127    PerpCancelByCloidRequest, PerpCancelByOidRequest, PerpLimitOrderRequest, PerpTimeInForce,
128    PlaceOrderRequest, Portfolio, PortfolioPosition, PortfolioResponse,
129    PortfolioUsdcWithdrawalResponse, RfqLegRequest, SetAccountAbstractionRequest, Side,
130    SpanMarginSummary, StandardMarginLiquidationOrderResponse,
131    StandardMarginLiquidationPositionRequest, StandardUsdcWithdrawalResponse, SubmitRfqRequest,
132    TimeInForce, UsdcWithdrawalDomainStatus,
133};
134pub use hypercall_sdk_types::{
135    PerpLiquidationBinding, PerpPreviewAction, PerpPreviewDecision, PerpPreviewLeverageSetting,
136    PerpPreviewLimit, PerpPreviewMargin, PerpPreviewMaxSize, PerpPreviewOrder,
137    PerpPreviewOrderType, PerpPreviewRequest, PerpPreviewResponse, PerpPreviewTif,
138    PerpPreviewTrigger, PerpRejectionReasonCode, TeeApiWalletApprovalPackage,
139    TeePerpCancelResponse, TeePerpErrorCode, TeePerpLeverageAction, TeePerpLeverageResponse,
140    TeePerpMarketEntry, TeePerpMarketsResponse, TeePerpModifyVenueOrder, TeePerpOrderBatchAction,
141    TeePerpOrderBatchResponse, TeePerpOrderGrouping, TeePerpOrderResponse, TeePerpOrderStage,
142    TeePerpOrderType, TeePerpOrderWire, TeePerpTpsl, TeePerpVenueActionResponse,
143};
144pub use hypercall_sdk_types::{
145    TeePerpBatchModifyAction, TeePerpBatchModifyChildResponse, TeePerpBatchModifyResponse,
146    TeePerpModifyAction, TeePerpModifyResponse, TeePerpTwapAction, TeePerpTwapCancelAction,
147    TeePerpTwapResponse, DEFAULT_TEE_PERP_BATCH_MODIFY_MAX_CHILDREN,
148    MAX_TEE_PERP_BATCH_MODIFY_CHILDREN, TEE_PERP_TWAP_MAX_MINUTES, TEE_PERP_TWAP_MIN_MINUTES,
149};