Skip to main content

Crate hypercall_client

Crate hypercall_client 

Source
Expand description

§Hypercall Client

Rust SDK for trading on Hypercall public HTTP and websocket APIs.

§Quick Start: Place an Options Order

use hypercall_client::{HypercallClient, HypercallWallet};
use hypercall_sdk_types::{Side, TimeInForce};
use rust_decimal::Decimal;

let api = HypercallClient::new("https://api.hypercall.xyz");
let wallet = HypercallWallet::from_private_key("0xYOUR_PRIVATE_KEY", 999)?;

// Place a BTC call buy (options use typed args)
let resp = api.place_order(&wallet, "BTC-20260501-76000-C", Side::Buy, Decimal::new(2000, 0), Decimal::new(5, 0), TimeInForce::IOC).await?;
println!("Order ID: {:?}", resp);

§Crate Features

Re-exports§

pub use account::CreateAccountParams;
pub use account::CreateAccountResult;
pub use api::BulkOrderParams;
pub use api::BulkReplaceOrderParams;
pub use api::HypercallClient;
pub use api::OrderDecimalInput;
pub use api::OrderOptions;
pub use api::PlaceOrderParams;
pub use api::PublicLiquidationsQuery;
pub use api::ReplaceOrderParams;
pub use api::StandardMarginLiquidationParams;
pub use error::ClientError;
pub use error::Result;
pub use funding::DepositUsdcParams;
pub use funding::DepositUsdcResult;
pub use funding::WithdrawUsdcParams;
pub use perp::PerpCancelByCloidParams;
pub use perp::PerpCancelByOidParams;
pub use perp::PerpLimitOrderParams;
pub use perp::SetAccountAbstractionParams;
pub use perp::UpdateApiWalletParams;
pub use pm_financing::PmFinancingItem;
pub use pm_financing::PmFinancingItemKind;
pub use pm_financing::PmFinancingItemStatus;
pub use pm_financing::PmFinancingMargin;
pub use pm_financing::PmFinancingRepayment;
pub use pm_financing::PmFinancingResponse;
pub use pm_financing::PmFinancingTotals;
pub use pm_financing::PmLoanRepayResponse;
pub use pm_financing::PmLoanRepaymentRequest;
pub use pm_financing::PmRepayRejection;
pub use pm_financing::PmRepaymentBlockedReason;
pub use pm_financing::PmRepaymentStatus;
pub use pm_financing::RepayAmount;
pub use pm_financing::RepayPmLoanParams;
pub use qp_client::NoopCallbacks;
pub use qp_client::QpClientCallbacks;
pub use qp_client::QpClientConfig;
pub use qp_client::QpDisconnectReason;
pub use qp_client::QpWriteFailure;
pub use qp_client::QpWriteOperation;
pub use qp_client::RfqDropReason;
pub use tee_perp::build_perp_scale_order_legs;
pub use tee_perp::build_tee_perp_batch_modify;
pub use tee_perp::build_tee_perp_bracket_batch;
pub use tee_perp::build_tee_perp_position_tpsl_batch;
pub use tee_perp::build_tee_perp_scale_batch;
pub use tee_perp::perp_market_limit_price;
pub use tee_perp::perp_preview_batch_action;
pub use tee_perp::perp_preview_order;
pub use tee_perp::resolve_hypercall_builder_address;
pub use tee_perp::round_perp_price_to_tick;
pub use tee_perp::tee_api_wallet_approval_progress;
pub use tee_perp::tee_perp_batch_cloid;
pub use tee_perp::tee_perp_batch_modify_signing_hash;
pub use tee_perp::tee_perp_limit_order_wire;
pub use tee_perp::tee_perp_modify_signing_hash;
pub use tee_perp::tee_perp_nonce_in_window;
pub use tee_perp::tee_perp_trigger_order_wire;
pub use tee_perp::tee_perp_twap_cancel_signing_hash;
pub use tee_perp::tee_perp_twap_signing_hash;
pub use tee_perp::tee_perp_venue_expires_after_ms;
pub use tee_perp::ApproveHypercallBuilderParams;
pub use tee_perp::HyperliquidInfoClient;
pub use tee_perp::HyperliquidLeverage;
pub use tee_perp::HyperliquidUserRole;
pub use tee_perp::PerpScaleLeg;
pub use tee_perp::PerpScaleOrderSpec;
pub use tee_perp::TeeApiWalletApprovalChallenge;
pub use tee_perp::TeeApiWalletApprovalProgress;
pub use tee_perp::TeeApiWalletApprovalSignature;
pub use tee_perp::TeeApiWalletEnrollment;
pub use tee_perp::TeeApiWalletEnrollmentPolling;
pub use tee_perp::TeeApiWalletManagerSigner;
pub use tee_perp::TeePerpBatchModifyParams;
pub use tee_perp::TeePerpBatchModifySignature;
pub use tee_perp::TeePerpBracketEntry;
pub use tee_perp::TeePerpBracketOrderParams;
pub use tee_perp::TeePerpExit;
pub use tee_perp::TeePerpLeverageParams;
pub use tee_perp::TeePerpLeverageSignature;
pub use tee_perp::TeePerpMarketOrderParams;
pub use tee_perp::TeePerpModifyParams;
pub use tee_perp::TeePerpModifySignature;
pub use tee_perp::TeePerpOrderBatchParams;
pub use tee_perp::TeePerpOrderBatchSignature;
pub use tee_perp::TeePerpOrderReplacement;
pub use tee_perp::TeePerpPositionTpslParams;
pub use tee_perp::TeePerpScaleOrderParams;
pub use tee_perp::TeePerpSigner;
pub use tee_perp::TeePerpTriggerExecution;
pub use tee_perp::TeePerpTriggerOrderParams;
pub use tee_perp::TeePerpTriggerOrderSignature;
pub use tee_perp::TeePerpTwapCancelParams;
pub use tee_perp::TeePerpTwapCancelSignature;
pub use tee_perp::TeePerpTwapParams;
pub use tee_perp::TeePerpTwapSignature;
pub use tee_perp::PERP_MARKET_SLIPPAGE_BPS;
pub use tee_spot::tee_spot_cancel_signing_hash;
pub use tee_spot::tee_spot_order_signing_hash;
pub use tee_spot::TeeSpotCancelParams;
pub use tee_spot::TeeSpotCancelSignature;
pub use tee_spot::TeeSpotOrderParams;
pub use tee_spot::TeeSpotOrderSignature;
pub use tee_spot::TeeSpotSigner;
pub use vaults::CreateVaultResponse;
pub use vaults::Vault;
pub use vaults::VaultConfigParams;
pub use vaults::VaultFill;
pub use vaults::VaultHistoryPage;
pub use vaults::VaultHolder;
pub use vaults::VaultMetadata;
pub use vaults::VaultPage;
pub use vaults::VaultQueuedRequest;
pub use vaults::VaultRequestResponse;
pub use vaults::VaultSettlement;
pub use vaults::VaultSettlementsPage;
pub use vaults::VaultStatusChange;
pub use vaults::VaultStatusChangesPage;
pub use wallet::AccountAddress;
pub use wallet::ApiWalletDirectiveSigner;
pub use wallet::AtomicNonceProvider;
pub use wallet::CancelOrderSignature;
pub use wallet::HypercallSigner;
pub use wallet::HypercallWallet;
pub use wallet::ManagerDirectiveSigner;
pub use wallet::NonceProvider;
pub use wallet::PerpCancelByCloidSignature;
pub use wallet::PerpCancelByOidSignature;
pub use wallet::PerpDirectiveSigner;
pub use wallet::PerpLimitOrderSignature;
pub use wallet::PlaceOrderSignature;
pub use wallet::PortfolioUsdcWithdrawalSignature;
pub use wallet::ReplaceOrderSignature;
pub use wallet::SetAccountAbstractionSignature;
pub use wallet::StandardMarginLiquidationSignature;
pub use wallet::StandardUsdcWithdrawalSignature;
pub use wallet::UpdateApiWalletSignature;
pub use wallet::UsdcWithdrawalSigner;
pub use websocket::WsClient;
pub use websocket::WsClientConfig;
pub use websocket::WsConnectionState;
pub use websocket::WsDisconnectReason;
pub use websocket::WsRecoveryPlan;

