@lifi/perps-sdk-provider-lighter 8.2.1 → 9.0.0

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.
Files changed (96) hide show
  1. package/README.md +14 -10
  2. package/dist/cjs/LighterProvider.d.ts +5 -10
  3. package/dist/cjs/LighterProvider.d.ts.map +1 -1
  4. package/dist/cjs/LighterProvider.js +27 -26
  5. package/dist/cjs/LighterProvider.js.map +1 -1
  6. package/dist/cjs/constants.d.ts +5 -8
  7. package/dist/cjs/constants.d.ts.map +1 -1
  8. package/dist/cjs/constants.js +15 -12
  9. package/dist/cjs/constants.js.map +1 -1
  10. package/dist/cjs/index.d.ts +3 -4
  11. package/dist/cjs/index.d.ts.map +1 -1
  12. package/dist/cjs/index.js +6 -5
  13. package/dist/cjs/index.js.map +1 -1
  14. package/dist/cjs/signers/LighterSigner.d.ts +5 -7
  15. package/dist/cjs/signers/LighterSigner.d.ts.map +1 -1
  16. package/dist/cjs/signers/LighterSigner.js +5 -12
  17. package/dist/cjs/signers/LighterSigner.js.map +1 -1
  18. package/dist/cjs/signers/generated/wasmExecRuntime.d.ts +2 -0
  19. package/dist/cjs/signers/generated/wasmExecRuntime.d.ts.map +1 -0
  20. package/dist/cjs/signers/generated/wasmExecRuntime.js +569 -0
  21. package/dist/cjs/signers/generated/wasmExecRuntime.js.map +1 -0
  22. package/dist/cjs/signers/signActions.d.ts +2 -2
  23. package/dist/cjs/signers/signActions.d.ts.map +1 -1
  24. package/dist/cjs/signers/signActions.js +4 -10
  25. package/dist/cjs/signers/signActions.js.map +1 -1
  26. package/dist/cjs/signers/wasmBinaryUrl.js +11 -0
  27. package/dist/cjs/signers/wasmLoader.d.ts +1 -6
  28. package/dist/cjs/signers/wasmLoader.d.ts.map +1 -1
  29. package/dist/cjs/signers/wasmLoader.js +15 -69
  30. package/dist/cjs/signers/wasmLoader.js.map +1 -1
  31. package/dist/esm/LighterProvider.d.ts +53 -56
  32. package/dist/esm/LighterProvider.d.ts.map +1 -1
  33. package/dist/esm/LighterProvider.js +69 -48
  34. package/dist/esm/LighterProvider.js.map +1 -1
  35. package/dist/esm/constants.d.ts +25 -36
  36. package/dist/esm/constants.d.ts.map +1 -1
  37. package/dist/esm/constants.js +31 -18
  38. package/dist/esm/constants.js.map +1 -1
  39. package/dist/esm/index.d.ts +6 -7
  40. package/dist/esm/index.d.ts.map +1 -1
  41. package/dist/esm/index.js +5 -6
  42. package/dist/esm/index.js.map +1 -1
  43. package/dist/esm/signers/LighterSigner.d.ts +10 -18
  44. package/dist/esm/signers/LighterSigner.d.ts.map +1 -1
  45. package/dist/esm/signers/LighterSigner.js +7 -14
  46. package/dist/esm/signers/LighterSigner.js.map +1 -1
  47. package/dist/esm/signers/generated/wasmExecRuntime.d.ts +8 -0
  48. package/dist/esm/signers/generated/wasmExecRuntime.d.ts.map +1 -0
  49. package/dist/esm/signers/generated/wasmExecRuntime.js +574 -0
  50. package/dist/esm/signers/generated/wasmExecRuntime.js.map +1 -0
  51. package/dist/esm/signers/signActions.d.ts +3 -5
  52. package/dist/esm/signers/signActions.d.ts.map +1 -1
  53. package/dist/esm/signers/signActions.js +4 -10
  54. package/dist/esm/signers/signActions.js.map +1 -1
  55. package/dist/esm/signers/wasmBinaryUrl.js +10 -0
  56. package/dist/esm/signers/wasmLoader.d.ts +7 -31
  57. package/dist/esm/signers/wasmLoader.d.ts.map +1 -1
  58. package/dist/esm/signers/wasmLoader.js +32 -108
  59. package/dist/esm/signers/wasmLoader.js.map +1 -1
  60. package/dist/types/LighterProvider.d.ts +53 -56
  61. package/dist/types/LighterProvider.d.ts.map +1 -1
  62. package/dist/types/constants.d.ts +25 -36
  63. package/dist/types/constants.d.ts.map +1 -1
  64. package/dist/types/index.d.ts +6 -7
  65. package/dist/types/index.d.ts.map +1 -1
  66. package/dist/types/signers/LighterSigner.d.ts +10 -18
  67. package/dist/types/signers/LighterSigner.d.ts.map +1 -1
  68. package/dist/types/signers/generated/wasmExecRuntime.d.ts +8 -0
  69. package/dist/types/signers/generated/wasmExecRuntime.d.ts.map +1 -0
  70. package/dist/types/signers/signActions.d.ts +3 -5
  71. package/dist/types/signers/signActions.d.ts.map +1 -1
  72. package/dist/types/signers/wasmLoader.d.ts +7 -31
  73. package/dist/types/signers/wasmLoader.d.ts.map +1 -1
  74. package/package.json +1 -4
  75. package/src/LighterProvider.ts +98 -101
  76. package/src/constants.ts +35 -45
  77. package/src/index.ts +13 -10
  78. package/src/signers/LighterSigner.ts +15 -36
  79. package/src/signers/generated/wasmExecRuntime.ts +575 -0
  80. package/src/signers/signActions.ts +12 -30
  81. package/src/signers/wasmBinaryUrl.d.ts +7 -0
  82. package/src/signers/wasmLoader.ts +33 -152
  83. package/dist/cjs/signers/index.d.ts +0 -11
  84. package/dist/cjs/signers/index.d.ts.map +0 -1
  85. package/dist/cjs/signers/index.js +0 -18
  86. package/dist/cjs/signers/index.js.map +0 -1
  87. package/dist/esm/signers/index.d.ts +0 -11
  88. package/dist/esm/signers/index.d.ts.map +0 -1
  89. package/dist/esm/signers/index.js +0 -7
  90. package/dist/esm/signers/index.js.map +0 -1
  91. package/dist/types/signers/index.d.ts +0 -11
  92. package/dist/types/signers/index.d.ts.map +0 -1
  93. package/dist/wasm/wasm_exec.js +0 -561
  94. package/src/signers/index.ts +0 -35
  95. package/wasm/lighter-signer.wasm +0 -0
  96. package/wasm/wasm_exec.js +0 -561
