pub struct HyperliquidSDK { /* private fields */ }Expand description
Main Hyperliquid SDK client
Implementations§
Source§impl HyperliquidSDK
impl HyperliquidSDK
Sourcepub fn new() -> HyperliquidSDKBuilder
pub fn new() -> HyperliquidSDKBuilder
Create a new SDK builder
Sourcepub fn grpc(&self) -> GRPCStream
pub fn grpc(&self) -> GRPCStream
Create a gRPC stream
Sourcepub fn evm_stream(&self) -> EVMStream
pub fn evm_stream(&self) -> EVMStream
Access the EVM WebSocket stream
Sourcepub async fn open_orders(&self) -> Result<Value>
pub async fn open_orders(&self) -> Result<Value>
Get open orders for the current user
Sourcepub async fn order_status(&self, oid: u64, dex: Option<&str>) -> Result<Value>
pub async fn order_status(&self, oid: u64, dex: Option<&str>) -> Result<Value>
Get status of a specific order
Sourcepub async fn market_buy(&self, asset: &str) -> MarketOrderBuilder
pub async fn market_buy(&self, asset: &str) -> MarketOrderBuilder
Place a market buy order
Sourcepub async fn market_sell(&self, asset: &str) -> MarketOrderBuilder
pub async fn market_sell(&self, asset: &str) -> MarketOrderBuilder
Place a market sell order
Sourcepub async fn buy(
&self,
asset: &str,
size: f64,
price: f64,
tif: TIF,
) -> Result<PlacedOrder>
pub async fn buy( &self, asset: &str, size: f64, price: f64, tif: TIF, ) -> Result<PlacedOrder>
Place a limit buy order
Sourcepub async fn sell(
&self,
asset: &str,
size: f64,
price: f64,
tif: TIF,
) -> Result<PlacedOrder>
pub async fn sell( &self, asset: &str, size: f64, price: f64, tif: TIF, ) -> Result<PlacedOrder>
Place a limit sell order
Sourcepub async fn order(&self, order: Order) -> Result<PlacedOrder>
pub async fn order(&self, order: Order) -> Result<PlacedOrder>
Place an order using the fluent builder
Sourcepub async fn trigger_order(&self, order: TriggerOrder) -> Result<PlacedOrder>
pub async fn trigger_order(&self, order: TriggerOrder) -> Result<PlacedOrder>
Place a trigger order (stop-loss / take-profit)
Sourcepub async fn stop_loss(
&self,
asset: &str,
size: f64,
trigger_price: f64,
) -> Result<PlacedOrder>
pub async fn stop_loss( &self, asset: &str, size: f64, trigger_price: f64, ) -> Result<PlacedOrder>
Stop-loss helper
Sourcepub async fn take_profit(
&self,
asset: &str,
size: f64,
trigger_price: f64,
) -> Result<PlacedOrder>
pub async fn take_profit( &self, asset: &str, size: f64, trigger_price: f64, ) -> Result<PlacedOrder>
Take-profit helper
Sourcepub async fn modify(
&self,
oid: u64,
asset: &str,
is_buy: bool,
size: f64,
price: f64,
tif: TIF,
reduce_only: bool,
cloid: Option<&str>,
) -> Result<PlacedOrder>
pub async fn modify( &self, oid: u64, asset: &str, is_buy: bool, size: f64, price: f64, tif: TIF, reduce_only: bool, cloid: Option<&str>, ) -> Result<PlacedOrder>
Modify an existing order
The order is identified by OID, which is included in the returned order.
Sourcepub async fn cancel_all(&self, asset: Option<&str>) -> Result<Value>
pub async fn cancel_all(&self, asset: Option<&str>) -> Result<Value>
Cancel all orders (optionally for a specific asset)
Sourcepub async fn close_position(
&self,
asset: &str,
slippage: Option<f64>,
) -> Result<PlacedOrder>
pub async fn close_position( &self, asset: &str, slippage: Option<f64>, ) -> Result<PlacedOrder>
Close position for an asset
Delegates position lookup and counter-order building to the worker using
the closePosition action type. Optionally accepts a per-call slippage
override.
Sourcepub async fn update_leverage(
&self,
asset: &str,
leverage: i32,
is_cross: bool,
) -> Result<Value>
pub async fn update_leverage( &self, asset: &str, leverage: i32, is_cross: bool, ) -> Result<Value>
Update leverage for an asset
Sourcepub async fn update_isolated_margin(
&self,
asset: &str,
is_buy: bool,
amount_usd: f64,
) -> Result<Value>
pub async fn update_isolated_margin( &self, asset: &str, is_buy: bool, amount_usd: f64, ) -> Result<Value>
Update isolated margin
Sourcepub async fn twap_order(
&self,
asset: &str,
size: f64,
is_buy: bool,
duration_minutes: i64,
reduce_only: bool,
randomize: bool,
) -> Result<Value>
pub async fn twap_order( &self, asset: &str, size: f64, is_buy: bool, duration_minutes: i64, reduce_only: bool, randomize: bool, ) -> Result<Value>
Place a TWAP order
Sourcepub async fn twap_cancel(&self, asset: &str, twap_id: i64) -> Result<Value>
pub async fn twap_cancel(&self, asset: &str, twap_id: i64) -> Result<Value>
Cancel a TWAP order
Sourcepub async fn transfer_usd(
&self,
destination: &str,
amount: f64,
) -> Result<Value>
pub async fn transfer_usd( &self, destination: &str, amount: f64, ) -> Result<Value>
Transfer USD to another address
Sourcepub async fn transfer_spot(
&self,
token: &str,
destination: &str,
amount: f64,
) -> Result<Value>
pub async fn transfer_spot( &self, token: &str, destination: &str, amount: f64, ) -> Result<Value>
Transfer spot token to another address
Sourcepub async fn withdraw(
&self,
amount: f64,
destination: Option<&str>,
) -> Result<Value>
pub async fn withdraw( &self, amount: f64, destination: Option<&str>, ) -> Result<Value>
Withdraw to Arbitrum
Sourcepub async fn transfer_spot_to_perp(&self, amount: f64) -> Result<Value>
pub async fn transfer_spot_to_perp(&self, amount: f64) -> Result<Value>
Transfer spot balance to perp balance
Sourcepub async fn transfer_perp_to_spot(&self, amount: f64) -> Result<Value>
pub async fn transfer_perp_to_spot(&self, amount: f64) -> Result<Value>
Transfer perp balance to spot balance
Sourcepub async fn vault_deposit(
&self,
vault_address: &str,
amount: f64,
) -> Result<Value>
pub async fn vault_deposit( &self, vault_address: &str, amount: f64, ) -> Result<Value>
Deposit to a vault
Sourcepub async fn vault_withdraw(
&self,
vault_address: &str,
amount: f64,
) -> Result<Value>
pub async fn vault_withdraw( &self, vault_address: &str, amount: f64, ) -> Result<Value>
Withdraw from a vault
Sourcepub async fn delegate(
&self,
validator: &str,
amount_tokens: f64,
) -> Result<Value>
pub async fn delegate( &self, validator: &str, amount_tokens: f64, ) -> Result<Value>
Delegate tokens to a validator
Sourcepub async fn undelegate(
&self,
validator: &str,
amount_tokens: f64,
) -> Result<Value>
pub async fn undelegate( &self, validator: &str, amount_tokens: f64, ) -> Result<Value>
Undelegate tokens from a validator
Sourcepub async fn approve_builder_fee(&self, max_fee: Option<&str>) -> Result<Value>
pub async fn approve_builder_fee(&self, max_fee: Option<&str>) -> Result<Value>
Approve builder fee
Sourcepub async fn revoke_builder_fee(&self) -> Result<Value>
pub async fn revoke_builder_fee(&self) -> Result<Value>
Revoke builder fee approval
Sourcepub async fn approval_status(&self) -> Result<Value>
pub async fn approval_status(&self) -> Result<Value>
Check approval status
Sourcepub async fn reserve_request_weight(&self, weight: i32) -> Result<Value>
pub async fn reserve_request_weight(&self, weight: i32) -> Result<Value>
Reserve request weight (purchase rate limit capacity)
Sourcepub async fn preflight(
&self,
asset: &str,
side: Side,
price: f64,
size: f64,
) -> Result<Value>
pub async fn preflight( &self, asset: &str, side: Side, price: f64, size: f64, ) -> Result<Value>
Preflight validation
Sourcepub async fn approve_agent(
&self,
agent_address: &str,
name: Option<&str>,
) -> Result<Value>
pub async fn approve_agent( &self, agent_address: &str, name: Option<&str>, ) -> Result<Value>
Approve an agent (API wallet) to trade on your behalf
Sourcepub async fn set_abstraction(
&self,
mode: &str,
user: Option<&str>,
) -> Result<Value>
pub async fn set_abstraction( &self, mode: &str, user: Option<&str>, ) -> Result<Value>
Set account abstraction mode
Mode can be: “disabled”, “unifiedAccount”, or “portfolioMargin”
Sourcepub async fn agent_set_abstraction(&self, mode: &str) -> Result<Value>
pub async fn agent_set_abstraction(&self, mode: &str) -> Result<Value>
Set account abstraction mode as an agent
Sourcepub async fn send_asset(
&self,
token: &str,
amount: f64,
destination: &str,
source_dex: Option<&str>,
destination_dex: Option<&str>,
from_sub_account: Option<&str>,
) -> Result<Value>
pub async fn send_asset( &self, token: &str, amount: f64, destination: &str, source_dex: Option<&str>, destination_dex: Option<&str>, from_sub_account: Option<&str>, ) -> Result<Value>
Generalized asset transfer between DEXs and accounts
Sourcepub async fn send_to_evm_with_data(
&self,
token: &str,
amount: f64,
destination: &str,
data: &str,
source_dex: &str,
destination_chain_id: u32,
gas_limit: u64,
) -> Result<Value>
pub async fn send_to_evm_with_data( &self, token: &str, amount: f64, destination: &str, data: &str, source_dex: &str, destination_chain_id: u32, gas_limit: u64, ) -> Result<Value>
Transfer tokens to HyperEVM with custom data payload
Sourcepub async fn top_up_isolated_only_margin(
&self,
asset: &str,
leverage: f64,
) -> Result<Value>
pub async fn top_up_isolated_only_margin( &self, asset: &str, leverage: f64, ) -> Result<Value>
Top up isolated-only margin to target a specific leverage
Sourcepub async fn validator_l1_stream(&self, risk_free_rate: &str) -> Result<Value>
pub async fn validator_l1_stream(&self, risk_free_rate: &str) -> Result<Value>
Submit a validator vote for the risk-free rate (validator only)
Sourcepub async fn cancel_by_cloid(&self, cloid: &str, asset: &str) -> Result<Value>
pub async fn cancel_by_cloid(&self, cloid: &str, asset: &str) -> Result<Value>
Cancel an order by client order ID (cloid)
Sourcepub async fn schedule_cancel(&self, time_ms: Option<u64>) -> Result<Value>
pub async fn schedule_cancel(&self, time_ms: Option<u64>) -> Result<Value>
Schedule cancellation of all orders after a delay (dead-man’s switch)
Sourcepub async fn refresh_markets(&self) -> Result<()>
pub async fn refresh_markets(&self) -> Result<()>
Force refresh of market metadata cache
Auto Trait Implementations§
impl Freeze for HyperliquidSDK
impl !RefUnwindSafe for HyperliquidSDK
impl Send for HyperliquidSDK
impl Sync for HyperliquidSDK
impl Unpin for HyperliquidSDK
impl UnsafeUnpin for HyperliquidSDK
impl !UnwindSafe for HyperliquidSDK
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request