|
| 1 | +# Hyperliquid SDK Parity Plan (nktkas Alignment) |
| 2 | + |
| 3 | +## Goals |
| 4 | + |
| 5 | +- Match nktkas SDK coverage for all REST `/info`, REST `/exchange`, and WebSocket methods. |
| 6 | +- Implement schema validation for responses and structured error handling. |
| 7 | +- Preserve raw/parsed response behavior (parsed default, raw opt-in). |
| 8 | +- Keep undocumented endpoints when present in nktkas. |
| 9 | + |
| 10 | +## Scope |
| 11 | + |
| 12 | +- New first-class methods for missing info/exchange endpoints. |
| 13 | +- WebSocket subscription and post-message parity. |
| 14 | +- Types, response parsing, schema validation, and error taxonomy. |
| 15 | +- Minimal docs and tests to cover new functionality. |
| 16 | + |
| 17 | +## Non-goals |
| 18 | + |
| 19 | +- Large architectural rewrite or runtime portability changes. |
| 20 | +- Dropping existing behavior without a compatible path. |
| 21 | + |
| 22 | +## Plan of Record |
| 23 | + |
| 24 | +1. Inventory and Mapping |
| 25 | + |
| 26 | + - Extract full method list from nktkas (info/exchange/ws). |
| 27 | + - Compare against current SDK exports and document gaps. |
| 28 | + - Identify undocumented endpoints that must be included. |
| 29 | + |
| 30 | +2. Types and Constants Baseline |
| 31 | + |
| 32 | + - Add missing `InfoType`, `ExchangeType`, and WS subscription constants. |
| 33 | + - Define request/response types for all new methods. |
| 34 | + - Add shared payload fragments for reuse (e.g. user/subaccount, dex). |
| 35 | + |
| 36 | +3. REST `/info` Parity |
| 37 | + |
| 38 | + - Implement all missing info endpoints as first-class methods. |
| 39 | + - Add missing documented params and optional fields. |
| 40 | + - Ensure per-call raw override and default parsing behavior. |
| 41 | + |
| 42 | +4. REST `/exchange` Parity |
| 43 | + |
| 44 | + - Implement all missing exchange actions and method wrappers. |
| 45 | + - Ensure signing supports new action payload shapes. |
| 46 | + - Add any required subaccount overrides where applicable. |
| 47 | + |
| 48 | +5. WebSocket Parity |
| 49 | + |
| 50 | + - Add missing subscriptions, params, and payload builders. |
| 51 | + - Add response type support and raw/parsed handling. |
| 52 | + - Align WS errors and reconnect behavior with structured errors. |
| 53 | + |
| 54 | +6. Schema Validation |
| 55 | + |
| 56 | + - Add a validation layer for REST and WS responses using valibot. |
| 57 | + - Support: parsed (transform) and raw (shape-only) validation. |
| 58 | + - Allow global config toggle for validation with per-call override. |
| 59 | + |
| 60 | +7. Structured Errors |
| 61 | + |
| 62 | + - Introduce base `HyperliquidError` with typed subclasses: |
| 63 | + - `HyperliquidHttpError`, `HyperliquidSchemaError`, `HyperliquidWsError`, |
| 64 | + `HyperliquidRateLimitError`, `HyperliquidTimeoutError`, `HyperliquidRequestError`. |
| 65 | + - Attach context: method name, endpoint, requestId, status, payload. |
| 66 | + - Normalize server error payloads into consistent error codes. |
| 67 | + |
| 68 | +8. Tests and Docs |
| 69 | + |
| 70 | + - Add tests for new methods, validation, and error mapping. |
| 71 | + - Update README and changelog for new coverage and options. |
| 72 | + |
| 73 | +9. Rollout Strategy |
| 74 | + - Implement in phases: types/constants -> info -> exchange -> ws -> validation -> errors -> docs/tests. |
| 75 | + - Ship incremental commits to reduce review and integration risk. |
0 commit comments