Modules§

account
Managed Account.sol creation through the Hypercall Factory contract.
api
HTTP client for the Hypercall REST API.
error
Error types for the Hypercall client SDK.
funding
Direct HyperEVM USDC funding for Standard and Portfolio Margin accounts.
indicative
Decoding indicative_market_data frames, batched or not.
perp
Managed-account perp directive helpers.
pm_financing
Portfolio Margin financing: read an account’s PM loans and unpaid settlement obligations, and repay them from its HyperCore USDC.
qp_client
Quote Provider (QP) WebSocket client for the /ws/quotes endpoint.
qp_scoped
Scoped Quote Provider client runtime.
rfq
High-level RFQ quote builder for Quote Providers.
rfq_v2
Typed low-level client for the RFQ V2 HTTP contract (/private/rfqs*).
rfq_v2_recovery
Client-side recovery for RFQ v2: everything a client needs after a timeout, a lost WebSocket frame, a reconnect, or a process restart.
rfq_v2_signing
EIP-712 signing for every RFQ V2 action.
tee_perp
TEE perp trading: Hyperliquid perp orders signed by the account’s app key (API wallet) and executed through Hypercall’s TEE-held Hyperliquid API wallet.
tee_spot
TEE user spot orders: HyperCore spot orders signed by the account’s app key (an active Account API wallet) and placed through Hypercall’s TEE-held Hyperliquid API wallet, on a portfolio-margin account.
vaults
Managed vaults: read vaults, their settlement history and a holder’s position, create a vault, and queue deposits and withdrawals. Every write is EIP-712 signed in the Hypercall domain by the owner or holder it names.
wallet
EIP-712 wallet for signing Hypercall operations.
websocket
WebSocket client for real-time market data and account-scoped updates.

