pub struct HyperLiquidBuilder { /* private fields */ }Expand description
Builder for creating HyperLiquid exchange instances.
§Note on Market Types
HyperLiquid only supports perpetual futures (Swap). Attempting to set
default_type to any other value (Spot, Futures, Margin, Option) will
result in a validation error when calling build().
§Example
use ccxt_exchanges::hyperliquid::HyperLiquidBuilder;
let exchange = HyperLiquidBuilder::new()
.private_key("0x...")
.testnet(true)
.default_leverage(10)
.build()
.unwrap();Implementations§
Source§impl HyperLiquidBuilder
impl HyperLiquidBuilder
Sourcepub fn private_key(self, key: &str) -> Self
pub fn private_key(self, key: &str) -> Self
Sets the Ethereum private key for authentication.
The private key should be a 64-character hex string (32 bytes), optionally prefixed with “0x”.
§Arguments
key- The private key in hex format.
§Example
use ccxt_exchanges::hyperliquid::HyperLiquidBuilder;
let builder = HyperLiquidBuilder::new()
.private_key("0x1234567890abcdef...");Sourcepub fn sandbox(self, enabled: bool) -> Self
pub fn sandbox(self, enabled: bool) -> Self
Enables or disables sandbox/testnet mode.
When enabled, the exchange will connect to HyperLiquid testnet instead of mainnet.
This method is equivalent to testnet() and is provided for
consistency with other exchanges.
§Arguments
enabled- Whether to use sandbox mode.
Sourcepub fn testnet(self, enabled: bool) -> Self
pub fn testnet(self, enabled: bool) -> Self
Enables or disables testnet mode.
When enabled, the exchange will connect to HyperLiquid testnet instead of mainnet.
This method is equivalent to sandbox() and is provided for
backward compatibility.
§Arguments
enabled- Whether to use testnet.
Sourcepub fn vault_address(self, address: &str) -> Self
pub fn vault_address(self, address: &str) -> Self
Sets the vault address for vault trading.
When set, orders will be placed on behalf of the vault.
§Arguments
address- The vault’s Ethereum address.
Sourcepub fn default_leverage(self, leverage: u32) -> Self
pub fn default_leverage(self, leverage: u32) -> Self
Sets the default leverage multiplier.
This leverage will be used when placing orders if not specified.
§Arguments
leverage- The leverage multiplier (1-50).
Sourcepub fn default_type(self, default_type: impl Into<DefaultType>) -> Self
pub fn default_type(self, default_type: impl Into<DefaultType>) -> Self
Sets the default market type for trading.
Important: HyperLiquid only supports perpetual futures (Swap).
Attempting to set any other value (Spot, Futures, Margin, Option)
will result in a validation error when calling build().
§Arguments
default_type- The default market type. Must beSwapfor HyperLiquid.
§Example
use ccxt_exchanges::hyperliquid::HyperLiquidBuilder;
use ccxt_core::types::default_type::DefaultType;
// This works - HyperLiquid supports Swap (perpetuals)
let exchange = HyperLiquidBuilder::new()
.default_type(DefaultType::Swap)
.build()
.unwrap();
// This will fail - HyperLiquid does not support Spot
let result = HyperLiquidBuilder::new()
.default_type(DefaultType::Spot)
.build();
assert!(result.is_err());