diff --git a/.gitignore b/.gitignore index d583d66..2449020 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ README_BEFORE_RELEASE.md examples/tstests /tmp/ localtest.sh +rest-ts.ts diff --git a/README.md b/README.md index 48777b7..daf0326 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ Node.js 22 or newer is supported. Request and response types are exported from the package root. Every documented Info and Exchange operation has a corresponding `RestClient` method. Public lookup methods use `get...` names based on the information they return instead of exposing Hyperliquid's internal request type names. See the [examples](./examples) directory for REST API, WebSocket, and WebSocket API samples. -Exchange methods share one response wrapper: `ExchangeResponse` for acknowledgements, or `ExchangeResponse` when the response contains data, such as `ExchangeResponse` for orders and `ExchangeResponse` for a new vault or subaccount address. Check `status === 'ok'` before reading `response.data`. Raw Exchange methods use `ExchangeResponse` because the response depends on the submitted action. The same types apply to `RestClient` and `WebsocketAPIClient`. +Exchange methods share one response wrapper: `ExchangeResponse` for acknowledgements, or `ExchangeResponse` when the response contains data, such as `ExchangeResponse` for orders and `ExchangeResponse` for a new vault or subaccount address. For an order result, check `order.status === 'ok'` before reading `order.response.data`. Raw Exchange methods use `ExchangeResponse` because the response depends on the submitted action. The same types apply to `RestClient` and `WebsocketAPIClient`. ## Issues & Discussion @@ -149,7 +149,6 @@ const mids = await client.getAllMids(); const book = await client.getOrderBook({ coin: 'BTC', nSigFigs: 5, - mantissa: 1, }); const perpSummary = await client.getPerpAccountSummary({ user: '0x1234567890123456789012345678901234567890', @@ -188,7 +187,7 @@ console.log('Account:', balances.user); console.log('Spot:', balances.spot.balances); console.log('Perpetuals:', balances.perp.assetPositions); -const result = await client.submitOrder({ +const order = await client.submitOrder({ orders: [ { a: 'BTC', @@ -200,6 +199,8 @@ const result = await client.submitOrder({ }, ], }); + +if (order.status === 'ok') console.log(order.response.data); ``` We've added some convenient wrapper methods for common workflows: @@ -376,9 +377,9 @@ const book = { type: 'l2Book', coin: 'BTC', nSigFigs: 5, - mantissa: 1, fast: true, } as const; + const fills = { type: 'userFills', user: '0x1234567890123456789012345678901234567890', diff --git a/package-lock.json b/package-lock.json index d6e3f70..a411c56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@siebly/hyperliquid-api", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@siebly/hyperliquid-api", - "version": "1.0.1", + "version": "1.0.2", "license": "MIT", "dependencies": { "@msgpack/msgpack": "^3.1.2", diff --git a/package.json b/package.json index 08aa366..e68eded 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@siebly/hyperliquid-api", - "version": "1.0.1", + "version": "1.0.2", "description": "Professional JavaScript & Node.js SDK for Hyperliquid's REST APIs and WebSockets, built in TypeScript with strong end to end tests.", "scripts": { "clean": "node scripts/clean.mjs",