Structs§

AcceptRfqRequest
Request to accept an RFQ quote.
ApiResponse
Generic API response wrapper.
BulkCancelOrderResponse
Response from bulk cancel operation.
BulkPlaceOrderResponse
Response from bulk order placement.
CancelOrderRequest
Request to cancel an order.
CanonicalOrdersResponse
Canonical paginated /orders response.
CursorPage
Cursor metadata for public liquidation history.
DirectiveStatusResponse
Delivery status returned from /v1/directives/{directive_id}.
DirectiveSubmitRequest
Signed request accepted by one /v1/actions/{action_key} endpoint.
DirectiveSubmitResponse
Honest result returned from a directive submission.
ExchangeInfoResponse
Public exchange configuration for frontend deposit/withdraw integration.
Fill
Fill (trade execution) information.
FillApiResponse
A single fill (one side of a trade) for a specific wallet.
FillsResponse
Paginated list of fills.
HcUpdateApiWalletAction
Manager-authorized action that adds, replaces, or removes an API wallet.
HistoricalPnlPoint
A single historical equity point.
HistoricalPnlResponse
Historical equity response for a wallet and interval.
HistoricalTheoPoint
A single historical theoretical-price point.
HistoricalTheoResponse
Historical theo response for an instrument and interval.
HlSetAbstractionAction
Manager-authorized action that changes a managed Account’s HyperCore mode.
InstrumentSpecResponse
Canonical instrument specification for discovery, quoting, and lifecycle clients.
LiquidationHistoryEntry
Liquidation history transition entry.
MarginSummary
Unified margin summary that works for both Standard and Portfolio modes.
Market
Market information.
Order
A resting or historical order on the matching engine.
OrderInfo
Order information.
OrderMessage
Order message (response from order placement).
PerpPreviewLeverageSetting
Leverage the preview should assume instead of the account’s current one.
PerpPreviewLimit
Previewed limit order type.
PerpPreviewMargin
Portfolio margin before and after the action, as admission charges it.
PerpPreviewMaxSize
Largest same-side size that still passes the real admission check.
PerpPreviewOrder
One previewed order. Prices are USDC and sizes are coins, as decimals (not the 1e8-scaled integers of the signed submit wire).
PerpPreviewRequest
Request body of TEE_PERP_PREVIEW_ROUTE. Read-only; no signature.
PerpPreviewResponse
Response of TEE_PERP_PREVIEW_ROUTE (the data of its envelope).
PerpPreviewTrigger
Previewed trigger order type. Prices are USDC decimals.
PlaceOrderRequest
Request body for placing an order.
Portfolio
Full portfolio snapshot for a single account.
PortfolioPosition
Position information in portfolio response.
PortfolioResponse
Portfolio response from the API.
PortfolioUsdcWithdrawalResponse
Accepted Portfolio Margin USDC withdrawal.
PublicLiquidationsResponse
Public global liquidation history response.
RfqLegRequest
A single leg in an RFQ request.
SpanMarginSummary
SPAN-based portfolio margin breakdown for an account.
StandardMarginLiquidationOrderResponse
StandardMarginLiquidationPositionRequest
StandardUsdcWithdrawalResponse
Accepted Standard Margin USDC withdrawal.
SubmitRfqRequest
Request to submit an RFQ.
TeeApiWalletApprovalPackage
Response of TEE_API_WALLET_APPROVAL_REQUEST_ROUTE.
TeePerpBatchModifyAction
Batch modify action for TEE_PERP_ORDER_BATCH_MODIFY_ROUTE.
TeePerpBatchModifyChildResponse
One child of a TeePerpBatchModifyResponse, in request order.
TeePerpBatchModifyResponse
Response of TEE_PERP_ORDER_BATCH_MODIFY_ROUTE.
TeePerpCancelResponse
Response of TEE_PERP_CANCEL_SUBMIT_ROUTE.
TeePerpLeverageAction
Leverage and margin-mode change for TEE_PERP_LEVERAGE_SUBMIT_ROUTE.
TeePerpLeverageResponse
Response of TEE_PERP_LEVERAGE_SUBMIT_ROUTE.
TeePerpMarketEntry
One configured perp market and whether the TEE routes accept it.
TeePerpMarketsResponse
Response of TEE_PERP_MARKETS_ROUTE.
TeePerpModifyAction
Replacement terms for one resting limit order, for TEE_PERP_ORDER_MODIFY_ROUTE and as one child of TeePerpBatchModifyAction.
TeePerpModifyResponse
Response of TEE_PERP_ORDER_MODIFY_ROUTE.
TeePerpOrderBatchAction
Order batch action for TEE_PERP_ORDER_BATCH_SUBMIT_ROUTE.
TeePerpOrderBatchResponse
Response of TEE_PERP_TRIGGER_ORDER_SUBMIT_ROUTE and TEE_PERP_ORDER_BATCH_SUBMIT_ROUTE.
TeePerpOrderResponse
Response of TEE_PERP_ORDER_SUBMIT_ROUTE.
TeePerpOrderWire
One native order on the trigger and batch routes. Prices and sizes are 1e8-scaled integers; cloid is a non-zero u128.
TeePerpTwapAction
Native TWAP for TEE_PERP_TWAP_SUBMIT_ROUTE. Hyperliquid runs it as slices over minutes, each capped at 3% slippage; randomize varies the slice timing.
TeePerpTwapCancelAction
TWAP cancel for TEE_PERP_TWAP_CANCEL_ROUTE.
TeePerpTwapResponse
Response of TEE_PERP_TWAP_SUBMIT_ROUTE.
TeePerpVenueActionResponse
Response of TEE_PERP_CANCEL_BY_OID_SUBMIT_ROUTE and TEE_PERP_TWAP_CANCEL_ROUTE.
WsSlowConsumerCloseReason
Structured JSON reason carried by a slow-consumer close frame.

