Documentation
¶
Overview ¶
Package hyperliquid provides a Go SDK for the Hyperliquid exchange.
The SDK provides unified access to all Hyperliquid APIs through a single client:
- Trading: Place orders, cancel, modify, close positions
- Info: Market data, positions, orders, vaults
- HyperCore: Block data, trades, orders from the L1
- EVM: Ethereum JSON-RPC for HyperEVM
- Streaming: Real-time data via WebSocket and gRPC
Example:
sdk, err := hyperliquid.New("https://your-endpoint.quiknode.pro/TOKEN",
hyperliquid.WithPrivateKey("0x..."),
hyperliquid.WithAutoApprove(true),
)
if err != nil {
log.Fatal(err)
}
defer sdk.Close()
// Place a market buy
order, err := sdk.MarketBuy("BTC", hyperliquid.WithSize(0.001))
Index ¶
- Constants
- Variables
- func IsApprovalError(err error) bool
- func IsErrorCode(err error, code ErrorCode) bool
- func IsRetryable(err error) bool
- func IsValidationError(err error) bool
- func NormalizeAddress(addr string) string
- func ValidateAddress(addr string) bool
- type BuildResponse
- type CloseOption
- type Config
- type ConnectionState
- type Decimal
- type EVMClient
- func (c *EVMClient) Accounts() ([]string, error)
- func (c *EVMClient) BigBlockGasPrice() (int64, error)
- func (c *EVMClient) BlockNumber() (int64, error)
- func (c *EVMClient) Call(to, data string, blockNumber string) (string, error)
- func (c *EVMClient) ChainID() (int64, error)
- func (c *EVMClient) DebugGetBadBlocks() ([]any, error)
- func (c *EVMClient) DebugGetRawBlock(blockNumber string) (string, error)
- func (c *EVMClient) DebugGetRawHeader(blockNumber string) (string, error)
- func (c *EVMClient) DebugGetRawReceipts(blockNumber string) ([]string, error)
- func (c *EVMClient) DebugGetRawTransaction(txHash string) (string, error)
- func (c *EVMClient) DebugStorageRangeAt(blockHash string, txIndex int, contractAddress, keyStart string, maxResult int) (map[string]any, error)
- func (c *EVMClient) DebugTraceBlock(blockRLP string, tracerConfig map[string]any) ([]any, error)
- func (c *EVMClient) DebugTraceBlockByHash(blockHash string, tracerConfig map[string]any) ([]any, error)
- func (c *EVMClient) DebugTraceBlockByNumber(blockNumber string, tracerConfig map[string]any) ([]any, error)
- func (c *EVMClient) DebugTraceCall(tx map[string]any, blockNumber string, tracerConfig map[string]any) (map[string]any, error)
- func (c *EVMClient) DebugTraceTransaction(txHash string, tracerConfig map[string]any) (map[string]any, error)
- func (c *EVMClient) EstimateGas(to, data string) (int64, error)
- func (c *EVMClient) FeeHistory(blockCount int, newestBlock string, rewardPercentiles []float64) (map[string]any, error)
- func (c *EVMClient) GasPrice() (int64, error)
- func (c *EVMClient) GetBalance(address string, blockNumber string) (string, error)
- func (c *EVMClient) GetBlockByHash(hash string, fullTx bool) (map[string]any, error)
- func (c *EVMClient) GetBlockByNumber(blockNumber string, fullTx bool) (map[string]any, error)
- func (c *EVMClient) GetBlockReceipts(blockNumber string) ([]any, error)
- func (c *EVMClient) GetBlockTransactionCountByHash(blockHash string) (int64, error)
- func (c *EVMClient) GetBlockTransactionCountByNumber(blockNumber string) (int64, error)
- func (c *EVMClient) GetCode(address string, blockNumber string) (string, error)
- func (c *EVMClient) GetLogs(filter map[string]any) ([]any, error)
- func (c *EVMClient) GetNonce(address string, blockNumber string) (int64, error)
- func (c *EVMClient) GetStorageAt(address, position, blockNumber string) (string, error)
- func (c *EVMClient) GetSystemTxsByBlockHash(blockHash string) ([]any, error)
- func (c *EVMClient) GetSystemTxsByBlockNumber(blockNumber string) ([]any, error)
- func (c *EVMClient) GetTransactionByBlockHashAndIndex(blockHash string, index int) (map[string]any, error)
- func (c *EVMClient) GetTransactionByBlockNumberAndIndex(blockNumber string, index int) (map[string]any, error)
- func (c *EVMClient) GetTransactionByHash(hash string) (map[string]any, error)
- func (c *EVMClient) GetTransactionReceipt(hash string) (map[string]any, error)
- func (c *EVMClient) MaxPriorityFeePerGas() (int64, error)
- func (c *EVMClient) NetVersion() (string, error)
- func (c *EVMClient) SendRawTransaction(signedTx string) (string, error)
- func (c *EVMClient) Syncing() (any, error)
- func (c *EVMClient) TraceBlock(blockNumber string) ([]any, error)
- func (c *EVMClient) TraceCall(tx map[string]any, traceTypes []string, blockNumber string) (map[string]any, error)
- func (c *EVMClient) TraceCallMany(calls []any, blockNumber string) ([]any, error)
- func (c *EVMClient) TraceFilter(filterParams map[string]any) ([]any, error)
- func (c *EVMClient) TraceRawTransaction(rawTx string, traceTypes []string) (map[string]any, error)
- func (c *EVMClient) TraceReplayBlockTransactions(blockNumber string, traceTypes []string) ([]any, error)
- func (c *EVMClient) TraceReplayTransaction(txHash string, traceTypes []string) (map[string]any, error)
- func (c *EVMClient) TraceTransaction(txHash string) ([]any, error)
- func (c *EVMClient) UsingBigBlocks() (bool, error)
- func (c *EVMClient) Web3ClientVersion() (string, error)
- type EVMStream
- func (s *EVMStream) Connected() bool
- func (s *EVMStream) Logs(filter map[string]any, callback func(map[string]any)) *EVMStream
- func (s *EVMStream) NewHeads(callback func(map[string]any)) *EVMStream
- func (s *EVMStream) NewPendingTransactions(callback func(map[string]any)) *EVMStream
- func (s *EVMStream) Run() error
- func (s *EVMStream) Start() error
- func (s *EVMStream) State() ConnectionState
- func (s *EVMStream) Stop()
- func (s *EVMStream) Subscriptions() []string
- func (s *EVMStream) Unsubscribe(subscriptionID string) bool
- type EVMStreamConfig
- type EVMSubscriptionType
- type Error
- func ApprovalError(message string, approvalData map[string]any) *Error
- func BuildError(message string) *Error
- func DuplicateOrderError(rawError string) *Error
- func GeoBlockedError(message string, data map[string]any) *Error
- func InsufficientMarginError(rawError string) *Error
- func InvalidNonceError(rawError string) *Error
- func LeverageError(rawError string) *Error
- func MaxOrdersError(rawError string) *Error
- func MustDepositError(rawError string) *Error
- func NewError(code ErrorCode, message string) *Error
- func NoPositionError(asset string) *Error
- func OrderNotFoundError(oid int64) *Error
- func ParseAPIError(data map[string]any, statusCode int) *Error
- func RateLimitError(rawError string) *Error
- func ReduceOnlyError(rawError string) *Error
- func SendError(message string) *Error
- func SignatureError(message string) *Error
- func UserNotFoundError(rawError string) *Error
- func ValidationError(message string) *Error
- type ErrorCode
- type ExchangeResponse
- type GRPCStream
- func (s *GRPCStream) Blocks(callback func(map[string]any)) *GRPCStream
- func (s *GRPCStream) BookUpdates(coins []string, callback func(map[string]any)) *GRPCStream
- func (s *GRPCStream) Connected() bool
- func (s *GRPCStream) Events(callback func(map[string]any)) *GRPCStream
- func (s *GRPCStream) L2Book(coin string, callback func(map[string]any), opts ...L2BookOption) *GRPCStream
- func (s *GRPCStream) L4Book(coin string, callback func(map[string]any)) *GRPCStream
- func (s *GRPCStream) Orders(coins []string, callback func(map[string]any), users ...string) *GRPCStream
- func (s *GRPCStream) Ping() bool
- func (s *GRPCStream) ReconnectAttempts() int
- func (s *GRPCStream) Run() error
- func (s *GRPCStream) Start() error
- func (s *GRPCStream) State() ConnectionState
- func (s *GRPCStream) Stop()
- func (s *GRPCStream) TWAP(coins []string, callback func(map[string]any)) *GRPCStream
- func (s *GRPCStream) Trades(coins []string, callback func(map[string]any)) *GRPCStream
- func (s *GRPCStream) WriterActions(callback func(map[string]any)) *GRPCStream
- type GRPCStreamConfig
- type GRPCStreamType
- type HTTPClient
- func (c *HTTPClient) Close()
- func (c *HTTPClient) Get(ctx context.Context, baseURL string, params map[string]string) (map[string]any, error)
- func (c *HTTPClient) Post(ctx context.Context, url string, body any) (map[string]any, error)
- func (c *HTTPClient) PostRaw(ctx context.Context, url string, body any) (any, error)
- type HyperCoreClient
- func (c *HyperCoreClient) BuildApproveBuilderFee(user, builder, maxFeeRate string, nonce int64) (map[string]any, error)
- func (c *HyperCoreClient) BuildCancel(coin string, oid int64, user string) (map[string]any, error)
- func (c *HyperCoreClient) BuildModify(coin string, oid int64, user string, limitPx, sz *string, isBuy *bool) (map[string]any, error)
- func (c *HyperCoreClient) BuildOrder(coin string, isBuy bool, limitPx, sz, user string, reduceOnly bool, ...) (map[string]any, error)
- func (c *HyperCoreClient) BuildRevokeBuilderFee(user, builder string, nonce int64) (map[string]any, error)
- func (c *HyperCoreClient) GetBatchBlocks(fromBlock, toBlock int64, stream ...string) ([]any, error)
- func (c *HyperCoreClient) GetBlock(blockNumber int64, stream ...string) (map[string]any, error)
- func (c *HyperCoreClient) GetMaxBuilderFee(user, builder string) (map[string]any, error)
- func (c *HyperCoreClient) LatestBlockNumber(stream ...string) (int64, error)
- func (c *HyperCoreClient) LatestBlocks(stream string, count int) (map[string]any, error)
- func (c *HyperCoreClient) LatestBookUpdates(count int, coin string) ([]map[string]any, error)
- func (c *HyperCoreClient) LatestOrders(count int, coin string) ([]map[string]any, error)
- func (c *HyperCoreClient) LatestTrades(count int, coin string) ([]map[string]any, error)
- func (c *HyperCoreClient) ListDexes() ([]string, error)
- func (c *HyperCoreClient) ListMarkets(dex string) ([]any, error)
- func (c *HyperCoreClient) OpenOrders(user string) ([]any, error)
- func (c *HyperCoreClient) OrderStatus(user string, oid int64) (map[string]any, error)
- func (c *HyperCoreClient) Preflight(coin string, isBuy bool, limitPx, sz, user string, reduceOnly bool, ...) (map[string]any, error)
- func (c *HyperCoreClient) SendApproval(action map[string]any, signature string) (map[string]any, error)
- func (c *HyperCoreClient) SendCancel(action map[string]any, signature string, nonce int64) (map[string]any, error)
- func (c *HyperCoreClient) SendModify(action map[string]any, signature string, nonce int64) (map[string]any, error)
- func (c *HyperCoreClient) SendOrder(action map[string]any, signature string, nonce int64) (map[string]any, error)
- func (c *HyperCoreClient) SendRevocation(action map[string]any, signature string) (map[string]any, error)
- func (c *HyperCoreClient) Subscribe(subscription map[string]any) (map[string]any, error)
- func (c *HyperCoreClient) Unsubscribe(subscription map[string]any) (map[string]any, error)
- type InfoClient
- func (c *InfoClient) ActiveAssetData(user, coin string) (map[string]any, error)
- func (c *InfoClient) AlignedQuoteTokenInfo(token int) (map[string]any, error)
- func (c *InfoClient) AllBorrowLendReserveStates() ([]any, error)
- func (c *InfoClient) AllMids(opts ...InfoOption) (map[string]any, error)
- func (c *InfoClient) AllPerpMetas() (map[string]any, error)
- func (c *InfoClient) ApprovedBuilders(user string) ([]any, error)
- func (c *InfoClient) BatchClearinghouseStates(users []string) ([]any, error)
- func (c *InfoClient) BorrowLendReserveState(token int) (map[string]any, error)
- func (c *InfoClient) BorrowLendUserState(user string) (map[string]any, error)
- func (c *InfoClient) Candles(coin, interval string, startTime, endTime int64) ([]any, error)
- func (c *InfoClient) ClearinghouseState(user string, opts ...InfoOption) (map[string]any, error)
- func (c *InfoClient) Delegations(user string) ([]any, error)
- func (c *InfoClient) DelegatorHistory(user string) ([]any, error)
- func (c *InfoClient) DelegatorRewards(user string) (map[string]any, error)
- func (c *InfoClient) DelegatorSummary(user string) (map[string]any, error)
- func (c *InfoClient) ExchangeStatus() (map[string]any, error)
- func (c *InfoClient) ExtraAgents(user string) ([]any, error)
- func (c *InfoClient) FrontendOpenOrders(user string, opts ...InfoOption) ([]any, error)
- func (c *InfoClient) FundingHistory(coin string, startTime int64, endTime *int64) ([]any, error)
- func (c *InfoClient) GossipRootIPs() ([]string, error)
- func (c *InfoClient) HistoricalOrders(user string) ([]any, error)
- func (c *InfoClient) L2Book(coin string, opts ...InfoOption) (map[string]any, error)
- func (c *InfoClient) LeadingVaults(user string) ([]any, error)
- func (c *InfoClient) Liquidatable() ([]any, error)
- func (c *InfoClient) MaxBuilderFee(user, builder string) (map[string]any, error)
- func (c *InfoClient) MaxMarketOrderNtls() (map[string]any, error)
- func (c *InfoClient) Meta() (map[string]any, error)
- func (c *InfoClient) MetaAndAssetCtxs() (map[string]any, error)
- func (c *InfoClient) OpenOrders(user string, opts ...InfoOption) ([]any, error)
- func (c *InfoClient) OrderStatus(user string, oid int64, opts ...InfoOption) (map[string]any, error)
- func (c *InfoClient) PerpAnnotation(asset int) (map[string]any, error)
- func (c *InfoClient) PerpCategories() (map[string]any, error)
- func (c *InfoClient) PerpDeployAuctionStatus() (map[string]any, error)
- func (c *InfoClient) PerpDexLimits(dex string) (map[string]any, error)
- func (c *InfoClient) PerpDexStatus(dex string) (map[string]any, error)
- func (c *InfoClient) PerpDexs() ([]any, error)
- func (c *InfoClient) PerpsAtOpenInterestCap() ([]string, error)
- func (c *InfoClient) Portfolio(user string) (map[string]any, error)
- func (c *InfoClient) PredictedFundings() ([]any, error)
- func (c *InfoClient) RecentTrades(coin string) ([]any, error)
- func (c *InfoClient) Referral(user string) (map[string]any, error)
- func (c *InfoClient) SpotClearinghouseState(user string) (map[string]any, error)
- func (c *InfoClient) SpotDeployState(user string) (map[string]any, error)
- func (c *InfoClient) SpotMeta() (map[string]any, error)
- func (c *InfoClient) SpotMetaAndAssetCtxs() (map[string]any, error)
- func (c *InfoClient) SpotPairDeployAuctionStatus() (map[string]any, error)
- func (c *InfoClient) SubAccounts(user string) ([]any, error)
- func (c *InfoClient) TokenDetails(tokenID string) (map[string]any, error)
- func (c *InfoClient) UserAbstraction(user string) (map[string]any, error)
- func (c *InfoClient) UserDexAbstraction(user string) (map[string]any, error)
- func (c *InfoClient) UserFees(user string) (map[string]any, error)
- func (c *InfoClient) UserFills(user string, aggregateByTime bool) ([]any, error)
- func (c *InfoClient) UserFillsByTime(user string, startTime int64, endTime *int64) ([]any, error)
- func (c *InfoClient) UserFunding(user string, startTime, endTime *int64) ([]any, error)
- func (c *InfoClient) UserNonFundingLedgerUpdates(user string, startTime, endTime *int64) ([]any, error)
- func (c *InfoClient) UserRateLimit(user string) (map[string]any, error)
- func (c *InfoClient) UserRole(user string) (map[string]any, error)
- func (c *InfoClient) UserTWAPHistory(user string) ([]any, error)
- func (c *InfoClient) UserTWAPSliceFills(user string, limit int) ([]any, error)
- func (c *InfoClient) UserToMultiSigSigners(user string) (map[string]any, error)
- func (c *InfoClient) UserVaultEquities(user string) (map[string]any, error)
- func (c *InfoClient) ValidatorL1Votes() (map[string]any, error)
- func (c *InfoClient) VaultDetails(vaultAddress string, user string) (map[string]any, error)
- func (c *InfoClient) VaultSummaries() ([]any, error)
- func (c *InfoClient) WebData2(user string) (map[string]any, error)
- type InfoOption
- type L2Book
- type L2BookLevel
- type L2BookOption
- type L4Order
- type LeverageOption
- type Market
- type Markets
- type ModifyOption
- type OpenOrdersOption
- type Option
- type OrderBuilder
- func (o *OrderBuilder) ALO() *OrderBuilder
- func (o *OrderBuilder) Asset() string
- func (o *OrderBuilder) Buy(asset any) *OrderBuilder
- func (o *OrderBuilder) CLOID(cloid string) *OrderBuilder
- func (o *OrderBuilder) GTC() *OrderBuilder
- func (o *OrderBuilder) GetNotional() float64
- func (o *OrderBuilder) GetPrice() string
- func (o *OrderBuilder) GetPriorityFee() *uint64
- func (o *OrderBuilder) GetSide() Side
- func (o *OrderBuilder) GetSize() string
- func (o *OrderBuilder) GetTIF() TIF
- func (o *OrderBuilder) IOC() *OrderBuilder
- func (o *OrderBuilder) IsReduceOnly() bool
- func (o *OrderBuilder) Limit(price any) *OrderBuilder
- func (o *OrderBuilder) Long(asset any) *OrderBuilder
- func (o *OrderBuilder) Market() *OrderBuilder
- func (o *OrderBuilder) Notional(usd float64) *OrderBuilder
- func (o *OrderBuilder) Price(price any) *OrderBuilder
- func (o *OrderBuilder) PriorityFee(priorityFee uint64) *OrderBuilder
- func (o *OrderBuilder) ReduceOnly() *OrderBuilder
- func (o *OrderBuilder) Sell(asset any) *OrderBuilder
- func (o *OrderBuilder) SetSize(size string)
- func (o *OrderBuilder) Short(asset any) *OrderBuilder
- func (o *OrderBuilder) Size(size any) *OrderBuilder
- func (o *OrderBuilder) String() string
- func (o *OrderBuilder) TIF(tif TIF) *OrderBuilder
- func (o *OrderBuilder) ToAction() map[string]any
- func (o *OrderBuilder) Validate() error
- type OrderGrouping
- type OrderOption
- func WithGrouping(grouping OrderGrouping) OrderOption
- func WithNotional(usd float64) OrderOption
- func WithOrderSlippage(slippage float64) OrderOption
- func WithPrice(price any) OrderOption
- func WithPriorityFee(priorityFee uint64) OrderOption
- func WithReduceOnly() OrderOption
- func WithSize(size any) OrderOption
- func WithTIF(tif TIF) OrderOption
- type PlacedOrder
- type PredictionMarket
- type PredictionMarketFilter
- type PredictionMarkets
- type PredictionSide
- type PreflightOption
- type SDK
- func (s *SDK) Address() string
- func (s *SDK) AgentSetAbstraction(mode string) (map[string]any, error)
- func (s *SDK) ApprovalStatus(user string) (map[string]any, error)
- func (s *SDK) ApproveAgent(agentAddress, name string) (map[string]any, error)
- func (s *SDK) ApproveBuilderFee(maxFee, builder string) (map[string]any, error)
- func (s *SDK) Buy(asset any, opts ...OrderOption) (*PlacedOrder, error)
- func (s *SDK) BuyUSDH(amountUSDC any, opts ...OrderOption) (*PlacedOrder, error)
- func (s *SDK) Cancel(oid int64, asset string) (map[string]any, error)
- func (s *SDK) CancelAll(asset string) (map[string]any, error)
- func (s *SDK) CancelByCloid(cloid string, asset string) (map[string]any, error)
- func (s *SDK) Chain() string
- func (s *SDK) Close()
- func (s *SDK) ClosePosition(asset string, opts ...CloseOption) (*PlacedOrder, error)
- func (s *SDK) Core() *HyperCoreClient
- func (s *SDK) Delegate(validator string, amount float64) (map[string]any, error)
- func (s *SDK) Dexes() (map[string]any, error)
- func (s *SDK) EVM() *EVMClient
- func (s *SDK) FundPriorityFees(amountHype float64) (map[string]any, error)
- func (s *SDK) GetMid(assetInput any) (float64, error)
- func (s *SDK) Info() *InfoClient
- func (s *SDK) Long(asset any, opts ...OrderOption) (*PlacedOrder, error)
- func (s *SDK) MarketBuy(asset any, opts ...OrderOption) (*PlacedOrder, error)
- func (s *SDK) MarketSell(asset any, opts ...OrderOption) (*PlacedOrder, error)
- func (s *SDK) Markets() (*Markets, error)
- func (s *SDK) Modify(oid int64, asset, side, price, size string, opts ...ModifyOption) (*PlacedOrder, error)
- func (s *SDK) NewEVMStream(config *EVMStreamConfig) *EVMStream
- func (s *SDK) NewGRPCStream(config *GRPCStreamConfig) *GRPCStream
- func (s *SDK) NewStream(config *StreamConfig) *Stream
- func (s *SDK) Noop() (map[string]any, error)
- func (s *SDK) OpenOrders(user string, opts ...OpenOrdersOption) (map[string]any, error)
- func (s *SDK) OrderStatus(oid int64, user string) (map[string]any, error)
- func (s *SDK) PlaceOrder(order *OrderBuilder) (*PlacedOrder, error)
- func (s *SDK) PlaceTriggerOrder(order *TriggerOrderBuilder, grouping OrderGrouping) (*PlacedOrder, error)
- func (s *SDK) PredictionMarket(filter PredictionMarketFilter) (*PredictionMarket, error)
- func (s *SDK) PredictionMarkets() (PredictionMarkets, error)
- func (s *SDK) PredictionSides() ([]PredictionSide, error)
- func (s *SDK) Predictions() (PredictionMarkets, error)
- func (s *SDK) Preflight(asset string, side Side, price, size any, opts ...PreflightOption) (map[string]any, error)
- func (s *SDK) RefreshMarkets() (*Markets, error)
- func (s *SDK) ReserveRequestWeight(weight int) (map[string]any, error)
- func (s *SDK) RevokeBuilderFee(builder string) (map[string]any, error)
- func (s *SDK) SL(asset string, size any, triggerPrice any, opts ...TriggerOrderOption) (*PlacedOrder, error)
- func (s *SDK) ScheduleCancel(timeMs int64) (map[string]any, error)
- func (s *SDK) Sell(asset any, opts ...OrderOption) (*PlacedOrder, error)
- func (s *SDK) SellUSDH(amountUSDH any, opts ...OrderOption) (*PlacedOrder, error)
- func (s *SDK) SendAsset(token string, amount any, destination string, opts ...SendAssetOption) (map[string]any, error)
- func (s *SDK) SendToEVMWithData(token string, amount any, destination, data, sourceDex string, destChainID int, ...) (map[string]any, error)
- func (s *SDK) SetAbstraction(mode string, user string) (map[string]any, error)
- func (s *SDK) Short(asset any, opts ...OrderOption) (*PlacedOrder, error)
- func (s *SDK) Stake(amount float64) (map[string]any, error)
- func (s *SDK) StopLoss(asset string, size any, triggerPrice any, opts ...TriggerOrderOption) (*PlacedOrder, error)
- func (s *SDK) TP(asset string, size any, triggerPrice any, opts ...TriggerOrderOption) (*PlacedOrder, error)
- func (s *SDK) TWAPCancel(asset string, twapID int) (map[string]any, error)
- func (s *SDK) TWAPOrder(asset string, size any, isBuy bool, durationMinutes int, opts ...TWAPOption) (map[string]any, error)
- func (s *SDK) TakeProfit(asset string, size any, triggerPrice any, opts ...TriggerOrderOption) (*PlacedOrder, error)
- func (s *SDK) Testnet() bool
- func (s *SDK) TopUpIsolatedOnlyMargin(asset string, leverage float64) (map[string]any, error)
- func (s *SDK) TransferPerpToSpot(amount any) (map[string]any, error)
- func (s *SDK) TransferSpot(token, destination string, amount any) (map[string]any, error)
- func (s *SDK) TransferSpotToPerp(amount any) (map[string]any, error)
- func (s *SDK) TransferUSD(destination string, amount any) (map[string]any, error)
- func (s *SDK) Undelegate(validator string, amount float64) (map[string]any, error)
- func (s *SDK) Unstake(amount float64) (map[string]any, error)
- func (s *SDK) UpdateIsolatedMargin(asset string, isBuy bool, amount float64) (map[string]any, error)
- func (s *SDK) UpdateLeverage(asset string, leverage int, opts ...LeverageOption) (map[string]any, error)
- func (s *SDK) ValidatorL1Stream(riskFreeRate string) (map[string]any, error)
- func (s *SDK) VaultDeposit(vaultAddress string, amount float64) (map[string]any, error)
- func (s *SDK) VaultWithdraw(vaultAddress string, amount float64) (map[string]any, error)
- func (s *SDK) Withdraw(amount any, destination string) (map[string]any, error)
- type SendAssetOption
- type Side
- type Signature
- type Stream
- func (s *Stream) ActiveAssetCtx(coin string, callback func(map[string]any)) string
- func (s *Stream) ActiveAssetData(user, coin string, callback func(map[string]any)) string
- func (s *Stream) AllMids(callback func(map[string]any)) string
- func (s *Stream) BBO(coin string, callback func(map[string]any)) string
- func (s *Stream) BookUpdates(coins []string, callback func(map[string]any)) string
- func (s *Stream) Candle(coin, interval string, callback func(map[string]any)) string
- func (s *Stream) ClearinghouseState(user string, callback func(map[string]any)) string
- func (s *Stream) Connected() bool
- func (s *Stream) Events(callback func(map[string]any)) string
- func (s *Stream) L2Book(coin string, callback func(map[string]any)) string
- func (s *Stream) Notification(user string, callback func(map[string]any)) string
- func (s *Stream) OpenOrders(user string, callback func(map[string]any)) string
- func (s *Stream) OrderUpdates(user string, callback func(map[string]any)) string
- func (s *Stream) Orders(coins []string, callback func(map[string]any), users ...string) string
- func (s *Stream) ReconnectAttempts() int
- func (s *Stream) Run() error
- func (s *Stream) Start() error
- func (s *Stream) State() ConnectionState
- func (s *Stream) Stop()
- func (s *Stream) Subscribe(streamType StreamType, callback func(map[string]any), opts ...SubscribeOption) string
- func (s *Stream) TWAP(coins []string, callback func(map[string]any)) string
- func (s *Stream) TWAPStates(user string, callback func(map[string]any)) string
- func (s *Stream) Trades(coins []string, callback func(map[string]any)) string
- func (s *Stream) Unsubscribe(subID string)
- func (s *Stream) UserEvents(user string, callback func(map[string]any)) string
- func (s *Stream) UserFills(user string, callback func(map[string]any)) string
- func (s *Stream) UserFundings(user string, callback func(map[string]any)) string
- func (s *Stream) UserNonFundingLedger(user string, callback func(map[string]any)) string
- func (s *Stream) UserTWAPHistory(user string, callback func(map[string]any)) string
- func (s *Stream) UserTWAPSliceFills(user string, callback func(map[string]any)) string
- func (s *Stream) WebData3(user string, callback func(map[string]any)) string
- func (s *Stream) WriterActions(callback func(map[string]any)) string
- type StreamConfig
- type StreamType
- type SubscribeOption
- type TIF
- type TWAPOption
- type TpSl
- type TriggerOrderBuilder
- func (t *TriggerOrderBuilder) Asset() string
- func (t *TriggerOrderBuilder) CLOID(cloid string) *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) GetLimitPrice() string
- func (t *TriggerOrderBuilder) GetSide() Side
- func (t *TriggerOrderBuilder) GetSize() string
- func (t *TriggerOrderBuilder) GetTriggerPrice() string
- func (t *TriggerOrderBuilder) Limit(price any) *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) Market() *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) ReduceOnly() *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) SL(asset string) *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) Side(side Side) *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) Size(size any) *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) StopLoss(asset string) *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) String() string
- func (t *TriggerOrderBuilder) TP(asset string) *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) TakeProfit(asset string) *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) ToAction(grouping OrderGrouping) map[string]any
- func (t *TriggerOrderBuilder) Trigger(price any) *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) TriggerPrice(price any) *TriggerOrderBuilder
- func (t *TriggerOrderBuilder) Validate() error
- type TriggerOrderOption
- type Wallet
Constants ¶
const ( // DefaultTimeout is the default request timeout. DefaultTimeout = 30 * time.Second // DefaultSlippage is the default slippage for market orders (3%). DefaultSlippage = 0.03 // DefaultMaxFee is the default max builder fee. DefaultMaxFee = "1%" // DefaultWorkerURL is the public worker URL. DefaultWorkerURL = "https://send.hyperliquidapi.com" // DefaultBuilderAddress is the QuickNode builder address. DefaultBuilderAddress = "0x8D62d3000eF0639d1fc9667D06BE7BB98d9993F5" // CacheTTL is the market metadata cache TTL. CacheTTL = 5 * time.Minute // HYPEWeiDecimals is Hyperliquid's HYPE staking precision. HYPEWeiDecimals = 8 )
Variables ¶
var QNSupportedInfoMethods = map[string]bool{ "meta": true, "spotMeta": true, "clearinghouseState": true, "spotClearinghouseState": true, "openOrders": true, "exchangeStatus": true, "frontendOpenOrders": true, "liquidatable": true, "activeAssetData": true, "maxMarketOrderNtls": true, "vaultSummaries": true, "userVaultEquities": true, "leadingVaults": true, "extraAgents": true, "subAccounts": true, "userFees": true, "userRateLimit": true, "spotDeployState": true, "perpDeployAuctionStatus": true, "delegations": true, "delegatorSummary": true, "maxBuilderFee": true, "userToMultiSigSigners": true, "userRole": true, "perpsAtOpenInterestCap": true, "validatorL1Votes": true, "marginTable": true, "perpDexs": true, "webData2": true, "outcomeMeta": true, }
QNSupportedInfoMethods are Info API methods supported by QuickNode nodes.
Functions ¶
func IsApprovalError ¶
IsApprovalError checks if the error is an approval-related error.
func IsErrorCode ¶
IsErrorCode checks if an error has a specific code.
func IsValidationError ¶
IsValidationError checks if the error is a validation error.
func NormalizeAddress ¶
NormalizeAddress normalizes an Ethereum address to checksummed format.
func ValidateAddress ¶
ValidateAddress checks if a string is a valid Ethereum address.
Types ¶
type BuildResponse ¶
type BuildResponse struct {
Hash string `json:"hash"`
Nonce int64 `json:"nonce"`
Action map[string]any `json:"action"`
}
BuildResponse represents the response from a build request.
type CloseOption ¶ added in v0.1.4
type CloseOption func(*closeParams)
CloseOption is an option for closing a position.
func CloseWithSlippage ¶ added in v0.1.4
func CloseWithSlippage(slippage float64) CloseOption
CloseWithSlippage overrides the default slippage for this close. Slippage is expressed as a fraction (e.g. 0.05 = 5%).
type Config ¶
type Config struct {
Endpoint string
PrivateKey string
Testnet bool
AutoApprove bool
MaxFee string
Slippage float64
Timeout time.Duration
}
Config holds SDK configuration options.
type ConnectionState ¶
type ConnectionState string
ConnectionState represents WebSocket/gRPC connection states.
const ( ConnectionStateDisconnected ConnectionState = "disconnected" ConnectionStateConnecting ConnectionState = "connecting" ConnectionStateConnected ConnectionState = "connected" ConnectionStateReconnecting ConnectionState = "reconnecting" )
type Decimal ¶
type Decimal string
Decimal is a helper for precise decimal string handling.
func (Decimal) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Decimal) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type EVMClient ¶
type EVMClient struct {
// contains filtered or unexported fields
}
EVMClient provides access to the HyperEVM JSON-RPC API.
func NewEVMClient ¶
func NewEVMClient(endpoint string, http *HTTPClient) *EVMClient
NewEVMClient creates a new EVM API client.
func (*EVMClient) BigBlockGasPrice ¶
BigBlockGasPrice returns gas price for big blocks.
func (*EVMClient) BlockNumber ¶
BlockNumber returns the latest block number.
func (*EVMClient) DebugGetBadBlocks ¶
DebugGetBadBlocks returns bad blocks.
func (*EVMClient) DebugGetRawBlock ¶
DebugGetRawBlock returns raw block data.
func (*EVMClient) DebugGetRawHeader ¶
DebugGetRawHeader returns raw block header.
func (*EVMClient) DebugGetRawReceipts ¶
DebugGetRawReceipts returns raw receipts for a block.
func (*EVMClient) DebugGetRawTransaction ¶
DebugGetRawTransaction returns raw transaction data.
func (*EVMClient) DebugStorageRangeAt ¶
func (c *EVMClient) DebugStorageRangeAt(blockHash string, txIndex int, contractAddress, keyStart string, maxResult int) (map[string]any, error)
DebugStorageRangeAt returns storage range at a specific point.
func (*EVMClient) DebugTraceBlock ¶
DebugTraceBlock traces a block by RLP.
func (*EVMClient) DebugTraceBlockByHash ¶
func (c *EVMClient) DebugTraceBlockByHash(blockHash string, tracerConfig map[string]any) ([]any, error)
DebugTraceBlockByHash traces a block by hash.
func (*EVMClient) DebugTraceBlockByNumber ¶
func (c *EVMClient) DebugTraceBlockByNumber(blockNumber string, tracerConfig map[string]any) ([]any, error)
DebugTraceBlockByNumber traces a block by number.
func (*EVMClient) DebugTraceCall ¶
func (c *EVMClient) DebugTraceCall(tx map[string]any, blockNumber string, tracerConfig map[string]any) (map[string]any, error)
DebugTraceCall traces a call.
func (*EVMClient) DebugTraceTransaction ¶
func (c *EVMClient) DebugTraceTransaction(txHash string, tracerConfig map[string]any) (map[string]any, error)
DebugTraceTransaction traces a transaction's execution.
func (*EVMClient) EstimateGas ¶
EstimateGas estimates the gas needed for a transaction.
func (*EVMClient) FeeHistory ¶
func (c *EVMClient) FeeHistory(blockCount int, newestBlock string, rewardPercentiles []float64) (map[string]any, error)
FeeHistory returns fee history for a range of blocks.
func (*EVMClient) GetBalance ¶
GetBalance returns the balance of an address in wei.
func (*EVMClient) GetBlockByHash ¶
GetBlockByHash returns block info by hash.
func (*EVMClient) GetBlockByNumber ¶
GetBlockByNumber returns block info by number.
func (*EVMClient) GetBlockReceipts ¶
GetBlockReceipts returns all receipts for a block.
func (*EVMClient) GetBlockTransactionCountByHash ¶
GetBlockTransactionCountByHash returns transaction count in a block by hash.
func (*EVMClient) GetBlockTransactionCountByNumber ¶
GetBlockTransactionCountByNumber returns transaction count in a block by number.
func (*EVMClient) GetStorageAt ¶
GetStorageAt returns the value from a storage position at an address.
func (*EVMClient) GetSystemTxsByBlockHash ¶
GetSystemTxsByBlockHash returns system transactions by block hash.
func (*EVMClient) GetSystemTxsByBlockNumber ¶
GetSystemTxsByBlockNumber returns system transactions by block number.
func (*EVMClient) GetTransactionByBlockHashAndIndex ¶
func (c *EVMClient) GetTransactionByBlockHashAndIndex(blockHash string, index int) (map[string]any, error)
GetTransactionByBlockHashAndIndex returns transaction by block hash and index.
func (*EVMClient) GetTransactionByBlockNumberAndIndex ¶
func (c *EVMClient) GetTransactionByBlockNumberAndIndex(blockNumber string, index int) (map[string]any, error)
GetTransactionByBlockNumberAndIndex returns transaction by block number and index.
func (*EVMClient) GetTransactionByHash ¶
GetTransactionByHash returns transaction info by hash.
func (*EVMClient) GetTransactionReceipt ¶
GetTransactionReceipt returns transaction receipt by hash.
func (*EVMClient) MaxPriorityFeePerGas ¶
MaxPriorityFeePerGas returns max priority fee per gas.
func (*EVMClient) NetVersion ¶
NetVersion returns the network version.
func (*EVMClient) SendRawTransaction ¶
SendRawTransaction sends a signed transaction.
func (*EVMClient) Syncing ¶
Syncing returns sync status. Returns false if not syncing, or sync info if syncing.
func (*EVMClient) TraceBlock ¶
TraceBlock returns traces of all transactions in a block.
func (*EVMClient) TraceCall ¶
func (c *EVMClient) TraceCall(tx map[string]any, traceTypes []string, blockNumber string) (map[string]any, error)
TraceCall traces a call with specified trace types.
func (*EVMClient) TraceCallMany ¶
TraceCallMany traces multiple calls.
func (*EVMClient) TraceFilter ¶
TraceFilter filters traces.
func (*EVMClient) TraceRawTransaction ¶
TraceRawTransaction traces a raw transaction.
func (*EVMClient) TraceReplayBlockTransactions ¶
func (c *EVMClient) TraceReplayBlockTransactions(blockNumber string, traceTypes []string) ([]any, error)
TraceReplayBlockTransactions replays and traces all transactions in a block.
func (*EVMClient) TraceReplayTransaction ¶
func (c *EVMClient) TraceReplayTransaction(txHash string, traceTypes []string) (map[string]any, error)
TraceReplayTransaction replays and traces a transaction.
func (*EVMClient) TraceTransaction ¶
TraceTransaction returns trace of a transaction.
func (*EVMClient) UsingBigBlocks ¶
UsingBigBlocks returns whether the node is using big blocks.
func (*EVMClient) Web3ClientVersion ¶
Web3ClientVersion returns the client version.
type EVMStream ¶
type EVMStream struct {
// contains filtered or unexported fields
}
EVMStream is a WebSocket client for EVM event streams.
func NewEVMStream ¶
func NewEVMStream(endpoint string, config *EVMStreamConfig) *EVMStream
NewEVMStream creates a new EVM WebSocket stream client.
func (*EVMStream) NewPendingTransactions ¶
NewPendingTransactions subscribes to pending transaction hashes.
func (*EVMStream) State ¶
func (s *EVMStream) State() ConnectionState
State returns the current connection state.
func (*EVMStream) Subscriptions ¶
Subscriptions returns the list of active subscription IDs.
func (*EVMStream) Unsubscribe ¶
Unsubscribe unsubscribes from a subscription.
type EVMStreamConfig ¶
type EVMStreamConfig struct {
OnError func(error)
OnClose func()
OnOpen func()
OnStateChange func(ConnectionState)
Reconnect bool
MaxReconnect int
PingInterval time.Duration
}
EVMStreamConfig holds configuration for EVM WebSocket streaming.
func DefaultEVMStreamConfig ¶
func DefaultEVMStreamConfig() *EVMStreamConfig
DefaultEVMStreamConfig returns default EVM stream configuration.
type EVMSubscriptionType ¶
type EVMSubscriptionType string
EVMSubscriptionType represents EVM WebSocket subscription types.
const ( EVMSubscriptionNewHeads EVMSubscriptionType = "newHeads" EVMSubscriptionLogs EVMSubscriptionType = "logs" EVMSubscriptionNewPendingTransactions EVMSubscriptionType = "newPendingTransactions" )
type Error ¶
type Error struct {
Code ErrorCode `json:"code,omitempty"`
Message string `json:"message"`
Guidance string `json:"guidance,omitempty"`
Raw map[string]any `json:"raw,omitempty"`
}
Error represents a Hyperliquid SDK error with structured information.
func ApprovalError ¶
ApprovalError creates an approval-related error.
func DuplicateOrderError ¶
DuplicateOrderError creates a duplicate order error.
func GeoBlockedError ¶
GeoBlockedError creates a geo-blocked error.
func InsufficientMarginError ¶
InsufficientMarginError creates an insufficient margin error.
func InvalidNonceError ¶
InvalidNonceError creates an invalid nonce error.
func LeverageError ¶
LeverageError creates a leverage conflict error.
func MaxOrdersError ¶
MaxOrdersError creates a max orders exceeded error.
func MustDepositError ¶
MustDepositError creates a must deposit first error.
func NoPositionError ¶
NoPositionError creates a no position error.
func OrderNotFoundError ¶
OrderNotFoundError creates an order not found error.
func ParseAPIError ¶
ParseAPIError parses an API error response into an appropriate Error.
func RateLimitError ¶
RateLimitError creates a rate limit error.
func ReduceOnlyError ¶
ReduceOnlyError creates a reduce-only violation error.
func SignatureError ¶
SignatureError creates a signature error.
func UserNotFoundError ¶
UserNotFoundError creates a user not found error.
func ValidationError ¶
ValidationError creates a validation error.
func (*Error) WithGuidance ¶
WithGuidance adds guidance to the error.
type ErrorCode ¶
type ErrorCode string
ErrorCode represents semantic error codes.
const ( ErrorCodeUnknown ErrorCode = "UNKNOWN_ERROR" ErrorCodeTimeout ErrorCode = "TIMEOUT" ErrorCodeConnectionError ErrorCode = "CONNECTION_ERROR" ErrorCodeParseError ErrorCode = "PARSE_ERROR" ErrorCodeInvalidJSON ErrorCode = "INVALID_JSON" ErrorCodeMissingField ErrorCode = "MISSING_FIELD" ErrorCodeInvalidParams ErrorCode = "INVALID_PARAMS" ErrorCodeInvalidPriceTick ErrorCode = "INVALID_PRICE_TICK" ErrorCodeInvalidSize ErrorCode = "INVALID_SIZE" ErrorCodeSignatureInvalid ErrorCode = "SIGNATURE_INVALID" ErrorCodeNoPosition ErrorCode = "NO_POSITION" ErrorCodeOrderNotFound ErrorCode = "ORDER_NOT_FOUND" ErrorCodeGeoBlocked ErrorCode = "GEO_BLOCKED" ErrorCodeNotApproved ErrorCode = "NOT_APPROVED" ErrorCodeFeeExceedsApproved ErrorCode = "FEE_EXCEEDS_APPROVED" ErrorCodeInsufficientMargin ErrorCode = "INSUFFICIENT_MARGIN" ErrorCodeLeverageConflict ErrorCode = "LEVERAGE_CONFLICT" ErrorCodeRateLimited ErrorCode = "RATE_LIMITED" ErrorCodeMaxOrdersExceeded ErrorCode = "MAX_ORDERS_EXCEEDED" ErrorCodeReduceOnlyViolation ErrorCode = "REDUCE_ONLY_VIOLATION" ErrorCodeDuplicateOrder ErrorCode = "DUPLICATE_ORDER" ErrorCodeUserNotFound ErrorCode = "USER_NOT_FOUND" ErrorCodeMustDepositFirst ErrorCode = "MUST_DEPOSIT_FIRST" ErrorCodeInvalidNonce ErrorCode = "INVALID_NONCE" ErrorCodeGRPCError ErrorCode = "GRPC_ERROR" ErrorCodeHTTPError ErrorCode = "HTTP_ERROR" ErrorCodeBuildError ErrorCode = "BUILD_ERROR" ErrorCodeSendError ErrorCode = "SEND_ERROR" )
type ExchangeResponse ¶
type ExchangeResponse struct {
Success bool `json:"success,omitempty"`
User string `json:"user,omitempty"`
ExchangeResponse map[string]any `json:"exchangeResponse,omitempty"`
}
ExchangeResponse represents the response from an exchange request.
type GRPCStream ¶
type GRPCStream struct {
// contains filtered or unexported fields
}
GRPCStream is a gRPC client for real-time data streams.
func NewGRPCStream ¶
func NewGRPCStream(endpoint string, config *GRPCStreamConfig) *GRPCStream
NewGRPCStream creates a new gRPC stream client.
func (*GRPCStream) Blocks ¶
func (s *GRPCStream) Blocks(callback func(map[string]any)) *GRPCStream
Blocks subscribes to block data.
func (*GRPCStream) BookUpdates ¶
func (s *GRPCStream) BookUpdates(coins []string, callback func(map[string]any)) *GRPCStream
BookUpdates subscribes to order book updates.
func (*GRPCStream) Connected ¶
func (s *GRPCStream) Connected() bool
Connected returns true if the stream is connected.
func (*GRPCStream) Events ¶
func (s *GRPCStream) Events(callback func(map[string]any)) *GRPCStream
Events subscribes to system events.
func (*GRPCStream) L2Book ¶
func (s *GRPCStream) L2Book(coin string, callback func(map[string]any), opts ...L2BookOption) *GRPCStream
L2Book subscribes to Level 2 order book updates.
func (*GRPCStream) L4Book ¶
func (s *GRPCStream) L4Book(coin string, callback func(map[string]any)) *GRPCStream
L4Book subscribes to Level 4 order book updates (individual orders).
func (*GRPCStream) Orders ¶
func (s *GRPCStream) Orders(coins []string, callback func(map[string]any), users ...string) *GRPCStream
Orders subscribes to order stream.
func (*GRPCStream) ReconnectAttempts ¶
func (s *GRPCStream) ReconnectAttempts() int
ReconnectAttempts returns the number of reconnection attempts.
func (*GRPCStream) Start ¶
func (s *GRPCStream) Start() error
Start starts the stream in background.
func (*GRPCStream) State ¶
func (s *GRPCStream) State() ConnectionState
State returns the current connection state.
func (*GRPCStream) TWAP ¶
func (s *GRPCStream) TWAP(coins []string, callback func(map[string]any)) *GRPCStream
TWAP subscribes to TWAP execution stream.
func (*GRPCStream) Trades ¶
func (s *GRPCStream) Trades(coins []string, callback func(map[string]any)) *GRPCStream
Trades subscribes to trade stream.
func (*GRPCStream) WriterActions ¶
func (s *GRPCStream) WriterActions(callback func(map[string]any)) *GRPCStream
WriterActions subscribes to writer actions.
type GRPCStreamConfig ¶
type GRPCStreamConfig struct {
OnError func(error)
OnClose func()
OnConnect func()
OnReconnect func(attempt int)
OnStateChange func(ConnectionState)
Secure bool
Reconnect bool
MaxReconnect int
}
GRPCStreamConfig holds configuration for gRPC streaming.
func DefaultGRPCStreamConfig ¶
func DefaultGRPCStreamConfig() *GRPCStreamConfig
DefaultGRPCStreamConfig returns default gRPC stream configuration.
type GRPCStreamType ¶
type GRPCStreamType string
GRPCStreamType represents available gRPC stream types.
const ( GRPCStreamTypeTrades GRPCStreamType = "TRADES" GRPCStreamTypeOrders GRPCStreamType = "ORDERS" GRPCStreamTypeBookUpdates GRPCStreamType = "BOOK_UPDATES" GRPCStreamTypeTWAP GRPCStreamType = "TWAP" GRPCStreamTypeEvents GRPCStreamType = "EVENTS" GRPCStreamTypeBlocks GRPCStreamType = "BLOCKS" GRPCStreamTypeWriterActions GRPCStreamType = "WRITER_ACTIONS" )
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient wraps http.Client with SDK-specific functionality.
func NewHTTPClient ¶
func NewHTTPClient(timeout time.Duration) *HTTPClient
NewHTTPClient creates a new HTTP client with connection pooling.
func (*HTTPClient) Get ¶
func (c *HTTPClient) Get(ctx context.Context, baseURL string, params map[string]string) (map[string]any, error)
Get sends a GET request and returns the parsed response.
type HyperCoreClient ¶
type HyperCoreClient struct {
// contains filtered or unexported fields
}
HyperCoreClient provides access to the HyperCore JSON-RPC API.
func NewHyperCoreClient ¶
func NewHyperCoreClient(endpoint string, http *HTTPClient) *HyperCoreClient
NewHyperCoreClient creates a new HyperCore API client.
func (*HyperCoreClient) BuildApproveBuilderFee ¶
func (c *HyperCoreClient) BuildApproveBuilderFee(user, builder, maxFeeRate string, nonce int64) (map[string]any, error)
BuildApproveBuilderFee builds a builder fee approval for signing.
func (*HyperCoreClient) BuildCancel ¶
BuildCancel builds a cancel action for signing.
func (*HyperCoreClient) BuildModify ¶
func (c *HyperCoreClient) BuildModify(coin string, oid int64, user string, limitPx, sz *string, isBuy *bool) (map[string]any, error)
BuildModify builds a modify action for signing.
func (*HyperCoreClient) BuildOrder ¶
func (c *HyperCoreClient) BuildOrder(coin string, isBuy bool, limitPx, sz, user string, reduceOnly bool, orderType map[string]any, cloid string) (map[string]any, error)
BuildOrder builds an order action for signing.
func (*HyperCoreClient) BuildRevokeBuilderFee ¶
func (c *HyperCoreClient) BuildRevokeBuilderFee(user, builder string, nonce int64) (map[string]any, error)
BuildRevokeBuilderFee builds a builder fee revocation for signing.
func (*HyperCoreClient) GetBatchBlocks ¶
func (c *HyperCoreClient) GetBatchBlocks(fromBlock, toBlock int64, stream ...string) ([]any, error)
GetBatchBlocks returns a range of blocks. Stream options: "trades", "orders", "events", "book", "twap", "writer_actions"
func (*HyperCoreClient) GetBlock ¶
GetBlock returns block data by number. Stream options: "trades", "orders", "events", "book", "twap", "writer_actions"
func (*HyperCoreClient) GetMaxBuilderFee ¶
func (c *HyperCoreClient) GetMaxBuilderFee(user, builder string) (map[string]any, error)
GetMaxBuilderFee returns maximum builder fee for a user-builder pair.
func (*HyperCoreClient) LatestBlockNumber ¶
func (c *HyperCoreClient) LatestBlockNumber(stream ...string) (int64, error)
LatestBlockNumber returns the latest block number for a stream. Stream options: "trades", "orders", "events", "book", "twap", "writer_actions"
func (*HyperCoreClient) LatestBlocks ¶
LatestBlocks returns the latest N blocks for a stream. Stream options: "trades", "orders", "book_updates", "twap", "events", "writer_actions"
func (*HyperCoreClient) LatestBookUpdates ¶
LatestBookUpdates returns recent book updates from latest blocks.
func (*HyperCoreClient) LatestOrders ¶
LatestOrders returns recent order events from latest blocks.
func (*HyperCoreClient) LatestTrades ¶
LatestTrades returns recent trades from latest blocks. This is an alternative to Info.RecentTrades() which may not be available on QuickNode.
func (*HyperCoreClient) ListDexes ¶
func (c *HyperCoreClient) ListDexes() ([]string, error)
ListDexes returns all available DEX names.
func (*HyperCoreClient) ListMarkets ¶
func (c *HyperCoreClient) ListMarkets(dex string) ([]any, error)
ListMarkets returns all available markets, optionally filtered by DEX.
func (*HyperCoreClient) OpenOrders ¶
func (c *HyperCoreClient) OpenOrders(user string) ([]any, error)
OpenOrders returns open orders for a user.
func (*HyperCoreClient) OrderStatus ¶
OrderStatus returns status of a specific order.
func (*HyperCoreClient) Preflight ¶
func (c *HyperCoreClient) Preflight(coin string, isBuy bool, limitPx, sz, user string, reduceOnly bool, orderType map[string]any) (map[string]any, error)
Preflight validates an order before signing.
func (*HyperCoreClient) SendApproval ¶
func (c *HyperCoreClient) SendApproval(action map[string]any, signature string) (map[string]any, error)
SendApproval sends a signed builder fee approval.
func (*HyperCoreClient) SendCancel ¶
func (c *HyperCoreClient) SendCancel(action map[string]any, signature string, nonce int64) (map[string]any, error)
SendCancel sends a signed cancel.
func (*HyperCoreClient) SendModify ¶
func (c *HyperCoreClient) SendModify(action map[string]any, signature string, nonce int64) (map[string]any, error)
SendModify sends a signed modify.
func (*HyperCoreClient) SendOrder ¶
func (c *HyperCoreClient) SendOrder(action map[string]any, signature string, nonce int64) (map[string]any, error)
SendOrder sends a signed order.
func (*HyperCoreClient) SendRevocation ¶
func (c *HyperCoreClient) SendRevocation(action map[string]any, signature string) (map[string]any, error)
SendRevocation sends a signed builder fee revocation.
func (*HyperCoreClient) Unsubscribe ¶
Unsubscribe unsubscribes from a WebSocket stream.
type InfoClient ¶
type InfoClient struct {
// contains filtered or unexported fields
}
InfoClient provides access to the HyperCore Info API.
func NewInfoClient ¶
func NewInfoClient(endpoint string, http *HTTPClient) *InfoClient
NewInfoClient creates a new Info API client.
func (*InfoClient) ActiveAssetData ¶
func (c *InfoClient) ActiveAssetData(user, coin string) (map[string]any, error)
ActiveAssetData returns user's active asset trading parameters.
func (*InfoClient) AlignedQuoteTokenInfo ¶
func (c *InfoClient) AlignedQuoteTokenInfo(token int) (map[string]any, error)
AlignedQuoteTokenInfo returns aligned quote token information.
func (*InfoClient) AllBorrowLendReserveStates ¶
func (c *InfoClient) AllBorrowLendReserveStates() ([]any, error)
AllBorrowLendReserveStates returns borrow/lend reserve states for all tokens.
func (*InfoClient) AllMids ¶
func (c *InfoClient) AllMids(opts ...InfoOption) (map[string]any, error)
AllMids returns all asset mid prices.
func (*InfoClient) AllPerpMetas ¶
func (c *InfoClient) AllPerpMetas() (map[string]any, error)
AllPerpMetas returns consolidated universe, margin tables, asset contexts across all DEXs.
func (*InfoClient) ApprovedBuilders ¶
func (c *InfoClient) ApprovedBuilders(user string) ([]any, error)
ApprovedBuilders returns list of approved builders for a user.
func (*InfoClient) BatchClearinghouseStates ¶
func (c *InfoClient) BatchClearinghouseStates(users []string) ([]any, error)
BatchClearinghouseStates returns clearinghouse states for multiple users.
func (*InfoClient) BorrowLendReserveState ¶
func (c *InfoClient) BorrowLendReserveState(token int) (map[string]any, error)
BorrowLendReserveState returns borrow/lend reserve state for a token.
func (*InfoClient) BorrowLendUserState ¶
func (c *InfoClient) BorrowLendUserState(user string) (map[string]any, error)
BorrowLendUserState returns user's borrow/lend positions.
func (*InfoClient) Candles ¶
func (c *InfoClient) Candles(coin, interval string, startTime, endTime int64) ([]any, error)
Candles returns historical OHLCV candlestick data.
func (*InfoClient) ClearinghouseState ¶
func (c *InfoClient) ClearinghouseState(user string, opts ...InfoOption) (map[string]any, error)
ClearinghouseState returns user's perpetual positions and margin info.
func (*InfoClient) Delegations ¶
func (c *InfoClient) Delegations(user string) ([]any, error)
Delegations returns user's delegations.
func (*InfoClient) DelegatorHistory ¶
func (c *InfoClient) DelegatorHistory(user string) ([]any, error)
DelegatorHistory returns user's delegation history.
func (*InfoClient) DelegatorRewards ¶
func (c *InfoClient) DelegatorRewards(user string) (map[string]any, error)
DelegatorRewards returns user's delegation rewards.
func (*InfoClient) DelegatorSummary ¶
func (c *InfoClient) DelegatorSummary(user string) (map[string]any, error)
DelegatorSummary returns user's delegation summary.
func (*InfoClient) ExchangeStatus ¶
func (c *InfoClient) ExchangeStatus() (map[string]any, error)
ExchangeStatus returns current exchange status.
func (*InfoClient) ExtraAgents ¶
func (c *InfoClient) ExtraAgents(user string) ([]any, error)
ExtraAgents returns user's extra agents (API keys).
func (*InfoClient) FrontendOpenOrders ¶
func (c *InfoClient) FrontendOpenOrders(user string, opts ...InfoOption) ([]any, error)
FrontendOpenOrders returns user's open orders with enhanced info.
func (*InfoClient) FundingHistory ¶
FundingHistory returns historical funding rates for an asset.
func (*InfoClient) GossipRootIPs ¶
func (c *InfoClient) GossipRootIPs() ([]string, error)
GossipRootIPs returns gossip root IPs for the network.
func (*InfoClient) HistoricalOrders ¶
func (c *InfoClient) HistoricalOrders(user string) ([]any, error)
HistoricalOrders returns user's historical orders.
func (*InfoClient) L2Book ¶
func (c *InfoClient) L2Book(coin string, opts ...InfoOption) (map[string]any, error)
L2Book returns the Level 2 order book for an asset.
func (*InfoClient) LeadingVaults ¶
func (c *InfoClient) LeadingVaults(user string) ([]any, error)
LeadingVaults returns vaults that user is leading.
func (*InfoClient) Liquidatable ¶
func (c *InfoClient) Liquidatable() ([]any, error)
Liquidatable returns list of liquidatable positions.
func (*InfoClient) MaxBuilderFee ¶
func (c *InfoClient) MaxBuilderFee(user, builder string) (map[string]any, error)
MaxBuilderFee returns maximum builder fee for a user-builder pair.
func (*InfoClient) MaxMarketOrderNtls ¶
func (c *InfoClient) MaxMarketOrderNtls() (map[string]any, error)
MaxMarketOrderNtls returns maximum market order notionals per asset.
func (*InfoClient) Meta ¶
func (c *InfoClient) Meta() (map[string]any, error)
Meta returns exchange metadata including assets and margin configurations.
func (*InfoClient) MetaAndAssetCtxs ¶
func (c *InfoClient) MetaAndAssetCtxs() (map[string]any, error)
MetaAndAssetCtxs returns metadata + real-time asset context.
func (*InfoClient) OpenOrders ¶
func (c *InfoClient) OpenOrders(user string, opts ...InfoOption) ([]any, error)
OpenOrders returns user's open orders.
func (*InfoClient) OrderStatus ¶
func (c *InfoClient) OrderStatus(user string, oid int64, opts ...InfoOption) (map[string]any, error)
OrderStatus returns status of a specific order.
func (*InfoClient) PerpAnnotation ¶
func (c *InfoClient) PerpAnnotation(asset int) (map[string]any, error)
PerpAnnotation returns metadata descriptions for a perp.
func (*InfoClient) PerpCategories ¶
func (c *InfoClient) PerpCategories() (map[string]any, error)
PerpCategories returns asset classifications for perps.
func (*InfoClient) PerpDeployAuctionStatus ¶
func (c *InfoClient) PerpDeployAuctionStatus() (map[string]any, error)
PerpDeployAuctionStatus returns perpetual deploy auction status.
func (*InfoClient) PerpDexLimits ¶
func (c *InfoClient) PerpDexLimits(dex string) (map[string]any, error)
PerpDexLimits returns OI caps and transfer limits for builder-deployed markets.
func (*InfoClient) PerpDexStatus ¶
func (c *InfoClient) PerpDexStatus(dex string) (map[string]any, error)
PerpDexStatus returns total net deposits for builder-deployed markets.
func (*InfoClient) PerpDexs ¶
func (c *InfoClient) PerpDexs() ([]any, error)
PerpDexs returns perpetual DEX information.
func (*InfoClient) PerpsAtOpenInterestCap ¶
func (c *InfoClient) PerpsAtOpenInterestCap() ([]string, error)
PerpsAtOpenInterestCap returns perps that are at their open interest cap.
func (*InfoClient) Portfolio ¶
func (c *InfoClient) Portfolio(user string) (map[string]any, error)
Portfolio returns user's portfolio history.
func (*InfoClient) PredictedFundings ¶
func (c *InfoClient) PredictedFundings() ([]any, error)
PredictedFundings returns predicted funding rates for all assets.
func (*InfoClient) RecentTrades ¶
func (c *InfoClient) RecentTrades(coin string) ([]any, error)
RecentTrades returns recent trades for an asset.
func (*InfoClient) Referral ¶
func (c *InfoClient) Referral(user string) (map[string]any, error)
Referral returns user's referral information.
func (*InfoClient) SpotClearinghouseState ¶
func (c *InfoClient) SpotClearinghouseState(user string) (map[string]any, error)
SpotClearinghouseState returns user's spot token balances.
func (*InfoClient) SpotDeployState ¶
func (c *InfoClient) SpotDeployState(user string) (map[string]any, error)
SpotDeployState returns spot deployment state for user.
func (*InfoClient) SpotMeta ¶
func (c *InfoClient) SpotMeta() (map[string]any, error)
SpotMeta returns spot trading metadata.
func (*InfoClient) SpotMetaAndAssetCtxs ¶
func (c *InfoClient) SpotMetaAndAssetCtxs() (map[string]any, error)
SpotMetaAndAssetCtxs returns spot metadata + real-time asset context.
func (*InfoClient) SpotPairDeployAuctionStatus ¶
func (c *InfoClient) SpotPairDeployAuctionStatus() (map[string]any, error)
SpotPairDeployAuctionStatus returns Dutch auction status for spot pair deployments.
func (*InfoClient) SubAccounts ¶
func (c *InfoClient) SubAccounts(user string) ([]any, error)
SubAccounts returns user's sub-accounts.
func (*InfoClient) TokenDetails ¶
func (c *InfoClient) TokenDetails(tokenID string) (map[string]any, error)
TokenDetails returns token details.
func (*InfoClient) UserAbstraction ¶
func (c *InfoClient) UserAbstraction(user string) (map[string]any, error)
UserAbstraction returns user's account abstraction mode.
func (*InfoClient) UserDexAbstraction ¶
func (c *InfoClient) UserDexAbstraction(user string) (map[string]any, error)
UserDexAbstraction returns user's DEX abstraction eligibility.
func (*InfoClient) UserFees ¶
func (c *InfoClient) UserFees(user string) (map[string]any, error)
UserFees returns user's fee structure.
func (*InfoClient) UserFills ¶
func (c *InfoClient) UserFills(user string, aggregateByTime bool) ([]any, error)
UserFills returns user's trade fills.
func (*InfoClient) UserFillsByTime ¶
UserFillsByTime returns user's trade fills within a time range.
func (*InfoClient) UserFunding ¶
func (c *InfoClient) UserFunding(user string, startTime, endTime *int64) ([]any, error)
UserFunding returns user's funding payments.
func (*InfoClient) UserNonFundingLedgerUpdates ¶
func (c *InfoClient) UserNonFundingLedgerUpdates(user string, startTime, endTime *int64) ([]any, error)
UserNonFundingLedgerUpdates returns user's non-funding ledger updates.
func (*InfoClient) UserRateLimit ¶
func (c *InfoClient) UserRateLimit(user string) (map[string]any, error)
UserRateLimit returns user's rate limit status.
func (*InfoClient) UserRole ¶
func (c *InfoClient) UserRole(user string) (map[string]any, error)
UserRole returns account type (user, agent, vault, or sub-account).
func (*InfoClient) UserTWAPHistory ¶
func (c *InfoClient) UserTWAPHistory(user string) ([]any, error)
UserTWAPHistory returns user's TWAP order history.
func (*InfoClient) UserTWAPSliceFills ¶
func (c *InfoClient) UserTWAPSliceFills(user string, limit int) ([]any, error)
UserTWAPSliceFills returns user's TWAP slice fills.
func (*InfoClient) UserToMultiSigSigners ¶
func (c *InfoClient) UserToMultiSigSigners(user string) (map[string]any, error)
UserToMultiSigSigners returns multi-sig signers for a user.
func (*InfoClient) UserVaultEquities ¶
func (c *InfoClient) UserVaultEquities(user string) (map[string]any, error)
UserVaultEquities returns user's vault equities.
func (*InfoClient) ValidatorL1Votes ¶
func (c *InfoClient) ValidatorL1Votes() (map[string]any, error)
ValidatorL1Votes returns L1 validator votes.
func (*InfoClient) VaultDetails ¶
VaultDetails returns vault details.
func (*InfoClient) VaultSummaries ¶
func (c *InfoClient) VaultSummaries() ([]any, error)
VaultSummaries returns summaries of all vaults.
type InfoOption ¶
type InfoOption func(*infoParams)
InfoOption is an option for Info API methods.
func WithMantissa ¶
func WithMantissa(m int) InfoOption
WithMantissa sets the bucketing mantissa multiplier.
func WithNSigFigs ¶
func WithNSigFigs(n int) InfoOption
WithNSigFigs sets the number of significant figures for price bucketing.
type L2Book ¶
type L2Book struct {
Coin string `json:"coin"`
Time int64 `json:"time"`
BlockNumber int64 `json:"block_number"`
Bids []L2BookLevel `json:"bids"`
Asks []L2BookLevel `json:"asks"`
}
L2Book represents the L2 order book.
type L2BookLevel ¶
L2BookLevel represents a level in the L2 order book.
type L2BookOption ¶
type L2BookOption func(*grpcSubscription)
L2BookOption is an option for L2Book subscription.
func L2BookNLevels ¶
func L2BookNLevels(n int) L2BookOption
L2BookNLevels sets the number of price levels.
func L2BookNSigFigs ¶
func L2BookNSigFigs(n int) L2BookOption
L2BookNSigFigs sets the number of significant figures for price aggregation.
type L4Order ¶
type L4Order struct {
User string `json:"user"`
Coin string `json:"coin"`
Side string `json:"side"`
LimitPx string `json:"limit_px"`
Size string `json:"sz"`
OID int64 `json:"oid"`
Timestamp int64 `json:"timestamp"`
TriggerCondition string `json:"trigger_condition,omitempty"`
IsTrigger bool `json:"is_trigger,omitempty"`
TriggerPx string `json:"trigger_px,omitempty"`
IsPositionTPSL bool `json:"is_position_tpsl,omitempty"`
ReduceOnly bool `json:"reduce_only,omitempty"`
OrderType string `json:"order_type,omitempty"`
TIF string `json:"tif,omitempty"`
CLOID string `json:"cloid,omitempty"`
}
L4Order represents an individual order in the L4 order book.
type LeverageOption ¶
type LeverageOption func(*leverageParams)
LeverageOption is an option for leverage updates.
func LeverageWithIsolated ¶
func LeverageWithIsolated() LeverageOption
LeverageWithIsolated sets isolated margin mode.
type Market ¶
type Market struct {
Name string `json:"name"`
Index int `json:"index"`
SzDecimals int `json:"szDecimals"`
IsSpot bool `json:"isSpot,omitempty"`
Dex string `json:"dex,omitempty"`
}
Market represents market metadata.
type Markets ¶
type Markets struct {
Perps []Market `json:"perps"`
Spot []Market `json:"spot"`
HIP3 map[string][]Market `json:"hip3"`
HIP4 []Market `json:"hip4"`
}
Markets represents all available markets.
type ModifyOption ¶
type ModifyOption func(*modifyParams)
ModifyOption is an option for order modification.
func ModifyWithReduceOnly ¶
func ModifyWithReduceOnly() ModifyOption
ModifyWithReduceOnly sets the reduce-only flag for the modified order.
func ModifyWithTIF ¶
func ModifyWithTIF(tif TIF) ModifyOption
ModifyWithTIF sets the time in force for the modified order.
type OpenOrdersOption ¶
type OpenOrdersOption func(*openOrdersParams)
OpenOrdersOption is an option for OpenOrders.
func OpenOrdersWithDex ¶
func OpenOrdersWithDex(dex string) OpenOrdersOption
OpenOrdersWithDex filters open orders by HIP-3 DEX name.
type Option ¶
type Option func(*Config)
Option is a functional option for configuring the SDK.
func WithAutoApprove ¶
WithAutoApprove enables automatic builder fee approval.
func WithMaxFee ¶
WithMaxFee sets the maximum builder fee to approve.
func WithPrivateKey ¶
WithPrivateKey sets the private key for signing transactions.
func WithSlippage ¶
WithSlippage sets the default slippage for market orders.
func WithTimeout ¶
WithTimeout sets the request timeout.
type OrderBuilder ¶
type OrderBuilder struct {
// contains filtered or unexported fields
}
Order is a fluent order builder.
Examples:
// Simple limit buy
Order().Buy("BTC").Size(0.001).Price(67000).GTC()
// Market sell by notional
Order().Sell("ETH").Notional(500).Market()
// Post-only with reduce_only
Order().Buy("BTC").Size(0.01).Price(65000).ALO().ReduceOnly()
func (*OrderBuilder) ALO ¶
func (o *OrderBuilder) ALO() *OrderBuilder
ALO sets time in force to Add Liquidity Only (post-only, maker only).
func (*OrderBuilder) Buy ¶
func (o *OrderBuilder) Buy(asset any) *OrderBuilder
Buy creates a buy order for the given asset.
func (*OrderBuilder) CLOID ¶
func (o *OrderBuilder) CLOID(cloid string) *OrderBuilder
CLOID sets the client order ID for tracking.
func (*OrderBuilder) GTC ¶
func (o *OrderBuilder) GTC() *OrderBuilder
GTC sets time in force to Good Till Cancelled.
func (*OrderBuilder) GetNotional ¶
func (o *OrderBuilder) GetNotional() float64
GetNotional returns the order's notional value.
func (*OrderBuilder) GetPrice ¶
func (o *OrderBuilder) GetPrice() string
GetPrice returns the order's price.
func (*OrderBuilder) GetPriorityFee ¶ added in v0.1.8
func (o *OrderBuilder) GetPriorityFee() *uint64
GetPriorityFee returns the order priority fee if set.
func (*OrderBuilder) GetSide ¶
func (o *OrderBuilder) GetSide() Side
GetSide returns the order's side.
func (*OrderBuilder) GetSize ¶
func (o *OrderBuilder) GetSize() string
GetSize returns the order's size.
func (*OrderBuilder) GetTIF ¶
func (o *OrderBuilder) GetTIF() TIF
GetTIF returns the order's time in force.
func (*OrderBuilder) IOC ¶
func (o *OrderBuilder) IOC() *OrderBuilder
IOC sets time in force to Immediate or Cancel.
func (*OrderBuilder) IsReduceOnly ¶
func (o *OrderBuilder) IsReduceOnly() bool
IsReduceOnly returns whether the order is reduce-only.
func (*OrderBuilder) Limit ¶
func (o *OrderBuilder) Limit(price any) *OrderBuilder
Limit is an alias for Price.
func (*OrderBuilder) Long ¶
func (o *OrderBuilder) Long(asset any) *OrderBuilder
Long is an alias for Buy (perps terminology).
func (*OrderBuilder) Market ¶
func (o *OrderBuilder) Market() *OrderBuilder
Market sets the order as a market order (price computed automatically).
func (*OrderBuilder) Notional ¶
func (o *OrderBuilder) Notional(usd float64) *OrderBuilder
Notional sets the order size by USD notional value. SDK will calculate size based on current price.
func (*OrderBuilder) Price ¶
func (o *OrderBuilder) Price(price any) *OrderBuilder
Price sets the limit price.
func (*OrderBuilder) PriorityFee ¶ added in v0.1.8
func (o *OrderBuilder) PriorityFee(priorityFee uint64) *OrderBuilder
PriorityFee sets Hyperliquid order priority p. p=10000 is 1 bp and is paid from undelegated staking HYPE.
func (*OrderBuilder) ReduceOnly ¶
func (o *OrderBuilder) ReduceOnly() *OrderBuilder
ReduceOnly marks the order as reduce-only.
func (*OrderBuilder) Sell ¶
func (o *OrderBuilder) Sell(asset any) *OrderBuilder
Sell creates a sell order for the given asset.
func (*OrderBuilder) SetSize ¶
func (o *OrderBuilder) SetSize(size string)
SetSize sets the computed size (used internally for notional orders).
func (*OrderBuilder) Short ¶
func (o *OrderBuilder) Short(asset any) *OrderBuilder
Short is an alias for Sell (perps terminology).
func (*OrderBuilder) Size ¶
func (o *OrderBuilder) Size(size any) *OrderBuilder
Size sets the order size in asset units.
func (*OrderBuilder) String ¶
func (o *OrderBuilder) String() string
String returns a string representation of the order.
func (*OrderBuilder) TIF ¶
func (o *OrderBuilder) TIF(tif TIF) *OrderBuilder
TIF sets the time in force.
func (*OrderBuilder) ToAction ¶
func (o *OrderBuilder) ToAction() map[string]any
ToAction converts the order to an API action format.
func (*OrderBuilder) Validate ¶
func (o *OrderBuilder) Validate() error
Validate validates the order before sending.
type OrderGrouping ¶
type OrderGrouping string
OrderGrouping represents order grouping for TP/SL attachment.
const ( OrderGroupingNA OrderGrouping = "na" // No grouping (standalone order) OrderGroupingNormalTPSL OrderGrouping = "normalTpsl" // Attach TP/SL to the fill of this order OrderGroupingPositionTPSL OrderGrouping = "positionTpsl" // Attach TP/SL to the entire position )
type OrderOption ¶
type OrderOption func(*orderParams)
OrderOption is an option for order placement.
func WithGrouping ¶
func WithGrouping(grouping OrderGrouping) OrderOption
WithGrouping sets the order grouping for TP/SL attachment.
func WithNotional ¶
func WithNotional(usd float64) OrderOption
WithNotional sets the order size by USD notional value.
func WithOrderSlippage ¶ added in v0.1.4
func WithOrderSlippage(slippage float64) OrderOption
WithOrderSlippage overrides the default slippage for this order. Slippage is expressed as a fraction (e.g. 0.05 = 5%). Only applies to market orders; ignored for limit orders.
func WithPriorityFee ¶ added in v0.1.8
func WithPriorityFee(priorityFee uint64) OrderOption
WithPriorityFee sets Hyperliquid order priority p. p=10000 is 1 bp and is paid from undelegated staking HYPE.
func WithReduceOnly ¶
func WithReduceOnly() OrderOption
WithReduceOnly marks the order as reduce-only.
type PlacedOrder ¶
type PlacedOrder struct {
OID int64 `json:"oid,omitempty"`
Status string `json:"status"`
Asset string `json:"asset"`
Side string `json:"side"`
Size string `json:"size"`
Price string `json:"price,omitempty"`
FilledSize string `json:"filled_size,omitempty"`
AvgPrice string `json:"avg_price,omitempty"`
RawResponse map[string]any `json:"raw_response,omitempty"`
// contains filtered or unexported fields
}
PlacedOrder represents a successfully placed order with full context.
func ParsePlacedOrder ¶
func ParsePlacedOrder(response map[string]any, asset string, side Side, size, price string, sdk *SDK) *PlacedOrder
ParsePlacedOrder parses an exchange response into a PlacedOrder.
func (*PlacedOrder) Cancel ¶
func (o *PlacedOrder) Cancel() (map[string]any, error)
Cancel cancels this order.
func (*PlacedOrder) IsError ¶
func (o *PlacedOrder) IsError() bool
IsError returns true if the order encountered an error.
func (*PlacedOrder) IsFilled ¶
func (o *PlacedOrder) IsFilled() bool
IsFilled returns true if the order is completely filled.
func (*PlacedOrder) IsResting ¶
func (o *PlacedOrder) IsResting() bool
IsResting returns true if the order is resting on the order book.
func (*PlacedOrder) Modify ¶
func (o *PlacedOrder) Modify(price, size string) (*PlacedOrder, error)
Modify modifies this order's price and/or size.
type PredictionMarket ¶ added in v0.1.8
type PredictionMarket struct {
Outcome int `json:"outcome"`
Name string `json:"name"`
Description string `json:"description"`
Title string `json:"title"`
Slug string `json:"slug"`
Underlying string `json:"underlying,omitempty"`
TargetPrice string `json:"targetPrice,omitempty"`
Expiry string `json:"expiry,omitempty"`
Period string `json:"period,omitempty"`
Collateral string `json:"collateral"`
MinOrderValue string `json:"minOrderValue"`
Aliases []string `json:"aliases"`
Yes PredictionSide `json:"yes"`
No PredictionSide `json:"no"`
Sides []PredictionSide `json:"sides"`
}
PredictionMarket is a HIP-4 prediction market with yes/no tradeable sides.
type PredictionMarketFilter ¶ added in v0.1.8
type PredictionMarketFilter struct {
Query string
Underlying string
TargetPrice string
Expiry string
}
PredictionMarketFilter filters active HIP-4 markets by readable fields.
type PredictionMarkets ¶ added in v0.1.8
type PredictionMarkets []PredictionMarket
PredictionMarkets is a list of active HIP-4 markets.
func (PredictionMarkets) Find ¶ added in v0.1.8
func (p PredictionMarkets) Find(filter PredictionMarketFilter) (*PredictionMarket, bool)
Find returns the first market matching the filter.
type PredictionSide ¶ added in v0.1.8
type PredictionSide struct {
Outcome int `json:"outcome"`
Side int `json:"side"`
Name string `json:"name"`
Symbol string `json:"symbol"`
Token string `json:"token"`
AssetID int `json:"assetId"`
Mid string `json:"mid,omitempty"`
SzDecimals int `json:"szDecimals"`
SupportsPriorityFee bool `json:"supportsPriorityFee"`
}
PredictionSide is a tradeable HIP-4 outcome side.
func (PredictionSide) String ¶ added in v0.1.8
func (p PredictionSide) String() string
type PreflightOption ¶
type PreflightOption func(*preflightParams)
PreflightOption is an option for preflight validation.
func PreflightWithReduceOnly ¶
func PreflightWithReduceOnly() PreflightOption
PreflightWithReduceOnly sets the reduce-only flag for preflight.
func PreflightWithTIF ¶
func PreflightWithTIF(tif TIF) PreflightOption
PreflightWithTIF sets the time in force for preflight.
type SDK ¶
type SDK struct {
// contains filtered or unexported fields
}
SDK is the main Hyperliquid SDK client.
func New ¶
New creates a new SDK instance.
Example:
sdk, err := hyperliquid.New("https://your-endpoint.quiknode.pro/TOKEN",
hyperliquid.WithPrivateKey("0x..."),
hyperliquid.WithAutoApprove(true),
)
func (*SDK) AgentSetAbstraction ¶
AgentSetAbstraction sets account abstraction mode as an agent.
func (*SDK) ApprovalStatus ¶
ApprovalStatus checks builder fee approval status.
func (*SDK) ApproveAgent ¶
ApproveAgent approves an agent (API wallet) to trade on your behalf.
func (*SDK) ApproveBuilderFee ¶
ApproveBuilderFee approves builder fee for trading.
func (*SDK) Buy ¶
func (s *SDK) Buy(asset any, opts ...OrderOption) (*PlacedOrder, error)
Buy places a buy order.
func (*SDK) BuyUSDH ¶ added in v0.1.8
func (s *SDK) BuyUSDH(amountUSDC any, opts ...OrderOption) (*PlacedOrder, error)
BuyUSDH buys USDH with USDC for HIP-4 prediction markets.
func (*SDK) CancelByCloid ¶
CancelByCloid cancels an order by client order ID.
func (*SDK) ClosePosition ¶
func (s *SDK) ClosePosition(asset string, opts ...CloseOption) (*PlacedOrder, error)
ClosePosition closes an open position completely.
func (*SDK) FundPriorityFees ¶ added in v0.1.8
FundPriorityFees moves spot HYPE into undelegated staking HYPE for order priority fees.
func (*SDK) Long ¶
func (s *SDK) Long(asset any, opts ...OrderOption) (*PlacedOrder, error)
Long is an alias for Buy (perps terminology).
func (*SDK) MarketBuy ¶
func (s *SDK) MarketBuy(asset any, opts ...OrderOption) (*PlacedOrder, error)
MarketBuy places a market buy order.
func (*SDK) MarketSell ¶
func (s *SDK) MarketSell(asset any, opts ...OrderOption) (*PlacedOrder, error)
MarketSell places a market sell order.
func (*SDK) Modify ¶
func (s *SDK) Modify(oid int64, asset, side, price, size string, opts ...ModifyOption) (*PlacedOrder, error)
Modify modifies an existing order.
func (*SDK) NewEVMStream ¶
func (s *SDK) NewEVMStream(config *EVMStreamConfig) *EVMStream
NewEVMStream creates a new EVM WebSocket streaming client. The stream client is NOT shared across invocations - each call creates a new client.
func (*SDK) NewGRPCStream ¶
func (s *SDK) NewGRPCStream(config *GRPCStreamConfig) *GRPCStream
NewGRPCStream creates a new gRPC streaming client. The stream client is NOT shared across invocations - each call creates a new client.
func (*SDK) NewStream ¶
func (s *SDK) NewStream(config *StreamConfig) *Stream
NewStream creates a new WebSocket streaming client. The stream client is NOT shared across invocations - each call creates a new client.
func (*SDK) OpenOrders ¶
OpenOrders returns open orders with enriched info and pre-built cancel actions.
func (*SDK) OrderStatus ¶
OrderStatus returns detailed status for an order.
func (*SDK) PlaceOrder ¶
func (s *SDK) PlaceOrder(order *OrderBuilder) (*PlacedOrder, error)
PlaceOrder places an order using the fluent OrderBuilder.
func (*SDK) PlaceTriggerOrder ¶
func (s *SDK) PlaceTriggerOrder(order *TriggerOrderBuilder, grouping OrderGrouping) (*PlacedOrder, error)
PlaceTriggerOrder places a trigger order using the fluent TriggerOrderBuilder.
func (*SDK) PredictionMarket ¶ added in v0.1.8
func (s *SDK) PredictionMarket(filter PredictionMarketFilter) (*PredictionMarket, error)
PredictionMarket finds one active HIP-4 prediction market.
func (*SDK) PredictionMarkets ¶ added in v0.1.8
func (s *SDK) PredictionMarkets() (PredictionMarkets, error)
PredictionMarkets lists active HIP-4 prediction markets with tradeable yes/no sides.
func (*SDK) PredictionSides ¶ added in v0.1.8
func (s *SDK) PredictionSides() ([]PredictionSide, error)
PredictionSides returns a flat list of tradeable HIP-4 sides.
func (*SDK) Predictions ¶ added in v0.1.8
func (s *SDK) Predictions() (PredictionMarkets, error)
Predictions is an alias for PredictionMarkets.
func (*SDK) Preflight ¶
func (s *SDK) Preflight(asset string, side Side, price, size any, opts ...PreflightOption) (map[string]any, error)
Preflight validates an order before signing.
func (*SDK) RefreshMarkets ¶
RefreshMarkets forces refresh of market metadata cache.
func (*SDK) ReserveRequestWeight ¶
ReserveRequestWeight purchases additional rate limit capacity.
func (*SDK) RevokeBuilderFee ¶
RevokeBuilderFee revokes builder fee approval.
func (*SDK) SL ¶
func (s *SDK) SL(asset string, size any, triggerPrice any, opts ...TriggerOrderOption) (*PlacedOrder, error)
SL is an alias for StopLoss.
func (*SDK) ScheduleCancel ¶
ScheduleCancel schedules cancellation of all orders after a delay. Pass 0 to cancel the scheduled cancel.
func (*SDK) Sell ¶
func (s *SDK) Sell(asset any, opts ...OrderOption) (*PlacedOrder, error)
Sell places a sell order.
func (*SDK) SellUSDH ¶ added in v0.1.8
func (s *SDK) SellUSDH(amountUSDH any, opts ...OrderOption) (*PlacedOrder, error)
SellUSDH sells USDH back to USDC.
func (*SDK) SendAsset ¶
func (s *SDK) SendAsset(token string, amount any, destination string, opts ...SendAssetOption) (map[string]any, error)
SendAsset performs a generalized asset transfer between DEXs and accounts.
func (*SDK) SendToEVMWithData ¶
func (s *SDK) SendToEVMWithData(token string, amount any, destination, data, sourceDex string, destChainID int, gasLimit int) (map[string]any, error)
SendToEVMWithData transfers tokens to HyperEVM with custom data payload.
func (*SDK) SetAbstraction ¶
SetAbstraction sets account abstraction mode.
func (*SDK) Short ¶
func (s *SDK) Short(asset any, opts ...OrderOption) (*PlacedOrder, error)
Short is an alias for Sell (perps terminology).
func (*SDK) StopLoss ¶
func (s *SDK) StopLoss(asset string, size any, triggerPrice any, opts ...TriggerOrderOption) (*PlacedOrder, error)
StopLoss places a stop-loss trigger order.
func (*SDK) TP ¶
func (s *SDK) TP(asset string, size any, triggerPrice any, opts ...TriggerOrderOption) (*PlacedOrder, error)
TP is an alias for TakeProfit.
func (*SDK) TWAPCancel ¶
TWAPCancel cancels an active TWAP order.
func (*SDK) TWAPOrder ¶
func (s *SDK) TWAPOrder(asset string, size any, isBuy bool, durationMinutes int, opts ...TWAPOption) (map[string]any, error)
TWAPOrder places a TWAP (Time-Weighted Average Price) order.
func (*SDK) TakeProfit ¶
func (s *SDK) TakeProfit(asset string, size any, triggerPrice any, opts ...TriggerOrderOption) (*PlacedOrder, error)
TakeProfit places a take-profit trigger order.
func (*SDK) TopUpIsolatedOnlyMargin ¶
TopUpIsolatedOnlyMargin tops up isolated margin to target leverage.
func (*SDK) TransferPerpToSpot ¶
TransferPerpToSpot transfers USDC from perp balance to spot balance.
func (*SDK) TransferSpot ¶
TransferSpot transfers spot tokens to another Hyperliquid address.
func (*SDK) TransferSpotToPerp ¶
TransferSpotToPerp transfers USDC from spot balance to perp balance.
func (*SDK) TransferUSD ¶
TransferUSD transfers USDC to another Hyperliquid address.
func (*SDK) Undelegate ¶
Undelegate undelegates staked tokens from a validator.
func (*SDK) UpdateIsolatedMargin ¶
func (s *SDK) UpdateIsolatedMargin(asset string, isBuy bool, amount float64) (map[string]any, error)
UpdateIsolatedMargin adds or removes margin from an isolated position.
func (*SDK) UpdateLeverage ¶
func (s *SDK) UpdateLeverage(asset string, leverage int, opts ...LeverageOption) (map[string]any, error)
UpdateLeverage updates leverage for an asset.
func (*SDK) ValidatorL1Stream ¶
ValidatorL1Stream submits a validator vote for the risk-free rate.
func (*SDK) VaultDeposit ¶
VaultDeposit deposits USDC into a vault.
func (*SDK) VaultWithdraw ¶
VaultWithdraw withdraws USDC from a vault.
type SendAssetOption ¶
type SendAssetOption func(*sendAssetParams)
SendAssetOption is an option for SendAsset.
func SendAssetFromDex ¶
func SendAssetFromDex(dex string) SendAssetOption
SendAssetFromDex sets the source DEX.
func SendAssetFromSubAccount ¶
func SendAssetFromSubAccount(addr string) SendAssetOption
SendAssetFromSubAccount sets the source sub-account.
func SendAssetToDex ¶
func SendAssetToDex(dex string) SendAssetOption
SendAssetToDex sets the destination DEX.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a WebSocket client for real-time data streams.
func NewStream ¶
func NewStream(endpoint string, config *StreamConfig) *Stream
NewStream creates a new WebSocket stream client.
func (*Stream) ActiveAssetCtx ¶
ActiveAssetCtx subscribes to asset context data (pricing, volume, supply).
func (*Stream) ActiveAssetData ¶
ActiveAssetData subscribes to user's active asset trading parameters.
func (*Stream) BookUpdates ¶
BookUpdates subscribes to order book updates.
func (*Stream) ClearinghouseState ¶
ClearinghouseState subscribes to user's clearinghouse state updates.
func (*Stream) Notification ¶
Notification subscribes to user notifications.
func (*Stream) OpenOrders ¶
OpenOrders subscribes to user's open orders.
func (*Stream) OrderUpdates ¶
OrderUpdates subscribes to user's order status changes.
func (*Stream) ReconnectAttempts ¶
ReconnectAttempts returns the number of reconnection attempts since last successful connection.
func (*Stream) State ¶
func (s *Stream) State() ConnectionState
State returns the current connection state.
func (*Stream) Subscribe ¶
func (s *Stream) Subscribe(streamType StreamType, callback func(map[string]any), opts ...SubscribeOption) string
Subscribe subscribes to a stream type.
func (*Stream) TWAPStates ¶
TWAPStates subscribes to TWAP algorithm states.
func (*Stream) Unsubscribe ¶
Unsubscribe unsubscribes from a stream.
func (*Stream) UserEvents ¶
UserEvents subscribes to comprehensive user events (fills, funding, liquidations).
func (*Stream) UserFundings ¶
UserFundings subscribes to user's funding payment updates.
func (*Stream) UserNonFundingLedger ¶
UserNonFundingLedger subscribes to user's ledger changes (deposits, withdrawals, transfers).
func (*Stream) UserTWAPHistory ¶
UserTWAPHistory subscribes to TWAP execution history and status.
func (*Stream) UserTWAPSliceFills ¶
UserTWAPSliceFills subscribes to individual TWAP order slice fills.
type StreamConfig ¶
type StreamConfig struct {
OnError func(error)
OnClose func()
OnOpen func()
OnReconnect func(attempt int)
OnStateChange func(ConnectionState)
Reconnect bool
MaxReconnect int
PingInterval time.Duration
}
StreamConfig holds configuration for WebSocket streaming.
func DefaultStreamConfig ¶
func DefaultStreamConfig() *StreamConfig
DefaultStreamConfig returns default stream configuration.
type StreamType ¶
type StreamType string
StreamType represents available WebSocket stream types.
const ( // QuickNode-supported streams StreamTypeTrades StreamType = "trades" StreamTypeOrders StreamType = "orders" StreamTypeBookUpdates StreamType = "book_updates" StreamTypeTWAP StreamType = "twap" StreamTypeEvents StreamType = "events" StreamTypeWriterActions StreamType = "writer_actions" // Public Hyperliquid API streams StreamTypeL2Book StreamType = "l2Book" StreamTypeAllMids StreamType = "allMids" StreamTypeCandle StreamType = "candle" StreamTypeBBO StreamType = "bbo" StreamTypeOpenOrders StreamType = "openOrders" StreamTypeOrderUpdates StreamType = "orderUpdates" StreamTypeUserEvents StreamType = "userEvents" StreamTypeUserFills StreamType = "userFills" StreamTypeUserFundings StreamType = "userFundings" StreamTypeUserNonFundingLedger StreamType = "userNonFundingLedgerUpdates" StreamTypeClearinghouseState StreamType = "clearinghouseState" StreamTypeActiveAssetCtx StreamType = "activeAssetCtx" StreamTypeActiveAssetData StreamType = "activeAssetData" StreamTypeTWAPStates StreamType = "twapStates" StreamTypeUserTWAPSliceFills StreamType = "userTwapSliceFills" StreamTypeUserTWAPHistory StreamType = "userTwapHistory" StreamTypeNotification StreamType = "notification" StreamTypeWebData3 StreamType = "webData3" )
type SubscribeOption ¶
type SubscribeOption func(*subscribeParams)
SubscribeOption is an option for subscriptions.
func SubscribeWithCoins ¶
func SubscribeWithCoins(coins ...string) SubscribeOption
SubscribeWithCoins filters by coins.
func SubscribeWithUsers ¶
func SubscribeWithUsers(users ...string) SubscribeOption
SubscribeWithUsers filters by users.
type TWAPOption ¶
type TWAPOption func(*twapParams)
TWAPOption is an option for TWAP orders.
func TWAPWithRandomize ¶
func TWAPWithRandomize(randomize bool) TWAPOption
TWAPWithRandomize enables/disables slice timing randomization.
func TWAPWithReduceOnly ¶
func TWAPWithReduceOnly() TWAPOption
TWAPWithReduceOnly marks the TWAP as reduce-only.
type TriggerOrderBuilder ¶
type TriggerOrderBuilder struct {
// contains filtered or unexported fields
}
TriggerOrderBuilder is a fluent builder for stop-loss and take-profit orders.
Examples:
// Stop loss: sell when price drops to 60000 (market)
TriggerOrder().StopLoss("BTC").Size(0.001).TriggerPrice(60000).Market()
// Stop loss: sell at limit 59900 when price drops to 60000
TriggerOrder().StopLoss("BTC").Size(0.001).TriggerPrice(60000).Limit(59900)
// Take profit: sell when price rises to 80000
TriggerOrder().TakeProfit("BTC").Size(0.001).TriggerPrice(80000).Market()
func TriggerOrder ¶
func TriggerOrder() *TriggerOrderBuilder
TriggerOrder creates a new trigger order builder.
func (*TriggerOrderBuilder) Asset ¶
func (t *TriggerOrderBuilder) Asset() string
Asset returns the order's asset.
func (*TriggerOrderBuilder) CLOID ¶
func (t *TriggerOrderBuilder) CLOID(cloid string) *TriggerOrderBuilder
CLOID sets the client order ID for tracking.
func (*TriggerOrderBuilder) GetLimitPrice ¶
func (t *TriggerOrderBuilder) GetLimitPrice() string
GetLimitPrice returns the order's limit price.
func (*TriggerOrderBuilder) GetSide ¶
func (t *TriggerOrderBuilder) GetSide() Side
GetSide returns the order's side.
func (*TriggerOrderBuilder) GetSize ¶
func (t *TriggerOrderBuilder) GetSize() string
GetSize returns the order's size.
func (*TriggerOrderBuilder) GetTriggerPrice ¶
func (t *TriggerOrderBuilder) GetTriggerPrice() string
GetTriggerPrice returns the order's trigger price.
func (*TriggerOrderBuilder) Limit ¶
func (t *TriggerOrderBuilder) Limit(price any) *TriggerOrderBuilder
Limit sets the order to execute as a limit order when triggered.
func (*TriggerOrderBuilder) Market ¶
func (t *TriggerOrderBuilder) Market() *TriggerOrderBuilder
Market sets the order to execute as a market order when triggered.
func (*TriggerOrderBuilder) ReduceOnly ¶
func (t *TriggerOrderBuilder) ReduceOnly() *TriggerOrderBuilder
ReduceOnly marks the order as reduce-only (close position only).
func (*TriggerOrderBuilder) SL ¶
func (t *TriggerOrderBuilder) SL(asset string) *TriggerOrderBuilder
SL is an alias for StopLoss.
func (*TriggerOrderBuilder) Side ¶
func (t *TriggerOrderBuilder) Side(side Side) *TriggerOrderBuilder
Side sets the order side when triggered (default: SELL for closing longs).
func (*TriggerOrderBuilder) Size ¶
func (t *TriggerOrderBuilder) Size(size any) *TriggerOrderBuilder
Size sets the order size in asset units.
func (*TriggerOrderBuilder) StopLoss ¶
func (t *TriggerOrderBuilder) StopLoss(asset string) *TriggerOrderBuilder
StopLoss creates a stop-loss trigger order.
Stop loss triggers when price moves against your position:
- For longs: triggers when price FALLS to trigger_price (sell to exit)
- For shorts: triggers when price RISES to trigger_price (buy to exit)
func (*TriggerOrderBuilder) String ¶
func (t *TriggerOrderBuilder) String() string
String returns a string representation of the trigger order.
func (*TriggerOrderBuilder) TP ¶
func (t *TriggerOrderBuilder) TP(asset string) *TriggerOrderBuilder
TP is an alias for TakeProfit.
func (*TriggerOrderBuilder) TakeProfit ¶
func (t *TriggerOrderBuilder) TakeProfit(asset string) *TriggerOrderBuilder
TakeProfit creates a take-profit trigger order.
Take profit triggers when price moves in favor of your position:
- For longs: triggers when price RISES to trigger_price (sell to take profits)
- For shorts: triggers when price FALLS to trigger_price (buy to take profits)
func (*TriggerOrderBuilder) ToAction ¶
func (t *TriggerOrderBuilder) ToAction(grouping OrderGrouping) map[string]any
ToAction converts the trigger order to an API action format.
func (*TriggerOrderBuilder) Trigger ¶
func (t *TriggerOrderBuilder) Trigger(price any) *TriggerOrderBuilder
Trigger is an alias for TriggerPrice.
func (*TriggerOrderBuilder) TriggerPrice ¶
func (t *TriggerOrderBuilder) TriggerPrice(price any) *TriggerOrderBuilder
TriggerPrice sets the price at which the order activates.
func (*TriggerOrderBuilder) Validate ¶
func (t *TriggerOrderBuilder) Validate() error
Validate validates the trigger order before sending.
type TriggerOrderOption ¶
type TriggerOrderOption func(*TriggerOrderBuilder)
TriggerOrderOption is an option for trigger order placement.
func TriggerWithGrouping ¶
func TriggerWithGrouping(grouping OrderGrouping) TriggerOrderOption
TriggerWithGrouping sets the grouping for trigger order.
func TriggerWithLimitPrice ¶
func TriggerWithLimitPrice(price any) TriggerOrderOption
TriggerWithLimitPrice sets the limit price for trigger order execution.
func TriggerWithSide ¶
func TriggerWithSide(side Side) TriggerOrderOption
TriggerWithSide sets the side for trigger order execution.
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
Wallet wraps an Ethereum private key for signing operations.
func NewWallet ¶
NewWallet creates a wallet from a hex-encoded private key. The private key can optionally include the "0x" prefix.
func (*Wallet) AddressString ¶
AddressString returns the wallet's Ethereum address as a hex string.