@@ -2,21 +2,20 @@
2
2
  * Lighter provider plugin for `@lifi/perps-sdk`. Serves `PerpsProvider` reads
3
3
  * directly from Lighter's REST API (no LI.FI backend hop); auth-gated reads
4
4
  * use the user's Lighter read-only token. Also owns `signActions` (the
5
- * `WASM_BLOB` / `EVM_TX` arms of `PerpsClient.execute`) — `LighterSigner`,
6
- * `LighterKeyStore`, `LighterReadOnlyTokenManager`, and the WASM blob ship
7
- * with this package.
5
+ * `WASM_BLOB` / `EVM_TX` arms of `PerpsClient.execute`): each provider
6
+ * instance creates its own WASM signer, API-key store and read-only token
7
+ * manager, and the Go signer binary ships with this package.
8
8
  *
9
9
  * @packageDocumentation
10
10
  * @public
11
11
  */
12
12
  export { projectLighterConfigSettings } from './accountConfig.js';
13
13
  export { getAccountSummary } from './accountSummary.js';
14
- export type { LighterCollateralAsset, LighterInstanceConfig, LighterRhInstanceOverrides, } from './constants.js';
15
- export { DEFAULT_API_KEY_INDEX, DEFAULT_LIGHTER_EXPLORER_TX_BASE_URL, DEFAULT_LIGHTER_REST_URL, DEFAULT_LIGHTER_SIGNER_CHAIN_ID, DEFAULT_LIGHTER_WS_URL, LIGHTER_COLLATERAL_ASSETS, LIGHTER_MAINNET_INSTANCE, LIGHTER_PROVIDER_KEY, LIGHTER_RH_PROVIDER_KEY, LIGHTER_RH_REST_URL, LIGHTER_RH_WS_URL, LIGHTER_SPOT_CATEGORY_ID, lighterRhInstance, } from './constants.js';
14
+ export type { LighterCollateralAsset, LighterDeployment, } from './constants.js';
15
+ export { DEFAULT_API_KEY_INDEX, DEFAULT_LIGHTER_EXPLORER_TX_BASE_URL, DEFAULT_LIGHTER_REST_URL, DEFAULT_LIGHTER_WS_URL, LIGHTER_COLLATERAL_ASSETS, LIGHTER_MAINNET_DEPLOYMENT, LIGHTER_MAINNET_SIGNER_CHAIN_ID, LIGHTER_PROVIDER_KEY, LIGHTER_RH_DEPLOYMENT, LIGHTER_RH_PROVIDER_KEY, LIGHTER_RH_REST_URL, LIGHTER_RH_SIGNER_CHAIN_ID, LIGHTER_RH_WS_URL, LIGHTER_SPOT_CATEGORY_ID, } from './constants.js';
16
16
  export { lighterDepositFlow } from './depositFlow.js';
