Skip to main content

HyperliquidSDK

Struct HyperliquidSDK 

Source
pub struct HyperliquidSDK { /* private fields */ }
Expand description

Main Hyperliquid SDK client

Implementations§

Source§

impl HyperliquidSDK

Source

pub fn new() -> HyperliquidSDKBuilder

Create a new SDK builder

Source

pub fn address(&self) -> Option<Address>

Get the user’s address

Source

pub fn chain(&self) -> Chain

Get the chain

Source

pub fn info(&self) -> Info

Access the Info API

Source

pub fn core(&self) -> HyperCore

Access the HyperCore API

Source

pub fn evm(&self) -> EVM

Access the EVM API

Source

pub fn stream(&self) -> Stream

Create a WebSocket stream

Source

pub fn grpc(&self) -> GRPCStream

Create a gRPC stream

Source

pub fn evm_stream(&self) -> EVMStream

Access the EVM WebSocket stream

Source

pub async fn markets(&self) -> Result<Value>

Get all available markets

Source

pub async fn dexes(&self) -> Result<Value>

Get all DEXes (HIP-3)

Source

pub async fn open_orders(&self) -> Result<Value>

Get open orders for the current user

Source

pub async fn order_status(&self, oid: u64, dex: Option<&str>) -> Result<Value>

Get status of a specific order

Source

pub async fn market_buy(&self, asset: &str) -> MarketOrderBuilder

Place a market buy order

Source

pub async fn market_sell(&self, asset: &str) -> MarketOrderBuilder

Place a market sell order

Source

pub async fn buy( &self, asset: &str, size: f64, price: f64, tif: TIF, ) -> Result<PlacedOrder>

Place a limit buy order

Source

pub async fn sell( &self, asset: &str, size: f64, price: f64, tif: TIF, ) -> Result<PlacedOrder>

Place a limit sell order

Source

pub async fn order(&self, order: Order) -> Result<PlacedOrder>

Place an order using the fluent builder

Source

pub async fn trigger_order(&self, order: TriggerOrder) -> Result<PlacedOrder>

Place a trigger order (stop-loss / take-profit)

Source

pub async fn stop_loss( &self, asset: &str, size: f64, trigger_price: f64, ) -> Result<PlacedOrder>

Stop-loss helper

Source

pub async fn take_profit( &self, asset: &str, size: f64, trigger_price: f64, ) -> Result<PlacedOrder>

Take-profit helper

Source

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.

Source

pub async fn cancel(&self, oid: u64, asset: &str) -> Result<Value>

Cancel an order by OID

Source

pub async fn cancel_all(&self, asset: Option<&str>) -> Result<Value>

Cancel all orders (optionally for a specific asset)

Source

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.

Source

pub async fn update_leverage( &self, asset: &str, leverage: i32, is_cross: bool, ) -> Result<Value>

Update leverage for an asset

Source

pub async fn update_isolated_margin( &self, asset: &str, is_buy: bool, amount_usd: f64, ) -> Result<Value>

Update isolated margin

Source

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

Source

pub async fn twap_cancel(&self, asset: &str, twap_id: i64) -> Result<Value>

Cancel a TWAP order

Source

pub async fn transfer_usd( &self, destination: &str, amount: f64, ) -> Result<Value>

Transfer USD to another address

Source

pub async fn transfer_spot( &self, token: &str, destination: &str, amount: f64, ) -> Result<Value>

Transfer spot token to another address

Source

pub async fn withdraw( &self, amount: f64, destination: Option<&str>, ) -> Result<Value>

Withdraw to Arbitrum

Source

pub async fn transfer_spot_to_perp(&self, amount: f64) -> Result<Value>

Transfer spot balance to perp balance

Source

pub async fn transfer_perp_to_spot(&self, amount: f64) -> Result<Value>

Transfer perp balance to spot balance

Source

pub async fn vault_deposit( &self, vault_address: &str, amount: f64, ) -> Result<Value>

Deposit to a vault

Source

pub async fn vault_withdraw( &self, vault_address: &str, amount: f64, ) -> Result<Value>

Withdraw from a vault

Source

pub async fn stake(&self, amount_tokens: f64) -> Result<Value>

Stake tokens

Source

pub async fn unstake(&self, amount_tokens: f64) -> Result<Value>

Unstake tokens

Source

pub async fn delegate( &self, validator: &str, amount_tokens: f64, ) -> Result<Value>

Delegate tokens to a validator

Source

pub async fn undelegate( &self, validator: &str, amount_tokens: f64, ) -> Result<Value>

Undelegate tokens from a validator

Source

pub async fn approve_builder_fee(&self, max_fee: Option<&str>) -> Result<Value>

Approve builder fee

Source

pub async fn revoke_builder_fee(&self) -> Result<Value>

Revoke builder fee approval

Source

pub async fn approval_status(&self) -> Result<Value>

Check approval status

Source

pub async fn reserve_request_weight(&self, weight: i32) -> Result<Value>

Reserve request weight (purchase rate limit capacity)

Source

pub async fn noop(&self) -> Result<Value>

No-op (consume nonce)

Source

pub async fn preflight( &self, asset: &str, side: Side, price: f64, size: f64, ) -> Result<Value>

Preflight validation

Source

pub async fn approve_agent( &self, agent_address: &str, name: Option<&str>, ) -> Result<Value>

Approve an agent (API wallet) to trade on your behalf

Source

pub async fn set_abstraction( &self, mode: &str, user: Option<&str>, ) -> Result<Value>

Set account abstraction mode

Mode can be: “disabled”, “unifiedAccount”, or “portfolioMargin”

Source

pub async fn agent_set_abstraction(&self, mode: &str) -> Result<Value>

Set account abstraction mode as an agent

Source

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

Source

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

Source

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

Source

pub async fn validator_l1_stream(&self, risk_free_rate: &str) -> Result<Value>

Submit a validator vote for the risk-free rate (validator only)

Source

pub async fn cancel_by_cloid(&self, cloid: &str, asset: &str) -> Result<Value>

Cancel an order by client order ID (cloid)

Source

pub async fn schedule_cancel(&self, time_ms: Option<u64>) -> Result<Value>

Schedule cancellation of all orders after a delay (dead-man’s switch)

Source

pub async fn get_mid(&self, asset: &str) -> Result<f64>

Get mid price for an asset

Source

pub async fn refresh_markets(&self) -> Result<()>

Force refresh of market metadata cache

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more