@lifi/perps-sdk 0.0.0-preview-fd95606 → 0.0.0-preview-6c460bc

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 CHANGED
@@ -7,11 +7,11 @@
7
7
 
8
8
  </div>
9
9
 
10
- # `@lifi/perps-sdk`
10
+ <h1 align="center"><code>@lifi/perps-sdk</code></h1>
11
11
 
12
12
  Core of the [LI.FI Perps SDK](https://public-perps-docs.mintlify.app/) — a TypeScript SDK for trading perpetuals across multiple DEXes through one unified interface.
13
13
 
14
- - **Unified API** across perpetual DEXes (Hyperliquid, Lighter).
14
+ - **Unified API** across perpetual DEXes (Hyperliquid, Lighter, Ondo).
15
15
  - **Provider plugins** — each DEX ships as a separate package you register on the client.
16
16
  - **Agent-based signing** — trades execute without per-order wallet popups (one-time wallet signature during setup).
17
17
  - **Two layers** — low-level service functions and the high-level `PerpsClient`.
@@ -31,15 +31,55 @@ pnpm add @lifi/perps-sdk @lifi/perps-sdk-provider-hyperliquid
31
31
  | `@lifi/perps-sdk` | every project |
32
32
  | [`@lifi/perps-sdk-provider-hyperliquid`](https://www.npmjs.com/package/@lifi/perps-sdk-provider-hyperliquid) | Hyperliquid |
33
33
  | [`@lifi/perps-sdk-provider-lighter`](https://www.npmjs.com/package/@lifi/perps-sdk-provider-lighter) | Lighter |
34
+ | [`@lifi/perps-sdk-provider-ondo`](https://www.npmjs.com/package/@lifi/perps-sdk-provider-ondo) | Ondo |
34
35
 
35
36
  Get an API key from the [LI.FI Partner Portal](https://portal.li.fi/).
36
37
 
38
+ ## Quick start
39
+
40
+ Create a client, register the providers you installed, and call the service functions:
41
+
42
+ ```ts
43
+ import { createPerpsClient, getMarkets } from '@lifi/perps-sdk'
44
+ import { hyperliquidProvider } from '@lifi/perps-sdk-provider-hyperliquid'
45
+
46
+ const client = createPerpsClient({
47
+ integrator: 'my-app',
48
+ apiKey: 'your-api-key',
49
+ providers: [hyperliquidProvider()],
50
+ })
51
+
52
+ const { markets } = await getMarkets(client, { provider: 'hyperliquid' })
53
+ ```
54
+
55
+ ## WebSocket
56
+
57
+ `PerpsWsClient` streams prices, orderbook, and account events over WebSocket. Register a WS provider per DEX; `subscribe()` returns an unsubscribe function, and multiple listeners on the same channel share one wire subscription:
58
+
59
+ ```ts
60
+ import { PerpsWsClient } from '@lifi/perps-sdk'
61
+ import { hyperliquidWsProvider } from '@lifi/perps-sdk-provider-hyperliquid'
62
+
63
+ const ws = new PerpsWsClient(client, {
64
+ wsProviders: { hyperliquid: hyperliquidWsProvider() },
65
+ })
66
+
67
+ const unsubscribe = await ws.subscribe(
68
+ { channel: 'orderbook', dex: 'hyperliquid', marketId: markets[0].id },
69
+ (event) => console.log(event.data)
70
+ )
71
+ ```
72
+
37
73
  ## Architecture
38
74
 
39
75
  ### Package layering
40
76
 
41
77
  `@lifi/perps-types` is a zero-dependency wire-type package at the base. The core `@lifi/perps-sdk` depends on it. Each provider plugin depends on `@lifi/perps-types` directly and takes the core SDK as a peer dependency — so your project installs exactly one copy of the SDK.
42
78
 
79
+ ### Credential storage
80
+
81
+ Every provider persists its trading credentials (agent keys, API keys, session tokens) through a pluggable `StorageAdapter`. The default `localStorageAdapter` encrypts values with AES-GCM before writing to browser `localStorage`, holding the master key as a non-extractable `CryptoKey` handle in IndexedDB — key material is never stored as plaintext. Environments without WebCrypto or IndexedDB degrade to non-persistent sessions rather than plaintext writes. Pass a custom adapter to a provider's store to use another backend.
82
+
43
83
  ## Examples
44
84
 
45
85
  Runnable scripts live in the [`examples/`](https://github.com/lifinance/perps-sdk/tree/main/examples) directory of the repository — market data, account data, agent trading, error handling, custom storage, and WebSocket subscriptions.
@@ -1,3 +1,3 @@
1
1
  export declare const name = "@lifi/perps-sdk";
2
- export declare const version = "0.0.0-preview-fd95606";
2
+ export declare const version = "0.0.0-preview-6c460bc";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/perps-sdk';
5
- exports.version = '0.0.0-preview-fd95606';
5
+ exports.version = '0.0.0-preview-6c460bc';
6
6
  //# sourceMappingURL=version.js.map
@@ -1,3 +1,3 @@
1
1
  export declare const name = "@lifi/perps-sdk";
2
- export declare const version = "0.0.0-preview-fd95606";
2
+ export declare const version = "0.0.0-preview-6c460bc";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  export const name = '@lifi/perps-sdk';
2
- export const version = '0.0.0-preview-fd95606';
2
+ export const version = '0.0.0-preview-6c460bc';
3
3
  //# sourceMappingURL=version.js.map
@@ -1,3 +1,3 @@
1
1
  export declare const name = "@lifi/perps-sdk";
2
- export declare const version = "0.0.0-preview-fd95606";
2
+ export declare const version = "0.0.0-preview-6c460bc";
3
3
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/perps-sdk",
3
- "version": "0.0.0-preview-fd95606",
3
+ "version": "0.0.0-preview-6c460bc",
4
4
  "description": "LI.FI Perps SDK for perpetuals trading",
5
5
  "homepage": "https://github.com/lifinance/perps-sdk",
6
6
  "bugs": {
@@ -44,7 +44,7 @@
44
44
  "@lifi/types": "17.82.1",
45
45
  "partysocket": "^1.1.19",
46
46
  "viem": "^2.48.8",
47
- "@lifi/perps-types": "^2.0.0"
47
+ "@lifi/perps-types": "^0.0.0-preview-6c460bc"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/perps-sdk'
2
- export const version = '0.0.0-preview-fd95606'
2
+ export const version = '0.0.0-preview-6c460bc'