Enums§

DirectiveDeliveryStatus
DirectiveDomainStatus
DirectiveStage
HistoricalPnlInterval
Historical equity interval identifier.
HistoricalTheoInterval
Historical theo interval identifier.
HypercoreAccountAbstraction
HyperCore account abstraction modes supported by managed Account directives.
InstrumentKind
Instrument family represented by a portfolio, order, fill, or WebSocket row.
MarginMode
Margin regime selected for an account.
OptionType
Option type (call or put).
OrderStatus
Order status in the order lifecycle.
PerpLiquidationBinding
The liquidation reached first as the market’s price moves.
PerpPreviewAction
The action to preview, tagged by kind.
PerpPreviewDecision
Whether the previewed action would be admitted.
PerpPreviewOrderType
Exactly one of limit or trigger.
PerpPreviewTif
Native time in force of a previewed limit order.
PerpRejectionReasonCode
Stable machine code for why a perp action is (or would be) rejected. The preview and the real submit responses carry the same code for the same rejection.
PerpTimeInForce
HyperCore time-in-force encoding used by managed perp directives.
Side
Order side (buy or sell).
TeePerpErrorCode
Stable, non-sensitive failure classification of a TEE perp response.
TeePerpModifyVenueOrder
What rests at the venue under a modified order’s cloid after the call, read from the Hyperliquid response the server verified against venueResponseHash. The modify response is returned only after Hyperliquid answered, so trust it over an immediate orderStatus read, which can lag the venue by seconds.
TeePerpOrderGrouping
Native grouping of an order batch.
TeePerpOrderStage
Outcome stage of a same-call TEE perp submission.
TeePerpOrderType
Exactly one of limit or trigger.
TeePerpTpsl
Trigger direction, as Hyperliquid names it.
TimeInForce
Time in force for orders.
UsdcWithdrawalDomainStatus
Domain processing state returned by the USDC withdrawal acceptance routes.
WsDeliveryClass
Delivery semantics for a WebSocket message.
WsMessage
WsPressureCause
Safety boundary that caused the server to disconnect a slow consumer.
WsRecoveryAction
Recovery action required after a WebSocket delivery gap.

Constants§

DEFAULT_TEE_PERP_BATCH_MODIFY_MAX_CHILDREN
Default per-instance batch-modify cap (api.tee_perp_batch_modify_max_children). An instance may configure anything from 1 to MAX_TEE_PERP_BATCH_MODIFY_CHILDREN; a larger batch is refused with 400 invalid_field before it is charged against the rate limit.
MAX_TEE_PERP_BATCH_MODIFY_CHILDREN
Children a batch modify may carry on the wire (the enclave’s structural bound). No server instance accepts more.
TEE_PERP_TWAP_MAX_MINUTES
Longest native TWAP Hyperliquid runs, in minutes (24 hours).
TEE_PERP_TWAP_MIN_MINUTES
Shortest native TWAP Hyperliquid runs, in minutes.

Type Aliases§

OrdersApiResponse
Unambiguous root-level alias for the canonical orders response.
PerpCancelByCloidRequest
Signed managed-perp cancellation request body for a client order ID.
PerpCancelByOidRequest
Signed managed-perp cancellation request body for an exchange order ID.
PerpLimitOrderRequest
Signed managed-perp limit order request body.
SetAccountAbstractionRequest
Signed managed-account abstraction request body.