17
17
  export type { LighterPerpsProvider, LighterProviderOptions, } from './LighterProvider.js';
18
- export { Lighter, lighterProvider } from './LighterProvider.js';
19
- export * from './signers/index.js';
18
+ export { Lighter, lighterProvider, lighterRhProvider, } from './LighterProvider.js';
20
19
  export * from './types/index.js';
21
20
  export * from './utils/index.js';
22
21
  export type { LighterAuthTokenResolver } from './websocket/LighterWsProvider.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,qBAAqB,EACrB,oCAAoC,EACpC,wBAAwB,EACxB,+BAA+B,EAC/B,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,YAAY,EACV,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE/D,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAChF,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,iBAAiB,GAClB,MAAM,kCAAkC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,YAAY,EACV,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,qBAAqB,EACrB,oCAAoC,EACpC,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,+BAA+B,EAC/B,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,YAAY,EACV,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,OAAO,EACP,eAAe,EACf,iBAAiB,GAClB,MAAM,sBAAsB,CAAA;AAE7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAChF,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,iBAAiB,GAClB,MAAM,kCAAkC,CAAA"}
@@ -1,5 +1,4 @@
1
1
  import { ActionType } from '@lifi/perps-types';
2
- import { type LoadLighterWasmOptions } from './wasmLoader.js';
3
2
  /**
4
3
  * Credentials needed to initialize the Lighter WASM client for one account
5
4
  * and API-key slot. The private key is Lighter-native signing material; the
@@ -16,22 +15,16 @@ export interface LighterSignerContext {
16
15
  accountIndex: number;
17
16
  }
18
17
  /**
19
- * Configuration for {@link LighterSigner}: optional WASM asset overrides plus
20
- * the per-instance REST base URL, signing chain id and collateral asset index.
18
+ * Deployment facts {@link LighterSigner} signs against: the venue's REST base
19
+ * URL, its zkLighter L2 signing chain id, and the L2 asset index its
20
+ * withdrawals and transfers settle in.
21
21
  *
22
- * @public
22
+ * @internal
23
23
  */
