@nktkas/hyperliquid 0.24.3 → 0.25.0-beta.2
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 +141 -32
- package/esm/mod.d.ts +11 -11
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +2 -1
- package/esm/mod.js.map +1 -0
- package/esm/src/clients/exchange.d.ts +29 -25
- package/esm/src/clients/exchange.d.ts.map +1 -1
- package/esm/src/clients/exchange.js +54 -53
- package/esm/src/clients/exchange.js.map +1 -0
- package/esm/src/clients/info.d.ts +80 -20
- package/esm/src/clients/info.d.ts.map +1 -1
- package/esm/src/clients/info.js +312 -73
- package/esm/src/clients/info.js.map +1 -0
- package/esm/src/clients/multiSign.d.ts +11 -7
- package/esm/src/clients/multiSign.d.ts.map +1 -1
- package/esm/src/clients/multiSign.js +2 -1
- package/esm/src/clients/multiSign.js.map +1 -0
- package/esm/src/clients/subscription.d.ts +9 -9
- package/esm/src/clients/subscription.d.ts.map +1 -1
- package/esm/src/clients/subscription.js +29 -27
- package/esm/src/clients/subscription.js.map +1 -0
- package/esm/src/{base.d.ts → errors.d.ts} +1 -1
- package/esm/src/errors.d.ts.map +1 -0
- package/esm/src/{base.js → errors.js} +1 -0
- package/esm/src/errors.js.map +1 -0
- package/esm/src/schemas/_base.d.ts +14 -0
- package/esm/src/schemas/_base.d.ts.map +1 -0
- package/esm/src/schemas/_base.js +15 -0
- package/esm/src/schemas/_base.js.map +1 -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 +1414 -0
- package/esm/src/schemas/exchange/requests.js.map +1 -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 +244 -0
- package/esm/src/schemas/exchange/responses.js.map +1 -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 +33 -0
- package/esm/src/schemas/explorer/requests.js.map +1 -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 +57 -0
- package/esm/src/schemas/explorer/responses.js.map +1 -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 +623 -0
- package/esm/src/schemas/info/accounts.js.map +1 -0
- package/esm/src/schemas/info/assets.d.ts +974 -0
- package/esm/src/schemas/info/assets.d.ts.map +1 -0
- package/esm/src/schemas/info/assets.js +285 -0
- package/esm/src/schemas/info/assets.js.map +1 -0
- package/esm/src/schemas/info/markets.d.ts +155 -0
- package/esm/src/schemas/info/markets.d.ts.map +1 -0
- package/esm/src/schemas/info/markets.js +70 -0
- package/esm/src/schemas/info/markets.js.map +1 -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 +298 -0
- package/esm/src/schemas/info/orders.js.map +1 -0
- package/esm/src/schemas/info/requests.d.ts +924 -0
- package/esm/src/schemas/info/requests.d.ts.map +1 -0
- package/esm/src/schemas/info/requests.js +687 -0
- package/esm/src/schemas/info/requests.js.map +1 -0
- package/esm/src/schemas/info/validators.d.ts +326 -0
- package/esm/src/schemas/info/validators.d.ts.map +1 -0
- package/esm/src/schemas/info/validators.js +126 -0
- package/esm/src/schemas/info/validators.js.map +1 -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 +111 -0
- package/esm/src/schemas/info/vaults.js.map +1 -0
- package/esm/src/schemas/mod.d.ts +101 -0
- package/esm/src/schemas/mod.d.ts.map +1 -0
- package/esm/src/schemas/mod.js +115 -0
- package/esm/src/schemas/mod.js.map +1 -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 +259 -0
- package/esm/src/schemas/subscriptions/requests.js.map +1 -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 +234 -0
- package/esm/src/schemas/subscriptions/responses.js.map +1 -0
- package/esm/src/signing/_signTypedData/ethers.js +1 -0
- package/esm/src/signing/_signTypedData/ethers.js.map +1 -0
- package/esm/src/signing/_signTypedData/mod.js +1 -0
- package/esm/src/signing/_signTypedData/mod.js.map +1 -0
- package/esm/src/signing/_signTypedData/private_key.js +1 -0
- package/esm/src/signing/_signTypedData/private_key.js.map +1 -0
- package/esm/src/signing/_signTypedData/viem.js +1 -0
- package/esm/src/signing/_signTypedData/viem.js.map +1 -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 +136 -29
- package/esm/src/signing/mod.js.map +1 -0
- package/esm/src/transports/base.d.ts +4 -4
- package/esm/src/transports/base.d.ts.map +1 -1
- package/esm/src/transports/base.js +3 -2
- package/esm/src/transports/base.js.map +1 -0
- package/esm/src/transports/http/http_transport.d.ts +3 -2
- package/esm/src/transports/http/http_transport.d.ts.map +1 -1
- package/esm/src/transports/http/http_transport.js +1 -0
- package/esm/src/transports/http/http_transport.js.map +1 -0
- 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/_hyperliquid_event_target.js +1 -0
- package/esm/src/transports/websocket/_hyperliquid_event_target.js.map +1 -0
- package/esm/src/transports/websocket/_reconnecting_websocket.js +1 -0
- package/esm/src/transports/websocket/_reconnecting_websocket.js.map +1 -0
- package/esm/src/transports/websocket/_websocket_async_request.js +1 -0
- package/esm/src/transports/websocket/_websocket_async_request.js.map +1 -0
- package/esm/src/transports/websocket/websocket_transport.d.ts +9 -1
- package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/esm/src/transports/websocket/websocket_transport.js +4 -0
- package/esm/src/transports/websocket/websocket_transport.js.map +1 -0
- package/package.json +6 -5
- package/script/mod.d.ts +11 -11
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +2 -1
- package/script/mod.js.map +1 -0
- package/script/src/clients/exchange.d.ts +29 -25
- package/script/src/clients/exchange.d.ts.map +1 -1
- package/script/src/clients/exchange.js +60 -59
- package/script/src/clients/exchange.js.map +1 -0
- package/script/src/clients/info.d.ts +80 -20
- package/script/src/clients/info.d.ts.map +1 -1
- package/script/src/clients/info.js +312 -73
- package/script/src/clients/info.js.map +1 -0
- package/script/src/clients/multiSign.d.ts +11 -7
- package/script/src/clients/multiSign.d.ts.map +1 -1
- package/script/src/clients/multiSign.js +2 -1
- package/script/src/clients/multiSign.js.map +1 -0
- package/script/src/clients/subscription.d.ts +9 -9
- package/script/src/clients/subscription.d.ts.map +1 -1
- package/script/src/clients/subscription.js +29 -27
- package/script/src/clients/subscription.js.map +1 -0
- package/script/src/{base.d.ts → errors.d.ts} +1 -1
- package/script/src/errors.d.ts.map +1 -0
- package/script/src/{base.js → errors.js} +1 -0
- package/script/src/errors.js.map +1 -0
- package/script/src/schemas/_base.d.ts +14 -0
- package/script/src/schemas/_base.d.ts.map +1 -0
- package/script/src/schemas/_base.js +51 -0
- package/script/src/schemas/_base.js.map +1 -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 +1450 -0
- package/script/src/schemas/exchange/requests.js.map +1 -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 +280 -0
- package/script/src/schemas/exchange/responses.js.map +1 -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 +69 -0
- package/script/src/schemas/explorer/requests.js.map +1 -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 +93 -0
- package/script/src/schemas/explorer/responses.js.map +1 -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 +659 -0
- package/script/src/schemas/info/accounts.js.map +1 -0
- package/script/src/schemas/info/assets.d.ts +974 -0
- package/script/src/schemas/info/assets.d.ts.map +1 -0
- package/script/src/schemas/info/assets.js +321 -0
- package/script/src/schemas/info/assets.js.map +1 -0
- package/script/src/schemas/info/markets.d.ts +155 -0
- package/script/src/schemas/info/markets.d.ts.map +1 -0
- package/script/src/schemas/info/markets.js +106 -0
- package/script/src/schemas/info/markets.js.map +1 -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 +334 -0
- package/script/src/schemas/info/orders.js.map +1 -0
- package/script/src/schemas/info/requests.d.ts +924 -0
- package/script/src/schemas/info/requests.d.ts.map +1 -0
- package/script/src/schemas/info/requests.js +724 -0
- package/script/src/schemas/info/requests.js.map +1 -0
- package/script/src/schemas/info/validators.d.ts +326 -0
- package/script/src/schemas/info/validators.d.ts.map +1 -0
- package/script/src/schemas/info/validators.js +162 -0
- package/script/src/schemas/info/validators.js.map +1 -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 +147 -0
- package/script/src/schemas/info/vaults.js.map +1 -0
- package/script/src/schemas/mod.d.ts +101 -0
- package/script/src/schemas/mod.d.ts.map +1 -0
- package/script/src/schemas/mod.js +157 -0
- package/script/src/schemas/mod.js.map +1 -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 +295 -0
- package/script/src/schemas/subscriptions/requests.js.map +1 -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 +270 -0
- package/script/src/schemas/subscriptions/responses.js.map +1 -0
- package/script/src/signing/_signTypedData/ethers.js +1 -0
- package/script/src/signing/_signTypedData/ethers.js.map +1 -0
- package/script/src/signing/_signTypedData/mod.js +1 -0
- package/script/src/signing/_signTypedData/mod.js.map +1 -0
- package/script/src/signing/_signTypedData/private_key.js +1 -0
- package/script/src/signing/_signTypedData/private_key.js.map +1 -0
- package/script/src/signing/_signTypedData/viem.js +1 -0
- package/script/src/signing/_signTypedData/viem.js.map +1 -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 +138 -33
- package/script/src/signing/mod.js.map +1 -0
- package/script/src/transports/base.d.ts +4 -4
- package/script/src/transports/base.d.ts.map +1 -1
- package/script/src/transports/base.js +4 -3
- package/script/src/transports/base.js.map +1 -0
- package/script/src/transports/http/http_transport.d.ts +3 -2
- package/script/src/transports/http/http_transport.d.ts.map +1 -1
- package/script/src/transports/http/http_transport.js +1 -0
- package/script/src/transports/http/http_transport.js.map +1 -0
- 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/_hyperliquid_event_target.js +1 -0
- package/script/src/transports/websocket/_hyperliquid_event_target.js.map +1 -0
- package/script/src/transports/websocket/_reconnecting_websocket.js +1 -0
- package/script/src/transports/websocket/_reconnecting_websocket.js.map +1 -0
- package/script/src/transports/websocket/_websocket_async_request.js +1 -0
- package/script/src/transports/websocket/_websocket_async_request.js.map +1 -0
- package/script/src/transports/websocket/websocket_transport.d.ts +9 -1
- package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
- package/script/src/transports/websocket/websocket_transport.js +4 -0
- package/script/src/transports/websocket/websocket_transport.js.map +1 -0
- package/src/mod.ts +28 -0
- package/src/src/clients/exchange.ts +2246 -0
- package/src/src/clients/info.ts +2076 -0
- package/src/src/clients/multiSign.ts +183 -0
- package/src/src/clients/subscription.ts +841 -0
- package/src/src/errors.ts +7 -0
- package/src/src/schemas/_base.ts +43 -0
- package/src/src/schemas/exchange/requests.ts +3057 -0
- package/src/src/schemas/exchange/responses.ts +540 -0
- package/src/src/schemas/explorer/requests.ts +65 -0
- package/src/src/schemas/explorer/responses.ts +138 -0
- package/src/src/schemas/info/accounts.ts +1490 -0
- package/src/src/schemas/info/assets.ts +693 -0
- package/src/src/schemas/info/markets.ts +171 -0
- package/src/src/schemas/info/orders.ts +597 -0
- package/src/src/schemas/info/requests.ts +1369 -0
- package/src/src/schemas/info/validators.ts +299 -0
- package/src/src/schemas/info/vaults.ts +262 -0
- package/src/src/schemas/mod.ts +121 -0
- package/src/src/schemas/subscriptions/requests.ts +504 -0
- package/src/src/schemas/subscriptions/responses.ts +576 -0
- package/src/src/signing/_signTypedData/ethers.ts +59 -0
- package/src/src/signing/_signTypedData/mod.ts +121 -0
- package/src/src/signing/_signTypedData/private_key.ts +229 -0
- package/src/src/signing/_signTypedData/viem.ts +55 -0
- package/src/src/signing/mod.ts +572 -0
- package/src/src/transports/base.ts +54 -0
- package/src/src/transports/http/http_transport.ts +208 -0
- package/src/src/transports/websocket/_hyperliquid_event_target.ts +118 -0
- package/src/src/transports/websocket/_reconnecting_websocket.ts +404 -0
- package/src/src/transports/websocket/_websocket_async_request.ts +229 -0
- package/src/src/transports/websocket/websocket_transport.ts +394 -0
- 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 -640
- 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 -154
- 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 -238
- 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 -640
- 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 -154
- 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 -238
- package/script/src/types/subscriptions/responses.d.ts.map +0 -1
- package/script/src/types/subscriptions/responses.js +0 -2
|
@@ -0,0 +1,3057 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { Hex, TokenId, UnsignedDecimal, UnsignedInteger } from "../_base.js";
|
|
3
|
+
|
|
4
|
+
/** Deeply removes undefined keys from an object. */
|
|
5
|
+
function removeUndefinedKeys<T>(obj: T): T {
|
|
6
|
+
if (typeof obj !== "object" || obj === null) {
|
|
7
|
+
return obj;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (Array.isArray(obj)) {
|
|
11
|
+
return obj.map((value) => removeUndefinedKeys(value)) as T;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const result: Record<string, unknown> = {};
|
|
15
|
+
const entries = Object.entries(obj);
|
|
16
|
+
for (const [key, value] of entries) {
|
|
17
|
+
if (value !== undefined) {
|
|
18
|
+
result[key] = removeUndefinedKeys(value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return result as T;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Percent = v.pipe(v.string(), v.regex(/^[0-9]+(\.[0-9]+)?%$/), v.transform((value) => value as `${string}%`));
|
|
26
|
+
|
|
27
|
+
/** ECDSA signature components for Ethereum typed data. */
|
|
28
|
+
export const Signature = v.pipe(
|
|
29
|
+
v.object({
|
|
30
|
+
/** First 32-byte component of ECDSA signature. */
|
|
31
|
+
r: v.pipe(
|
|
32
|
+
v.pipe(
|
|
33
|
+
Hex,
|
|
34
|
+
v.length(66),
|
|
35
|
+
v.transform((value) => value.replace(/^0x0+/, "0x") as `0x${string}`),
|
|
36
|
+
),
|
|
37
|
+
v.description("First 32-byte component of ECDSA signature."),
|
|
38
|
+
),
|
|
39
|
+
/** Second 32-byte component of ECDSA signature. */
|
|
40
|
+
s: v.pipe(
|
|
41
|
+
v.pipe(
|
|
42
|
+
Hex,
|
|
43
|
+
v.length(66),
|
|
44
|
+
v.transform((value) => value.replace(/^0x0+/, "0x") as `0x${string}`),
|
|
45
|
+
),
|
|
46
|
+
v.description("Second 32-byte component of ECDSA signature."),
|
|
47
|
+
),
|
|
48
|
+
/** Recovery identifier. */
|
|
49
|
+
v: v.pipe(
|
|
50
|
+
v.union([v.literal(27), v.literal(28)]),
|
|
51
|
+
v.description("Recovery identifier."),
|
|
52
|
+
),
|
|
53
|
+
}),
|
|
54
|
+
v.description("ECDSA signature components for Ethereum typed data."),
|
|
55
|
+
);
|
|
56
|
+
export type Signature = v.InferOutput<typeof Signature>;
|
|
57
|
+
|
|
58
|
+
/** Order parameters. */
|
|
59
|
+
export const OrderParams = v.pipe(
|
|
60
|
+
v.object({
|
|
61
|
+
/** Asset ID. */
|
|
62
|
+
a: v.pipe(
|
|
63
|
+
UnsignedInteger,
|
|
64
|
+
v.description("Asset ID."),
|
|
65
|
+
),
|
|
66
|
+
/** Position side (`true` for long, `false` for short). */
|
|
67
|
+
b: v.pipe(
|
|
68
|
+
v.boolean(),
|
|
69
|
+
v.description("Position side (`true` for long, `false` for short)."),
|
|
70
|
+
),
|
|
71
|
+
/** Price. */
|
|
72
|
+
p: v.pipe(
|
|
73
|
+
UnsignedDecimal,
|
|
74
|
+
v.description("Price."),
|
|
75
|
+
),
|
|
76
|
+
/** Size (in base currency units). */
|
|
77
|
+
s: v.pipe(
|
|
78
|
+
UnsignedDecimal,
|
|
79
|
+
v.description("Size (in base currency units)."),
|
|
80
|
+
),
|
|
81
|
+
/** Is reduce-only? */
|
|
82
|
+
r: v.pipe(
|
|
83
|
+
v.boolean(),
|
|
84
|
+
v.description("Is reduce-only?"),
|
|
85
|
+
),
|
|
86
|
+
/** Order type. */
|
|
87
|
+
t: v.pipe(
|
|
88
|
+
v.union([
|
|
89
|
+
v.object({
|
|
90
|
+
/** Limit order parameters. */
|
|
91
|
+
limit: v.pipe(
|
|
92
|
+
v.object({
|
|
93
|
+
/** Time-in-force. */
|
|
94
|
+
tif: v.pipe(
|
|
95
|
+
v.union([
|
|
96
|
+
v.literal("Gtc"),
|
|
97
|
+
v.literal("Ioc"),
|
|
98
|
+
v.literal("Alo"),
|
|
99
|
+
v.literal("FrontendMarket"),
|
|
100
|
+
v.literal("LiquidationMarket"),
|
|
101
|
+
]),
|
|
102
|
+
v.description("Time-in-force."),
|
|
103
|
+
),
|
|
104
|
+
}),
|
|
105
|
+
v.description("Limit order parameters."),
|
|
106
|
+
),
|
|
107
|
+
}),
|
|
108
|
+
v.object({
|
|
109
|
+
/** Trigger order parameters. */
|
|
110
|
+
trigger: v.pipe(
|
|
111
|
+
v.object({
|
|
112
|
+
/** Is market order? */
|
|
113
|
+
isMarket: v.pipe(
|
|
114
|
+
v.boolean(),
|
|
115
|
+
v.description("Is market order?"),
|
|
116
|
+
),
|
|
117
|
+
/** Trigger price. */
|
|
118
|
+
triggerPx: v.pipe(
|
|
119
|
+
UnsignedDecimal,
|
|
120
|
+
v.description("Trigger price."),
|
|
121
|
+
),
|
|
122
|
+
/** Indicates whether it is take profit or stop loss. */
|
|
123
|
+
tpsl: v.pipe(
|
|
124
|
+
v.union([v.literal("tp"), v.literal("sl")]),
|
|
125
|
+
v.description("Indicates whether it is take profit or stop loss."),
|
|
126
|
+
),
|
|
127
|
+
}),
|
|
128
|
+
v.description("Trigger order parameters."),
|
|
129
|
+
),
|
|
130
|
+
}),
|
|
131
|
+
]),
|
|
132
|
+
v.description("Order type."),
|
|
133
|
+
),
|
|
134
|
+
/** Client Order ID. */
|
|
135
|
+
c: v.pipe(
|
|
136
|
+
v.optional(v.pipe(Hex, v.length(34))),
|
|
137
|
+
v.description("Client Order ID."),
|
|
138
|
+
),
|
|
139
|
+
}),
|
|
140
|
+
v.transform(removeUndefinedKeys),
|
|
141
|
+
v.description("Order parameters."),
|
|
142
|
+
);
|
|
143
|
+
export type OrderParams = v.InferOutput<typeof OrderParams>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Approve an agent to sign on behalf of the master account.
|
|
147
|
+
* @returns {SuccessResponse}
|
|
148
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#approve-an-api-wallet
|
|
149
|
+
*/
|
|
150
|
+
export const ApproveAgentRequest = v.pipe(
|
|
151
|
+
v.object({
|
|
152
|
+
/** Action to perform. */
|
|
153
|
+
action: v.pipe(
|
|
154
|
+
v.object({
|
|
155
|
+
/** Type of action. */
|
|
156
|
+
type: v.pipe(
|
|
157
|
+
v.literal("approveAgent"),
|
|
158
|
+
v.description("Type of action."),
|
|
159
|
+
),
|
|
160
|
+
/** Chain ID used for signing. */
|
|
161
|
+
signatureChainId: v.pipe(
|
|
162
|
+
Hex,
|
|
163
|
+
v.description("Chain ID used for signing."),
|
|
164
|
+
),
|
|
165
|
+
/** HyperLiquid network. */
|
|
166
|
+
hyperliquidChain: v.pipe(
|
|
167
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
168
|
+
v.description("HyperLiquid network."),
|
|
169
|
+
),
|
|
170
|
+
/** Agent address. */
|
|
171
|
+
agentAddress: v.pipe(
|
|
172
|
+
v.pipe(Hex, v.length(42)),
|
|
173
|
+
v.description("Agent address."),
|
|
174
|
+
),
|
|
175
|
+
/** Agent name or null for unnamed agent. */
|
|
176
|
+
agentName: v.pipe(
|
|
177
|
+
v.nullable(v.string()),
|
|
178
|
+
v.description("Agent name or null for unnamed agent."),
|
|
179
|
+
),
|
|
180
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
181
|
+
nonce: v.pipe(
|
|
182
|
+
UnsignedInteger,
|
|
183
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
184
|
+
),
|
|
185
|
+
}),
|
|
186
|
+
v.description("Action to perform."),
|
|
187
|
+
),
|
|
188
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
189
|
+
nonce: v.pipe(
|
|
190
|
+
UnsignedInteger,
|
|
191
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
192
|
+
),
|
|
193
|
+
/** Cryptographic signature. */
|
|
194
|
+
signature: v.pipe(
|
|
195
|
+
Signature,
|
|
196
|
+
v.description("Cryptographic signature."),
|
|
197
|
+
),
|
|
198
|
+
}),
|
|
199
|
+
v.transform(removeUndefinedKeys),
|
|
200
|
+
v.description("Approve an agent to sign on behalf of the master account."),
|
|
201
|
+
);
|
|
202
|
+
export type ApproveAgentRequest = v.InferOutput<typeof ApproveAgentRequest>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Approve a maximum fee rate for a builder.
|
|
206
|
+
* @returns {SuccessResponse}
|
|
207
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#approve-a-builder-fee
|
|
208
|
+
*/
|
|
209
|
+
export const ApproveBuilderFeeRequest = v.pipe(
|
|
210
|
+
v.object({
|
|
211
|
+
/** Action to perform. */
|
|
212
|
+
action: v.pipe(
|
|
213
|
+
v.object({
|
|
214
|
+
/** Type of action. */
|
|
215
|
+
type: v.pipe(
|
|
216
|
+
v.literal("approveBuilderFee"),
|
|
217
|
+
v.description("Type of action."),
|
|
218
|
+
),
|
|
219
|
+
/** Chain ID used for signing. */
|
|
220
|
+
signatureChainId: v.pipe(
|
|
221
|
+
Hex,
|
|
222
|
+
v.description("Chain ID used for signing."),
|
|
223
|
+
),
|
|
224
|
+
/** HyperLiquid network. */
|
|
225
|
+
hyperliquidChain: v.pipe(
|
|
226
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
227
|
+
v.description("HyperLiquid network."),
|
|
228
|
+
),
|
|
229
|
+
/** Max fee rate (e.g., "0.01%"). */
|
|
230
|
+
maxFeeRate: v.pipe(
|
|
231
|
+
Percent,
|
|
232
|
+
v.description('Max fee rate (e.g., "0.01%").'),
|
|
233
|
+
),
|
|
234
|
+
/** Builder address. */
|
|
235
|
+
builder: v.pipe(
|
|
236
|
+
v.pipe(Hex, v.length(42)),
|
|
237
|
+
v.description("Builder address."),
|
|
238
|
+
),
|
|
239
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
240
|
+
nonce: v.pipe(
|
|
241
|
+
UnsignedInteger,
|
|
242
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
243
|
+
),
|
|
244
|
+
}),
|
|
245
|
+
v.description("Action to perform."),
|
|
246
|
+
),
|
|
247
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
248
|
+
nonce: v.pipe(
|
|
249
|
+
UnsignedInteger,
|
|
250
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
251
|
+
),
|
|
252
|
+
/** Cryptographic signature. */
|
|
253
|
+
signature: v.pipe(
|
|
254
|
+
Signature,
|
|
255
|
+
v.description("Cryptographic signature."),
|
|
256
|
+
),
|
|
257
|
+
}),
|
|
258
|
+
v.transform(removeUndefinedKeys),
|
|
259
|
+
v.description("Approve a maximum fee rate for a builder."),
|
|
260
|
+
);
|
|
261
|
+
export type ApproveBuilderFeeRequest = v.InferOutput<typeof ApproveBuilderFeeRequest>;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Modify multiple orders.
|
|
265
|
+
* @returns {OrderResponse}
|
|
266
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders
|
|
267
|
+
*/
|
|
268
|
+
export const BatchModifyRequest = v.pipe(
|
|
269
|
+
v.object({
|
|
270
|
+
/** Action to perform. */
|
|
271
|
+
action: v.pipe(
|
|
272
|
+
v.object({
|
|
273
|
+
/** Type of action. */
|
|
274
|
+
type: v.pipe(
|
|
275
|
+
v.literal("batchModify"),
|
|
276
|
+
v.description("Type of action."),
|
|
277
|
+
),
|
|
278
|
+
/** Order modifications. */
|
|
279
|
+
modifies: v.pipe(
|
|
280
|
+
v.array(v.object({
|
|
281
|
+
/** Order ID or Client Order ID. */
|
|
282
|
+
oid: v.pipe(
|
|
283
|
+
v.union([
|
|
284
|
+
UnsignedInteger,
|
|
285
|
+
v.pipe(Hex, v.length(34)),
|
|
286
|
+
]),
|
|
287
|
+
v.description("Order ID or Client Order ID."),
|
|
288
|
+
),
|
|
289
|
+
/** New order parameters. */
|
|
290
|
+
order: v.pipe(
|
|
291
|
+
OrderParams,
|
|
292
|
+
v.description("New order parameters."),
|
|
293
|
+
),
|
|
294
|
+
})),
|
|
295
|
+
v.description("Order modifications."),
|
|
296
|
+
),
|
|
297
|
+
}),
|
|
298
|
+
v.description("Action to perform."),
|
|
299
|
+
),
|
|
300
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
301
|
+
nonce: v.pipe(
|
|
302
|
+
UnsignedInteger,
|
|
303
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
304
|
+
),
|
|
305
|
+
/** Cryptographic signature. */
|
|
306
|
+
signature: v.pipe(
|
|
307
|
+
Signature,
|
|
308
|
+
v.description("Cryptographic signature."),
|
|
309
|
+
),
|
|
310
|
+
/** Vault address (for vault trading). */
|
|
311
|
+
vaultAddress: v.pipe(
|
|
312
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
313
|
+
v.description("Vault address (for vault trading)."),
|
|
314
|
+
),
|
|
315
|
+
/** Expiration time of the action. */
|
|
316
|
+
expiresAfter: v.pipe(
|
|
317
|
+
v.optional(UnsignedInteger),
|
|
318
|
+
v.description("Expiration time of the action."),
|
|
319
|
+
),
|
|
320
|
+
}),
|
|
321
|
+
v.transform(removeUndefinedKeys),
|
|
322
|
+
v.description("Modify multiple orders."),
|
|
323
|
+
);
|
|
324
|
+
export type BatchModifyRequest = v.InferOutput<typeof BatchModifyRequest>;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Cancel order(s).
|
|
328
|
+
* @returns {CancelResponse}
|
|
329
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s
|
|
330
|
+
*/
|
|
331
|
+
export const CancelRequest = v.pipe(
|
|
332
|
+
v.object({
|
|
333
|
+
/** Action to perform. */
|
|
334
|
+
action: v.pipe(
|
|
335
|
+
v.object({
|
|
336
|
+
/** Type of action. */
|
|
337
|
+
type: v.pipe(
|
|
338
|
+
v.literal("cancel"),
|
|
339
|
+
v.description("Type of action."),
|
|
340
|
+
),
|
|
341
|
+
/** Orders to cancel. */
|
|
342
|
+
cancels: v.pipe(
|
|
343
|
+
v.array(v.object({
|
|
344
|
+
/** Asset ID. */
|
|
345
|
+
a: v.pipe(
|
|
346
|
+
UnsignedInteger,
|
|
347
|
+
v.description("Asset ID."),
|
|
348
|
+
),
|
|
349
|
+
/** Order ID. */
|
|
350
|
+
o: v.pipe(
|
|
351
|
+
UnsignedInteger,
|
|
352
|
+
v.description("Order ID."),
|
|
353
|
+
),
|
|
354
|
+
})),
|
|
355
|
+
v.description("Orders to cancel."),
|
|
356
|
+
),
|
|
357
|
+
}),
|
|
358
|
+
v.description("Action to perform."),
|
|
359
|
+
),
|
|
360
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
361
|
+
nonce: v.pipe(
|
|
362
|
+
UnsignedInteger,
|
|
363
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
364
|
+
),
|
|
365
|
+
/** Cryptographic signature. */
|
|
366
|
+
signature: v.pipe(
|
|
367
|
+
Signature,
|
|
368
|
+
v.description("Cryptographic signature."),
|
|
369
|
+
),
|
|
370
|
+
/** Vault address (for vault trading). */
|
|
371
|
+
vaultAddress: v.pipe(
|
|
372
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
373
|
+
v.description("Vault address (for vault trading)."),
|
|
374
|
+
),
|
|
375
|
+
/** Expiration time of the action. */
|
|
376
|
+
expiresAfter: v.pipe(
|
|
377
|
+
v.optional(UnsignedInteger),
|
|
378
|
+
v.description("Expiration time of the action."),
|
|
379
|
+
),
|
|
380
|
+
}),
|
|
381
|
+
v.transform(removeUndefinedKeys),
|
|
382
|
+
v.description("Cancel order(s)."),
|
|
383
|
+
);
|
|
384
|
+
export type CancelRequest = v.InferOutput<typeof CancelRequest>;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Cancel order(s) by cloid.
|
|
388
|
+
* @returns {CancelResponse}
|
|
389
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid
|
|
390
|
+
*/
|
|
391
|
+
export const CancelByCloidRequest = v.pipe(
|
|
392
|
+
v.object({
|
|
393
|
+
/** Action to perform. */
|
|
394
|
+
action: v.pipe(
|
|
395
|
+
v.object({
|
|
396
|
+
/** Type of action. */
|
|
397
|
+
type: v.pipe(
|
|
398
|
+
v.literal("cancelByCloid"),
|
|
399
|
+
v.description("Type of action."),
|
|
400
|
+
),
|
|
401
|
+
/** Orders to cancel. */
|
|
402
|
+
cancels: v.pipe(
|
|
403
|
+
v.array(v.object({
|
|
404
|
+
/** Asset ID. */
|
|
405
|
+
asset: v.pipe(
|
|
406
|
+
UnsignedInteger,
|
|
407
|
+
v.description("Asset ID."),
|
|
408
|
+
),
|
|
409
|
+
/** Client Order ID. */
|
|
410
|
+
cloid: v.pipe(
|
|
411
|
+
v.pipe(Hex, v.length(34)),
|
|
412
|
+
v.description("Client Order ID."),
|
|
413
|
+
),
|
|
414
|
+
})),
|
|
415
|
+
v.description("Orders to cancel."),
|
|
416
|
+
),
|
|
417
|
+
}),
|
|
418
|
+
v.description("Action to perform."),
|
|
419
|
+
),
|
|
420
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
421
|
+
nonce: v.pipe(
|
|
422
|
+
UnsignedInteger,
|
|
423
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
424
|
+
),
|
|
425
|
+
/** Cryptographic signature. */
|
|
426
|
+
signature: v.pipe(
|
|
427
|
+
Signature,
|
|
428
|
+
v.description("Cryptographic signature."),
|
|
429
|
+
),
|
|
430
|
+
/** Vault address (for vault trading). */
|
|
431
|
+
vaultAddress: v.pipe(
|
|
432
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
433
|
+
v.description("Vault address (for vault trading)."),
|
|
434
|
+
),
|
|
435
|
+
/** Expiration time of the action. */
|
|
436
|
+
expiresAfter: v.pipe(
|
|
437
|
+
v.optional(UnsignedInteger),
|
|
438
|
+
v.description("Expiration time of the action."),
|
|
439
|
+
),
|
|
440
|
+
}),
|
|
441
|
+
v.transform(removeUndefinedKeys),
|
|
442
|
+
v.description("Cancel order(s) by cloid."),
|
|
443
|
+
);
|
|
444
|
+
export type CancelByCloidRequest = v.InferOutput<typeof CancelByCloidRequest>;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Transfer native token from the user spot account into staking for delegating to validators.
|
|
448
|
+
* @returns {SuccessResponse}
|
|
449
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-into-staking
|
|
450
|
+
*/
|
|
451
|
+
export const CDepositRequest = v.pipe(
|
|
452
|
+
v.object({
|
|
453
|
+
/** Action to perform. */
|
|
454
|
+
action: v.pipe(
|
|
455
|
+
v.object({
|
|
456
|
+
/** Type of action. */
|
|
457
|
+
type: v.pipe(
|
|
458
|
+
v.literal("cDeposit"),
|
|
459
|
+
v.description("Type of action."),
|
|
460
|
+
),
|
|
461
|
+
/** Chain ID used for signing. */
|
|
462
|
+
signatureChainId: v.pipe(
|
|
463
|
+
Hex,
|
|
464
|
+
v.description("Chain ID used for signing."),
|
|
465
|
+
),
|
|
466
|
+
/** HyperLiquid network. */
|
|
467
|
+
hyperliquidChain: v.pipe(
|
|
468
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
469
|
+
v.description("HyperLiquid network."),
|
|
470
|
+
),
|
|
471
|
+
/** Amount of wei to deposit into staking balance (float * 1e8). */
|
|
472
|
+
wei: v.pipe(
|
|
473
|
+
UnsignedInteger,
|
|
474
|
+
v.description("Amount of wei to deposit into staking balance (float * 1e8)."),
|
|
475
|
+
),
|
|
476
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
477
|
+
nonce: v.pipe(
|
|
478
|
+
UnsignedInteger,
|
|
479
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
480
|
+
),
|
|
481
|
+
}),
|
|
482
|
+
v.description("Action to perform."),
|
|
483
|
+
),
|
|
484
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
485
|
+
nonce: v.pipe(
|
|
486
|
+
UnsignedInteger,
|
|
487
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
488
|
+
),
|
|
489
|
+
/** Cryptographic signature. */
|
|
490
|
+
signature: v.pipe(
|
|
491
|
+
Signature,
|
|
492
|
+
v.description("Cryptographic signature."),
|
|
493
|
+
),
|
|
494
|
+
}),
|
|
495
|
+
v.transform(removeUndefinedKeys),
|
|
496
|
+
v.description("Transfer native token from the user spot account into staking for delegating to validators."),
|
|
497
|
+
);
|
|
498
|
+
export type CDepositRequest = v.InferOutput<typeof CDepositRequest>;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Claim rewards from referral program.
|
|
502
|
+
* @returns {SuccessResponse}
|
|
503
|
+
* @see null
|
|
504
|
+
*/
|
|
505
|
+
export const ClaimRewardsRequest = v.pipe(
|
|
506
|
+
v.object({
|
|
507
|
+
/** Action to perform. */
|
|
508
|
+
action: v.pipe(
|
|
509
|
+
v.object({
|
|
510
|
+
/** Type of action. */
|
|
511
|
+
type: v.pipe(
|
|
512
|
+
v.literal("claimRewards"),
|
|
513
|
+
v.description("Type of action."),
|
|
514
|
+
),
|
|
515
|
+
}),
|
|
516
|
+
v.description("Action to perform."),
|
|
517
|
+
),
|
|
518
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
519
|
+
nonce: v.pipe(
|
|
520
|
+
UnsignedInteger,
|
|
521
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
522
|
+
),
|
|
523
|
+
/** Cryptographic signature. */
|
|
524
|
+
signature: v.pipe(
|
|
525
|
+
Signature,
|
|
526
|
+
v.description("Cryptographic signature."),
|
|
527
|
+
),
|
|
528
|
+
/** Expiration time of the action. */
|
|
529
|
+
expiresAfter: v.pipe(
|
|
530
|
+
v.optional(UnsignedInteger),
|
|
531
|
+
v.description("Expiration time of the action."),
|
|
532
|
+
),
|
|
533
|
+
}),
|
|
534
|
+
v.transform(removeUndefinedKeys),
|
|
535
|
+
v.description("Claim rewards from referral program."),
|
|
536
|
+
);
|
|
537
|
+
export type ClaimRewardsRequest = v.InferOutput<typeof ClaimRewardsRequest>;
|
|
538
|
+
|
|
539
|
+
/** Signers configuration for {@linkcode ConvertToMultiSigUserRequest}. */
|
|
540
|
+
export const ConvertToMultiSigUserRequestSigners = v.pipe(
|
|
541
|
+
v.union([
|
|
542
|
+
v.object({
|
|
543
|
+
/** List of authorized user addresses. */
|
|
544
|
+
authorizedUsers: v.pipe(
|
|
545
|
+
v.array(v.pipe(Hex, v.length(42))),
|
|
546
|
+
v.description("List of authorized user addresses."),
|
|
547
|
+
),
|
|
548
|
+
/** Minimum number of signatures required. */
|
|
549
|
+
threshold: v.pipe(
|
|
550
|
+
UnsignedInteger,
|
|
551
|
+
v.description("Minimum number of signatures required."),
|
|
552
|
+
),
|
|
553
|
+
}),
|
|
554
|
+
/** Convert a multi-signature account to a single-signature account. */
|
|
555
|
+
v.pipe(
|
|
556
|
+
v.null(),
|
|
557
|
+
v.description("Convert a multi-signature account to a single-signature account."),
|
|
558
|
+
),
|
|
559
|
+
]),
|
|
560
|
+
v.description("Signers configuration for `ConvertToMultiSigUserRequest`"),
|
|
561
|
+
);
|
|
562
|
+
export type ConvertToMultiSigUserRequestSigners = v.InferOutput<typeof ConvertToMultiSigUserRequestSigners>;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Convert a single-signature account to a multi-signature account.
|
|
566
|
+
* @returns {SuccessResponse}
|
|
567
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/multi-sig
|
|
568
|
+
*/
|
|
569
|
+
export const ConvertToMultiSigUserRequest = v.pipe(
|
|
570
|
+
v.object({
|
|
571
|
+
/** Action to perform. */
|
|
572
|
+
action: v.pipe(
|
|
573
|
+
v.object({
|
|
574
|
+
/** Type of action. */
|
|
575
|
+
type: v.pipe(
|
|
576
|
+
v.literal("convertToMultiSigUser"),
|
|
577
|
+
v.description("Type of action."),
|
|
578
|
+
),
|
|
579
|
+
/** Chain ID used for signing. */
|
|
580
|
+
signatureChainId: v.pipe(
|
|
581
|
+
Hex,
|
|
582
|
+
v.description("Chain ID used for signing."),
|
|
583
|
+
),
|
|
584
|
+
/** HyperLiquid network. */
|
|
585
|
+
hyperliquidChain: v.pipe(
|
|
586
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
587
|
+
v.description("HyperLiquid network."),
|
|
588
|
+
),
|
|
589
|
+
/**
|
|
590
|
+
* Signers configuration.
|
|
591
|
+
*
|
|
592
|
+
* Must be {@linkcode ConvertToMultiSigUserRequestSigners} converted to a string via `JSON.stringify(...)`.
|
|
593
|
+
*/
|
|
594
|
+
signers: v.pipe(
|
|
595
|
+
v.union([
|
|
596
|
+
v.pipe(
|
|
597
|
+
v.string(),
|
|
598
|
+
v.parseJson(),
|
|
599
|
+
ConvertToMultiSigUserRequestSigners,
|
|
600
|
+
v.stringifyJson(),
|
|
601
|
+
),
|
|
602
|
+
v.pipe(
|
|
603
|
+
ConvertToMultiSigUserRequestSigners,
|
|
604
|
+
v.stringifyJson(),
|
|
605
|
+
),
|
|
606
|
+
]),
|
|
607
|
+
v.description(
|
|
608
|
+
"Signers configuration." +
|
|
609
|
+
"\n\nMust be `ConvertToMultiSigUserRequestSigners` converted to a string via `JSON.stringify(...)`.",
|
|
610
|
+
),
|
|
611
|
+
),
|
|
612
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
613
|
+
nonce: v.pipe(
|
|
614
|
+
UnsignedInteger,
|
|
615
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
616
|
+
),
|
|
617
|
+
}),
|
|
618
|
+
v.description("Action to perform."),
|
|
619
|
+
),
|
|
620
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
621
|
+
nonce: v.pipe(
|
|
622
|
+
UnsignedInteger,
|
|
623
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
624
|
+
),
|
|
625
|
+
/** Cryptographic signature. */
|
|
626
|
+
signature: v.pipe(
|
|
627
|
+
Signature,
|
|
628
|
+
v.description("Cryptographic signature."),
|
|
629
|
+
),
|
|
630
|
+
}),
|
|
631
|
+
v.transform(removeUndefinedKeys),
|
|
632
|
+
v.description("Convert a single-signature account to a multi-signature account."),
|
|
633
|
+
);
|
|
634
|
+
export type ConvertToMultiSigUserRequest = v.InferOutput<typeof ConvertToMultiSigUserRequest>;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Create a sub-account.
|
|
638
|
+
* @returns {CreateSubAccountResponse}
|
|
639
|
+
* @see null
|
|
640
|
+
*/
|
|
641
|
+
export const CreateSubAccountRequest = v.pipe(
|
|
642
|
+
v.object({
|
|
643
|
+
/** Action to perform. */
|
|
644
|
+
action: v.pipe(
|
|
645
|
+
v.object({
|
|
646
|
+
/** Type of action. */
|
|
647
|
+
type: v.pipe(
|
|
648
|
+
v.literal("createSubAccount"),
|
|
649
|
+
v.description("Type of action."),
|
|
650
|
+
),
|
|
651
|
+
/** Sub-account name. */
|
|
652
|
+
name: v.pipe(
|
|
653
|
+
v.string(),
|
|
654
|
+
v.minLength(1),
|
|
655
|
+
v.description("Sub-account name."),
|
|
656
|
+
),
|
|
657
|
+
}),
|
|
658
|
+
v.description("Action to perform."),
|
|
659
|
+
),
|
|
660
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
661
|
+
nonce: v.pipe(
|
|
662
|
+
UnsignedInteger,
|
|
663
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
664
|
+
),
|
|
665
|
+
/** Cryptographic signature. */
|
|
666
|
+
signature: v.pipe(
|
|
667
|
+
Signature,
|
|
668
|
+
v.description("Cryptographic signature."),
|
|
669
|
+
),
|
|
670
|
+
/** Expiration time of the action. */
|
|
671
|
+
expiresAfter: v.pipe(
|
|
672
|
+
v.optional(UnsignedInteger),
|
|
673
|
+
v.description("Expiration time of the action."),
|
|
674
|
+
),
|
|
675
|
+
}),
|
|
676
|
+
v.transform(removeUndefinedKeys),
|
|
677
|
+
v.description("Create a sub-account."),
|
|
678
|
+
);
|
|
679
|
+
export type CreateSubAccountRequest = v.InferOutput<typeof CreateSubAccountRequest>;
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Create a vault.
|
|
683
|
+
* @returns {CreateVaultResponse}
|
|
684
|
+
* @see null
|
|
685
|
+
*/
|
|
686
|
+
export const CreateVaultRequest = v.pipe(
|
|
687
|
+
v.object({
|
|
688
|
+
/** Action to perform. */
|
|
689
|
+
action: v.pipe(
|
|
690
|
+
v.object({
|
|
691
|
+
/** Type of action. */
|
|
692
|
+
type: v.pipe(
|
|
693
|
+
v.literal("createVault"),
|
|
694
|
+
v.description("Type of action."),
|
|
695
|
+
),
|
|
696
|
+
/** Vault name. */
|
|
697
|
+
name: v.pipe(
|
|
698
|
+
v.string(),
|
|
699
|
+
v.minLength(3),
|
|
700
|
+
v.description("Vault name."),
|
|
701
|
+
),
|
|
702
|
+
/** Vault description. */
|
|
703
|
+
description: v.pipe(
|
|
704
|
+
v.string(),
|
|
705
|
+
v.minLength(10),
|
|
706
|
+
v.description("Vault description."),
|
|
707
|
+
),
|
|
708
|
+
/** Initial balance (float * 1e6). */
|
|
709
|
+
initialUsd: v.pipe(
|
|
710
|
+
UnsignedInteger,
|
|
711
|
+
v.minValue(100000000), // 100 USDC
|
|
712
|
+
v.description("Initial balance (float * 1e6)."),
|
|
713
|
+
),
|
|
714
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
715
|
+
nonce: v.pipe(
|
|
716
|
+
UnsignedInteger,
|
|
717
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
718
|
+
),
|
|
719
|
+
}),
|
|
720
|
+
v.description("Action to perform."),
|
|
721
|
+
),
|
|
722
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
723
|
+
nonce: v.pipe(
|
|
724
|
+
UnsignedInteger,
|
|
725
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
726
|
+
),
|
|
727
|
+
/** Cryptographic signature. */
|
|
728
|
+
signature: v.pipe(
|
|
729
|
+
Signature,
|
|
730
|
+
v.description("Cryptographic signature."),
|
|
731
|
+
),
|
|
732
|
+
/** Expiration time of the action. */
|
|
733
|
+
expiresAfter: v.pipe(
|
|
734
|
+
v.optional(UnsignedInteger),
|
|
735
|
+
v.description("Expiration time of the action."),
|
|
736
|
+
),
|
|
737
|
+
}),
|
|
738
|
+
v.transform(removeUndefinedKeys),
|
|
739
|
+
v.description("Create a vault."),
|
|
740
|
+
);
|
|
741
|
+
export type CreateVaultRequest = v.InferOutput<typeof CreateVaultRequest>;
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Perform an action on a signer:
|
|
745
|
+
* - Jail to prevent them from signing transactions.
|
|
746
|
+
* - Unjail to allow them to sign transactions again.
|
|
747
|
+
* @returns {SuccessResponse}
|
|
748
|
+
* @see null
|
|
749
|
+
*/
|
|
750
|
+
export const CSignerActionRequest = v.pipe(
|
|
751
|
+
v.object({
|
|
752
|
+
/** Action to perform. */
|
|
753
|
+
action: v.pipe(
|
|
754
|
+
v.union([
|
|
755
|
+
v.object({
|
|
756
|
+
/** Type of action. */
|
|
757
|
+
type: v.pipe(
|
|
758
|
+
v.literal("CSignerAction"),
|
|
759
|
+
v.description("Type of action."),
|
|
760
|
+
),
|
|
761
|
+
/** Jail the signer. */
|
|
762
|
+
jailSelf: v.pipe(
|
|
763
|
+
v.null(),
|
|
764
|
+
v.description("Jail the signer."),
|
|
765
|
+
),
|
|
766
|
+
}),
|
|
767
|
+
v.object({
|
|
768
|
+
/** Type of action. */
|
|
769
|
+
type: v.pipe(
|
|
770
|
+
v.literal("CSignerAction"),
|
|
771
|
+
v.description("Type of action."),
|
|
772
|
+
),
|
|
773
|
+
/** Unjail the signer. */
|
|
774
|
+
unjailSelf: v.pipe(
|
|
775
|
+
v.null(),
|
|
776
|
+
v.description("Unjail the signer."),
|
|
777
|
+
),
|
|
778
|
+
}),
|
|
779
|
+
]),
|
|
780
|
+
v.description("Action to perform."),
|
|
781
|
+
),
|
|
782
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
783
|
+
nonce: v.pipe(
|
|
784
|
+
UnsignedInteger,
|
|
785
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
786
|
+
),
|
|
787
|
+
/** Cryptographic signature. */
|
|
788
|
+
signature: v.pipe(
|
|
789
|
+
Signature,
|
|
790
|
+
v.description("Cryptographic signature."),
|
|
791
|
+
),
|
|
792
|
+
/** Expiration time of the action. */
|
|
793
|
+
expiresAfter: v.pipe(
|
|
794
|
+
v.optional(UnsignedInteger),
|
|
795
|
+
v.description("Expiration time of the action."),
|
|
796
|
+
),
|
|
797
|
+
}),
|
|
798
|
+
v.transform(removeUndefinedKeys),
|
|
799
|
+
v.description(
|
|
800
|
+
"Perform an action on a signer." +
|
|
801
|
+
"\n- Jail to prevent them from signing transactions." +
|
|
802
|
+
"\n- Unjail to allow them to sign transactions again.",
|
|
803
|
+
),
|
|
804
|
+
);
|
|
805
|
+
export type CSignerActionRequest = v.InferOutput<typeof CSignerActionRequest>;
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* Perform an action on a validator:
|
|
809
|
+
* - Change profile information.
|
|
810
|
+
* - Register a new validator.
|
|
811
|
+
* - Unregister an existing validator.
|
|
812
|
+
* @returns {SuccessResponse}
|
|
813
|
+
* @see null
|
|
814
|
+
*/
|
|
815
|
+
export const CValidatorActionRequest = v.pipe(
|
|
816
|
+
v.object({
|
|
817
|
+
/** Action to perform. */
|
|
818
|
+
action: v.pipe(
|
|
819
|
+
v.union([
|
|
820
|
+
v.object({
|
|
821
|
+
/** Type of action. */
|
|
822
|
+
type: v.pipe(
|
|
823
|
+
v.literal("CValidatorAction"),
|
|
824
|
+
v.description("Type of action."),
|
|
825
|
+
),
|
|
826
|
+
/** Profile changes to apply. */
|
|
827
|
+
changeProfile: v.pipe(
|
|
828
|
+
v.object({
|
|
829
|
+
/** Validator node IP address. */
|
|
830
|
+
node_ip: v.pipe(
|
|
831
|
+
v.union([
|
|
832
|
+
v.object({
|
|
833
|
+
/** IP address. */
|
|
834
|
+
Ip: v.pipe(
|
|
835
|
+
v.string(),
|
|
836
|
+
v.ip(),
|
|
837
|
+
v.description("IP address."),
|
|
838
|
+
),
|
|
839
|
+
}),
|
|
840
|
+
v.null(),
|
|
841
|
+
]),
|
|
842
|
+
v.description("Validator node IP address."),
|
|
843
|
+
),
|
|
844
|
+
/** Validator name. */
|
|
845
|
+
name: v.pipe(
|
|
846
|
+
v.nullable(v.string()),
|
|
847
|
+
v.description("Validator name."),
|
|
848
|
+
),
|
|
849
|
+
/** Validator description. */
|
|
850
|
+
description: v.pipe(
|
|
851
|
+
v.nullable(v.string()),
|
|
852
|
+
v.description("Validator description."),
|
|
853
|
+
),
|
|
854
|
+
/** Validator jail status. */
|
|
855
|
+
unjailed: v.pipe(
|
|
856
|
+
v.boolean(),
|
|
857
|
+
v.description("Validator jail status."),
|
|
858
|
+
),
|
|
859
|
+
/** Enable or disable delegations. */
|
|
860
|
+
disable_delegations: v.pipe(
|
|
861
|
+
v.nullable(v.boolean()),
|
|
862
|
+
v.description("Enable or disable delegations."),
|
|
863
|
+
),
|
|
864
|
+
/** Commission rate in basis points (1 = 0.0001%). */
|
|
865
|
+
commission_bps: v.pipe(
|
|
866
|
+
v.nullable(UnsignedInteger),
|
|
867
|
+
v.description("Commission rate in basis points (1 = 0.0001%)."),
|
|
868
|
+
),
|
|
869
|
+
/** Signer address. */
|
|
870
|
+
signer: v.pipe(
|
|
871
|
+
v.nullable(v.pipe(Hex, v.length(42))),
|
|
872
|
+
v.description("Signer address."),
|
|
873
|
+
),
|
|
874
|
+
}),
|
|
875
|
+
v.description("Profile changes to apply."),
|
|
876
|
+
),
|
|
877
|
+
}),
|
|
878
|
+
v.object({
|
|
879
|
+
/** Type of action. */
|
|
880
|
+
type: v.pipe(
|
|
881
|
+
v.literal("CValidatorAction"),
|
|
882
|
+
v.description("Type of action."),
|
|
883
|
+
),
|
|
884
|
+
/** Registration parameters. */
|
|
885
|
+
register: v.pipe(
|
|
886
|
+
v.object({
|
|
887
|
+
/** Validator profile information. */
|
|
888
|
+
profile: v.pipe(
|
|
889
|
+
v.object({
|
|
890
|
+
/** Validator node IP address. */
|
|
891
|
+
node_ip: v.pipe(
|
|
892
|
+
v.object({
|
|
893
|
+
/** IP address. */
|
|
894
|
+
Ip: v.pipe(
|
|
895
|
+
v.string(),
|
|
896
|
+
v.ip(),
|
|
897
|
+
v.description("IP address."),
|
|
898
|
+
),
|
|
899
|
+
}),
|
|
900
|
+
v.description("Validator node IP address."),
|
|
901
|
+
),
|
|
902
|
+
/** Validator name. */
|
|
903
|
+
name: v.pipe(
|
|
904
|
+
v.string(),
|
|
905
|
+
v.description("Validator name."),
|
|
906
|
+
),
|
|
907
|
+
/** Validator description. */
|
|
908
|
+
description: v.pipe(
|
|
909
|
+
v.string(),
|
|
910
|
+
v.description("Validator description."),
|
|
911
|
+
),
|
|
912
|
+
/** Whether delegations are disabled. */
|
|
913
|
+
delegations_disabled: v.pipe(
|
|
914
|
+
v.boolean(),
|
|
915
|
+
v.description("Whether delegations are disabled."),
|
|
916
|
+
),
|
|
917
|
+
/** Commission rate in basis points (1 = 0.0001%). */
|
|
918
|
+
commission_bps: v.pipe(
|
|
919
|
+
UnsignedInteger,
|
|
920
|
+
v.description("Commission rate in basis points (1 = 0.0001%)."),
|
|
921
|
+
),
|
|
922
|
+
/** Signer address. */
|
|
923
|
+
signer: v.pipe(
|
|
924
|
+
v.pipe(Hex, v.length(42)),
|
|
925
|
+
v.description("Signer address."),
|
|
926
|
+
),
|
|
927
|
+
}),
|
|
928
|
+
v.description("Validator profile information."),
|
|
929
|
+
),
|
|
930
|
+
/** Initial jail status. */
|
|
931
|
+
unjailed: v.pipe(
|
|
932
|
+
v.boolean(),
|
|
933
|
+
v.description("Initial jail status."),
|
|
934
|
+
),
|
|
935
|
+
/** Initial stake amount in wei. */
|
|
936
|
+
initial_wei: v.pipe(
|
|
937
|
+
UnsignedInteger,
|
|
938
|
+
v.description("Initial stake amount in wei."),
|
|
939
|
+
),
|
|
940
|
+
}),
|
|
941
|
+
v.description("Registration parameters."),
|
|
942
|
+
),
|
|
943
|
+
}),
|
|
944
|
+
v.object({
|
|
945
|
+
/** Type of action. */
|
|
946
|
+
type: v.pipe(
|
|
947
|
+
v.literal("CValidatorAction"),
|
|
948
|
+
v.description("Type of action."),
|
|
949
|
+
),
|
|
950
|
+
/** Unregister the validator. */
|
|
951
|
+
unregister: v.pipe(
|
|
952
|
+
v.null(),
|
|
953
|
+
v.description("Unregister the validator."),
|
|
954
|
+
),
|
|
955
|
+
}),
|
|
956
|
+
]),
|
|
957
|
+
v.description("Action to perform."),
|
|
958
|
+
),
|
|
959
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
960
|
+
nonce: v.pipe(
|
|
961
|
+
UnsignedInteger,
|
|
962
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
963
|
+
),
|
|
964
|
+
/** Cryptographic signature. */
|
|
965
|
+
signature: v.pipe(
|
|
966
|
+
Signature,
|
|
967
|
+
v.description("Cryptographic signature."),
|
|
968
|
+
),
|
|
969
|
+
/** Expiration time of the action. */
|
|
970
|
+
expiresAfter: v.pipe(
|
|
971
|
+
v.optional(UnsignedInteger),
|
|
972
|
+
v.description("Expiration time of the action."),
|
|
973
|
+
),
|
|
974
|
+
}),
|
|
975
|
+
v.transform(removeUndefinedKeys),
|
|
976
|
+
v.description(
|
|
977
|
+
"Perform an action on a validator:" +
|
|
978
|
+
"\n- Change profile information." +
|
|
979
|
+
"\n- Register a new validator." +
|
|
980
|
+
"\n- Unregister an existing validator.",
|
|
981
|
+
),
|
|
982
|
+
);
|
|
983
|
+
export type CValidatorActionRequest = v.InferOutput<typeof CValidatorActionRequest>;
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Transfer native token from staking into the user spot account.
|
|
987
|
+
* @returns {SuccessResponse}
|
|
988
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#withdraw-from-staking
|
|
989
|
+
*/
|
|
990
|
+
export const CWithdrawRequest = v.pipe(
|
|
991
|
+
v.object({
|
|
992
|
+
/** Action to perform. */
|
|
993
|
+
action: v.pipe(
|
|
994
|
+
v.object({
|
|
995
|
+
/** Type of action. */
|
|
996
|
+
type: v.pipe(
|
|
997
|
+
v.literal("cWithdraw"),
|
|
998
|
+
v.description("Type of action."),
|
|
999
|
+
),
|
|
1000
|
+
/** Chain ID used for signing. */
|
|
1001
|
+
signatureChainId: v.pipe(
|
|
1002
|
+
Hex,
|
|
1003
|
+
v.description("Chain ID used for signing."),
|
|
1004
|
+
),
|
|
1005
|
+
/** HyperLiquid network. */
|
|
1006
|
+
hyperliquidChain: v.pipe(
|
|
1007
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
1008
|
+
v.description("HyperLiquid network."),
|
|
1009
|
+
),
|
|
1010
|
+
/** Amount of wei to withdraw from staking balance (float * 1e8). */
|
|
1011
|
+
wei: v.pipe(
|
|
1012
|
+
UnsignedInteger,
|
|
1013
|
+
v.description("Amount of wei to withdraw from staking balance (float * 1e8)."),
|
|
1014
|
+
),
|
|
1015
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1016
|
+
nonce: v.pipe(
|
|
1017
|
+
UnsignedInteger,
|
|
1018
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1019
|
+
),
|
|
1020
|
+
}),
|
|
1021
|
+
v.description("Action to perform."),
|
|
1022
|
+
),
|
|
1023
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1024
|
+
nonce: v.pipe(
|
|
1025
|
+
UnsignedInteger,
|
|
1026
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1027
|
+
),
|
|
1028
|
+
/** Cryptographic signature. */
|
|
1029
|
+
signature: v.pipe(
|
|
1030
|
+
Signature,
|
|
1031
|
+
v.description("Cryptographic signature."),
|
|
1032
|
+
),
|
|
1033
|
+
}),
|
|
1034
|
+
v.transform(removeUndefinedKeys),
|
|
1035
|
+
v.description("Transfer native token from staking into the user spot account."),
|
|
1036
|
+
);
|
|
1037
|
+
export type CWithdrawRequest = v.InferOutput<typeof CWithdrawRequest>;
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Configure block type for EVM transactions.
|
|
1041
|
+
* @returns {SuccessResponse}
|
|
1042
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/dual-block-architecture
|
|
1043
|
+
*/
|
|
1044
|
+
export const EvmUserModifyRequest = v.pipe(
|
|
1045
|
+
v.object({
|
|
1046
|
+
/** Action to perform. */
|
|
1047
|
+
action: v.pipe(
|
|
1048
|
+
v.object({
|
|
1049
|
+
/** Type of action. */
|
|
1050
|
+
type: v.pipe(
|
|
1051
|
+
v.literal("evmUserModify"),
|
|
1052
|
+
v.description("Type of action."),
|
|
1053
|
+
),
|
|
1054
|
+
/** `true` for large blocks, `false` for small blocks. */
|
|
1055
|
+
usingBigBlocks: v.pipe(
|
|
1056
|
+
v.boolean(),
|
|
1057
|
+
v.description("`true` for large blocks, `false` for small blocks."),
|
|
1058
|
+
),
|
|
1059
|
+
}),
|
|
1060
|
+
v.description("Action to perform."),
|
|
1061
|
+
),
|
|
1062
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1063
|
+
nonce: v.pipe(
|
|
1064
|
+
UnsignedInteger,
|
|
1065
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1066
|
+
),
|
|
1067
|
+
/** Cryptographic signature. */
|
|
1068
|
+
signature: v.pipe(
|
|
1069
|
+
Signature,
|
|
1070
|
+
v.description("Cryptographic signature."),
|
|
1071
|
+
),
|
|
1072
|
+
/** Expiration time of the action. */
|
|
1073
|
+
expiresAfter: v.pipe(
|
|
1074
|
+
v.optional(UnsignedInteger),
|
|
1075
|
+
v.description("Expiration time of the action."),
|
|
1076
|
+
),
|
|
1077
|
+
}),
|
|
1078
|
+
v.transform(removeUndefinedKeys),
|
|
1079
|
+
v.description("Configure block type for EVM transactions."),
|
|
1080
|
+
);
|
|
1081
|
+
export type EvmUserModifyRequest = v.InferOutput<typeof EvmUserModifyRequest>;
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* Modify an order.
|
|
1085
|
+
* @returns {SuccessResponse}
|
|
1086
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-an-order
|
|
1087
|
+
*/
|
|
1088
|
+
export const ModifyRequest = v.pipe(
|
|
1089
|
+
v.object({
|
|
1090
|
+
/** Action to perform. */
|
|
1091
|
+
action: v.pipe(
|
|
1092
|
+
v.object({
|
|
1093
|
+
/** Type of action. */
|
|
1094
|
+
type: v.pipe(
|
|
1095
|
+
v.literal("modify"),
|
|
1096
|
+
v.description("Type of action."),
|
|
1097
|
+
),
|
|
1098
|
+
/** Order ID or Client Order ID. */
|
|
1099
|
+
oid: v.pipe(
|
|
1100
|
+
v.union([
|
|
1101
|
+
UnsignedInteger,
|
|
1102
|
+
v.pipe(Hex, v.length(34)),
|
|
1103
|
+
]),
|
|
1104
|
+
v.description("Order ID or Client Order ID."),
|
|
1105
|
+
),
|
|
1106
|
+
/** New order parameters. */
|
|
1107
|
+
order: v.pipe(
|
|
1108
|
+
OrderParams,
|
|
1109
|
+
v.description("New order parameters."),
|
|
1110
|
+
),
|
|
1111
|
+
}),
|
|
1112
|
+
v.description("Action to perform."),
|
|
1113
|
+
),
|
|
1114
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1115
|
+
nonce: v.pipe(
|
|
1116
|
+
UnsignedInteger,
|
|
1117
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1118
|
+
),
|
|
1119
|
+
/** Cryptographic signature. */
|
|
1120
|
+
signature: v.pipe(
|
|
1121
|
+
Signature,
|
|
1122
|
+
v.description("Cryptographic signature."),
|
|
1123
|
+
),
|
|
1124
|
+
/** Vault address (for vault trading). */
|
|
1125
|
+
vaultAddress: v.pipe(
|
|
1126
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
1127
|
+
v.description("Vault address (for vault trading)."),
|
|
1128
|
+
),
|
|
1129
|
+
/** Expiration time of the action. */
|
|
1130
|
+
expiresAfter: v.pipe(
|
|
1131
|
+
v.optional(UnsignedInteger),
|
|
1132
|
+
v.description("Expiration time of the action."),
|
|
1133
|
+
),
|
|
1134
|
+
}),
|
|
1135
|
+
v.transform(removeUndefinedKeys),
|
|
1136
|
+
v.description("Modify an order."),
|
|
1137
|
+
);
|
|
1138
|
+
export type ModifyRequest = v.InferOutput<typeof ModifyRequest>;
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* This action does not do anything (no operation), but causes the nonce to be marked as used.
|
|
1142
|
+
* @returns {SuccessResponse}
|
|
1143
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#invalidate-pending-nonce-noop
|
|
1144
|
+
*/
|
|
1145
|
+
export const NoopRequest = v.pipe(
|
|
1146
|
+
v.object({
|
|
1147
|
+
/** Action to perform. */
|
|
1148
|
+
action: v.pipe(
|
|
1149
|
+
v.object({
|
|
1150
|
+
/** Type of action. */
|
|
1151
|
+
type: v.pipe(
|
|
1152
|
+
v.literal("noop"),
|
|
1153
|
+
v.description("Type of action."),
|
|
1154
|
+
),
|
|
1155
|
+
}),
|
|
1156
|
+
v.description("Action to perform."),
|
|
1157
|
+
),
|
|
1158
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1159
|
+
nonce: v.pipe(
|
|
1160
|
+
UnsignedInteger,
|
|
1161
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1162
|
+
),
|
|
1163
|
+
/** Cryptographic signature. */
|
|
1164
|
+
signature: v.pipe(
|
|
1165
|
+
Signature,
|
|
1166
|
+
v.description("Cryptographic signature."),
|
|
1167
|
+
),
|
|
1168
|
+
/** Expiration time of the action. */
|
|
1169
|
+
expiresAfter: v.pipe(
|
|
1170
|
+
v.optional(UnsignedInteger),
|
|
1171
|
+
v.description("Expiration time of the action."),
|
|
1172
|
+
),
|
|
1173
|
+
}),
|
|
1174
|
+
v.transform(removeUndefinedKeys),
|
|
1175
|
+
v.description("This action does not do anything (no operation), but causes the nonce to be marked as used."),
|
|
1176
|
+
);
|
|
1177
|
+
export type NoopRequest = v.InferOutput<typeof NoopRequest>;
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* Place an order(s).
|
|
1181
|
+
* @returns {OrderResponse}
|
|
1182
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
|
|
1183
|
+
*/
|
|
1184
|
+
export const OrderRequest = v.pipe(
|
|
1185
|
+
v.object({
|
|
1186
|
+
/** Action to perform. */
|
|
1187
|
+
action: v.pipe(
|
|
1188
|
+
v.object({
|
|
1189
|
+
/** Type of action. */
|
|
1190
|
+
type: v.pipe(
|
|
1191
|
+
v.literal("order"),
|
|
1192
|
+
v.description("Type of action."),
|
|
1193
|
+
),
|
|
1194
|
+
/** Order parameters. */
|
|
1195
|
+
orders: v.pipe(
|
|
1196
|
+
v.array(OrderParams),
|
|
1197
|
+
v.description("Order parameters."),
|
|
1198
|
+
),
|
|
1199
|
+
/**
|
|
1200
|
+
* Order grouping strategy:
|
|
1201
|
+
* - `na`: Standard order without grouping.
|
|
1202
|
+
* - `normalTpsl`: TP/SL order with fixed size that doesn't adjust with position changes.
|
|
1203
|
+
* - `positionTpsl`: TP/SL order that adjusts proportionally with the position size.
|
|
1204
|
+
*/
|
|
1205
|
+
grouping: v.pipe(
|
|
1206
|
+
v.union([
|
|
1207
|
+
v.literal("na"),
|
|
1208
|
+
v.literal("normalTpsl"),
|
|
1209
|
+
v.literal("positionTpsl"),
|
|
1210
|
+
]),
|
|
1211
|
+
v.description(
|
|
1212
|
+
"Order grouping strategy:" +
|
|
1213
|
+
"\n- `na`: Standard order without grouping." +
|
|
1214
|
+
"\n- `normalTpsl`: TP/SL order with fixed size that doesn't adjust with position changes." +
|
|
1215
|
+
"\n- `positionTpsl`: TP/SL order that adjusts proportionally with the position size.",
|
|
1216
|
+
),
|
|
1217
|
+
),
|
|
1218
|
+
/** Builder fee. */
|
|
1219
|
+
builder: v.pipe(
|
|
1220
|
+
v.optional(v.object({
|
|
1221
|
+
/** Builder address. */
|
|
1222
|
+
b: v.pipe(
|
|
1223
|
+
v.pipe(Hex, v.length(42)),
|
|
1224
|
+
v.description("Builder address."),
|
|
1225
|
+
),
|
|
1226
|
+
/** Builder fee in 0.1bps (1 = 0.0001%). */
|
|
1227
|
+
f: v.pipe(
|
|
1228
|
+
UnsignedInteger,
|
|
1229
|
+
v.description("Builder fee in 0.1bps (1 = 0.0001%)."),
|
|
1230
|
+
),
|
|
1231
|
+
})),
|
|
1232
|
+
v.description("Builder fee."),
|
|
1233
|
+
),
|
|
1234
|
+
}),
|
|
1235
|
+
v.description("Action to perform."),
|
|
1236
|
+
),
|
|
1237
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1238
|
+
nonce: v.pipe(
|
|
1239
|
+
UnsignedInteger,
|
|
1240
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1241
|
+
),
|
|
1242
|
+
/** Cryptographic signature. */
|
|
1243
|
+
signature: v.pipe(
|
|
1244
|
+
Signature,
|
|
1245
|
+
v.description("Cryptographic signature."),
|
|
1246
|
+
),
|
|
1247
|
+
/** Vault address (for vault trading). */
|
|
1248
|
+
vaultAddress: v.pipe(
|
|
1249
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
1250
|
+
v.description("Vault address (for vault trading)."),
|
|
1251
|
+
),
|
|
1252
|
+
/** Expiration time of the action. */
|
|
1253
|
+
expiresAfter: v.pipe(
|
|
1254
|
+
v.optional(UnsignedInteger),
|
|
1255
|
+
v.description("Expiration time of the action."),
|
|
1256
|
+
),
|
|
1257
|
+
}),
|
|
1258
|
+
v.transform(removeUndefinedKeys),
|
|
1259
|
+
v.description("Place an order(s)."),
|
|
1260
|
+
);
|
|
1261
|
+
export type OrderRequest = v.InferOutput<typeof OrderRequest>;
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Deploying HIP-3 assets:
|
|
1265
|
+
* - Register Asset
|
|
1266
|
+
* - Set Oracle
|
|
1267
|
+
* @returns {SuccessResponse}
|
|
1268
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/deploying-hip-3-assets
|
|
1269
|
+
*/
|
|
1270
|
+
export const PerpDeployRequest = v.pipe(
|
|
1271
|
+
v.object({
|
|
1272
|
+
/** Action to perform. */
|
|
1273
|
+
action: v.pipe(
|
|
1274
|
+
v.union([
|
|
1275
|
+
v.pipe(
|
|
1276
|
+
v.object({
|
|
1277
|
+
/** Type of action. */
|
|
1278
|
+
type: v.pipe(
|
|
1279
|
+
v.literal("perpDeploy"),
|
|
1280
|
+
v.description("Type of action."),
|
|
1281
|
+
),
|
|
1282
|
+
/** Parameters for registering a new perpetual asset. */
|
|
1283
|
+
registerAsset: v.pipe(
|
|
1284
|
+
v.object({
|
|
1285
|
+
/** Max gas in native token wei. If not provided, then uses current deploy auction price. */
|
|
1286
|
+
maxGas: v.pipe(
|
|
1287
|
+
v.nullable(UnsignedInteger),
|
|
1288
|
+
v.description(
|
|
1289
|
+
"Max gas in native token wei. If not provided, then uses current deploy auction price.",
|
|
1290
|
+
),
|
|
1291
|
+
),
|
|
1292
|
+
/** Contains new asset listing parameters. */
|
|
1293
|
+
assetRequest: v.pipe(
|
|
1294
|
+
v.object({
|
|
1295
|
+
/** Coin symbol for the new asset. */
|
|
1296
|
+
coin: v.pipe(
|
|
1297
|
+
v.string(),
|
|
1298
|
+
v.description("Coin symbol for the new asset."),
|
|
1299
|
+
),
|
|
1300
|
+
/** Number of decimal places for size. */
|
|
1301
|
+
szDecimals: v.pipe(
|
|
1302
|
+
UnsignedInteger,
|
|
1303
|
+
v.description("Number of decimal places for size."),
|
|
1304
|
+
),
|
|
1305
|
+
/** Initial oracle price for the asset. */
|
|
1306
|
+
oraclePx: v.pipe(
|
|
1307
|
+
UnsignedDecimal,
|
|
1308
|
+
v.description("Initial oracle price for the asset."),
|
|
1309
|
+
),
|
|
1310
|
+
/** Margin table identifier for risk management. */
|
|
1311
|
+
marginTableId: v.pipe(
|
|
1312
|
+
UnsignedInteger,
|
|
1313
|
+
v.description("Margin table identifier for risk management."),
|
|
1314
|
+
),
|
|
1315
|
+
/** Whether the asset can only be traded with isolated margin. */
|
|
1316
|
+
onlyIsolated: v.pipe(
|
|
1317
|
+
v.boolean(),
|
|
1318
|
+
v.description("Whether the asset can only be traded with isolated margin."),
|
|
1319
|
+
),
|
|
1320
|
+
}),
|
|
1321
|
+
v.description("Contains new asset listing parameters."),
|
|
1322
|
+
),
|
|
1323
|
+
/** Name of the dex. */
|
|
1324
|
+
dex: v.pipe(
|
|
1325
|
+
v.string(),
|
|
1326
|
+
v.description("Name of the dex."),
|
|
1327
|
+
),
|
|
1328
|
+
/** Contains new dex parameters. */
|
|
1329
|
+
schema: v.pipe(
|
|
1330
|
+
v.nullable(v.object({
|
|
1331
|
+
/** Full name of the dex. */
|
|
1332
|
+
fullName: v.pipe(
|
|
1333
|
+
v.string(),
|
|
1334
|
+
v.description("Full name of the dex."),
|
|
1335
|
+
),
|
|
1336
|
+
/** Collateral token index. */
|
|
1337
|
+
collateralToken: v.pipe(
|
|
1338
|
+
UnsignedInteger,
|
|
1339
|
+
v.description("Collateral token index."),
|
|
1340
|
+
),
|
|
1341
|
+
/** User to update oracles. If not provided, then deployer is assumed to be oracle updater. */
|
|
1342
|
+
oracleUpdater: v.pipe(
|
|
1343
|
+
v.nullable(v.pipe(Hex, v.length(42))),
|
|
1344
|
+
v.description(
|
|
1345
|
+
"User to update oracles. If not provided, then deployer is assumed to be oracle updater.",
|
|
1346
|
+
),
|
|
1347
|
+
),
|
|
1348
|
+
})),
|
|
1349
|
+
v.description("Contains new dex parameters."),
|
|
1350
|
+
),
|
|
1351
|
+
}),
|
|
1352
|
+
v.description("Parameters for registering a new perpetual asset."),
|
|
1353
|
+
),
|
|
1354
|
+
}),
|
|
1355
|
+
v.description("Register asset variant"),
|
|
1356
|
+
),
|
|
1357
|
+
v.pipe(
|
|
1358
|
+
v.object({
|
|
1359
|
+
/** Type of action. */
|
|
1360
|
+
type: v.pipe(
|
|
1361
|
+
v.literal("perpDeploy"),
|
|
1362
|
+
v.description("Type of action."),
|
|
1363
|
+
),
|
|
1364
|
+
/** Parameters for setting oracle and mark prices for assets. */
|
|
1365
|
+
setOracle: v.pipe(
|
|
1366
|
+
v.object({
|
|
1367
|
+
/** Name of the dex. */
|
|
1368
|
+
dex: v.pipe(
|
|
1369
|
+
v.string(),
|
|
1370
|
+
v.minLength(1),
|
|
1371
|
+
v.description("Name of the dex."),
|
|
1372
|
+
),
|
|
1373
|
+
/** A list (sorted by key) of asset and oracle prices. */
|
|
1374
|
+
oraclePxs: v.pipe(
|
|
1375
|
+
v.array(v.tuple([v.string(), UnsignedDecimal])),
|
|
1376
|
+
v.description("A list (sorted by key) of asset and oracle prices."),
|
|
1377
|
+
),
|
|
1378
|
+
/** An outer list of inner lists (inner list sorted by key) of asset and mark prices. */
|
|
1379
|
+
markPxs: v.pipe(
|
|
1380
|
+
v.array(v.array(v.tuple([v.string(), UnsignedDecimal]))),
|
|
1381
|
+
v.description(
|
|
1382
|
+
"An outer list of inner lists (inner list sorted by key) of asset and mark prices.",
|
|
1383
|
+
),
|
|
1384
|
+
),
|
|
1385
|
+
}),
|
|
1386
|
+
v.description("Parameters for setting oracle and mark prices for assets."),
|
|
1387
|
+
),
|
|
1388
|
+
}),
|
|
1389
|
+
v.description("Set oracle variant"),
|
|
1390
|
+
),
|
|
1391
|
+
]),
|
|
1392
|
+
v.description("Action to perform."),
|
|
1393
|
+
),
|
|
1394
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1395
|
+
nonce: v.pipe(
|
|
1396
|
+
UnsignedInteger,
|
|
1397
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1398
|
+
),
|
|
1399
|
+
/** Cryptographic signature. */
|
|
1400
|
+
signature: v.pipe(
|
|
1401
|
+
Signature,
|
|
1402
|
+
v.description("Cryptographic signature."),
|
|
1403
|
+
),
|
|
1404
|
+
/** Expiration time of the action. */
|
|
1405
|
+
expiresAfter: v.pipe(
|
|
1406
|
+
v.optional(UnsignedInteger),
|
|
1407
|
+
v.description("Expiration time of the action."),
|
|
1408
|
+
),
|
|
1409
|
+
}),
|
|
1410
|
+
v.transform(removeUndefinedKeys),
|
|
1411
|
+
v.description(
|
|
1412
|
+
"Deploying HIP-3 assets:" +
|
|
1413
|
+
"\n- Register Asset" +
|
|
1414
|
+
"\n- Set Oracle",
|
|
1415
|
+
),
|
|
1416
|
+
);
|
|
1417
|
+
export type PerpDeployRequest = v.InferOutput<typeof PerpDeployRequest>;
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* Create a referral code.
|
|
1421
|
+
* @returns {SuccessResponse}
|
|
1422
|
+
* @see null
|
|
1423
|
+
*/
|
|
1424
|
+
export const RegisterReferrerRequest = v.pipe(
|
|
1425
|
+
v.object({
|
|
1426
|
+
/** Action to perform. */
|
|
1427
|
+
action: v.pipe(
|
|
1428
|
+
v.object({
|
|
1429
|
+
/** Type of action. */
|
|
1430
|
+
type: v.pipe(
|
|
1431
|
+
v.literal("registerReferrer"),
|
|
1432
|
+
v.description("Type of action."),
|
|
1433
|
+
),
|
|
1434
|
+
/** Referral code to create. */
|
|
1435
|
+
code: v.pipe(
|
|
1436
|
+
v.string(),
|
|
1437
|
+
v.minLength(1),
|
|
1438
|
+
v.description("Referral code to create."),
|
|
1439
|
+
),
|
|
1440
|
+
}),
|
|
1441
|
+
v.description("Action to perform."),
|
|
1442
|
+
),
|
|
1443
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1444
|
+
nonce: v.pipe(
|
|
1445
|
+
UnsignedInteger,
|
|
1446
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1447
|
+
),
|
|
1448
|
+
/** Cryptographic signature. */
|
|
1449
|
+
signature: v.pipe(
|
|
1450
|
+
Signature,
|
|
1451
|
+
v.description("Cryptographic signature."),
|
|
1452
|
+
),
|
|
1453
|
+
/** Expiration time of the action. */
|
|
1454
|
+
expiresAfter: v.pipe(
|
|
1455
|
+
v.optional(UnsignedInteger),
|
|
1456
|
+
v.description("Expiration time of the action."),
|
|
1457
|
+
),
|
|
1458
|
+
}),
|
|
1459
|
+
v.transform(removeUndefinedKeys),
|
|
1460
|
+
v.description("Create a referral code."),
|
|
1461
|
+
);
|
|
1462
|
+
export type RegisterReferrerRequest = v.InferOutput<typeof RegisterReferrerRequest>;
|
|
1463
|
+
|
|
1464
|
+
/**
|
|
1465
|
+
* Reserve additional rate-limited actions for a fee.
|
|
1466
|
+
* @returns {SuccessResponse}
|
|
1467
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#reserve-additional-actions
|
|
1468
|
+
*/
|
|
1469
|
+
export const ReserveRequestWeightRequest = v.pipe(
|
|
1470
|
+
v.object({
|
|
1471
|
+
/** Action to perform. */
|
|
1472
|
+
action: v.pipe(
|
|
1473
|
+
v.object({
|
|
1474
|
+
/** Type of action. */
|
|
1475
|
+
type: v.pipe(
|
|
1476
|
+
v.literal("reserveRequestWeight"),
|
|
1477
|
+
v.description("Type of action."),
|
|
1478
|
+
),
|
|
1479
|
+
/** Amount of request weight to reserve. */
|
|
1480
|
+
weight: v.pipe(
|
|
1481
|
+
UnsignedInteger,
|
|
1482
|
+
v.description("Amount of request weight to reserve."),
|
|
1483
|
+
),
|
|
1484
|
+
}),
|
|
1485
|
+
v.description("Action to perform."),
|
|
1486
|
+
),
|
|
1487
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1488
|
+
nonce: v.pipe(
|
|
1489
|
+
UnsignedInteger,
|
|
1490
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1491
|
+
),
|
|
1492
|
+
/** Cryptographic signature. */
|
|
1493
|
+
signature: v.pipe(
|
|
1494
|
+
Signature,
|
|
1495
|
+
v.description("Cryptographic signature."),
|
|
1496
|
+
),
|
|
1497
|
+
/** Expiration time of the action. */
|
|
1498
|
+
expiresAfter: v.pipe(
|
|
1499
|
+
v.optional(UnsignedInteger),
|
|
1500
|
+
v.description("Expiration time of the action."),
|
|
1501
|
+
),
|
|
1502
|
+
}),
|
|
1503
|
+
v.transform(removeUndefinedKeys),
|
|
1504
|
+
v.description("Reserve additional rate-limited actions for a fee."),
|
|
1505
|
+
);
|
|
1506
|
+
export type ReserveRequestWeightRequest = v.InferOutput<typeof ReserveRequestWeightRequest>;
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* Schedule a cancel-all operation at a future time.
|
|
1510
|
+
* @returns {SuccessResponse}
|
|
1511
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#schedule-cancel-dead-mans-switch
|
|
1512
|
+
*/
|
|
1513
|
+
export const ScheduleCancelRequest = v.pipe(
|
|
1514
|
+
v.object({
|
|
1515
|
+
/** Action to perform. */
|
|
1516
|
+
action: v.pipe(
|
|
1517
|
+
v.object({
|
|
1518
|
+
/** Type of action. */
|
|
1519
|
+
type: v.pipe(
|
|
1520
|
+
v.literal("scheduleCancel"),
|
|
1521
|
+
v.description("Type of action."),
|
|
1522
|
+
),
|
|
1523
|
+
/**
|
|
1524
|
+
* Scheduled time (in ms since epoch).
|
|
1525
|
+
* Must be at least 5 seconds in the future.
|
|
1526
|
+
*
|
|
1527
|
+
* If not specified, will cause all scheduled cancel operations to be deleted.
|
|
1528
|
+
*/
|
|
1529
|
+
time: v.pipe(
|
|
1530
|
+
v.optional(UnsignedInteger),
|
|
1531
|
+
v.description(
|
|
1532
|
+
"Scheduled time (in ms since epoch)." +
|
|
1533
|
+
"\nMust be at least 5 seconds in the future." +
|
|
1534
|
+
"\n\nIf not specified, will cause all scheduled cancel operations to be deleted.",
|
|
1535
|
+
),
|
|
1536
|
+
),
|
|
1537
|
+
}),
|
|
1538
|
+
v.description("Action to perform."),
|
|
1539
|
+
),
|
|
1540
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1541
|
+
nonce: v.pipe(
|
|
1542
|
+
UnsignedInteger,
|
|
1543
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1544
|
+
),
|
|
1545
|
+
/** Cryptographic signature. */
|
|
1546
|
+
signature: v.pipe(
|
|
1547
|
+
Signature,
|
|
1548
|
+
v.description("Cryptographic signature."),
|
|
1549
|
+
),
|
|
1550
|
+
/** Vault address (for vault trading). */
|
|
1551
|
+
vaultAddress: v.pipe(
|
|
1552
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
1553
|
+
v.description("Vault address (for vault trading)."),
|
|
1554
|
+
),
|
|
1555
|
+
/** Expiration time of the action. */
|
|
1556
|
+
expiresAfter: v.pipe(
|
|
1557
|
+
v.optional(UnsignedInteger),
|
|
1558
|
+
v.description("Expiration time of the action."),
|
|
1559
|
+
),
|
|
1560
|
+
}),
|
|
1561
|
+
v.transform(removeUndefinedKeys),
|
|
1562
|
+
v.description("Schedule a cancel-all operation at a future time."),
|
|
1563
|
+
);
|
|
1564
|
+
export type ScheduleCancelRequest = v.InferOutput<typeof ScheduleCancelRequest>;
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* Transfer tokens between different perp DEXs, spot balance, users, and/or sub-accounts.
|
|
1568
|
+
* @returns {SuccessResponse}
|
|
1569
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#send-asset-testnet-only
|
|
1570
|
+
*/
|
|
1571
|
+
export const SendAssetRequest = v.pipe(
|
|
1572
|
+
v.object({
|
|
1573
|
+
/** Action to perform. */
|
|
1574
|
+
action: v.pipe(
|
|
1575
|
+
v.object({
|
|
1576
|
+
/** Type of action. */
|
|
1577
|
+
type: v.pipe(
|
|
1578
|
+
v.literal("sendAsset"),
|
|
1579
|
+
v.description("Type of action."),
|
|
1580
|
+
),
|
|
1581
|
+
/** Chain ID used for signing. */
|
|
1582
|
+
signatureChainId: v.pipe(
|
|
1583
|
+
Hex,
|
|
1584
|
+
v.description("Chain ID used for signing."),
|
|
1585
|
+
),
|
|
1586
|
+
/** HyperLiquid network. */
|
|
1587
|
+
hyperliquidChain: v.pipe(
|
|
1588
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
1589
|
+
v.description("HyperLiquid network."),
|
|
1590
|
+
),
|
|
1591
|
+
/** Destination address. */
|
|
1592
|
+
destination: v.pipe(
|
|
1593
|
+
v.pipe(Hex, v.length(42)),
|
|
1594
|
+
v.description("Destination address."),
|
|
1595
|
+
),
|
|
1596
|
+
/** Source DEX ("" for default USDC perp DEX, "spot" for spot). */
|
|
1597
|
+
sourceDex: v.pipe(
|
|
1598
|
+
v.string(),
|
|
1599
|
+
v.description('Source DEX ("" for default USDC perp DEX, "spot" for spot).'),
|
|
1600
|
+
),
|
|
1601
|
+
/** Destination DEX ("" for default USDC perp DEX, "spot" for spot). */
|
|
1602
|
+
destinationDex: v.pipe(
|
|
1603
|
+
v.string(),
|
|
1604
|
+
v.description('Destination DEX ("" for default USDC perp DEX, "spot" for spot).'),
|
|
1605
|
+
),
|
|
1606
|
+
/** Token identifier. */
|
|
1607
|
+
token: v.pipe(
|
|
1608
|
+
TokenId,
|
|
1609
|
+
v.description("Token identifier."),
|
|
1610
|
+
),
|
|
1611
|
+
/** Amount to send (not in wei). */
|
|
1612
|
+
amount: v.pipe(
|
|
1613
|
+
UnsignedDecimal,
|
|
1614
|
+
v.description("Amount to send (not in wei)."),
|
|
1615
|
+
),
|
|
1616
|
+
/** Source sub-account address ("" for main account). */
|
|
1617
|
+
fromSubAccount: v.pipe(
|
|
1618
|
+
v.union([
|
|
1619
|
+
v.literal(""),
|
|
1620
|
+
v.pipe(Hex, v.length(42)),
|
|
1621
|
+
]),
|
|
1622
|
+
v.description('Source sub-account address ("" for main account).'),
|
|
1623
|
+
),
|
|
1624
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1625
|
+
nonce: v.pipe(
|
|
1626
|
+
UnsignedInteger,
|
|
1627
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1628
|
+
),
|
|
1629
|
+
}),
|
|
1630
|
+
v.description("Action to perform."),
|
|
1631
|
+
),
|
|
1632
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1633
|
+
nonce: v.pipe(
|
|
1634
|
+
UnsignedInteger,
|
|
1635
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1636
|
+
),
|
|
1637
|
+
/** Cryptographic signature. */
|
|
1638
|
+
signature: v.pipe(
|
|
1639
|
+
Signature,
|
|
1640
|
+
v.description("Cryptographic signature."),
|
|
1641
|
+
),
|
|
1642
|
+
}),
|
|
1643
|
+
v.transform(removeUndefinedKeys),
|
|
1644
|
+
v.description("Transfer tokens between different perp DEXs, spot balance, users, and/or sub-accounts."),
|
|
1645
|
+
);
|
|
1646
|
+
export type SendAssetRequest = v.InferOutput<typeof SendAssetRequest>;
|
|
1647
|
+
|
|
1648
|
+
/**
|
|
1649
|
+
* Set the display name in the leaderboard.
|
|
1650
|
+
* @returns {SuccessResponse}
|
|
1651
|
+
* @see null
|
|
1652
|
+
*/
|
|
1653
|
+
export const SetDisplayNameRequest = v.pipe(
|
|
1654
|
+
v.object({
|
|
1655
|
+
/** Action to perform. */
|
|
1656
|
+
action: v.pipe(
|
|
1657
|
+
v.object({
|
|
1658
|
+
/** Type of action. */
|
|
1659
|
+
type: v.pipe(
|
|
1660
|
+
v.literal("setDisplayName"),
|
|
1661
|
+
v.description("Type of action."),
|
|
1662
|
+
),
|
|
1663
|
+
/**
|
|
1664
|
+
* Display name.
|
|
1665
|
+
*
|
|
1666
|
+
* Set to an empty string to remove the display name.
|
|
1667
|
+
*/
|
|
1668
|
+
displayName: v.pipe(
|
|
1669
|
+
v.string(),
|
|
1670
|
+
v.description(
|
|
1671
|
+
"Display name." +
|
|
1672
|
+
"\n\nSet to an empty string to remove the display name.",
|
|
1673
|
+
),
|
|
1674
|
+
),
|
|
1675
|
+
}),
|
|
1676
|
+
v.description("Action to perform."),
|
|
1677
|
+
),
|
|
1678
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1679
|
+
nonce: v.pipe(
|
|
1680
|
+
UnsignedInteger,
|
|
1681
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1682
|
+
),
|
|
1683
|
+
/** Cryptographic signature. */
|
|
1684
|
+
signature: v.pipe(
|
|
1685
|
+
Signature,
|
|
1686
|
+
v.description("Cryptographic signature."),
|
|
1687
|
+
),
|
|
1688
|
+
/** Expiration time of the action. */
|
|
1689
|
+
expiresAfter: v.pipe(
|
|
1690
|
+
v.optional(UnsignedInteger),
|
|
1691
|
+
v.description("Expiration time of the action."),
|
|
1692
|
+
),
|
|
1693
|
+
}),
|
|
1694
|
+
v.transform(removeUndefinedKeys),
|
|
1695
|
+
v.description("Set the display name in the leaderboard."),
|
|
1696
|
+
);
|
|
1697
|
+
export type SetDisplayNameRequest = v.InferOutput<typeof SetDisplayNameRequest>;
|
|
1698
|
+
|
|
1699
|
+
/**
|
|
1700
|
+
* Set a referral code.
|
|
1701
|
+
* @returns {SuccessResponse}
|
|
1702
|
+
* @see null
|
|
1703
|
+
*/
|
|
1704
|
+
export const SetReferrerRequest = v.pipe(
|
|
1705
|
+
v.object({
|
|
1706
|
+
/** Action to perform. */
|
|
1707
|
+
action: v.pipe(
|
|
1708
|
+
v.object({
|
|
1709
|
+
/** Type of action. */
|
|
1710
|
+
type: v.pipe(
|
|
1711
|
+
v.literal("setReferrer"),
|
|
1712
|
+
v.description("Type of action."),
|
|
1713
|
+
),
|
|
1714
|
+
/** Referral code. */
|
|
1715
|
+
code: v.pipe(
|
|
1716
|
+
v.string(),
|
|
1717
|
+
v.minLength(1),
|
|
1718
|
+
v.description("Referral code."),
|
|
1719
|
+
),
|
|
1720
|
+
}),
|
|
1721
|
+
v.description("Action to perform."),
|
|
1722
|
+
),
|
|
1723
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1724
|
+
nonce: v.pipe(
|
|
1725
|
+
UnsignedInteger,
|
|
1726
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1727
|
+
),
|
|
1728
|
+
/** Cryptographic signature. */
|
|
1729
|
+
signature: v.pipe(
|
|
1730
|
+
Signature,
|
|
1731
|
+
v.description("Cryptographic signature."),
|
|
1732
|
+
),
|
|
1733
|
+
/** Expiration time of the action. */
|
|
1734
|
+
expiresAfter: v.pipe(
|
|
1735
|
+
v.optional(UnsignedInteger),
|
|
1736
|
+
v.description("Expiration time of the action."),
|
|
1737
|
+
),
|
|
1738
|
+
}),
|
|
1739
|
+
v.transform(removeUndefinedKeys),
|
|
1740
|
+
v.description("Set a referral code."),
|
|
1741
|
+
);
|
|
1742
|
+
export type SetReferrerRequest = v.InferOutput<typeof SetReferrerRequest>;
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* Deploying HIP-1 and HIP-2 assets:
|
|
1746
|
+
* - Genesis
|
|
1747
|
+
* - Register Hyperliquidity
|
|
1748
|
+
* - Register Spot
|
|
1749
|
+
* - Register Token2
|
|
1750
|
+
* - Set Deployer Trading Fee Share
|
|
1751
|
+
* - User Genesis
|
|
1752
|
+
* @returns {SuccessResponse}
|
|
1753
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/deploying-hip-1-and-hip-2-assets
|
|
1754
|
+
*/
|
|
1755
|
+
export const SpotDeployRequest = v.pipe(
|
|
1756
|
+
v.object({
|
|
1757
|
+
/** Action to perform. */
|
|
1758
|
+
action: v.pipe(
|
|
1759
|
+
v.union([
|
|
1760
|
+
v.pipe(
|
|
1761
|
+
v.object({
|
|
1762
|
+
/** Type of action. */
|
|
1763
|
+
type: v.pipe(
|
|
1764
|
+
v.literal("spotDeploy"),
|
|
1765
|
+
v.description("Type of action."),
|
|
1766
|
+
),
|
|
1767
|
+
/** Genesis parameters. */
|
|
1768
|
+
genesis: v.pipe(
|
|
1769
|
+
v.object({
|
|
1770
|
+
/** Token identifier. */
|
|
1771
|
+
token: v.pipe(
|
|
1772
|
+
UnsignedInteger,
|
|
1773
|
+
v.description("Token identifier."),
|
|
1774
|
+
),
|
|
1775
|
+
/** Maximum token supply. */
|
|
1776
|
+
maxSupply: v.pipe(
|
|
1777
|
+
UnsignedDecimal,
|
|
1778
|
+
v.description("Maximum token supply."),
|
|
1779
|
+
),
|
|
1780
|
+
/** Set hyperliquidity balance to 0. */
|
|
1781
|
+
noHyperliquidity: v.pipe(
|
|
1782
|
+
v.optional(v.literal(true)),
|
|
1783
|
+
v.description("Set hyperliquidity balance to 0."),
|
|
1784
|
+
),
|
|
1785
|
+
}),
|
|
1786
|
+
v.description("Genesis parameters."),
|
|
1787
|
+
),
|
|
1788
|
+
}),
|
|
1789
|
+
v.description("Genesis variant"),
|
|
1790
|
+
),
|
|
1791
|
+
v.pipe(
|
|
1792
|
+
v.object({
|
|
1793
|
+
/** Type of action. */
|
|
1794
|
+
type: v.pipe(
|
|
1795
|
+
v.literal("spotDeploy"),
|
|
1796
|
+
v.description("Type of action."),
|
|
1797
|
+
),
|
|
1798
|
+
/** Register hyperliquidity parameters. */
|
|
1799
|
+
registerHyperliquidity: v.pipe(
|
|
1800
|
+
v.object({
|
|
1801
|
+
/** Spot index (distinct from base token index). */
|
|
1802
|
+
spot: v.pipe(
|
|
1803
|
+
UnsignedInteger,
|
|
1804
|
+
v.description("Spot index (distinct from base token index)."),
|
|
1805
|
+
),
|
|
1806
|
+
/** Starting price for liquidity seeding. */
|
|
1807
|
+
startPx: v.pipe(
|
|
1808
|
+
UnsignedDecimal,
|
|
1809
|
+
v.description("Starting price for liquidity seeding."),
|
|
1810
|
+
),
|
|
1811
|
+
/** Order size as a float (not in wei). */
|
|
1812
|
+
orderSz: v.pipe(
|
|
1813
|
+
UnsignedDecimal,
|
|
1814
|
+
v.description("Order size as a float (not in wei)."),
|
|
1815
|
+
),
|
|
1816
|
+
/** Total number of orders to place. */
|
|
1817
|
+
nOrders: v.pipe(
|
|
1818
|
+
UnsignedInteger,
|
|
1819
|
+
v.description("Total number of orders to place."),
|
|
1820
|
+
),
|
|
1821
|
+
/** Number of levels to seed with USDC. */
|
|
1822
|
+
nSeededLevels: v.pipe(
|
|
1823
|
+
v.optional(UnsignedInteger),
|
|
1824
|
+
v.description("Number of levels to seed with USDC."),
|
|
1825
|
+
),
|
|
1826
|
+
}),
|
|
1827
|
+
v.description("Register hyperliquidity parameters."),
|
|
1828
|
+
),
|
|
1829
|
+
}),
|
|
1830
|
+
v.description("Register hyperliquidity variant"),
|
|
1831
|
+
),
|
|
1832
|
+
v.pipe(
|
|
1833
|
+
v.object({
|
|
1834
|
+
/** Type of action. */
|
|
1835
|
+
type: v.pipe(
|
|
1836
|
+
v.literal("spotDeploy"),
|
|
1837
|
+
v.description("Type of action."),
|
|
1838
|
+
),
|
|
1839
|
+
/** Register spot parameters. */
|
|
1840
|
+
registerSpot: v.pipe(
|
|
1841
|
+
v.object({
|
|
1842
|
+
/** Tuple containing base and quote token indices. */
|
|
1843
|
+
tokens: v.pipe(
|
|
1844
|
+
v.tuple([
|
|
1845
|
+
UnsignedInteger,
|
|
1846
|
+
UnsignedInteger,
|
|
1847
|
+
]),
|
|
1848
|
+
v.description("Tuple containing base and quote token indices."),
|
|
1849
|
+
),
|
|
1850
|
+
}),
|
|
1851
|
+
v.description("Register spot parameters."),
|
|
1852
|
+
),
|
|
1853
|
+
}),
|
|
1854
|
+
v.description("Register spot variant"),
|
|
1855
|
+
),
|
|
1856
|
+
v.pipe(
|
|
1857
|
+
v.object({
|
|
1858
|
+
/** Type of action. */
|
|
1859
|
+
type: v.pipe(
|
|
1860
|
+
v.literal("spotDeploy"),
|
|
1861
|
+
v.description("Type of action."),
|
|
1862
|
+
),
|
|
1863
|
+
/** Register token parameters. */
|
|
1864
|
+
registerToken2: v.pipe(
|
|
1865
|
+
v.object({
|
|
1866
|
+
/** Token specifications. */
|
|
1867
|
+
spec: v.pipe(
|
|
1868
|
+
v.object({
|
|
1869
|
+
/** Token name. */
|
|
1870
|
+
name: v.pipe(
|
|
1871
|
+
v.string(),
|
|
1872
|
+
v.description("Token name."),
|
|
1873
|
+
),
|
|
1874
|
+
/** Number of decimals for token size. */
|
|
1875
|
+
szDecimals: v.pipe(
|
|
1876
|
+
UnsignedInteger,
|
|
1877
|
+
v.description("Number of decimals for token size."),
|
|
1878
|
+
),
|
|
1879
|
+
/** Number of decimals for token amounts in wei. */
|
|
1880
|
+
weiDecimals: v.pipe(
|
|
1881
|
+
UnsignedInteger,
|
|
1882
|
+
v.description("Number of decimals for token amounts in wei."),
|
|
1883
|
+
),
|
|
1884
|
+
}),
|
|
1885
|
+
v.description("Token specifications."),
|
|
1886
|
+
),
|
|
1887
|
+
/** Maximum gas allowed for registration. */
|
|
1888
|
+
maxGas: v.pipe(
|
|
1889
|
+
UnsignedInteger,
|
|
1890
|
+
v.description("Maximum gas allowed for registration."),
|
|
1891
|
+
),
|
|
1892
|
+
/** Optional full token name. */
|
|
1893
|
+
fullName: v.pipe(
|
|
1894
|
+
v.optional(v.string()),
|
|
1895
|
+
v.description("Optional full token name."),
|
|
1896
|
+
),
|
|
1897
|
+
}),
|
|
1898
|
+
v.description("Register token parameters."),
|
|
1899
|
+
),
|
|
1900
|
+
}),
|
|
1901
|
+
v.description("Register token variant"),
|
|
1902
|
+
),
|
|
1903
|
+
v.pipe(
|
|
1904
|
+
v.object({
|
|
1905
|
+
/** Type of action. */
|
|
1906
|
+
type: v.pipe(
|
|
1907
|
+
v.literal("spotDeploy"),
|
|
1908
|
+
v.description("Type of action."),
|
|
1909
|
+
),
|
|
1910
|
+
/** Set deployer trading fee share parameters. */
|
|
1911
|
+
setDeployerTradingFeeShare: v.pipe(
|
|
1912
|
+
v.object({
|
|
1913
|
+
/** Token identifier. */
|
|
1914
|
+
token: v.pipe(
|
|
1915
|
+
UnsignedInteger,
|
|
1916
|
+
v.description("Token identifier."),
|
|
1917
|
+
),
|
|
1918
|
+
/** The deployer trading fee share. Range is 0% to 100%. */
|
|
1919
|
+
share: v.pipe(
|
|
1920
|
+
Percent,
|
|
1921
|
+
v.description("The deployer trading fee share. Range is 0% to 100%."),
|
|
1922
|
+
),
|
|
1923
|
+
}),
|
|
1924
|
+
v.description("Set deployer trading fee share parameters."),
|
|
1925
|
+
),
|
|
1926
|
+
}),
|
|
1927
|
+
v.description("Set deployer trading fee share variant"),
|
|
1928
|
+
),
|
|
1929
|
+
v.pipe(
|
|
1930
|
+
v.object({
|
|
1931
|
+
/** Type of action. */
|
|
1932
|
+
type: v.pipe(
|
|
1933
|
+
v.literal("spotDeploy"),
|
|
1934
|
+
v.description("Type of action."),
|
|
1935
|
+
),
|
|
1936
|
+
/** User genesis parameters. */
|
|
1937
|
+
userGenesis: v.pipe(
|
|
1938
|
+
v.object({
|
|
1939
|
+
/** Token identifier. */
|
|
1940
|
+
token: v.pipe(
|
|
1941
|
+
UnsignedInteger,
|
|
1942
|
+
v.description("Token identifier."),
|
|
1943
|
+
),
|
|
1944
|
+
/** Array of tuples: [user address, genesis amount in wei]. */
|
|
1945
|
+
userAndWei: v.pipe(
|
|
1946
|
+
v.array(v.tuple([v.pipe(Hex, v.length(42)), UnsignedDecimal])),
|
|
1947
|
+
v.description("Array of tuples: [user address, genesis amount in wei]."),
|
|
1948
|
+
),
|
|
1949
|
+
/** Array of tuples: [existing token identifier, genesis amount in wei]. */
|
|
1950
|
+
existingTokenAndWei: v.pipe(
|
|
1951
|
+
v.array(
|
|
1952
|
+
v.tuple([
|
|
1953
|
+
UnsignedInteger,
|
|
1954
|
+
UnsignedDecimal,
|
|
1955
|
+
]),
|
|
1956
|
+
),
|
|
1957
|
+
v.description(
|
|
1958
|
+
"Array of tuples: [existing token identifier, genesis amount in wei].",
|
|
1959
|
+
),
|
|
1960
|
+
),
|
|
1961
|
+
/** Array of tuples: [user address, blacklist status] (`true` for blacklist, `false` to remove existing blacklisted user). */
|
|
1962
|
+
blacklistUsers: v.pipe(
|
|
1963
|
+
v.optional(v.array(v.tuple([v.pipe(Hex, v.length(42)), v.boolean()]))),
|
|
1964
|
+
v.description(
|
|
1965
|
+
"Array of tuples: [user address, blacklist status] (`true` for blacklist, `false` to remove existing blacklisted user).",
|
|
1966
|
+
),
|
|
1967
|
+
),
|
|
1968
|
+
}),
|
|
1969
|
+
v.description("User genesis parameters."),
|
|
1970
|
+
),
|
|
1971
|
+
}),
|
|
1972
|
+
v.description("User genesis variant"),
|
|
1973
|
+
),
|
|
1974
|
+
]),
|
|
1975
|
+
v.description("Action to perform."),
|
|
1976
|
+
),
|
|
1977
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
1978
|
+
nonce: v.pipe(
|
|
1979
|
+
UnsignedInteger,
|
|
1980
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
1981
|
+
),
|
|
1982
|
+
/** Cryptographic signature. */
|
|
1983
|
+
signature: v.pipe(
|
|
1984
|
+
Signature,
|
|
1985
|
+
v.description("Cryptographic signature."),
|
|
1986
|
+
),
|
|
1987
|
+
/** Expiration time of the action. */
|
|
1988
|
+
expiresAfter: v.pipe(
|
|
1989
|
+
v.optional(UnsignedInteger),
|
|
1990
|
+
v.description("Expiration time of the action."),
|
|
1991
|
+
),
|
|
1992
|
+
}),
|
|
1993
|
+
v.transform(removeUndefinedKeys),
|
|
1994
|
+
v.description(
|
|
1995
|
+
"Deploying HIP-1 and HIP-2 assets:" +
|
|
1996
|
+
"\n- Genesis" +
|
|
1997
|
+
"\n- Register Hyperliquidity" +
|
|
1998
|
+
"\n- Register Spot" +
|
|
1999
|
+
"\n- Register Token2" +
|
|
2000
|
+
"\n- Set Deployer Trading Fee Share" +
|
|
2001
|
+
"\n- User Genesis",
|
|
2002
|
+
),
|
|
2003
|
+
);
|
|
2004
|
+
export type SpotDeployRequest = v.InferOutput<typeof SpotDeployRequest>;
|
|
2005
|
+
|
|
2006
|
+
/**
|
|
2007
|
+
* Send spot assets to another address.
|
|
2008
|
+
* @returns {SuccessResponse}
|
|
2009
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#core-spot-transfer
|
|
2010
|
+
*/
|
|
2011
|
+
export const SpotSendRequest = v.pipe(
|
|
2012
|
+
v.object({
|
|
2013
|
+
/** Action to perform. */
|
|
2014
|
+
action: v.pipe(
|
|
2015
|
+
v.object({
|
|
2016
|
+
/** Type of action. */
|
|
2017
|
+
type: v.pipe(
|
|
2018
|
+
v.literal("spotSend"),
|
|
2019
|
+
v.description("Type of action."),
|
|
2020
|
+
),
|
|
2021
|
+
/** Chain ID used for signing. */
|
|
2022
|
+
signatureChainId: v.pipe(
|
|
2023
|
+
Hex,
|
|
2024
|
+
v.description("Chain ID used for signing."),
|
|
2025
|
+
),
|
|
2026
|
+
/** HyperLiquid network. */
|
|
2027
|
+
hyperliquidChain: v.pipe(
|
|
2028
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
2029
|
+
v.description("HyperLiquid network."),
|
|
2030
|
+
),
|
|
2031
|
+
/** Destination address. */
|
|
2032
|
+
destination: v.pipe(
|
|
2033
|
+
v.pipe(Hex, v.length(42)),
|
|
2034
|
+
v.description("Destination address."),
|
|
2035
|
+
),
|
|
2036
|
+
/** Token identifier. */
|
|
2037
|
+
token: v.pipe(
|
|
2038
|
+
TokenId,
|
|
2039
|
+
v.description("Token identifier."),
|
|
2040
|
+
),
|
|
2041
|
+
/** Amount to send (not in wei). */
|
|
2042
|
+
amount: v.pipe(
|
|
2043
|
+
UnsignedDecimal,
|
|
2044
|
+
v.description("Amount to send (not in wei)."),
|
|
2045
|
+
),
|
|
2046
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2047
|
+
time: v.pipe(
|
|
2048
|
+
UnsignedInteger,
|
|
2049
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2050
|
+
),
|
|
2051
|
+
}),
|
|
2052
|
+
v.description("Action to perform."),
|
|
2053
|
+
),
|
|
2054
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2055
|
+
nonce: v.pipe(
|
|
2056
|
+
UnsignedInteger,
|
|
2057
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2058
|
+
),
|
|
2059
|
+
/** Cryptographic signature. */
|
|
2060
|
+
signature: v.pipe(
|
|
2061
|
+
Signature,
|
|
2062
|
+
v.description("Cryptographic signature."),
|
|
2063
|
+
),
|
|
2064
|
+
}),
|
|
2065
|
+
v.transform(removeUndefinedKeys),
|
|
2066
|
+
v.description("Send spot assets to another address."),
|
|
2067
|
+
);
|
|
2068
|
+
export type SpotSendRequest = v.InferOutput<typeof SpotSendRequest>;
|
|
2069
|
+
|
|
2070
|
+
/**
|
|
2071
|
+
* Opt Out of Spot Dusting.
|
|
2072
|
+
* @returns {SuccessResponse}
|
|
2073
|
+
* @see null
|
|
2074
|
+
*/
|
|
2075
|
+
export const SpotUserRequest = v.pipe(
|
|
2076
|
+
v.object({
|
|
2077
|
+
/** Action to perform. */
|
|
2078
|
+
action: v.pipe(
|
|
2079
|
+
v.object({
|
|
2080
|
+
/** Type of action. */
|
|
2081
|
+
type: v.pipe(
|
|
2082
|
+
v.literal("spotUser"),
|
|
2083
|
+
v.description("Type of action."),
|
|
2084
|
+
),
|
|
2085
|
+
/** Spot dusting options. */
|
|
2086
|
+
toggleSpotDusting: v.pipe(
|
|
2087
|
+
v.object({
|
|
2088
|
+
/** Opt out of spot dusting. */
|
|
2089
|
+
optOut: v.pipe(
|
|
2090
|
+
v.boolean(),
|
|
2091
|
+
v.description("Opt out of spot dusting."),
|
|
2092
|
+
),
|
|
2093
|
+
}),
|
|
2094
|
+
v.description("Spot dusting options."),
|
|
2095
|
+
),
|
|
2096
|
+
}),
|
|
2097
|
+
v.description("Action to perform."),
|
|
2098
|
+
),
|
|
2099
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2100
|
+
nonce: v.pipe(
|
|
2101
|
+
UnsignedInteger,
|
|
2102
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2103
|
+
),
|
|
2104
|
+
/** Cryptographic signature. */
|
|
2105
|
+
signature: v.pipe(
|
|
2106
|
+
Signature,
|
|
2107
|
+
v.description("Cryptographic signature."),
|
|
2108
|
+
),
|
|
2109
|
+
/** Expiration time of the action. */
|
|
2110
|
+
expiresAfter: v.pipe(
|
|
2111
|
+
v.optional(UnsignedInteger),
|
|
2112
|
+
v.description("Expiration time of the action."),
|
|
2113
|
+
),
|
|
2114
|
+
}),
|
|
2115
|
+
v.transform(removeUndefinedKeys),
|
|
2116
|
+
v.description("Opt Out of Spot Dusting."),
|
|
2117
|
+
);
|
|
2118
|
+
export type SpotUserRequest = v.InferOutput<typeof SpotUserRequest>;
|
|
2119
|
+
|
|
2120
|
+
/**
|
|
2121
|
+
* Modify a sub-account.
|
|
2122
|
+
* @returns {SuccessResponse}
|
|
2123
|
+
* @see null
|
|
2124
|
+
*/
|
|
2125
|
+
export const SubAccountModifyRequest = v.pipe(
|
|
2126
|
+
v.object({
|
|
2127
|
+
/** Action to perform. */
|
|
2128
|
+
action: v.pipe(
|
|
2129
|
+
v.object({
|
|
2130
|
+
/** Type of action. */
|
|
2131
|
+
type: v.pipe(
|
|
2132
|
+
v.literal("subAccountModify"),
|
|
2133
|
+
v.description("Type of action."),
|
|
2134
|
+
),
|
|
2135
|
+
/** Sub-account address to modify. */
|
|
2136
|
+
subAccountUser: v.pipe(
|
|
2137
|
+
v.pipe(Hex, v.length(42)),
|
|
2138
|
+
v.description("Sub-account address to modify."),
|
|
2139
|
+
),
|
|
2140
|
+
/** New sub-account name. */
|
|
2141
|
+
name: v.pipe(
|
|
2142
|
+
v.string(),
|
|
2143
|
+
v.minLength(1),
|
|
2144
|
+
v.description("New sub-account name."),
|
|
2145
|
+
),
|
|
2146
|
+
}),
|
|
2147
|
+
v.description("Action to perform."),
|
|
2148
|
+
),
|
|
2149
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2150
|
+
nonce: v.pipe(
|
|
2151
|
+
UnsignedInteger,
|
|
2152
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2153
|
+
),
|
|
2154
|
+
/** Cryptographic signature. */
|
|
2155
|
+
signature: v.pipe(
|
|
2156
|
+
Signature,
|
|
2157
|
+
v.description("Cryptographic signature."),
|
|
2158
|
+
),
|
|
2159
|
+
/** Expiration time of the action. */
|
|
2160
|
+
expiresAfter: v.pipe(
|
|
2161
|
+
v.optional(UnsignedInteger),
|
|
2162
|
+
v.description("Expiration time of the action."),
|
|
2163
|
+
),
|
|
2164
|
+
}),
|
|
2165
|
+
v.transform(removeUndefinedKeys),
|
|
2166
|
+
v.description("Modify a sub-account."),
|
|
2167
|
+
);
|
|
2168
|
+
export type SubAccountModifyRequest = v.InferOutput<typeof SubAccountModifyRequest>;
|
|
2169
|
+
|
|
2170
|
+
/**
|
|
2171
|
+
* Transfer between sub-accounts (spot).
|
|
2172
|
+
* @returns {SuccessResponse}
|
|
2173
|
+
* @see null
|
|
2174
|
+
*/
|
|
2175
|
+
export const SubAccountSpotTransferRequest = v.pipe(
|
|
2176
|
+
v.object({
|
|
2177
|
+
/** Action to perform. */
|
|
2178
|
+
action: v.pipe(
|
|
2179
|
+
v.object({
|
|
2180
|
+
/** Type of action. */
|
|
2181
|
+
type: v.pipe(
|
|
2182
|
+
v.literal("subAccountSpotTransfer"),
|
|
2183
|
+
v.description("Type of action."),
|
|
2184
|
+
),
|
|
2185
|
+
/** Sub-account address. */
|
|
2186
|
+
subAccountUser: v.pipe(
|
|
2187
|
+
v.pipe(Hex, v.length(42)),
|
|
2188
|
+
v.description("Sub-account address."),
|
|
2189
|
+
),
|
|
2190
|
+
/** `true` for deposit, `false` for withdrawal. */
|
|
2191
|
+
isDeposit: v.pipe(
|
|
2192
|
+
v.boolean(),
|
|
2193
|
+
v.description("`true` for deposit, `false` for withdrawal."),
|
|
2194
|
+
),
|
|
2195
|
+
/** Token identifier. */
|
|
2196
|
+
token: v.pipe(
|
|
2197
|
+
TokenId,
|
|
2198
|
+
v.description("Token identifier."),
|
|
2199
|
+
),
|
|
2200
|
+
/** Amount to send (not in wei). */
|
|
2201
|
+
amount: v.pipe(
|
|
2202
|
+
UnsignedDecimal,
|
|
2203
|
+
v.description("Amount to send (not in wei)."),
|
|
2204
|
+
),
|
|
2205
|
+
}),
|
|
2206
|
+
v.description("Action to perform."),
|
|
2207
|
+
),
|
|
2208
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2209
|
+
nonce: v.pipe(
|
|
2210
|
+
UnsignedInteger,
|
|
2211
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2212
|
+
),
|
|
2213
|
+
/** Cryptographic signature. */
|
|
2214
|
+
signature: v.pipe(
|
|
2215
|
+
Signature,
|
|
2216
|
+
v.description("Cryptographic signature."),
|
|
2217
|
+
),
|
|
2218
|
+
/** Expiration time of the action. */
|
|
2219
|
+
expiresAfter: v.pipe(
|
|
2220
|
+
v.optional(UnsignedInteger),
|
|
2221
|
+
v.description("Expiration time of the action."),
|
|
2222
|
+
),
|
|
2223
|
+
}),
|
|
2224
|
+
v.transform(removeUndefinedKeys),
|
|
2225
|
+
v.description("Transfer between sub-accounts (spot)."),
|
|
2226
|
+
);
|
|
2227
|
+
export type SubAccountSpotTransferRequest = v.InferOutput<typeof SubAccountSpotTransferRequest>;
|
|
2228
|
+
|
|
2229
|
+
/**
|
|
2230
|
+
* Transfer between sub-accounts (perpetual).
|
|
2231
|
+
* @returns {SuccessResponse}
|
|
2232
|
+
* @see null
|
|
2233
|
+
*/
|
|
2234
|
+
export const SubAccountTransferRequest = v.pipe(
|
|
2235
|
+
v.object({
|
|
2236
|
+
/** Action to perform. */
|
|
2237
|
+
action: v.pipe(
|
|
2238
|
+
v.object({
|
|
2239
|
+
/** Type of action. */
|
|
2240
|
+
type: v.pipe(
|
|
2241
|
+
v.literal("subAccountTransfer"),
|
|
2242
|
+
v.description("Type of action."),
|
|
2243
|
+
),
|
|
2244
|
+
/** Sub-account address. */
|
|
2245
|
+
subAccountUser: v.pipe(
|
|
2246
|
+
v.pipe(Hex, v.length(42)),
|
|
2247
|
+
v.description("Sub-account address."),
|
|
2248
|
+
),
|
|
2249
|
+
/** `true` for deposit, `false` for withdrawal. */
|
|
2250
|
+
isDeposit: v.pipe(
|
|
2251
|
+
v.boolean(),
|
|
2252
|
+
v.description("`true` for deposit, `false` for withdrawal."),
|
|
2253
|
+
),
|
|
2254
|
+
/** Amount to transfer (float * 1e6). */
|
|
2255
|
+
usd: v.pipe(
|
|
2256
|
+
UnsignedInteger,
|
|
2257
|
+
v.description("Amount to transfer (float * 1e6)."),
|
|
2258
|
+
),
|
|
2259
|
+
}),
|
|
2260
|
+
v.description("Action to perform."),
|
|
2261
|
+
),
|
|
2262
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2263
|
+
nonce: v.pipe(
|
|
2264
|
+
UnsignedInteger,
|
|
2265
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2266
|
+
),
|
|
2267
|
+
/** Cryptographic signature. */
|
|
2268
|
+
signature: v.pipe(
|
|
2269
|
+
Signature,
|
|
2270
|
+
v.description("Cryptographic signature."),
|
|
2271
|
+
),
|
|
2272
|
+
/** Expiration time of the action. */
|
|
2273
|
+
expiresAfter: v.pipe(
|
|
2274
|
+
v.optional(UnsignedInteger),
|
|
2275
|
+
v.description("Expiration time of the action."),
|
|
2276
|
+
),
|
|
2277
|
+
}),
|
|
2278
|
+
v.transform(removeUndefinedKeys),
|
|
2279
|
+
v.description("Transfer between sub-accounts (perpetual)."),
|
|
2280
|
+
);
|
|
2281
|
+
export type SubAccountTransferRequest = v.InferOutput<typeof SubAccountTransferRequest>;
|
|
2282
|
+
|
|
2283
|
+
/**
|
|
2284
|
+
* Delegate or undelegate native tokens to or from a validator.
|
|
2285
|
+
* @returns {SuccessResponse}
|
|
2286
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#delegate-or-undelegate-stake-from-validator
|
|
2287
|
+
*/
|
|
2288
|
+
export const TokenDelegateRequest = v.pipe(
|
|
2289
|
+
v.object({
|
|
2290
|
+
/** Action to perform. */
|
|
2291
|
+
action: v.pipe(
|
|
2292
|
+
v.object({
|
|
2293
|
+
/** Type of action. */
|
|
2294
|
+
type: v.pipe(
|
|
2295
|
+
v.literal("tokenDelegate"),
|
|
2296
|
+
v.description("Type of action."),
|
|
2297
|
+
),
|
|
2298
|
+
/** Chain ID used for signing. */
|
|
2299
|
+
signatureChainId: v.pipe(
|
|
2300
|
+
Hex,
|
|
2301
|
+
v.description("Chain ID used for signing."),
|
|
2302
|
+
),
|
|
2303
|
+
/** HyperLiquid network. */
|
|
2304
|
+
hyperliquidChain: v.pipe(
|
|
2305
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
2306
|
+
v.description("HyperLiquid network."),
|
|
2307
|
+
),
|
|
2308
|
+
/** Validator address. */
|
|
2309
|
+
validator: v.pipe(
|
|
2310
|
+
v.pipe(Hex, v.length(42)),
|
|
2311
|
+
v.description("Validator address."),
|
|
2312
|
+
),
|
|
2313
|
+
/** Amount for delegate/undelegate (float * 1e8). */
|
|
2314
|
+
wei: v.pipe(
|
|
2315
|
+
UnsignedInteger,
|
|
2316
|
+
v.description("Amount for delegate/undelegate (float * 1e8)."),
|
|
2317
|
+
),
|
|
2318
|
+
/** `true` for undelegate, `false` for delegate. */
|
|
2319
|
+
isUndelegate: v.pipe(
|
|
2320
|
+
v.boolean(),
|
|
2321
|
+
v.description("`true` for undelegate, `false` for delegate."),
|
|
2322
|
+
),
|
|
2323
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2324
|
+
nonce: v.pipe(
|
|
2325
|
+
UnsignedInteger,
|
|
2326
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2327
|
+
),
|
|
2328
|
+
}),
|
|
2329
|
+
v.description("Action to perform."),
|
|
2330
|
+
),
|
|
2331
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2332
|
+
nonce: v.pipe(
|
|
2333
|
+
UnsignedInteger,
|
|
2334
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2335
|
+
),
|
|
2336
|
+
/** Cryptographic signature. */
|
|
2337
|
+
signature: v.pipe(
|
|
2338
|
+
Signature,
|
|
2339
|
+
v.description("Cryptographic signature."),
|
|
2340
|
+
),
|
|
2341
|
+
}),
|
|
2342
|
+
v.transform(removeUndefinedKeys),
|
|
2343
|
+
v.description("Delegate or undelegate native tokens to or from a validator."),
|
|
2344
|
+
);
|
|
2345
|
+
export type TokenDelegateRequest = v.InferOutput<typeof TokenDelegateRequest>;
|
|
2346
|
+
|
|
2347
|
+
/**
|
|
2348
|
+
* Cancel a TWAP order.
|
|
2349
|
+
* @returns {TwapCancelResponse}
|
|
2350
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-a-twap-order
|
|
2351
|
+
*/
|
|
2352
|
+
export const TwapCancelRequest = v.pipe(
|
|
2353
|
+
v.object({
|
|
2354
|
+
/** Action to perform. */
|
|
2355
|
+
action: v.pipe(
|
|
2356
|
+
v.object({
|
|
2357
|
+
/** Type of action. */
|
|
2358
|
+
type: v.pipe(
|
|
2359
|
+
v.literal("twapCancel"),
|
|
2360
|
+
v.description("Type of action."),
|
|
2361
|
+
),
|
|
2362
|
+
/** Asset ID. */
|
|
2363
|
+
a: v.pipe(
|
|
2364
|
+
UnsignedInteger,
|
|
2365
|
+
v.description("Asset ID."),
|
|
2366
|
+
),
|
|
2367
|
+
/** Twap ID. */
|
|
2368
|
+
t: v.pipe(
|
|
2369
|
+
UnsignedInteger,
|
|
2370
|
+
v.description("Twap ID."),
|
|
2371
|
+
),
|
|
2372
|
+
}),
|
|
2373
|
+
v.description("Action to perform."),
|
|
2374
|
+
),
|
|
2375
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2376
|
+
nonce: v.pipe(
|
|
2377
|
+
UnsignedInteger,
|
|
2378
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2379
|
+
),
|
|
2380
|
+
/** Cryptographic signature. */
|
|
2381
|
+
signature: v.pipe(
|
|
2382
|
+
Signature,
|
|
2383
|
+
v.description("Cryptographic signature."),
|
|
2384
|
+
),
|
|
2385
|
+
/** Vault address (for vault trading). */
|
|
2386
|
+
vaultAddress: v.pipe(
|
|
2387
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
2388
|
+
v.description("Vault address (for vault trading)."),
|
|
2389
|
+
),
|
|
2390
|
+
/** Expiration time of the action. */
|
|
2391
|
+
expiresAfter: v.pipe(
|
|
2392
|
+
v.optional(UnsignedInteger),
|
|
2393
|
+
v.description("Expiration time of the action."),
|
|
2394
|
+
),
|
|
2395
|
+
}),
|
|
2396
|
+
v.transform(removeUndefinedKeys),
|
|
2397
|
+
v.description("Cancel a TWAP order."),
|
|
2398
|
+
);
|
|
2399
|
+
export type TwapCancelRequest = v.InferOutput<typeof TwapCancelRequest>;
|
|
2400
|
+
|
|
2401
|
+
/**
|
|
2402
|
+
* Place a TWAP order.
|
|
2403
|
+
* @returns {TwapOrderResponse}
|
|
2404
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-a-twap-order
|
|
2405
|
+
*/
|
|
2406
|
+
export const TwapOrderRequest = v.pipe(
|
|
2407
|
+
v.object({
|
|
2408
|
+
/** Action to perform. */
|
|
2409
|
+
action: v.pipe(
|
|
2410
|
+
v.object({
|
|
2411
|
+
/** Type of action. */
|
|
2412
|
+
type: v.pipe(
|
|
2413
|
+
v.literal("twapOrder"),
|
|
2414
|
+
v.description("Type of action."),
|
|
2415
|
+
),
|
|
2416
|
+
/** Twap parameters. */
|
|
2417
|
+
twap: v.pipe(
|
|
2418
|
+
v.object({
|
|
2419
|
+
/** Asset ID. */
|
|
2420
|
+
a: v.pipe(
|
|
2421
|
+
UnsignedInteger,
|
|
2422
|
+
v.description("Asset ID."),
|
|
2423
|
+
),
|
|
2424
|
+
/** Position side (`true` for long, `false` for short). */
|
|
2425
|
+
b: v.pipe(
|
|
2426
|
+
v.boolean(),
|
|
2427
|
+
v.description("Position side (`true` for long, `false` for short)."),
|
|
2428
|
+
),
|
|
2429
|
+
/** Size (in base currency units). */
|
|
2430
|
+
s: v.pipe(
|
|
2431
|
+
UnsignedDecimal,
|
|
2432
|
+
v.description("Size (in base currency units)."),
|
|
2433
|
+
),
|
|
2434
|
+
/** Is reduce-only? */
|
|
2435
|
+
r: v.pipe(
|
|
2436
|
+
v.boolean(),
|
|
2437
|
+
v.description("Is reduce-only?"),
|
|
2438
|
+
),
|
|
2439
|
+
/** TWAP duration in minutes. */
|
|
2440
|
+
m: v.pipe(
|
|
2441
|
+
UnsignedInteger,
|
|
2442
|
+
v.description("TWAP duration in minutes."),
|
|
2443
|
+
),
|
|
2444
|
+
/** Enable random order timing. */
|
|
2445
|
+
t: v.pipe(
|
|
2446
|
+
v.boolean(),
|
|
2447
|
+
v.description("Enable random order timing."),
|
|
2448
|
+
),
|
|
2449
|
+
}),
|
|
2450
|
+
v.description("Twap parameters."),
|
|
2451
|
+
),
|
|
2452
|
+
}),
|
|
2453
|
+
v.description("Action to perform."),
|
|
2454
|
+
),
|
|
2455
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2456
|
+
nonce: v.pipe(
|
|
2457
|
+
UnsignedInteger,
|
|
2458
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2459
|
+
),
|
|
2460
|
+
/** Cryptographic signature. */
|
|
2461
|
+
signature: v.pipe(
|
|
2462
|
+
Signature,
|
|
2463
|
+
v.description("Cryptographic signature."),
|
|
2464
|
+
),
|
|
2465
|
+
/** Vault address (for vault trading). */
|
|
2466
|
+
vaultAddress: v.pipe(
|
|
2467
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
2468
|
+
v.description("Vault address (for vault trading)."),
|
|
2469
|
+
),
|
|
2470
|
+
/** Expiration time of the action. */
|
|
2471
|
+
expiresAfter: v.pipe(
|
|
2472
|
+
v.optional(UnsignedInteger),
|
|
2473
|
+
v.description("Expiration time of the action."),
|
|
2474
|
+
),
|
|
2475
|
+
}),
|
|
2476
|
+
v.transform(removeUndefinedKeys),
|
|
2477
|
+
v.description("Place a TWAP order."),
|
|
2478
|
+
);
|
|
2479
|
+
export type TwapOrderRequest = v.InferOutput<typeof TwapOrderRequest>;
|
|
2480
|
+
|
|
2481
|
+
/**
|
|
2482
|
+
* Add or remove margin from isolated position.
|
|
2483
|
+
* @returns {SuccessResponse}
|
|
2484
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#update-isolated-margin
|
|
2485
|
+
*/
|
|
2486
|
+
export const UpdateIsolatedMarginRequest = v.pipe(
|
|
2487
|
+
v.object({
|
|
2488
|
+
/** Action to perform. */
|
|
2489
|
+
action: v.pipe(
|
|
2490
|
+
v.object({
|
|
2491
|
+
/** Type of action. */
|
|
2492
|
+
type: v.pipe(
|
|
2493
|
+
v.literal("updateIsolatedMargin"),
|
|
2494
|
+
v.description("Type of action."),
|
|
2495
|
+
),
|
|
2496
|
+
/** Asset ID. */
|
|
2497
|
+
asset: v.pipe(
|
|
2498
|
+
UnsignedInteger,
|
|
2499
|
+
v.description("Asset ID."),
|
|
2500
|
+
),
|
|
2501
|
+
/** Position side (`true` for long, `false` for short). */
|
|
2502
|
+
isBuy: v.pipe(
|
|
2503
|
+
v.boolean(),
|
|
2504
|
+
v.description("Position side (`true` for long, `false` for short)."),
|
|
2505
|
+
),
|
|
2506
|
+
/** Amount to adjust (float * 1e6). */
|
|
2507
|
+
ntli: v.pipe(
|
|
2508
|
+
UnsignedInteger,
|
|
2509
|
+
v.description("Amount to adjust (float * 1e6)."),
|
|
2510
|
+
),
|
|
2511
|
+
}),
|
|
2512
|
+
v.description("Action to perform."),
|
|
2513
|
+
),
|
|
2514
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2515
|
+
nonce: v.pipe(
|
|
2516
|
+
UnsignedInteger,
|
|
2517
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2518
|
+
),
|
|
2519
|
+
/** Cryptographic signature. */
|
|
2520
|
+
signature: v.pipe(
|
|
2521
|
+
Signature,
|
|
2522
|
+
v.description("Cryptographic signature."),
|
|
2523
|
+
),
|
|
2524
|
+
/** Vault address (for vault trading). */
|
|
2525
|
+
vaultAddress: v.pipe(
|
|
2526
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
2527
|
+
v.description("Vault address (for vault trading)."),
|
|
2528
|
+
),
|
|
2529
|
+
/** Expiration time of the action. */
|
|
2530
|
+
expiresAfter: v.pipe(
|
|
2531
|
+
v.optional(UnsignedInteger),
|
|
2532
|
+
v.description("Expiration time of the action."),
|
|
2533
|
+
),
|
|
2534
|
+
}),
|
|
2535
|
+
v.transform(removeUndefinedKeys),
|
|
2536
|
+
v.description("Add or remove margin from isolated position."),
|
|
2537
|
+
);
|
|
2538
|
+
export type UpdateIsolatedMarginRequest = v.InferOutput<typeof UpdateIsolatedMarginRequest>;
|
|
2539
|
+
|
|
2540
|
+
/**
|
|
2541
|
+
* Update cross or isolated leverage on a coin.
|
|
2542
|
+
* @returns {SuccessResponse}
|
|
2543
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#update-leverage
|
|
2544
|
+
*/
|
|
2545
|
+
export const UpdateLeverageRequest = v.pipe(
|
|
2546
|
+
v.object({
|
|
2547
|
+
/** Action to perform. */
|
|
2548
|
+
action: v.pipe(
|
|
2549
|
+
v.object({
|
|
2550
|
+
/** Type of action. */
|
|
2551
|
+
type: v.pipe(
|
|
2552
|
+
v.literal("updateLeverage"),
|
|
2553
|
+
v.description("Type of action."),
|
|
2554
|
+
),
|
|
2555
|
+
/** Asset ID. */
|
|
2556
|
+
asset: v.pipe(
|
|
2557
|
+
UnsignedInteger,
|
|
2558
|
+
v.description("Asset ID."),
|
|
2559
|
+
),
|
|
2560
|
+
/** `true` for cross leverage, `false` for isolated leverage. */
|
|
2561
|
+
isCross: v.pipe(
|
|
2562
|
+
v.boolean(),
|
|
2563
|
+
v.description("`true` for cross leverage, `false` for isolated leverage."),
|
|
2564
|
+
),
|
|
2565
|
+
/** New leverage value. */
|
|
2566
|
+
leverage: v.pipe(
|
|
2567
|
+
v.pipe(UnsignedInteger, v.minValue(1)),
|
|
2568
|
+
v.description("New leverage value."),
|
|
2569
|
+
),
|
|
2570
|
+
}),
|
|
2571
|
+
v.description("Action to perform."),
|
|
2572
|
+
),
|
|
2573
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2574
|
+
nonce: v.pipe(
|
|
2575
|
+
UnsignedInteger,
|
|
2576
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2577
|
+
),
|
|
2578
|
+
/** Cryptographic signature. */
|
|
2579
|
+
signature: v.pipe(
|
|
2580
|
+
Signature,
|
|
2581
|
+
v.description("Cryptographic signature."),
|
|
2582
|
+
),
|
|
2583
|
+
/** Vault address (for vault trading). */
|
|
2584
|
+
vaultAddress: v.pipe(
|
|
2585
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
2586
|
+
v.description("Vault address (for vault trading)."),
|
|
2587
|
+
),
|
|
2588
|
+
/** Expiration time of the action. */
|
|
2589
|
+
expiresAfter: v.pipe(
|
|
2590
|
+
v.optional(UnsignedInteger),
|
|
2591
|
+
v.description("Expiration time of the action."),
|
|
2592
|
+
),
|
|
2593
|
+
}),
|
|
2594
|
+
v.transform(removeUndefinedKeys),
|
|
2595
|
+
v.description("Update cross or isolated leverage on a coin."),
|
|
2596
|
+
);
|
|
2597
|
+
export type UpdateLeverageRequest = v.InferOutput<typeof UpdateLeverageRequest>;
|
|
2598
|
+
|
|
2599
|
+
/**
|
|
2600
|
+
* Transfer funds between Spot account and Perp account.
|
|
2601
|
+
* @returns {SuccessResponse}
|
|
2602
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#transfer-from-spot-account-to-perp-account-and-vice-versa
|
|
2603
|
+
*/
|
|
2604
|
+
export const UsdClassTransferRequest = v.pipe(
|
|
2605
|
+
v.object({
|
|
2606
|
+
/** Action to perform. */
|
|
2607
|
+
action: v.pipe(
|
|
2608
|
+
v.object({
|
|
2609
|
+
/** Type of action. */
|
|
2610
|
+
type: v.pipe(
|
|
2611
|
+
v.literal("usdClassTransfer"),
|
|
2612
|
+
v.description("Type of action."),
|
|
2613
|
+
),
|
|
2614
|
+
/** Chain ID used for signing. */
|
|
2615
|
+
signatureChainId: v.pipe(
|
|
2616
|
+
Hex,
|
|
2617
|
+
v.description("Chain ID used for signing."),
|
|
2618
|
+
),
|
|
2619
|
+
/** HyperLiquid network. */
|
|
2620
|
+
hyperliquidChain: v.pipe(
|
|
2621
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
2622
|
+
v.description("HyperLiquid network."),
|
|
2623
|
+
),
|
|
2624
|
+
/** Amount to transfer (1 = 1$). */
|
|
2625
|
+
amount: v.pipe(
|
|
2626
|
+
UnsignedDecimal,
|
|
2627
|
+
v.description("Amount to transfer (1 = 1$)."),
|
|
2628
|
+
),
|
|
2629
|
+
/** `true` for Spot to Perp, `false` for Perp to Spot. */
|
|
2630
|
+
toPerp: v.pipe(
|
|
2631
|
+
v.boolean(),
|
|
2632
|
+
v.description("`true` for Spot to Perp, `false` for Perp to Spot."),
|
|
2633
|
+
),
|
|
2634
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2635
|
+
nonce: v.pipe(
|
|
2636
|
+
UnsignedInteger,
|
|
2637
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2638
|
+
),
|
|
2639
|
+
}),
|
|
2640
|
+
v.description("Action to perform."),
|
|
2641
|
+
),
|
|
2642
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2643
|
+
nonce: v.pipe(
|
|
2644
|
+
UnsignedInteger,
|
|
2645
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2646
|
+
),
|
|
2647
|
+
/** Cryptographic signature. */
|
|
2648
|
+
signature: v.pipe(
|
|
2649
|
+
Signature,
|
|
2650
|
+
v.description("Cryptographic signature."),
|
|
2651
|
+
),
|
|
2652
|
+
}),
|
|
2653
|
+
v.transform(removeUndefinedKeys),
|
|
2654
|
+
v.description("Transfer funds between Spot account and Perp account."),
|
|
2655
|
+
);
|
|
2656
|
+
export type UsdClassTransferRequest = v.InferOutput<typeof UsdClassTransferRequest>;
|
|
2657
|
+
|
|
2658
|
+
/**
|
|
2659
|
+
* Send usd to another address.
|
|
2660
|
+
* @returns {SuccessResponse}
|
|
2661
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#core-usdc-transfer
|
|
2662
|
+
*/
|
|
2663
|
+
export const UsdSendRequest = v.pipe(
|
|
2664
|
+
v.object({
|
|
2665
|
+
/** Action to perform. */
|
|
2666
|
+
action: v.pipe(
|
|
2667
|
+
v.object({
|
|
2668
|
+
/** Type of action. */
|
|
2669
|
+
type: v.pipe(
|
|
2670
|
+
v.literal("usdSend"),
|
|
2671
|
+
v.description("Type of action."),
|
|
2672
|
+
),
|
|
2673
|
+
/** Chain ID used for signing. */
|
|
2674
|
+
signatureChainId: v.pipe(
|
|
2675
|
+
Hex,
|
|
2676
|
+
v.description("Chain ID used for signing."),
|
|
2677
|
+
),
|
|
2678
|
+
/** HyperLiquid network. */
|
|
2679
|
+
hyperliquidChain: v.pipe(
|
|
2680
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
2681
|
+
v.description("HyperLiquid network."),
|
|
2682
|
+
),
|
|
2683
|
+
/** Destination address. */
|
|
2684
|
+
destination: v.pipe(
|
|
2685
|
+
v.pipe(Hex, v.length(42)),
|
|
2686
|
+
v.description("Destination address."),
|
|
2687
|
+
),
|
|
2688
|
+
/** Amount to send (1 = 1$). */
|
|
2689
|
+
amount: v.pipe(
|
|
2690
|
+
UnsignedDecimal,
|
|
2691
|
+
v.description("Amount to send (1 = 1$)."),
|
|
2692
|
+
),
|
|
2693
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2694
|
+
time: v.pipe(
|
|
2695
|
+
UnsignedInteger,
|
|
2696
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2697
|
+
),
|
|
2698
|
+
}),
|
|
2699
|
+
v.description("Action to perform."),
|
|
2700
|
+
),
|
|
2701
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2702
|
+
nonce: v.pipe(
|
|
2703
|
+
UnsignedInteger,
|
|
2704
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2705
|
+
),
|
|
2706
|
+
/** Cryptographic signature. */
|
|
2707
|
+
signature: v.pipe(
|
|
2708
|
+
Signature,
|
|
2709
|
+
v.description("Cryptographic signature."),
|
|
2710
|
+
),
|
|
2711
|
+
}),
|
|
2712
|
+
v.transform(removeUndefinedKeys),
|
|
2713
|
+
v.description("Send usd to another address."),
|
|
2714
|
+
);
|
|
2715
|
+
export type UsdSendRequest = v.InferOutput<typeof UsdSendRequest>;
|
|
2716
|
+
|
|
2717
|
+
/**
|
|
2718
|
+
* Distribute funds from a vault between followers.
|
|
2719
|
+
* @returns {SuccessResponse}
|
|
2720
|
+
* @see null
|
|
2721
|
+
*/
|
|
2722
|
+
export const VaultDistributeRequest = v.pipe(
|
|
2723
|
+
v.object({
|
|
2724
|
+
/** Action to perform. */
|
|
2725
|
+
action: v.pipe(
|
|
2726
|
+
v.object({
|
|
2727
|
+
/** Type of action. */
|
|
2728
|
+
type: v.pipe(
|
|
2729
|
+
v.literal("vaultDistribute"),
|
|
2730
|
+
v.description("Type of action."),
|
|
2731
|
+
),
|
|
2732
|
+
/** Vault address. */
|
|
2733
|
+
vaultAddress: v.pipe(
|
|
2734
|
+
v.pipe(Hex, v.length(42)),
|
|
2735
|
+
v.description("Vault address."),
|
|
2736
|
+
),
|
|
2737
|
+
/**
|
|
2738
|
+
* Amount to distribute (float * 1e6).
|
|
2739
|
+
*
|
|
2740
|
+
* Set to 0 to close the vault.
|
|
2741
|
+
*/
|
|
2742
|
+
usd: v.pipe(
|
|
2743
|
+
UnsignedInteger,
|
|
2744
|
+
v.description(
|
|
2745
|
+
"Amount to distribute (float * 1e6)." +
|
|
2746
|
+
"\n\nSet to 0 to close the vault.",
|
|
2747
|
+
),
|
|
2748
|
+
),
|
|
2749
|
+
}),
|
|
2750
|
+
v.description("Action to perform."),
|
|
2751
|
+
),
|
|
2752
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2753
|
+
nonce: v.pipe(
|
|
2754
|
+
UnsignedInteger,
|
|
2755
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2756
|
+
),
|
|
2757
|
+
/** Cryptographic signature. */
|
|
2758
|
+
signature: v.pipe(
|
|
2759
|
+
Signature,
|
|
2760
|
+
v.description("Cryptographic signature."),
|
|
2761
|
+
),
|
|
2762
|
+
/** Expiration time of the action. */
|
|
2763
|
+
expiresAfter: v.pipe(
|
|
2764
|
+
v.optional(UnsignedInteger),
|
|
2765
|
+
v.description("Expiration time of the action."),
|
|
2766
|
+
),
|
|
2767
|
+
}),
|
|
2768
|
+
v.transform(removeUndefinedKeys),
|
|
2769
|
+
v.description("Distribute funds from a vault between followers."),
|
|
2770
|
+
);
|
|
2771
|
+
export type VaultDistributeRequest = v.InferOutput<typeof VaultDistributeRequest>;
|
|
2772
|
+
|
|
2773
|
+
/**
|
|
2774
|
+
* Modify a vault configuration.
|
|
2775
|
+
* @returns {SuccessResponse}
|
|
2776
|
+
* @see null
|
|
2777
|
+
*/
|
|
2778
|
+
export const VaultModifyRequest = v.pipe(
|
|
2779
|
+
v.object({
|
|
2780
|
+
/** Action to perform. */
|
|
2781
|
+
action: v.pipe(
|
|
2782
|
+
v.object({
|
|
2783
|
+
/** Type of action. */
|
|
2784
|
+
type: v.pipe(
|
|
2785
|
+
v.literal("vaultModify"),
|
|
2786
|
+
v.description("Type of action."),
|
|
2787
|
+
),
|
|
2788
|
+
/** Vault address. */
|
|
2789
|
+
vaultAddress: v.pipe(
|
|
2790
|
+
v.pipe(Hex, v.length(42)),
|
|
2791
|
+
v.description("Vault address."),
|
|
2792
|
+
),
|
|
2793
|
+
/** Allow deposits from followers. */
|
|
2794
|
+
allowDeposits: v.pipe(
|
|
2795
|
+
v.nullable(v.boolean()),
|
|
2796
|
+
v.description("Allow deposits from followers."),
|
|
2797
|
+
),
|
|
2798
|
+
/** Always close positions on withdrawal. */
|
|
2799
|
+
alwaysCloseOnWithdraw: v.pipe(
|
|
2800
|
+
v.nullable(v.boolean()),
|
|
2801
|
+
v.description("Always close positions on withdrawal."),
|
|
2802
|
+
),
|
|
2803
|
+
}),
|
|
2804
|
+
v.description("Action to perform."),
|
|
2805
|
+
),
|
|
2806
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2807
|
+
nonce: v.pipe(
|
|
2808
|
+
UnsignedInteger,
|
|
2809
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2810
|
+
),
|
|
2811
|
+
/** Cryptographic signature. */
|
|
2812
|
+
signature: v.pipe(
|
|
2813
|
+
Signature,
|
|
2814
|
+
v.description("Cryptographic signature."),
|
|
2815
|
+
),
|
|
2816
|
+
/** Expiration time of the action. */
|
|
2817
|
+
expiresAfter: v.pipe(
|
|
2818
|
+
v.optional(UnsignedInteger),
|
|
2819
|
+
v.description("Expiration time of the action."),
|
|
2820
|
+
),
|
|
2821
|
+
}),
|
|
2822
|
+
v.transform(removeUndefinedKeys),
|
|
2823
|
+
v.description("Modify a vault configuration."),
|
|
2824
|
+
);
|
|
2825
|
+
export type VaultModifyRequest = v.InferOutput<typeof VaultModifyRequest>;
|
|
2826
|
+
|
|
2827
|
+
/**
|
|
2828
|
+
* Deposit or withdraw from a vault.
|
|
2829
|
+
* @returns {SuccessResponse}
|
|
2830
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-or-withdraw-from-a-vault
|
|
2831
|
+
*/
|
|
2832
|
+
export const VaultTransferRequest = v.pipe(
|
|
2833
|
+
v.object({
|
|
2834
|
+
/** Action to perform. */
|
|
2835
|
+
action: v.pipe(
|
|
2836
|
+
v.object({
|
|
2837
|
+
/** Type of action. */
|
|
2838
|
+
type: v.pipe(
|
|
2839
|
+
v.literal("vaultTransfer"),
|
|
2840
|
+
v.description("Type of action."),
|
|
2841
|
+
),
|
|
2842
|
+
/** Vault address. */
|
|
2843
|
+
vaultAddress: v.pipe(
|
|
2844
|
+
v.pipe(Hex, v.length(42)),
|
|
2845
|
+
v.description("Vault address."),
|
|
2846
|
+
),
|
|
2847
|
+
/** `true` for deposit, `false` for withdrawal. */
|
|
2848
|
+
isDeposit: v.pipe(
|
|
2849
|
+
v.boolean(),
|
|
2850
|
+
v.description("`true` for deposit, `false` for withdrawal."),
|
|
2851
|
+
),
|
|
2852
|
+
/** Amount for deposit/withdrawal (float * 1e6). */
|
|
2853
|
+
usd: v.pipe(
|
|
2854
|
+
UnsignedInteger,
|
|
2855
|
+
v.description("Amount for deposit/withdrawal (float * 1e6)."),
|
|
2856
|
+
),
|
|
2857
|
+
}),
|
|
2858
|
+
v.description("Action to perform."),
|
|
2859
|
+
),
|
|
2860
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2861
|
+
nonce: v.pipe(
|
|
2862
|
+
UnsignedInteger,
|
|
2863
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2864
|
+
),
|
|
2865
|
+
/** Cryptographic signature. */
|
|
2866
|
+
signature: v.pipe(
|
|
2867
|
+
Signature,
|
|
2868
|
+
v.description("Cryptographic signature."),
|
|
2869
|
+
),
|
|
2870
|
+
/** Expiration time of the action. */
|
|
2871
|
+
expiresAfter: v.pipe(
|
|
2872
|
+
v.optional(UnsignedInteger),
|
|
2873
|
+
v.description("Expiration time of the action."),
|
|
2874
|
+
),
|
|
2875
|
+
}),
|
|
2876
|
+
v.transform(removeUndefinedKeys),
|
|
2877
|
+
v.description("Deposit or withdraw from a vault."),
|
|
2878
|
+
);
|
|
2879
|
+
export type VaultTransferRequest = v.InferOutput<typeof VaultTransferRequest>;
|
|
2880
|
+
|
|
2881
|
+
/**
|
|
2882
|
+
* Initiate a withdrawal request.
|
|
2883
|
+
* @returns {SuccessResponse}
|
|
2884
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#initiate-a-withdrawal-request
|
|
2885
|
+
*/
|
|
2886
|
+
export const Withdraw3Request = v.pipe(
|
|
2887
|
+
v.object({
|
|
2888
|
+
/** Action to perform. */
|
|
2889
|
+
action: v.pipe(
|
|
2890
|
+
v.object({
|
|
2891
|
+
/** Type of action. */
|
|
2892
|
+
type: v.pipe(
|
|
2893
|
+
v.literal("withdraw3"),
|
|
2894
|
+
v.description("Type of action."),
|
|
2895
|
+
),
|
|
2896
|
+
/** Chain ID used for signing. */
|
|
2897
|
+
signatureChainId: v.pipe(
|
|
2898
|
+
Hex,
|
|
2899
|
+
v.description("Chain ID used for signing."),
|
|
2900
|
+
),
|
|
2901
|
+
/** HyperLiquid network. */
|
|
2902
|
+
hyperliquidChain: v.pipe(
|
|
2903
|
+
v.union([v.literal("Mainnet"), v.literal("Testnet")]),
|
|
2904
|
+
v.description("HyperLiquid network."),
|
|
2905
|
+
),
|
|
2906
|
+
/** Destination address. */
|
|
2907
|
+
destination: v.pipe(
|
|
2908
|
+
v.pipe(Hex, v.length(42)),
|
|
2909
|
+
v.description("Destination address."),
|
|
2910
|
+
),
|
|
2911
|
+
/** Amount to withdraw (1 = 1$). */
|
|
2912
|
+
amount: v.pipe(
|
|
2913
|
+
UnsignedDecimal,
|
|
2914
|
+
v.description("Amount to withdraw (1 = 1$)."),
|
|
2915
|
+
),
|
|
2916
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2917
|
+
time: v.pipe(
|
|
2918
|
+
UnsignedInteger,
|
|
2919
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2920
|
+
),
|
|
2921
|
+
}),
|
|
2922
|
+
v.description("Action to perform."),
|
|
2923
|
+
),
|
|
2924
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
2925
|
+
nonce: v.pipe(
|
|
2926
|
+
UnsignedInteger,
|
|
2927
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
2928
|
+
),
|
|
2929
|
+
/** Cryptographic signature. */
|
|
2930
|
+
signature: v.pipe(
|
|
2931
|
+
Signature,
|
|
2932
|
+
v.description("Cryptographic signature."),
|
|
2933
|
+
),
|
|
2934
|
+
}),
|
|
2935
|
+
v.transform(removeUndefinedKeys),
|
|
2936
|
+
v.description("Initiate a withdrawal request."),
|
|
2937
|
+
);
|
|
2938
|
+
export type Withdraw3Request = v.InferOutput<typeof Withdraw3Request>;
|
|
2939
|
+
|
|
2940
|
+
/**
|
|
2941
|
+
* A multi-signature request.
|
|
2942
|
+
* @returns {SuccessResponse}
|
|
2943
|
+
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/hypercore/multi-sig
|
|
2944
|
+
*/
|
|
2945
|
+
export const MultiSigRequest = v.pipe(
|
|
2946
|
+
v.object({
|
|
2947
|
+
/** Action to perform. */
|
|
2948
|
+
action: v.pipe(
|
|
2949
|
+
v.object({
|
|
2950
|
+
/** Type of action. */
|
|
2951
|
+
type: v.pipe(
|
|
2952
|
+
v.literal("multiSig"),
|
|
2953
|
+
v.description("Type of action."),
|
|
2954
|
+
),
|
|
2955
|
+
/** Chain ID used for signing. */
|
|
2956
|
+
signatureChainId: v.pipe(
|
|
2957
|
+
Hex,
|
|
2958
|
+
v.description("Chain ID used for signing."),
|
|
2959
|
+
),
|
|
2960
|
+
/** List of signatures from authorized signers. */
|
|
2961
|
+
signatures: v.pipe(
|
|
2962
|
+
v.array(Signature),
|
|
2963
|
+
v.description("List of signatures from authorized signers."),
|
|
2964
|
+
),
|
|
2965
|
+
/** Multi-signature payload information. */
|
|
2966
|
+
payload: v.pipe(
|
|
2967
|
+
v.object({
|
|
2968
|
+
/** Address of the multi-signature user account. */
|
|
2969
|
+
multiSigUser: v.pipe(
|
|
2970
|
+
v.pipe(Hex, v.length(42)),
|
|
2971
|
+
v.description("Address of the multi-signature user account."),
|
|
2972
|
+
),
|
|
2973
|
+
/** Address of the authorized user initiating the request (any authorized user). */
|
|
2974
|
+
outerSigner: v.pipe(
|
|
2975
|
+
v.pipe(Hex, v.length(42)),
|
|
2976
|
+
v.description(
|
|
2977
|
+
"Address of the authorized user initiating the request (any authorized user).",
|
|
2978
|
+
),
|
|
2979
|
+
),
|
|
2980
|
+
/** The underlying action to be executed through multi-sig. */
|
|
2981
|
+
action: v.pipe(
|
|
2982
|
+
v.union([
|
|
2983
|
+
ApproveAgentRequest.entries.action,
|
|
2984
|
+
ApproveBuilderFeeRequest.entries.action,
|
|
2985
|
+
BatchModifyRequest.entries.action,
|
|
2986
|
+
CancelRequest.entries.action,
|
|
2987
|
+
CancelByCloidRequest.entries.action,
|
|
2988
|
+
CDepositRequest.entries.action,
|
|
2989
|
+
ClaimRewardsRequest.entries.action,
|
|
2990
|
+
ConvertToMultiSigUserRequest.entries.action,
|
|
2991
|
+
CreateSubAccountRequest.entries.action,
|
|
2992
|
+
CreateVaultRequest.entries.action,
|
|
2993
|
+
CSignerActionRequest.entries.action,
|
|
2994
|
+
CValidatorActionRequest.entries.action,
|
|
2995
|
+
CWithdrawRequest.entries.action,
|
|
2996
|
+
EvmUserModifyRequest.entries.action,
|
|
2997
|
+
ModifyRequest.entries.action,
|
|
2998
|
+
NoopRequest.entries.action,
|
|
2999
|
+
OrderRequest.entries.action,
|
|
3000
|
+
PerpDeployRequest.entries.action,
|
|
3001
|
+
RegisterReferrerRequest.entries.action,
|
|
3002
|
+
ReserveRequestWeightRequest.entries.action,
|
|
3003
|
+
ScheduleCancelRequest.entries.action,
|
|
3004
|
+
SendAssetRequest.entries.action,
|
|
3005
|
+
SetDisplayNameRequest.entries.action,
|
|
3006
|
+
SetReferrerRequest.entries.action,
|
|
3007
|
+
SpotDeployRequest.entries.action,
|
|
3008
|
+
SpotSendRequest.entries.action,
|
|
3009
|
+
SpotUserRequest.entries.action,
|
|
3010
|
+
SubAccountModifyRequest.entries.action,
|
|
3011
|
+
SubAccountSpotTransferRequest.entries.action,
|
|
3012
|
+
SubAccountTransferRequest.entries.action,
|
|
3013
|
+
TokenDelegateRequest.entries.action,
|
|
3014
|
+
TwapCancelRequest.entries.action,
|
|
3015
|
+
TwapOrderRequest.entries.action,
|
|
3016
|
+
UpdateIsolatedMarginRequest.entries.action,
|
|
3017
|
+
UpdateLeverageRequest.entries.action,
|
|
3018
|
+
UsdClassTransferRequest.entries.action,
|
|
3019
|
+
UsdSendRequest.entries.action,
|
|
3020
|
+
VaultDistributeRequest.entries.action,
|
|
3021
|
+
VaultModifyRequest.entries.action,
|
|
3022
|
+
VaultTransferRequest.entries.action,
|
|
3023
|
+
Withdraw3Request.entries.action,
|
|
3024
|
+
]),
|
|
3025
|
+
v.description("The underlying action to be executed through multi-sig."),
|
|
3026
|
+
),
|
|
3027
|
+
}),
|
|
3028
|
+
v.description("Multi-signature payload information."),
|
|
3029
|
+
),
|
|
3030
|
+
}),
|
|
3031
|
+
v.description("Action to perform."),
|
|
3032
|
+
),
|
|
3033
|
+
/** Unique request identifier (current timestamp in ms). */
|
|
3034
|
+
nonce: v.pipe(
|
|
3035
|
+
UnsignedInteger,
|
|
3036
|
+
v.description("Unique request identifier (current timestamp in ms)."),
|
|
3037
|
+
),
|
|
3038
|
+
/** Cryptographic signature. */
|
|
3039
|
+
signature: v.pipe(
|
|
3040
|
+
Signature,
|
|
3041
|
+
v.description("Cryptographic signature."),
|
|
3042
|
+
),
|
|
3043
|
+
/** Vault address (for vault trading). */
|
|
3044
|
+
vaultAddress: v.pipe(
|
|
3045
|
+
v.optional(v.pipe(Hex, v.length(42))),
|
|
3046
|
+
v.description("Vault address (for vault trading)."),
|
|
3047
|
+
),
|
|
3048
|
+
/** Expiration time of the action. */
|
|
3049
|
+
expiresAfter: v.pipe(
|
|
3050
|
+
v.optional(UnsignedInteger),
|
|
3051
|
+
v.description("Expiration time of the action."),
|
|
3052
|
+
),
|
|
3053
|
+
}),
|
|
3054
|
+
v.transform(removeUndefinedKeys),
|
|
3055
|
+
v.description("A multi-signature request."),
|
|
3056
|
+
);
|
|
3057
|
+
export type MultiSigRequest = v.InferOutput<typeof MultiSigRequest>;
|