@nktkas/hyperliquid 0.24.2 → 0.25.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +197 -117
- package/esm/mod.d.ts +11 -11
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/esm/src/clients/exchange.d.ts +29 -18
- package/esm/src/clients/exchange.d.ts.map +1 -1
- package/esm/src/clients/exchange.js +50 -48
- package/esm/src/clients/info.d.ts +79 -75
- package/esm/src/clients/info.d.ts.map +1 -1
- package/esm/src/clients/info.js +294 -163
- package/esm/src/clients/multiSign.d.ts +11 -7
- package/esm/src/clients/multiSign.d.ts.map +1 -1
- package/esm/src/clients/subscription.d.ts +105 -32
- package/esm/src/clients/subscription.d.ts.map +1 -1
- package/esm/src/clients/subscription.js +114 -33
- package/esm/src/{base.d.ts → errors.d.ts} +1 -1
- package/esm/src/errors.d.ts.map +1 -0
- package/esm/src/schemas/_base.d.ts +10 -0
- package/esm/src/schemas/_base.d.ts.map +1 -0
- package/esm/src/schemas/_base.js +12 -0
- package/esm/src/schemas/exchange/requests.d.ts +8953 -0
- package/esm/src/schemas/exchange/requests.d.ts.map +1 -0
- package/esm/src/schemas/exchange/requests.js +1413 -0
- package/esm/src/schemas/exchange/responses.d.ts +567 -0
- package/esm/src/schemas/exchange/responses.d.ts.map +1 -0
- package/esm/src/schemas/exchange/responses.js +243 -0
- package/esm/src/schemas/explorer/requests.d.ts +44 -0
- package/esm/src/schemas/explorer/requests.d.ts.map +1 -0
- package/esm/src/schemas/explorer/requests.js +32 -0
- package/esm/src/schemas/explorer/responses.d.ts +360 -0
- package/esm/src/schemas/explorer/responses.d.ts.map +1 -0
- package/esm/src/schemas/explorer/responses.js +56 -0
- package/esm/src/schemas/info/accounts.d.ts +2159 -0
- package/esm/src/schemas/info/accounts.d.ts.map +1 -0
- package/esm/src/schemas/info/accounts.js +622 -0
- package/esm/src/schemas/info/assets.d.ts +945 -0
- package/esm/src/schemas/info/assets.d.ts.map +1 -0
- package/esm/src/schemas/info/assets.js +265 -0
- package/esm/src/schemas/info/markets.d.ts +138 -0
- package/esm/src/schemas/info/markets.d.ts.map +1 -0
- package/esm/src/schemas/info/markets.js +58 -0
- package/esm/src/schemas/info/orders.d.ts +957 -0
- package/esm/src/schemas/info/orders.d.ts.map +1 -0
- package/esm/src/schemas/info/orders.js +297 -0
- package/esm/src/schemas/info/requests.d.ts +882 -0
- package/esm/src/schemas/info/requests.d.ts.map +1 -0
- package/esm/src/schemas/info/requests.js +655 -0
- package/esm/src/schemas/info/validators.d.ts +305 -0
- package/esm/src/schemas/info/validators.d.ts.map +1 -0
- package/esm/src/schemas/info/validators.js +112 -0
- package/esm/src/schemas/info/vaults.d.ts +447 -0
- package/esm/src/schemas/info/vaults.d.ts.map +1 -0
- package/esm/src/schemas/info/vaults.js +110 -0
- package/esm/src/schemas/mod.d.ts +100 -0
- package/esm/src/schemas/mod.d.ts.map +1 -0
- package/esm/src/schemas/mod.js +113 -0
- package/esm/src/schemas/subscriptions/requests.d.ts +332 -0
- package/esm/src/schemas/subscriptions/requests.d.ts.map +1 -0
- package/esm/src/schemas/subscriptions/requests.js +258 -0
- package/esm/src/schemas/subscriptions/responses.d.ts +3643 -0
- package/esm/src/schemas/subscriptions/responses.d.ts.map +1 -0
- package/esm/src/schemas/subscriptions/responses.js +233 -0
- package/esm/src/signing/mod.d.ts +109 -29
- package/esm/src/signing/mod.d.ts.map +1 -1
- package/esm/src/signing/mod.js +135 -29
- package/esm/src/transports/base.d.ts +2 -2
- package/esm/src/transports/base.d.ts.map +1 -1
- package/esm/src/transports/base.js +2 -2
- package/esm/src/transports/http/http_transport.d.ts +2 -1
- package/esm/src/transports/http/http_transport.d.ts.map +1 -1
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
- package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
- package/esm/src/transports/websocket/websocket_transport.d.ts +2 -1
- package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/package.json +6 -5
- package/script/mod.d.ts +11 -11
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -1
- package/script/src/clients/exchange.d.ts +29 -18
- package/script/src/clients/exchange.d.ts.map +1 -1
- package/script/src/clients/exchange.js +56 -54
- package/script/src/clients/info.d.ts +79 -75
- package/script/src/clients/info.d.ts.map +1 -1
- package/script/src/clients/info.js +294 -163
- package/script/src/clients/multiSign.d.ts +11 -7
- package/script/src/clients/multiSign.d.ts.map +1 -1
- package/script/src/clients/subscription.d.ts +105 -32
- package/script/src/clients/subscription.d.ts.map +1 -1
- package/script/src/clients/subscription.js +114 -33
- package/script/src/{base.d.ts → errors.d.ts} +1 -1
- package/script/src/errors.d.ts.map +1 -0
- package/script/src/schemas/_base.d.ts +10 -0
- package/script/src/schemas/_base.d.ts.map +1 -0
- package/script/src/schemas/_base.js +48 -0
- package/script/src/schemas/exchange/requests.d.ts +8953 -0
- package/script/src/schemas/exchange/requests.d.ts.map +1 -0
- package/script/src/schemas/exchange/requests.js +1449 -0
- package/script/src/schemas/exchange/responses.d.ts +567 -0
- package/script/src/schemas/exchange/responses.d.ts.map +1 -0
- package/script/src/schemas/exchange/responses.js +279 -0
- package/script/src/schemas/explorer/requests.d.ts +44 -0
- package/script/src/schemas/explorer/requests.d.ts.map +1 -0
- package/script/src/schemas/explorer/requests.js +68 -0
- package/script/src/schemas/explorer/responses.d.ts +360 -0
- package/script/src/schemas/explorer/responses.d.ts.map +1 -0
- package/script/src/schemas/explorer/responses.js +92 -0
- package/script/src/schemas/info/accounts.d.ts +2159 -0
- package/script/src/schemas/info/accounts.d.ts.map +1 -0
- package/script/src/schemas/info/accounts.js +658 -0
- package/script/src/schemas/info/assets.d.ts +945 -0
- package/script/src/schemas/info/assets.d.ts.map +1 -0
- package/script/src/schemas/info/assets.js +301 -0
- package/script/src/schemas/info/markets.d.ts +138 -0
- package/script/src/schemas/info/markets.d.ts.map +1 -0
- package/script/src/schemas/info/markets.js +94 -0
- package/script/src/schemas/info/orders.d.ts +957 -0
- package/script/src/schemas/info/orders.d.ts.map +1 -0
- package/script/src/schemas/info/orders.js +333 -0
- package/script/src/schemas/info/requests.d.ts +882 -0
- package/script/src/schemas/info/requests.d.ts.map +1 -0
- package/script/src/schemas/info/requests.js +692 -0
- package/script/src/schemas/info/validators.d.ts +305 -0
- package/script/src/schemas/info/validators.d.ts.map +1 -0
- package/script/src/schemas/info/validators.js +148 -0
- package/script/src/schemas/info/vaults.d.ts +447 -0
- package/script/src/schemas/info/vaults.d.ts.map +1 -0
- package/script/src/schemas/info/vaults.js +146 -0
- package/script/src/schemas/mod.d.ts +100 -0
- package/script/src/schemas/mod.d.ts.map +1 -0
- package/script/src/schemas/mod.js +154 -0
- package/script/src/schemas/subscriptions/requests.d.ts +332 -0
- package/script/src/schemas/subscriptions/requests.d.ts.map +1 -0
- package/script/src/schemas/subscriptions/requests.js +294 -0
- package/script/src/schemas/subscriptions/responses.d.ts +3643 -0
- package/script/src/schemas/subscriptions/responses.d.ts.map +1 -0
- package/script/src/schemas/subscriptions/responses.js +269 -0
- package/script/src/signing/mod.d.ts +109 -29
- package/script/src/signing/mod.d.ts.map +1 -1
- package/script/src/signing/mod.js +137 -33
- package/script/src/transports/base.d.ts +2 -2
- package/script/src/transports/base.d.ts.map +1 -1
- package/script/src/transports/base.js +3 -3
- package/script/src/transports/http/http_transport.d.ts +2 -1
- package/script/src/transports/http/http_transport.d.ts.map +1 -1
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +1 -1
- package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
- package/script/src/transports/websocket/websocket_transport.d.ts +2 -1
- package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/esm/src/base.d.ts.map +0 -1
- package/esm/src/signing/_sorter.d.ts +0 -127
- package/esm/src/signing/_sorter.d.ts.map +0 -1
- package/esm/src/signing/_sorter.js +0 -693
- package/esm/src/types/exchange/requests.d.ts +0 -1345
- package/esm/src/types/exchange/requests.d.ts.map +0 -1
- package/esm/src/types/exchange/requests.js +0 -1
- package/esm/src/types/exchange/responses.d.ts +0 -233
- package/esm/src/types/exchange/responses.d.ts.map +0 -1
- package/esm/src/types/exchange/responses.js +0 -1
- package/esm/src/types/explorer/requests.d.ts +0 -32
- package/esm/src/types/explorer/requests.d.ts.map +0 -1
- package/esm/src/types/explorer/requests.js +0 -1
- package/esm/src/types/explorer/responses.d.ts +0 -58
- package/esm/src/types/explorer/responses.d.ts.map +0 -1
- package/esm/src/types/explorer/responses.js +0 -1
- package/esm/src/types/info/accounts.d.ts +0 -864
- package/esm/src/types/info/accounts.d.ts.map +0 -1
- package/esm/src/types/info/accounts.js +0 -1
- package/esm/src/types/info/assets.d.ts +0 -354
- package/esm/src/types/info/assets.d.ts.map +0 -1
- package/esm/src/types/info/assets.js +0 -1
- package/esm/src/types/info/markets.d.ts +0 -79
- package/esm/src/types/info/markets.d.ts.map +0 -1
- package/esm/src/types/info/markets.js +0 -1
- package/esm/src/types/info/orders.d.ts +0 -266
- package/esm/src/types/info/orders.d.ts.map +0 -1
- package/esm/src/types/info/orders.js +0 -1
- package/esm/src/types/info/requests.d.ts +0 -634
- package/esm/src/types/info/requests.d.ts.map +0 -1
- package/esm/src/types/info/requests.js +0 -1
- package/esm/src/types/info/validators.d.ts +0 -147
- package/esm/src/types/info/validators.d.ts.map +0 -1
- package/esm/src/types/info/validators.js +0 -1
- package/esm/src/types/info/vaults.d.ts +0 -119
- package/esm/src/types/info/vaults.d.ts.map +0 -1
- package/esm/src/types/info/vaults.js +0 -1
- package/esm/src/types/mod.d.ts +0 -38
- package/esm/src/types/mod.d.ts.map +0 -1
- package/esm/src/types/mod.js +0 -24
- package/esm/src/types/subscriptions/requests.d.ts +0 -143
- package/esm/src/types/subscriptions/requests.d.ts.map +0 -1
- package/esm/src/types/subscriptions/requests.js +0 -1
- package/esm/src/types/subscriptions/responses.d.ts +0 -213
- package/esm/src/types/subscriptions/responses.d.ts.map +0 -1
- package/esm/src/types/subscriptions/responses.js +0 -1
- package/script/src/base.d.ts.map +0 -1
- package/script/src/signing/_sorter.d.ts +0 -127
- package/script/src/signing/_sorter.d.ts.map +0 -1
- package/script/src/signing/_sorter.js +0 -696
- package/script/src/types/exchange/requests.d.ts +0 -1345
- package/script/src/types/exchange/requests.d.ts.map +0 -1
- package/script/src/types/exchange/requests.js +0 -2
- package/script/src/types/exchange/responses.d.ts +0 -233
- package/script/src/types/exchange/responses.d.ts.map +0 -1
- package/script/src/types/exchange/responses.js +0 -2
- package/script/src/types/explorer/requests.d.ts +0 -32
- package/script/src/types/explorer/requests.d.ts.map +0 -1
- package/script/src/types/explorer/requests.js +0 -2
- package/script/src/types/explorer/responses.d.ts +0 -58
- package/script/src/types/explorer/responses.d.ts.map +0 -1
- package/script/src/types/explorer/responses.js +0 -2
- package/script/src/types/info/accounts.d.ts +0 -864
- package/script/src/types/info/accounts.d.ts.map +0 -1
- package/script/src/types/info/accounts.js +0 -2
- package/script/src/types/info/assets.d.ts +0 -354
- package/script/src/types/info/assets.d.ts.map +0 -1
- package/script/src/types/info/assets.js +0 -2
- package/script/src/types/info/markets.d.ts +0 -79
- package/script/src/types/info/markets.d.ts.map +0 -1
- package/script/src/types/info/markets.js +0 -2
- package/script/src/types/info/orders.d.ts +0 -266
- package/script/src/types/info/orders.d.ts.map +0 -1
- package/script/src/types/info/orders.js +0 -2
- package/script/src/types/info/requests.d.ts +0 -634
- package/script/src/types/info/requests.d.ts.map +0 -1
- package/script/src/types/info/requests.js +0 -2
- package/script/src/types/info/validators.d.ts +0 -147
- package/script/src/types/info/validators.d.ts.map +0 -1
- package/script/src/types/info/validators.js +0 -2
- package/script/src/types/info/vaults.d.ts +0 -119
- package/script/src/types/info/vaults.d.ts.map +0 -1
- package/script/src/types/info/vaults.js +0 -2
- package/script/src/types/mod.d.ts +0 -38
- package/script/src/types/mod.d.ts.map +0 -1
- package/script/src/types/mod.js +0 -25
- package/script/src/types/subscriptions/requests.d.ts +0 -143
- package/script/src/types/subscriptions/requests.d.ts.map +0 -1
- package/script/src/types/subscriptions/requests.js +0 -2
- package/script/src/types/subscriptions/responses.d.ts +0 -213
- package/script/src/types/subscriptions/responses.d.ts.map +0 -1
- package/script/src/types/subscriptions/responses.js +0 -2
- /package/esm/src/{base.js → errors.js} +0 -0
- /package/script/src/{base.js → errors.js} +0 -0
package/README.md
CHANGED
|
@@ -396,76 +396,76 @@ class InfoClient {
|
|
|
396
396
|
});
|
|
397
397
|
|
|
398
398
|
// Market
|
|
399
|
-
allMids(): Promise<AllMids>;
|
|
400
|
-
candleSnapshot(
|
|
401
|
-
fundingHistory(
|
|
402
|
-
l2Book(
|
|
399
|
+
allMids(params?: AllMidsParameters): Promise<AllMids>;
|
|
400
|
+
candleSnapshot(params: CandleSnapshotParameters): Promise<Candle[]>;
|
|
401
|
+
fundingHistory(params: FundingHistoryParameters): Promise<FundingHistory[]>;
|
|
402
|
+
l2Book(params: L2BookParameters): Promise<Book>;
|
|
403
403
|
liquidatable(): Promise<unknown[]>;
|
|
404
|
-
marginTable(
|
|
404
|
+
marginTable(params: MarginTableParameters): Promise<MarginTable>;
|
|
405
405
|
maxMarketOrderNtls(): Promise<[number, string][]>;
|
|
406
|
-
meta(): Promise<PerpsMeta>;
|
|
407
|
-
metaAndAssetCtxs(): Promise<PerpsMetaAndAssetCtxs>;
|
|
406
|
+
meta(params?: MetaParameters): Promise<PerpsMeta>;
|
|
407
|
+
metaAndAssetCtxs(params?: MetaAndAssetCtxsParameters): Promise<PerpsMetaAndAssetCtxs>;
|
|
408
408
|
perpDeployAuctionStatus(): Promise<DeployAuctionStatus>;
|
|
409
409
|
perpDexs(): Promise<(PerpDex | null)[]>;
|
|
410
|
-
perpsAtOpenInterestCap(): Promise<string[]>;
|
|
410
|
+
perpsAtOpenInterestCap(params?: PerpsAtOpenInterestCapParameters): Promise<string[]>;
|
|
411
411
|
predictedFundings(): Promise<PredictedFunding[]>;
|
|
412
|
-
spotDeployState(
|
|
412
|
+
spotDeployState(params: SpotDeployStateParameters): Promise<SpotDeployState>;
|
|
413
413
|
spotMeta(): Promise<SpotMeta>;
|
|
414
414
|
spotMetaAndAssetCtxs(): Promise<SpotMetaAndAssetCtxs>;
|
|
415
415
|
spotPairDeployAuctionStatus(): Promise<DeployAuctionStatus>;
|
|
416
|
-
tokenDetails(
|
|
416
|
+
tokenDetails(params: TokenDetailsParameters): Promise<TokenDetails>;
|
|
417
417
|
|
|
418
418
|
// Account
|
|
419
|
-
activeAssetData(
|
|
420
|
-
clearinghouseState(
|
|
421
|
-
extraAgents(
|
|
422
|
-
isVip(
|
|
423
|
-
legalCheck(
|
|
424
|
-
maxBuilderFee(
|
|
425
|
-
portfolio(
|
|
426
|
-
preTransferCheck(
|
|
427
|
-
referral(
|
|
428
|
-
spotClearinghouseState(
|
|
429
|
-
subAccounts(
|
|
430
|
-
userFees(
|
|
431
|
-
userFunding(
|
|
432
|
-
userNonFundingLedgerUpdates(
|
|
433
|
-
userRateLimit(
|
|
434
|
-
userRole(
|
|
435
|
-
userToMultiSigSigners(
|
|
419
|
+
activeAssetData(params: ActiveAssetDataParameters): Promise<ActiveAssetData>;
|
|
420
|
+
clearinghouseState(params: ClearinghouseStateParameters): Promise<PerpsClearinghouseState>;
|
|
421
|
+
extraAgents(params: ExtraAgentsParameters): Promise<ExtraAgent[]>;
|
|
422
|
+
isVip(params: IsVipParameters): Promise<boolean | null>;
|
|
423
|
+
legalCheck(params: LegalCheckParameters): Promise<LegalCheck>;
|
|
424
|
+
maxBuilderFee(params: MaxBuilderFeeParameters): Promise<number>;
|
|
425
|
+
portfolio(params: PortfolioParameters): Promise<PortfolioPeriods>;
|
|
426
|
+
preTransferCheck(params: PreTransferCheckParameters): Promise<PreTransferCheck>;
|
|
427
|
+
referral(params: ReferralParameters): Promise<Referral>;
|
|
428
|
+
spotClearinghouseState(params: SpotClearinghouseStateParameters): Promise<SpotClearinghouseState>;
|
|
429
|
+
subAccounts(params: SubAccountsParameters): Promise<SubAccount[] | null>;
|
|
430
|
+
userFees(params: UserFeesParameters): Promise<UserFees>;
|
|
431
|
+
userFunding(params: UserFundingParameters): Promise<UserFundingUpdate[]>;
|
|
432
|
+
userNonFundingLedgerUpdates(params: UserNonFundingLedgerUpdatesParameters): Promise<UserNonFundingLedgerUpdate[]>;
|
|
433
|
+
userRateLimit(params: UserRateLimitParameters): Promise<UserRateLimit>;
|
|
434
|
+
userRole(params: UserRoleParameters): Promise<UserRole>;
|
|
435
|
+
userToMultiSigSigners(params: UserToMultiSigSignersParameters): Promise<MultiSigSigners | null>;
|
|
436
436
|
|
|
437
437
|
// Order
|
|
438
|
-
frontendOpenOrders(
|
|
439
|
-
historicalOrders(
|
|
440
|
-
openOrders(
|
|
441
|
-
orderStatus(
|
|
442
|
-
twapHistory(
|
|
443
|
-
userFills(
|
|
444
|
-
userFillsByTime(
|
|
445
|
-
userTwapSliceFills(
|
|
446
|
-
userTwapSliceFillsByTime(
|
|
438
|
+
frontendOpenOrders(params: FrontendOpenOrdersParameters): Promise<FrontendOrder[]>;
|
|
439
|
+
historicalOrders(params: HistoricalOrdersParameters): Promise<FrontendOrderStatus[]>;
|
|
440
|
+
openOrders(params: OpenOrdersParameters): Promise<Order[]>;
|
|
441
|
+
orderStatus(params: OrderStatusParameters): Promise<OrderLookup>;
|
|
442
|
+
twapHistory(params: TwapHistoryParameters): Promise<TwapHistory[]>;
|
|
443
|
+
userFills(params: UserFillsParameters): Promise<Fill[]>;
|
|
444
|
+
userFillsByTime(params: UserFillsByTimeParameters): Promise<Fill[]>;
|
|
445
|
+
userTwapSliceFills(params: UserTwapSliceFillsParameters): Promise<TwapSliceFill[]>;
|
|
446
|
+
userTwapSliceFillsByTime(params: UserTwapSliceFillsByTimeParameters): Promise<TwapSliceFill[]>;
|
|
447
447
|
|
|
448
448
|
// Validator
|
|
449
|
-
delegations(
|
|
450
|
-
delegatorHistory(
|
|
451
|
-
delegatorRewards(
|
|
452
|
-
delegatorSummary(
|
|
449
|
+
delegations(params: DelegationsParameters): Promise<Delegation[]>;
|
|
450
|
+
delegatorHistory(params: DelegatorHistoryParameters): Promise<DelegatorUpdate[]>;
|
|
451
|
+
delegatorRewards(params: DelegatorRewardsParameters): Promise<DelegatorReward[]>;
|
|
452
|
+
delegatorSummary(params: DelegatorSummaryParameters): Promise<DelegatorSummary>;
|
|
453
453
|
validatorL1Votes(): Promise<unknown[]>;
|
|
454
454
|
validatorSummaries(): Promise<ValidatorSummary[]>;
|
|
455
455
|
|
|
456
456
|
// Vault
|
|
457
|
-
leadingVaults(
|
|
458
|
-
userVaultEquities(
|
|
459
|
-
vaultDetails(
|
|
457
|
+
leadingVaults(params: LeadingVaultsParameters): Promise<VaultLeading[]>;
|
|
458
|
+
userVaultEquities(params: UserVaultEquitiesParameters): Promise<VaultEquity[]>;
|
|
459
|
+
vaultDetails(params: VaultDetailsParameters): Promise<VaultDetails | null>;
|
|
460
460
|
vaultSummaries(): Promise<VaultSummary[]>;
|
|
461
461
|
|
|
462
462
|
// Server
|
|
463
463
|
exchangeStatus(): Promise<ExchangeStatus>;
|
|
464
464
|
|
|
465
465
|
// Explorer (RPC endpoint)
|
|
466
|
-
blockDetails(
|
|
467
|
-
txDetails(
|
|
468
|
-
userDetails(
|
|
466
|
+
blockDetails(params: BlockDetailsParameters): Promise<BlockDetails>;
|
|
467
|
+
txDetails(params: TxDetailsParameters): Promise<TxDetails>;
|
|
468
|
+
userDetails(params: UserDetailsParameters): Promise<TxDetails[]>;
|
|
469
469
|
}
|
|
470
470
|
```
|
|
471
471
|
|
|
@@ -483,62 +483,70 @@ class ExchangeClient {
|
|
|
483
483
|
});
|
|
484
484
|
|
|
485
485
|
// Order
|
|
486
|
-
batchModify(
|
|
487
|
-
cancel(
|
|
488
|
-
cancelByCloid(
|
|
489
|
-
modify(
|
|
490
|
-
order(
|
|
491
|
-
scheduleCancel(
|
|
492
|
-
twapCancel(
|
|
493
|
-
twapOrder(
|
|
494
|
-
updateIsolatedMargin(
|
|
495
|
-
updateLeverage(
|
|
486
|
+
batchModify(params: BatchModifyParameters): Promise<OrderResponseSuccess>;
|
|
487
|
+
cancel(params: CancelParameters): Promise<CancelResponseSuccess>;
|
|
488
|
+
cancelByCloid(params: CancelByCloidParameters): Promise<CancelResponseSuccess>;
|
|
489
|
+
modify(params: ModifyParameters): Promise<SuccessResponse>;
|
|
490
|
+
order(params: OrderParameters): Promise<OrderResponseSuccess>;
|
|
491
|
+
scheduleCancel(params?: ScheduleCancelParameters): Promise<SuccessResponse>;
|
|
492
|
+
twapCancel(params: TwapCancelParameters): Promise<TwapCancelResponseSuccess>;
|
|
493
|
+
twapOrder(params: TwapOrderParameters): Promise<TwapOrderResponseSuccess>;
|
|
494
|
+
updateIsolatedMargin(params: UpdateIsolatedMarginParameters): Promise<SuccessResponse>;
|
|
495
|
+
updateLeverage(params: UpdateLeverageParameters): Promise<SuccessResponse>;
|
|
496
496
|
|
|
497
497
|
// Account
|
|
498
|
-
approveAgent(
|
|
499
|
-
approveBuilderFee(
|
|
498
|
+
approveAgent(params: ApproveAgentParameters): Promise<SuccessResponse>;
|
|
499
|
+
approveBuilderFee(params: ApproveBuilderFeeParameters): Promise<SuccessResponse>;
|
|
500
500
|
claimRewards(): Promise<SuccessResponse>;
|
|
501
|
-
createSubAccount(
|
|
502
|
-
evmUserModify(
|
|
501
|
+
createSubAccount(params: CreateSubAccountParameters): Promise<CreateSubAccountResponse>;
|
|
502
|
+
evmUserModify(params: EvmUserModifyParameters): Promise<SuccessResponse>;
|
|
503
503
|
noop(): Promise<SuccessResponse>;
|
|
504
|
-
registerReferrer(
|
|
505
|
-
reserveRequestWeight(
|
|
506
|
-
setDisplayName(
|
|
507
|
-
setReferrer(
|
|
508
|
-
subAccountModify(
|
|
509
|
-
spotUser(
|
|
504
|
+
registerReferrer(params: RegisterReferrerParameters): Promise<SuccessResponse>;
|
|
505
|
+
reserveRequestWeight(params: ReserveRequestWeightParameters): Promise<SuccessResponse>;
|
|
506
|
+
setDisplayName(params: SetDisplayNameParameters): Promise<SuccessResponse>;
|
|
507
|
+
setReferrer(params: SetReferrerParameters): Promise<SuccessResponse>;
|
|
508
|
+
subAccountModify(params: SubAccountModifyParameters): Promise<SuccessResponse>;
|
|
509
|
+
spotUser(params: SpotUserParameters): Promise<SuccessResponse>;
|
|
510
510
|
|
|
511
511
|
// Transfer
|
|
512
|
-
sendAsset(
|
|
513
|
-
spotSend(
|
|
514
|
-
subAccountSpotTransfer(
|
|
515
|
-
subAccountTransfer(
|
|
516
|
-
usdClassTransfer(
|
|
517
|
-
usdSend(
|
|
518
|
-
withdraw3(
|
|
512
|
+
sendAsset(params: SendAssetParameters): Promise<SuccessResponse>;
|
|
513
|
+
spotSend(params: SpotSendParameters): Promise<SuccessResponse>;
|
|
514
|
+
subAccountSpotTransfer(params: SubAccountSpotTransferParameters): Promise<SuccessResponse>;
|
|
515
|
+
subAccountTransfer(params: SubAccountTransferParameters): Promise<SuccessResponse>;
|
|
516
|
+
usdClassTransfer(params: UsdClassTransferParameters): Promise<SuccessResponse>;
|
|
517
|
+
usdSend(params: UsdSendParameters): Promise<SuccessResponse>;
|
|
518
|
+
withdraw3(params: Withdraw3Parameters): Promise<SuccessResponse>;
|
|
519
519
|
|
|
520
520
|
// Staking
|
|
521
|
-
cDeposit(
|
|
522
|
-
cWithdraw(
|
|
523
|
-
tokenDelegate(
|
|
521
|
+
cDeposit(params: CDepositParameters): Promise<SuccessResponse>;
|
|
522
|
+
cWithdraw(params: CWithdrawParameters): Promise<SuccessResponse>;
|
|
523
|
+
tokenDelegate(params: TokenDelegateParameters): Promise<SuccessResponse>;
|
|
524
524
|
|
|
525
525
|
// Market
|
|
526
|
-
perpDeploy(
|
|
527
|
-
spotDeploy(
|
|
526
|
+
perpDeploy(params: PerpDeployParameters): Promise<SuccessResponse>;
|
|
527
|
+
spotDeploy(params: SpotDeployParameters): Promise<SuccessResponse>;
|
|
528
528
|
|
|
529
529
|
// Vault
|
|
530
|
-
createVault(
|
|
531
|
-
vaultDistribute(
|
|
532
|
-
vaultModify(
|
|
533
|
-
vaultTransfer(
|
|
530
|
+
createVault(params: CreateVaultParameters): Promise<CreateVaultResponse>;
|
|
531
|
+
vaultDistribute(params: VaultDistributeParameters): Promise<SuccessResponse>;
|
|
532
|
+
vaultModify(params: VaultModifyParameters): Promise<SuccessResponse>;
|
|
533
|
+
vaultTransfer(params: VaultTransferParameters): Promise<SuccessResponse>;
|
|
534
534
|
|
|
535
535
|
// Multi-Sign
|
|
536
|
-
convertToMultiSigUser(
|
|
537
|
-
multiSig(
|
|
536
|
+
convertToMultiSigUser(params: ConvertToMultiSigUserParameters): Promise<SuccessResponse>;
|
|
537
|
+
multiSig(params: MultiSigParameters): Promise<
|
|
538
|
+
| SuccessResponse
|
|
539
|
+
| CancelSuccessResponse
|
|
540
|
+
| CreateSubAccountResponse
|
|
541
|
+
| CreateVaultResponse
|
|
542
|
+
| OrderSuccessResponse
|
|
543
|
+
| TwapOrderSuccessResponse
|
|
544
|
+
| TwapCancelSuccessResponse
|
|
545
|
+
>;
|
|
538
546
|
|
|
539
547
|
// Validator
|
|
540
|
-
cSignerAction(
|
|
541
|
-
cValidatorAction(
|
|
548
|
+
cSignerAction(params: CSignerActionParameters): Promise<SuccessResponse>;
|
|
549
|
+
cValidatorAction(params: CValidatorActionParameters): Promise<SuccessResponse>;
|
|
542
550
|
}
|
|
543
551
|
```
|
|
544
552
|
|
|
@@ -552,26 +560,29 @@ class SubscriptionClient {
|
|
|
552
560
|
});
|
|
553
561
|
|
|
554
562
|
// Market
|
|
555
|
-
activeAssetCtx(
|
|
556
|
-
allMids(listener: (data: WsAllMids) => void): Promise<Subscription>;
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
563
|
+
activeAssetCtx(params: WsActiveAssetCtxParameters, listener: (data: WsActiveAssetCtx | WsActiveSpotAssetCtx) => void): Promise<Subscription>;
|
|
564
|
+
allMids(params?: WsAllMidsParameters, listener: (data: WsAllMids) => void): Promise<Subscription>;
|
|
565
|
+
assetCtxs(params?: WsAssetCtxsParameters, listener: (data: WsAssetCtxs) => void): Promise<Subscription>;
|
|
566
|
+
bbo(params: WsBboParameters, listener: (data: WsBbo) => void): Promise<Subscription>;
|
|
567
|
+
candle(params: WsCandleParameters, listener: (data: Candle) => void): Promise<Subscription>;
|
|
568
|
+
l2Book(params: WsL2BookParameters, listener: (data: Book) => void): Promise<Subscription>;
|
|
569
|
+
trades(params: WsTradesParameters, listener: (data: WsTrade[]) => void): Promise<Subscription>;
|
|
561
570
|
|
|
562
571
|
// Account
|
|
563
|
-
activeAssetData(
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
572
|
+
activeAssetData(params: WsActiveAssetDataParameters, listener: (data: ActiveAssetData) => void): Promise<Subscription>;
|
|
573
|
+
clearinghouseState(params: WsClearinghouseStateParameters, listener: (data: WsClearinghouseState) => void): Promise<Subscription>;
|
|
574
|
+
notification(params: WsNotificationParameters, listener: (data: WsNotification) => void): Promise<Subscription>;
|
|
575
|
+
userEvents(params: WsUserEventsParameters, listener: (data: WsUserEvent) => void): Promise<Subscription>;
|
|
576
|
+
userFundings(params: WsUserFundingsParameters, listener: (data: WsUserFundings) => void): Promise<Subscription>;
|
|
577
|
+
userNonFundingLedgerUpdates(params: WsUserNonFundingLedgerUpdatesParameters, listener: (data: WsUserNonFundingLedgerUpdates) => void): Promise<Subscription>;
|
|
578
|
+
webData2(params: WsWebData2Parameters, listener: (data: WsWebData2) => void): Promise<Subscription>;
|
|
569
579
|
|
|
570
580
|
// Order
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
581
|
+
openOrders(params: WsOpenOrdersParameters, listener: (data: WsOpenOrders) => void): Promise<Subscription>;
|
|
582
|
+
orderUpdates(params: WsOrderUpdatesParameters, listener: (data: OrderStatus[]) => void): Promise<Subscription>;
|
|
583
|
+
userFills(params: WsUserFillsParameters, listener: (data: WsUserFills) => void): Promise<Subscription>;
|
|
584
|
+
userTwapHistory(params: WsUserTwapHistoryParameters, listener: (data: WsUserTwapHistory) => void): Promise<Subscription>;
|
|
585
|
+
userTwapSliceFills(params: WsUserTwapSliceFillsParameters, listener: (data: WsUserTwapSliceFills) => void): Promise<Subscription>;
|
|
575
586
|
|
|
576
587
|
// Explorer (RPC endpoint)
|
|
577
588
|
explorerBlock(listener: (data: WsBlockDetails[]) => void): Promise<Subscription>;
|
|
@@ -670,20 +681,90 @@ class WebSocketTransport {
|
|
|
670
681
|
|
|
671
682
|
## Additional Import Points
|
|
672
683
|
|
|
673
|
-
### `/
|
|
684
|
+
### `/schemas`
|
|
674
685
|
|
|
675
|
-
|
|
686
|
+
This module provides [valibot](https://valibot.dev) schemas for validating, formatting, and inferring types for data
|
|
687
|
+
used in the Hyperliquid API.
|
|
688
|
+
|
|
689
|
+
```ts
|
|
690
|
+
import { OrderRequest, parser } from "@nktkas/hyperliquid/schemas";
|
|
691
|
+
// ^^^^^^^^^^^^
|
|
692
|
+
// both a valibot schema and a typescript type
|
|
693
|
+
|
|
694
|
+
const action = {
|
|
695
|
+
type: "order",
|
|
696
|
+
orders: [{
|
|
697
|
+
a: 0,
|
|
698
|
+
b: true,
|
|
699
|
+
p: "50000",
|
|
700
|
+
s: "0.1",
|
|
701
|
+
r: false,
|
|
702
|
+
t: { limit: { tif: "Gtc" } },
|
|
703
|
+
}],
|
|
704
|
+
grouping: "na",
|
|
705
|
+
} satisfies OrderRequest["action"]; // can be used as type
|
|
706
|
+
|
|
707
|
+
// or as valibot schema
|
|
708
|
+
// ⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄
|
|
709
|
+
const validatedAction = parser(OrderRequest.entries.action)(action);
|
|
710
|
+
// ^^^^^^
|
|
711
|
+
// validates, formats, sorts object keys for correct signature generation
|
|
712
|
+
// and returns typed data
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
Also valibot schema can be converted to JSON Schema:
|
|
716
|
+
|
|
717
|
+
```ts
|
|
718
|
+
import { OrderRequest } from "@nktkas/hyperliquid/schemas";
|
|
719
|
+
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
720
|
+
|
|
721
|
+
const schema = toJsonSchema(OrderRequest, { errorMode: "ignore" });
|
|
722
|
+
|
|
723
|
+
console.log(JSON.stringify(schema, null, 2));
|
|
724
|
+
// {
|
|
725
|
+
// "$schema": "http://json-schema.org/draft-07/schema#",
|
|
726
|
+
// "type": "object",
|
|
727
|
+
// "properties": {
|
|
728
|
+
// "action": {
|
|
729
|
+
// "type": "object",
|
|
730
|
+
// "properties": {
|
|
731
|
+
// "type": { "const": "order" },
|
|
732
|
+
// "orders": { "type": "array", "items": {...} },
|
|
733
|
+
// "grouping": { "anyOf": [...] },
|
|
734
|
+
// "builder": { "type": "object", ... }
|
|
735
|
+
// },
|
|
736
|
+
// "required": ["type", "orders", "grouping"]
|
|
737
|
+
// },
|
|
738
|
+
// "nonce": { "type": "number" },
|
|
739
|
+
// "signature": {
|
|
740
|
+
// "type": "object",
|
|
741
|
+
// "properties": {
|
|
742
|
+
// "r": { "type": "string", ... },
|
|
743
|
+
// "s": { "type": "string", ... },
|
|
744
|
+
// "v": { "anyOf": [{"const": 27}, {"const": 28}] }
|
|
745
|
+
// },
|
|
746
|
+
// "required": ["r", "s", "v"]
|
|
747
|
+
// },
|
|
748
|
+
// "vaultAddress": { "type": "string", ... },
|
|
749
|
+
// "expiresAfter": { "type": "number" }
|
|
750
|
+
// },
|
|
751
|
+
// "required": ["action", "nonce", "signature"]
|
|
752
|
+
// }
|
|
753
|
+
```
|
|
676
754
|
|
|
677
755
|
### `/signing`
|
|
678
756
|
|
|
679
|
-
|
|
757
|
+
This module contains functions for generating Hyperliquid transaction signatures.
|
|
680
758
|
|
|
681
759
|
#### L1 Action
|
|
682
760
|
|
|
683
761
|
```ts
|
|
684
|
-
import {
|
|
762
|
+
import { signL1Action } from "@nktkas/hyperliquid/signing";
|
|
763
|
+
import { CancelRequest, parser } from "@nktkas/hyperliquid/schemas";
|
|
764
|
+
|
|
765
|
+
const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
685
766
|
|
|
686
|
-
const action =
|
|
767
|
+
const action = parser(CancelRequest.entries.action)({ // for correct signature generation
|
|
687
768
|
type: "cancel",
|
|
688
769
|
cancels: [
|
|
689
770
|
{ a: 0, o: 12345 },
|
|
@@ -691,17 +772,13 @@ const action = actionSorter.cancel({
|
|
|
691
772
|
});
|
|
692
773
|
const nonce = Date.now();
|
|
693
774
|
|
|
694
|
-
const signature = await signL1Action({
|
|
695
|
-
wallet: "0x...", // `viem`, `ethers`, or private key directly
|
|
696
|
-
action,
|
|
697
|
-
nonce,
|
|
698
|
-
});
|
|
775
|
+
const signature = await signL1Action({ wallet: privateKey, action, nonce });
|
|
699
776
|
|
|
700
777
|
// Send the signed action to the Hyperliquid API
|
|
701
778
|
const response = await fetch("https://api.hyperliquid.xyz/exchange", {
|
|
702
779
|
method: "POST",
|
|
703
780
|
headers: { "Content-Type": "application/json" },
|
|
704
|
-
body: JSON.stringify({ action, signature, nonce }),
|
|
781
|
+
body: JSON.stringify({ action, signature, nonce }),
|
|
705
782
|
});
|
|
706
783
|
const body = await response.json();
|
|
707
784
|
```
|
|
@@ -709,9 +786,12 @@ const body = await response.json();
|
|
|
709
786
|
#### User Signed Action
|
|
710
787
|
|
|
711
788
|
```ts
|
|
712
|
-
import {
|
|
789
|
+
import { signUserSignedAction, userSignedActionEip712Types } from "@nktkas/hyperliquid/signing";
|
|
790
|
+
import { ApproveAgentRequest, parser } from "@nktkas/hyperliquid/schemas";
|
|
713
791
|
|
|
714
|
-
const
|
|
792
|
+
const privateKey = "0x..."; // `viem`, `ethers`, or private key directly
|
|
793
|
+
|
|
794
|
+
const action = parser(ApproveAgentRequest.entries.action)({ // for correct signature generation
|
|
715
795
|
type: "approveAgent",
|
|
716
796
|
signatureChainId: "0x66eee",
|
|
717
797
|
hyperliquidChain: "Mainnet",
|
|
@@ -721,7 +801,7 @@ const action = actionSorter.approveAgent({
|
|
|
721
801
|
});
|
|
722
802
|
|
|
723
803
|
const signature = await signUserSignedAction({
|
|
724
|
-
wallet:
|
|
804
|
+
wallet: privateKey,
|
|
725
805
|
action,
|
|
726
806
|
types: userSignedActionEip712Types[action.type],
|
|
727
807
|
});
|
|
@@ -730,7 +810,7 @@ const signature = await signUserSignedAction({
|
|
|
730
810
|
const response = await fetch("https://api.hyperliquid.xyz/exchange", {
|
|
731
811
|
method: "POST",
|
|
732
812
|
headers: { "Content-Type": "application/json" },
|
|
733
|
-
body: JSON.stringify({ action, signature, nonce: action.nonce }),
|
|
813
|
+
body: JSON.stringify({ action, signature, nonce: action.nonce }),
|
|
734
814
|
});
|
|
735
815
|
const body = await response.json();
|
|
736
816
|
```
|
package/esm/mod.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./src/
|
|
1
|
+
export * from "./src/errors.js";
|
|
2
2
|
export * from "./src/transports/base.js";
|
|
3
3
|
export type { AbstractWallet } from "./src/signing/mod.js";
|
|
4
4
|
export * from "./src/clients/exchange.js";
|
|
@@ -7,14 +7,14 @@ export * from "./src/clients/multiSign.js";
|
|
|
7
7
|
export * from "./src/clients/subscription.js";
|
|
8
8
|
export * from "./src/transports/http/http_transport.js";
|
|
9
9
|
export * from "./src/transports/websocket/websocket_transport.js";
|
|
10
|
-
export type { OrderParams, Signature } from "./src/
|
|
11
|
-
export type * from "./src/
|
|
12
|
-
export type * from "./src/
|
|
13
|
-
export type * from "./src/
|
|
14
|
-
export type * from "./src/
|
|
15
|
-
export type * from "./src/
|
|
16
|
-
export type * from "./src/
|
|
17
|
-
export type * from "./src/
|
|
18
|
-
export type * from "./src/
|
|
19
|
-
export type * from "./src/
|
|
10
|
+
export type { OrderParams, Signature } from "./src/schemas/exchange/requests.js";
|
|
11
|
+
export type * from "./src/schemas/exchange/responses.js";
|
|
12
|
+
export type * from "./src/schemas/explorer/responses.js";
|
|
13
|
+
export type * from "./src/schemas/info/accounts.js";
|
|
14
|
+
export type * from "./src/schemas/info/assets.js";
|
|
15
|
+
export type * from "./src/schemas/info/validators.js";
|
|
16
|
+
export type * from "./src/schemas/info/markets.js";
|
|
17
|
+
export type * from "./src/schemas/info/orders.js";
|
|
18
|
+
export type * from "./src/schemas/info/vaults.js";
|
|
19
|
+
export type * from "./src/schemas/subscriptions/responses.js";
|
|
20
20
|
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AACA,cAAc,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AAGzC,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAG9C,cAAc,yCAAyC,CAAC;AACxD,cAAc,mDAAmD,CAAC;AAGlE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACjF,mBAAmB,qCAAqC,CAAC;AACzD,mBAAmB,qCAAqC,CAAC;AACzD,mBAAmB,gCAAgC,CAAC;AACpD,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,kCAAkC,CAAC;AACtD,mBAAmB,+BAA+B,CAAC;AACnD,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,0CAA0C,CAAC"}
|
package/esm/mod.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HyperliquidError } from "../
|
|
1
|
+
import { HyperliquidError } from "../errors.js";
|
|
2
2
|
import type { IRequestTransport } from "../transports/base.js";
|
|
3
|
-
import
|
|
4
|
-
import { type AbstractWallet,
|
|
3
|
+
import { ApproveAgentRequest, ApproveBuilderFeeRequest, BatchModifyRequest, CancelByCloidRequest, CancelRequest, type CancelResponse, type CancelSuccessResponse, CDepositRequest, ClaimRewardsRequest, ConvertToMultiSigUserRequest, type ConvertToMultiSigUserRequestSigners, CreateSubAccountRequest, type CreateSubAccountResponse, CreateVaultRequest, type CreateVaultResponse, CSignerActionRequest, CValidatorActionRequest, CWithdrawRequest, type ErrorResponse, EvmUserModifyRequest, ModifyRequest, MultiSigRequest, NoopRequest, OrderRequest, type OrderResponse, type OrderSuccessResponse, PerpDeployRequest, RegisterReferrerRequest, ReserveRequestWeightRequest, ScheduleCancelRequest, SendAssetRequest, SetDisplayNameRequest, SetReferrerRequest, SpotDeployRequest, SpotSendRequest, SpotUserRequest, SubAccountModifyRequest, SubAccountSpotTransferRequest, SubAccountTransferRequest, type SuccessResponse, TokenDelegateRequest, TwapCancelRequest, type TwapCancelResponse, type TwapCancelSuccessResponse, TwapOrderRequest, type TwapOrderResponse, type TwapOrderSuccessResponse, UpdateIsolatedMarginRequest, UpdateLeverageRequest, UsdClassTransferRequest, UsdSendRequest, VaultDistributeRequest, VaultModifyRequest, VaultTransferRequest, Withdraw3Request } from "../schemas/mod.js";
|
|
4
|
+
import { type AbstractWallet, userSignedActionEip712Types } from "../signing/mod.js";
|
|
5
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
6
|
/** @see https://github.com/microsoft/TypeScript/issues/13923#issuecomment-2191862501 */
|
|
7
7
|
type DeepImmutable<T> = {
|
|
@@ -20,7 +20,7 @@ export interface ExchangeClientParameters<T extends IRequestTransport = IRequest
|
|
|
20
20
|
*/
|
|
21
21
|
isTestnet?: boolean;
|
|
22
22
|
/** Sets a default vaultAddress to be used if no vaultAddress is explicitly passed to a method. */
|
|
23
|
-
defaultVaultAddress?:
|
|
23
|
+
defaultVaultAddress?: `0x${string}`;
|
|
24
24
|
/** Sets a default expiresAfter to be used if no expiresAfter is explicitly passed to a method. */
|
|
25
25
|
defaultExpiresAfter?: number | (() => MaybePromise<number>);
|
|
26
26
|
/**
|
|
@@ -29,7 +29,7 @@ export interface ExchangeClientParameters<T extends IRequestTransport = IRequest
|
|
|
29
29
|
*
|
|
30
30
|
* Defaults to get chain id from wallet otherwise `0x1`.
|
|
31
31
|
*/
|
|
32
|
-
signatureChainId?:
|
|
32
|
+
signatureChainId?: `0x${string}` | (() => MaybePromise<`0x${string}`>);
|
|
33
33
|
/**
|
|
34
34
|
* Function to get the next nonce for signing transactions.
|
|
35
35
|
*
|
|
@@ -56,7 +56,10 @@ export type CancelByCloidParameters = ExtractRequestAction<CancelByCloidRequest>
|
|
|
56
56
|
/** Action parameters for the {@linkcode ExchangeClient.cDeposit} method. */
|
|
57
57
|
export type CDepositParameters = ExtractRequestAction<CDepositRequest>;
|
|
58
58
|
/** Action parameters for the {@linkcode ExchangeClient.convertToMultiSigUser} method. */
|
|
59
|
-
export type ConvertToMultiSigUserParameters = ExtractRequestAction<
|
|
59
|
+
export type ConvertToMultiSigUserParameters = Omit<ExtractRequestAction<ConvertToMultiSigUserRequest>, "signers"> & {
|
|
60
|
+
/** Signers configuration. */
|
|
61
|
+
signers: ConvertToMultiSigUserRequestSigners;
|
|
62
|
+
};
|
|
60
63
|
/** Action parameters for the {@linkcode ExchangeClient.createSubAccount} method. */
|
|
61
64
|
export type CreateSubAccountParameters = ExtractRequestAction<CreateSubAccountRequest>;
|
|
62
65
|
/** Action parameters for the {@linkcode ExchangeClient.createVault} method. */
|
|
@@ -218,7 +221,7 @@ export type VaultModifyOptions = ExtractRequestOptions<VaultModifyRequest>;
|
|
|
218
221
|
export type VaultTransferOptions = ExtractRequestOptions<VaultTransferRequest>;
|
|
219
222
|
/** Request options for the {@linkcode ExchangeClient.withdraw3} method. */
|
|
220
223
|
export type Withdraw3Options = ExtractRequestOptions<Withdraw3Request>;
|
|
221
|
-
/**
|
|
224
|
+
/** Thrown when an API request fails. */
|
|
222
225
|
export declare class ApiRequestError extends HyperliquidError {
|
|
223
226
|
response: ErrorResponse | OrderResponse | CancelResponse | TwapOrderResponse | TwapCancelResponse;
|
|
224
227
|
constructor(response: ErrorResponse | OrderResponse | CancelResponse | TwapOrderResponse | TwapCancelResponse);
|
|
@@ -232,9 +235,9 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
232
235
|
transport: T;
|
|
233
236
|
wallet: W;
|
|
234
237
|
isTestnet: boolean;
|
|
235
|
-
defaultVaultAddress?:
|
|
238
|
+
defaultVaultAddress?: `0x${string}`;
|
|
236
239
|
defaultExpiresAfter?: number | (() => MaybePromise<number>);
|
|
237
|
-
signatureChainId:
|
|
240
|
+
signatureChainId: `0x${string}` | (() => MaybePromise<`0x${string}`>);
|
|
238
241
|
nonceManager: () => MaybePromise<number>;
|
|
239
242
|
/**
|
|
240
243
|
* Initialises a new instance.
|
|
@@ -709,7 +712,8 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
709
712
|
* @example
|
|
710
713
|
* ```ts
|
|
711
714
|
* import * as hl from "@nktkas/hyperliquid";
|
|
712
|
-
* import {
|
|
715
|
+
* import { signL1Action } from "@nktkas/hyperliquid/signing";
|
|
716
|
+
* import { parser, ScheduleCancelRequest } from "@nktkas/hyperliquid/schemas";
|
|
713
717
|
* import { privateKeyToAccount } from "npm:viem/accounts";
|
|
714
718
|
*
|
|
715
719
|
* const wallet = privateKeyToAccount("0x..."); // or any other wallet libraries
|
|
@@ -719,7 +723,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
719
723
|
* const exchClient = new hl.ExchangeClient({ wallet, transport });
|
|
720
724
|
*
|
|
721
725
|
* const nonce = Date.now();
|
|
722
|
-
* const action =
|
|
726
|
+
* const action = parser(ScheduleCancelRequest.entries.action)({ // for correct signature generation
|
|
723
727
|
* type: "scheduleCancel",
|
|
724
728
|
* time: Date.now() + 10000,
|
|
725
729
|
* });
|
|
@@ -733,7 +737,7 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
733
737
|
* });
|
|
734
738
|
* }));
|
|
735
739
|
*
|
|
736
|
-
* // or user-signed action
|
|
740
|
+
* // // or user-signed action
|
|
737
741
|
* // const signatures = await Promise.all(["0x...", "0x..."].map(async (signerPrivKey) => {
|
|
738
742
|
* // return await signUserSignedAction({
|
|
739
743
|
* // wallet: signerPrivKey as `0x${string}`,
|
|
@@ -1397,21 +1401,28 @@ export declare class ExchangeClient<T extends IRequestTransport = IRequestTransp
|
|
|
1397
1401
|
*/
|
|
1398
1402
|
withdraw3(params: DeepImmutable<Withdraw3Parameters>, opts?: Withdraw3Options): Promise<SuccessResponse>;
|
|
1399
1403
|
protected _executeL1Action<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(request: {
|
|
1400
|
-
action:
|
|
1401
|
-
vaultAddress?:
|
|
1404
|
+
action: Record<string, unknown>;
|
|
1405
|
+
vaultAddress?: `0x${string}`;
|
|
1402
1406
|
expiresAfter: number | undefined;
|
|
1403
1407
|
}, signal?: AbortSignal): Promise<T>;
|
|
1404
1408
|
protected _executeUserSignedAction<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(request: {
|
|
1405
|
-
action:
|
|
1409
|
+
action: {
|
|
1410
|
+
type: keyof typeof userSignedActionEip712Types;
|
|
1411
|
+
signatureChainId: `0x${string}`;
|
|
1412
|
+
[key: string]: unknown;
|
|
1413
|
+
};
|
|
1406
1414
|
}, signal?: AbortSignal): Promise<T>;
|
|
1407
1415
|
protected _executeMultiSigAction<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(request: {
|
|
1408
|
-
action:
|
|
1416
|
+
action: {
|
|
1417
|
+
signatureChainId: `0x${string}`;
|
|
1418
|
+
[key: string]: unknown;
|
|
1419
|
+
};
|
|
1409
1420
|
nonce: number;
|
|
1410
|
-
vaultAddress?:
|
|
1421
|
+
vaultAddress?: `0x${string}`;
|
|
1411
1422
|
expiresAfter?: number;
|
|
1412
1423
|
}, signal?: AbortSignal): Promise<T>;
|
|
1413
1424
|
protected _getDefaultExpiresAfter(): Promise<number | undefined>;
|
|
1414
|
-
protected _getSignatureChainId(): Promise
|
|
1425
|
+
protected _getSignatureChainId(): Promise<`0x${string}`>;
|
|
1415
1426
|
protected _getHyperliquidChain(): "Mainnet" | "Testnet";
|
|
1416
1427
|
protected _validateResponse<T extends SuccessResponse | CancelSuccessResponse | CreateSubAccountResponse | CreateVaultResponse | OrderSuccessResponse | TwapOrderSuccessResponse | TwapCancelSuccessResponse>(response: SuccessResponse | ErrorResponse | CancelResponse | CreateSubAccountResponse | CreateVaultResponse | OrderResponse | TwapOrderResponse | TwapCancelResponse): asserts response is T;
|
|
1417
1428
|
[Symbol.asyncDispose](): Promise<void>;
|