24
- export interface LighterSignerConfig extends LoadLighterWasmOptions {
25
- /** Lighter REST API base URL. */
26
- apiUrl?: string;
27
- /** Lighter chain ID (304 = mainnet). */
28
- chainId?: number;
29
- /**
30
- * L2 asset index this instance's withdrawals and transfers are signed
31
- * against — pass the instance's `collateral.assetIndex`. Defaults to
32
- * mainnet's USDC slot.
33
- */
34
- collateralAssetIndex?: number;
24
+ export interface LighterSignerConfig {
25
+ apiUrl: string;
26
+ signerChainId: number;
27
+ collateralAssetIndex: number;
35
28
  }
36
29
  /**
37
30
  * Signed Lighter transaction blob returned by the WASM signer. `txType`,
@@ -80,16 +73,15 @@ export interface ApiKeyPair {
80
73
  * hybrid flows. The instance memoizes WASM initialization and registered
81
74
  * `(apiKeyIndex, accountIndex)` clients.
82
75
  *
83
- * @public
76
+ * @internal
84
77
  */
85
78
  export declare class LighterSigner {
86
79
  private readonly apiUrl;
87
80
  private readonly chainId;
88
81
  private readonly collateralAssetIndex;
89
- private readonly loaderOptions;
90
82
  private wasm;
91
83
  private readonly registeredClients;
92
- constructor(config?: LighterSignerConfig);
84
+ constructor(config: LighterSignerConfig);
93
85
  /**
94
86
  * Load and cache the Go WASM signer exports. Most signing methods initialize
95
87
  * lazily, so callers only need this method when they want an explicit warm-up.
@@ -1 +1 @@
1
- {"version":3,"file":"LighterSigner.d.ts","sourceRoot":"","sources":["../../../src/signers/LighterSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAW9C,OAAO,EAEL,KAAK,sBAAsB,EAG5B,MAAM,iBAAiB,CAAA;AAOxB;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAA;IACxB,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAA;IACnB,6EAA6E;IAC7E,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAoB,SAAQ,sBAAsB;IACjE,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,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,EAAE,oBAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC;YAiBJ,YAAY;YAOZ,YAAY;IAmB1B;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;CA+MjB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Go's canonical `wasm_exec.js`, verbatim, as opaque runtime text. Evaluated by
3
+ * the WASM loader to install `globalThis.Go`.
4
+ *
5
+ * @internal
6
+ */
7
+ export declare const WASM_EXEC_JS: string;
8
+ //# sourceMappingURL=wasmExecRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasmExecRuntime.d.ts","sourceRoot":"","sources":["../../../../src/signers/generated/wasmExecRuntime.ts"],"names":[],"mappings":"AAwjBA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,MAAmC,CAAA"}
@@ -7,18 +7,16 @@ import type { LighterKeyStore } from './LighterKeyStore.js';
7
7
  import type { LighterSigner } from './LighterSigner.js';
8
8
  /**
9
9
  * Per-batch dependencies the Lighter `signActions` implementation needs:
10
- * a WASM signer (`LighterSigner`), the API-key store keyed on L1 address,
10
+ * the provider instance's WASM signer, its API-key store keyed on L1 address,
11
11
  * a REST client for the token-authenticated venue mutations that execute
12
12
  * client-side, and an `accountIndex` resolver for the REGISTER_API_KEY
13
13
  * hybrid flow.
14
14
  *
15
- * `signer` and `keyStore` are optional because only the `WASM_BLOB` arm signs
16
- * with them — `EVM_TX` broadcasts through the end-user wallet in `ctx`.
17
15
  * @internal
18
16
  */
19
17
  export interface LighterSignActionsDeps {
20
- signer?: LighterSigner;
21
- keyStore?: LighterKeyStore;
18
+ signer: LighterSigner;
19
+ keyStore: LighterKeyStore;
22
20
  /** REST client bound to the user's Lighter base URL, used for the direct
23
21
  * `changeAccountTier` / `referral/use` POSTs so their auth token never
24
22
  * transits the LI.FI backend. */
@@ -1 +1 @@
1
- {"version":3,"file":"signActions.d.ts","sourceRoot":"","sources":["../../../src/signers/signActions.ts"],"names":[],"mappings":"AAAA,OAAO,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AAG,SAAS,GAClC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CA6ElC;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,sBAAsB,EAC5B,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,GAAG,CAAC,EAAE,kBAAkB,GACvB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAsB7B"}
@@ -1,28 +1,3 @@
1
- /**
2
- * Overrides for locating the Lighter Go WASM binary and its runtime loader.
3
- * Supplying explicit URLs or source is useful when a bundler does not preserve
4
- * the package's relative asset layout.
5
- *
6
- * @public
7
- */
8
- export interface LoadLighterWasmOptions {
9
- /** Override URL for the `.wasm` binary (browser: fetch; Node: fs). */
10
- wasmBinaryUrl?: string | URL;
11
- /** Override URL for Go's `wasm_exec.js` runtime. */
12
- wasmExecJsUrl?: string | URL;
13
- /**
14
- * Pre-fetched source of Go's `wasm_exec.js`. Preferred over
15
- * `wasmExecJsUrl` for bundlers (Vite/webpack) that may transform a `.js`
16
- * URL on serve, breaking the IIFE that installs `globalThis.Go`. Pass via
17
- * a `?raw` import (Vite) or equivalent so the original source survives
18
- * intact.
19
- *
20
- * @security This string is evaluated via `new Function(...)`. The caller is
21
- * responsible for ensuring it originates from the bundled `wasm_exec.js`;
22
- * attacker-controlled content would execute arbitrary code in the host.
23
- */
24
- wasmExecJsSource?: string;
25
- }
26
1
  /**
27
2
  * Function table installed by the Lighter Go WASM runtime. Methods mirror the
28
3
  * venue signer ABI and return a result containing either signed transaction
@@ -145,16 +120,17 @@ export interface SignResult {
145
120
  error?: string;
146
121
  }
147
122
  /**
148
- * Load the Lighter WASM signer. Memoized per-process: subsequent calls return
149
- * the cached exports. The Go runtime keeps a long-running goroutine to service
150
- * JS calls — we start it once and never stop it.
151
- * @public
123
+ * Load the Lighter WASM signer from the binary shipped with this package.
124
+ * Memoized per-process: subsequent calls return the cached exports. The Go
125
+ * runtime keeps a long-running goroutine to service JS calls — we start it
126
+ * once and never stop it.
127
+ * @internal
152
128
  */
153
- export declare function loadLighterWasm(options?: LoadLighterWasmOptions): Promise<LighterWasmExports>;
129
+ export declare function loadLighterWasm(): Promise<LighterWasmExports>;
154
130
  /**
155
131
  * Testing helper — drop the cached WASM instance so the next load reinitializes.
156
132
  *
157
- * @public
133
+ * @internal
158
134
  */
159
135
  export declare function resetLighterWasmCache(): void;
160
136
  //# sourceMappingURL=wasmLoader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wasmLoader.d.ts","sourceRoot":"","sources":["../../../src/signers/wasmLoader.ts"],"names":[],"mappings":"AAkDA;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;IAC5B,oDAAoD;IACpD,aAAa,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;IAC5B;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM;QACpB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;IACD,YAAY,EAAE,CACZ,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,KACjB;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACvB,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9E;;;;;OAKG;IACH,eAAe,EAAE,CACf,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,YAAY,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EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,UAAU,CAAA;CACjE;AAED,gBAAgB;AAChB,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAyDD;;;;;;GAMG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAKnE;AAmDD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/perps-sdk-provider-lighter",
3
- "version": "8.2.1",
3
+ "version": "9.0.0",
4
4
  "description": "Lighter provider plugin for @lifi/perps-sdk",
5
5
  "homepage": "https://github.com/lifinance/perps-sdk",
6
6
  "bugs": {
@@ -24,15 +24,12 @@
24
24
  "import": "./dist/esm/index.js",
25
25
  "default": "./dist/cjs/index.js"
26
26
  },
27
- "./wasm/*": "./wasm/*",
28
27
  "./package.json": "./package.json"
29
28
  },
30
29
  "files": [
31
30
  "dist/**",
32
31
  "!dist/**/*.tsbuildinfo",
33
32
  "src/**/*.ts",
34
- "wasm/lighter-signer.wasm",
35
- "wasm/wasm_exec.js",
36
33
  "!src/**/*.spec.ts",
37
34
  "!src/**/*.test.ts",
38
35
  "!src/**/*.mock.ts",
@@ -4,6 +4,7 @@ import {
4
4
  getAssetRegistry,
5
5
  getMarketRegistry,
6
6
  getProviders,
7
+ localStorageAdapter,
7
8
  PerpsError,
8
9
  type PerpsProviderPlugin,
9
10
  type PerpsSDKClient,
@@ -21,6 +22,7 @@ import {
21
22
  resolveRetryPolicy,
22
23
  type SDKRequestOptions,
23
24
  type SignActionsContext,
25
+ type StorageAdapter,
24
26
  toPerpsMarketDisplay,
25
27
  } from '@lifi/perps-sdk'
26
28
  import type {
@@ -34,7 +36,6 @@ import type {
34
36
  Balance,
35
37
  FillsResponse,
36
38
  LighterAccountConfig,
37
- LighterProviderKey,
38
39
  MarketSettings,
39
40
  Order,
40
41
  OrdersResponse,
@@ -56,23 +57,21 @@ import { projectLighterConfigSettings } from './accountConfig.js'
56
57
  import { getAccountSummary } from './accountSummary.js'
57
58
  import {
58
59
  DEFAULT_API_KEY_INDEX,
59
- DEFAULT_LIGHTER_EXPLORER_TX_BASE_URL,
60
- DEFAULT_LIGHTER_REST_URL,
61
60
  DEFAULT_TRADES_LIMIT,
62
61
  LIGHTER_ALL_MARKETS_WILDCARD,
63
62
  LIGHTER_BASE_FEE_TIER,
64
- LIGHTER_COLLATERAL_ASSETS,
65
63
  LIGHTER_FEE_TICK_SCALE,
66
64
  LIGHTER_HISTORY_PAGE_SIZE,
67
- LIGHTER_PROVIDER_KEY,
65
+ LIGHTER_MAINNET_DEPLOYMENT,
66
+ LIGHTER_RH_DEPLOYMENT,
68
67
  LIGHTER_SPOT_CATEGORY_ID,
68
+ type LighterDeployment,
69
69
  } from './constants.js'
70
70
  import { lighterDepositFlow } from './depositFlow.js'
71
71
  import { createAuthToken } from './signers/createAuthToken.js'
72
- import type { LighterKeyStore } from './signers/LighterKeyStore.js'
73
- import type { LighterReadOnlyTokenManagerOptions } from './signers/LighterReadOnlyTokenManager.js'
72
+ import { LighterKeyStore } from './signers/LighterKeyStore.js'
74
73
  import { LighterReadOnlyTokenManager } from './signers/LighterReadOnlyTokenManager.js'
75
- import type { LighterSigner } from './signers/LighterSigner.js'
74
+ import { LighterSigner } from './signers/LighterSigner.js'
76
75
  import { lighterSignActions } from './signers/signActions.js'
77
76
  import type {
78
77
  LtAccountLimits,
@@ -170,67 +169,42 @@ const normalizeLighterPublicKey = (key: string): string =>
170
169
  key.replace(/^0x/i, '').toLowerCase()
171
170
 
172
171
  /**
173
- * Construction options for the Lighter {@link PerpsProviderPlugin}.
174
- *
175
- * `restUrl` defaults to Lighter mainnet; pass a testnet URL or a self-hosted
176
- * mirror to override.
172
+ * Consumer-level overrides for a ready-made Lighter provider plugin. Every
173
+ * deployment fact — provider key, endpoints, signing chain id, collateral
174
+ * asset, explorer — belongs to the SDK's {@link LighterDeployment} descriptor
175
+ * and is not settable here; the signer, API-key store and read-only token
176
+ * manager are created per plugin instance.
177
177
  *
178
178
  * Auth-token resolution order for the auth-gated reads:
179
179
  * 1. Per-call `options.lighterAuthToken`
180
180
  * 2. Constructor `authToken` (string or async factory)
181
- * 3. Persisted long-lived read-only token (via `readOnlyTokenOptions`'s
182
- * storage), keyed on the resolved Lighter `accountIndex`
183
- * 4. Fresh 1h create via the WASM signer + the user's registered API key
184
- * from `keyStore`
181
+ * 3. Persisted long-lived read-only token, keyed on the resolved Lighter
182
+ * `accountIndex`
183
+ * 4. Fresh 1h create via this instance's WASM signer + the user's registered
184
+ * API key
185
185
  *
186
186
  * When none of these yields a token the auth-gated reads degrade gracefully:
187
187
  * - `getOrders`, `getActivity` return empty results (mirrors backend behaviour)
188
188
  * - `getOrder` throws `Unauthorized`
189
189
  * - `getAccount` returns zero fee tier rather than failing
190
190
  *
191
- * `WASM_BLOB` write actions (`signActions`) require `signer` and `keyStore` to
192
- * be supplied; the `EVM_TX` arm signs with the end-user wallet alone.
193
- *
194
191
  * @public
195
192
  */
196
193
  export interface LighterProviderOptions {
197
194
  /**
198
- * Provider key: the plugin `type`, the `Provider.key` matched against the
199
- * backend `/providers` response, and the namespace for this instance's market
200
- * / asset registries and retry policy. Defaults to `'lighter'` (mainnet).
201
- * Set a distinct key (e.g. `'lighter-rh'`) to register a second Lighter
202
- * instance on the same client.
195
+ * Persistence backend for this instance's Lighter API keypair and read-only
196
+ * token. Defaults to browser `localStorage` (encrypted at rest). Pass a
197
+ * custom adapter for SSR / non-browser hosts or another storage backend.
203
198
  */
204
- providerKey?: LighterProviderKey
205
- /** Lighter REST base URL. Defaults to mainnet. */
206
- restUrl?: string
199
+ storage?: StorageAdapter
207
200
  /**
208
- * Explorer tx base URL for transfer-activity links (`${base}${txHash}`).
209
- * Defaults to the mainnet Lighter explorer for the default provider key, and
210
- * to `undefined` (no transfer links) for any other key unless supplied.
201
+ * Lighter REST base URL. Defaults to the deployment's own endpoint; override
202
+ * to point at a reverse proxy, self-hosted mirror or rate-limit gateway. The
203
+ * instance's signer and read-only token manager follow this URL.
211
204
  */
212
- explorerTxBaseUrl?: string
213
- /** Pre-created Lighter read-only bearer. */
205
+ restUrl?: string
206
+ /** Pre-created Lighter read-only bearer, bypassing SDK token resolution. */
214
207
  authToken?: string | (() => string | Promise<string>)
215
- /**
216
- * WASM signer instance. Required for the `WASM_BLOB` arm of `signActions`
217
- * and for on-demand auth-token creating from the user's API key. The default
218
- * configuration loads the WASM blob shipped with this package.
219
- */
220
- signer?: LighterSigner
221
- /**
222
- * Store for the user's per-address Lighter API keypair. Required for the
223
- * `WASM_BLOB` arm of `signActions` and for on-demand auth-token creating.
224
- */
225
- keyStore?: LighterKeyStore
226
- /**
227
- * Injection overrides (storage, fetcher, clock, host) for the read-only
228
- * token manager, which is always active — Lighter reads create a long-lived
229
- * read-only token on first use and reuse it thereafter. The host defaults to
230
- * `restUrl`. This does not enable or disable the manager; it only overrides
231
- * its dependencies (primarily for tests / non-browser storage).
232
- */
233
- readOnlyTokenOptions?: LighterReadOnlyTokenManagerOptions
234
208
  /** Token lifetime for on-demand standard-token creates (Lighter caps at 8h). Default 1h. */
235
209
  tokenLifetimeSeconds?: number
236
210
  /** Re-create when the cached standard token's remaining life is below this. Default 60s. */
@@ -270,27 +244,14 @@ export interface LighterPerpsProvider extends PerpsProviderPlugin {
270
244
  }
271
245
 
272
246
  /**
273
- * Lighter provider plugin factory. Returns an object implementing
274
- * {@link PerpsProviderPlugin}, mirroring the `EthereumProvider()` / `hyperliquidProvider()`
275
- * shape used by the rest of the LI.FI SDK family.
276
- *
277
- * Read functions call Lighter's REST API directly with no LI.FI backend hop.
278
- * Auth-gated reads resolve their token via the order documented on
279
- * {@link LighterProviderOptions}.
247
+ * Build a Lighter provider plugin for one deployment. The deployment
248
+ * descriptor is SDK-owned, so this stays package-internal: consumers reach it
249
+ * through {@link lighterProvider} / {@link lighterRhProvider}.
280
250
  *
281
- * Write actions (`WASM_BLOB` and `EVM_TX` signing) are dispatched via
282
- * `signActions` — `PerpsClient.execute` delegates those arms here.
283
- *
284
- * @example
285
- * ```ts
286
- * const client = createPerpsClient({
287
- * integrator: 'my-app',
288
- * providers: [lighterProvider()],
289
- * })
290
- * ```
291
- * @public
251
+ * @internal
292
252
  */
293
- export const lighterProvider = (
253
+ export const createLighterProvider = (
254
+ deployment: LighterDeployment,
294
255
  options: LighterProviderOptions = {}
295
256
  ): LighterPerpsProvider => {
296
257
  // Late-bind slot: the factory runs before the client exists, so `bind`
@@ -301,34 +262,34 @@ export const lighterProvider = (
301
262
  if (boundClient === undefined) {
302
263
  throw new PerpsError(
303
264
  PerpsErrorCode.SDKError,
304
- 'lighterProvider used before binding. Register it via ' +
305
- 'createPerpsClient({ providers: [lighterProvider()] }).'
265
+ `${deployment.providerKey} provider used before binding. Register it ` +
266
+ 'via createPerpsClient({ providers: [lighterProvider()] }).'
306
267
  )
307
268
  }
308
269
  return boundClient
309
270
  }
310
271
 
311
- const providerKey = options.providerKey ?? LIGHTER_PROVIDER_KEY
312
- const restUrl = options.restUrl ?? DEFAULT_LIGHTER_REST_URL
313
- const explorerTxBaseUrl =
314
- options.explorerTxBaseUrl ??
315
- (providerKey === LIGHTER_PROVIDER_KEY
316
- ? DEFAULT_LIGHTER_EXPLORER_TX_BASE_URL
317
- : undefined)
318
- const collateral = LIGHTER_COLLATERAL_ASSETS[providerKey]
272
+ const providerKey = deployment.providerKey
273
+ const restUrl = options.restUrl ?? deployment.restUrl
274
+ const explorerTxBaseUrl = deployment.explorerTxBaseUrl
275
+ const collateral = deployment.collateral
319
276
  const authTokenSource: (() => string | Promise<string>) | undefined =
320
277
  typeof options.authToken === 'function'
321
278
  ? options.authToken
322
279
  : options.authToken !== undefined
323
280
  ? () => options.authToken as string
324
281
  : undefined
325
- const signer = options.signer
326
- const keyStore = options.keyStore
327
- keyStore?.bindProviderKey(providerKey)
282
+ const storage = options.storage ?? localStorageAdapter
283
+ const signer = new LighterSigner({
284
+ apiUrl: restUrl,
285
+ signerChainId: deployment.signerChainId,
286
+ collateralAssetIndex: collateral.assetIndex,
287
+ })
288
+ const keyStore = new LighterKeyStore(storage, providerKey)
328
289
  const readOnlyTokenManager = new LighterReadOnlyTokenManager({
290
+ storage,
329
291
  providerKey,
330
292
  lighterApiUrl: restUrl,
331
- ...options.readOnlyTokenOptions,
332
293
  })
333
294
  const tokenLifetimeSeconds = options.tokenLifetimeSeconds ?? 60 * 60
334
295
  const tokenRenewBufferSeconds = options.tokenRenewBufferSeconds ?? 60
@@ -360,12 +321,6 @@ export const lighterProvider = (
360
321
  apiKeyPrivateKey: string,
361
322
  indices: { apiKeyIndex: number; accountIndex: number }
362
323
  ): Promise<string> => {
363
- if (signer === undefined) {
364
- throw new PerpsError(
365
- PerpsErrorCode.SDKError,
366
- 'lighterProvider: getStandardAuthToken called without a configured signer.'
367
- )
368
- }
369
324
  const cacheKey = address.toLowerCase()
370
325
  const nowSec = Math.floor(Date.now() / 1000)
371
326
  const cached = standardTokenByAddress.get(cacheKey)
@@ -414,11 +369,11 @@ export const lighterProvider = (
414
369
  if (authTokenSource !== undefined) {
415
370
  return authTokenSource()
416
371
  }
417
- if (address === undefined || keyStore === undefined) {
372
+ if (address === undefined) {
418
373
  return undefined
419
374
  }
420
375
  const apiKey = await keyStore.get(address)
421
- if (apiKey === null || signer === undefined) {
376
+ if (apiKey === null) {
422
377
  return undefined
423
378
  }
424
379
 
@@ -496,7 +451,7 @@ export const lighterProvider = (
496
451
  // rides reads during the creation-failure fallback and authorises
497
452
  // read-only token creation — so a revocation must re-sign it too.
498
453
  standardTokenByAddress.delete(cacheKey)
499
- const apiKey = keyStore ? await keyStore.get(address) : null
454
+ const apiKey = await keyStore.get(address)
500
455
  if (apiKey !== null) {
501
456
  await readOnlyTokenManager.remove(address, apiKey.accountIndex)
502
457
  }
@@ -748,7 +703,7 @@ export const lighterProvider = (
748
703
  : retryOnRevoked(opts, params.address, token, (t) =>
749
704
  fetchAccountLimits(client, account.index, t)
750
705
  ),
751
- keyStore ? keyStore.get(params.address) : Promise.resolve(null),
706
+ keyStore.get(params.address),
752
707
  readOnlyTokenManager.get(params.address, account.index),
753
708
  // No referral code to compare against, or no token to authenticate the
754
709
  // read → undefined → `referralPresent: false`.
@@ -1349,9 +1304,8 @@ export const lighterProvider = (
1349
1304
 
1350
1305
  /**
1351
1306
  * Hand the backend the local pubkey for REGISTER_API_KEY so its
1352
- * idempotency check can compare against the on-chain slot. No keystore
1353
- * configured, or no key stored for this address → omit the field;
1354
- * backend stages a fresh registration.
1307
+ * idempotency check can compare against the on-chain slot. No key stored
1308
+ * for this address → omit the field; backend stages a fresh registration.
1355
1309
  */
1356
1310
  async resolveSetupParams(
1357
1311
  action: ActionType,
@@ -1360,9 +1314,6 @@ export const lighterProvider = (
1360
1314
  if (action !== ActionType.REGISTER_API_KEY) {
1361
1315
  return {}
1362
1316
  }
1363
- if (keyStore === undefined) {
1364
- return {}
1365
- }
1366
1317
  const local = await keyStore.get(address)
1367
1318
  if (local === null) {
1368
1319
  return {}
@@ -1390,7 +1341,7 @@ export const lighterProvider = (
1390
1341
  keyStore,
1391
1342
  apiClient: apiClient(),
1392
1343
  resolveAccountIndex: async (addr) => {
1393
- const apiKey = keyStore ? await keyStore.get(addr) : null
1344
+ const apiKey = await keyStore.get(addr)
1394
1345
  if (apiKey !== null) {
1395
1346
  return apiKey.accountIndex
1396
1347
  }
@@ -1407,6 +1358,52 @@ export const lighterProvider = (
1407
1358
  }
1408
1359
  }
1409
1360
 
1361
+ /**
1362
+ * Lighter mainnet provider plugin. Returns an object implementing
1363
+ * {@link PerpsProviderPlugin}, mirroring the `EthereumProvider()` /
1364
+ * `hyperliquidProvider()` shape used by the rest of the LI.FI SDK family.
1365
+ *
1366
+ * Read functions call Lighter's REST API directly with no LI.FI backend hop;
1367
+ * auth-gated reads resolve their token via the order documented on
1368
+ * {@link LighterProviderOptions}. Write actions (`WASM_BLOB` and `EVM_TX`
1369
+ * signing) are dispatched via `signActions` — `PerpsClient.execute` delegates
1370
+ * those arms here. The instance owns its WASM signer, API-key store and
1371
+ * read-only token manager.
1372
+ *
1373
+ * @example
1374
+ * ```ts
1375
+ * const client = createPerpsClient({
1376
+ * integrator: 'my-app',
1377
+ * providers: [lighterProvider()],
1378
+ * })
1379
+ * ```
1380
+ * @public
1381
+ */
1382
+ export const lighterProvider = (
1383
+ options: LighterProviderOptions = {}
1384
+ ): LighterPerpsProvider =>
1385
+ createLighterProvider(LIGHTER_MAINNET_DEPLOYMENT, options)
1386
+
1387
+ /**
1388
+ * Lighter-on-Robinhood-chain provider plugin. Same contract as
1389
+ * {@link lighterProvider}, bound to the RH deployment: its own endpoints,
1390
+ * zkLighter signing chain id, USDG collateral, and its own signer, API-key
1391
+ * store and read-only token manager. Registering both factories on one client
1392
+ * keeps their credentials and caches separate.
1393
+ *
1394
+ * @example
1395
+ * ```ts
1396
+ * const client = createPerpsClient({
1397
+ * integrator: 'my-app',
1398
+ * providers: [lighterProvider(), lighterRhProvider()],
1399
+ * })
1400
+ * ```
1401
+ * @public
1402
+ */
1403
+ export const lighterRhProvider = (
1404
+ options: LighterProviderOptions = {}
1405
+ ): LighterPerpsProvider => createLighterProvider(LIGHTER_RH_DEPLOYMENT, options)
1406
+
1410
1407
  /**
1411
1408
  * Alias matching `@lifi/sdk`'s capitalised factory naming (`EVM()`, `EthereumProvider()`).
1412
1409
  *