@lifi/perps-sdk-provider-lighter 4.0.0 → 5.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.
- package/README.md +16 -3
- package/dist/cjs/LighterProvider.d.ts +3 -0
- package/dist/cjs/LighterProvider.d.ts.map +1 -1
- package/dist/cjs/LighterProvider.js +35 -29
- package/dist/cjs/LighterProvider.js.map +1 -1
- package/dist/cjs/constants.d.ts +19 -1
- package/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/constants.js +21 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +9 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/signers/LighterReadOnlyTokenManager.d.ts +3 -1
- package/dist/cjs/signers/LighterReadOnlyTokenManager.d.ts.map +1 -1
- package/dist/cjs/signers/LighterReadOnlyTokenManager.js +4 -3
- package/dist/cjs/signers/LighterReadOnlyTokenManager.js.map +1 -1
- package/dist/cjs/signers/LighterSigner.d.ts +4 -0
- package/dist/cjs/signers/LighterSigner.d.ts.map +1 -1
- package/dist/cjs/signers/LighterSigner.js +26 -3
- package/dist/cjs/signers/LighterSigner.js.map +1 -1
- package/dist/cjs/signers/signActions.d.ts.map +1 -1
- package/dist/cjs/signers/signActions.js +30 -0
- package/dist/cjs/signers/signActions.js.map +1 -1
- package/dist/cjs/signers/wasmLoader.d.ts +3 -1
- package/dist/cjs/signers/wasmLoader.d.ts.map +1 -1
- package/dist/cjs/signers/wasmLoader.js.map +1 -1
- package/dist/cjs/websocket/LighterWsProvider.d.ts.map +1 -1
- package/dist/cjs/websocket/LighterWsProvider.js +5 -5
- package/dist/cjs/websocket/LighterWsProvider.js.map +1 -1
- package/dist/esm/LighterProvider.d.ts +15 -0
- package/dist/esm/LighterProvider.d.ts.map +1 -1
- package/dist/esm/LighterProvider.js +37 -31
- package/dist/esm/LighterProvider.js.map +1 -1
- package/dist/esm/constants.d.ts +81 -1
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +50 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/signers/LighterReadOnlyTokenManager.d.ts +9 -1
- package/dist/esm/signers/LighterReadOnlyTokenManager.d.ts.map +1 -1
- package/dist/esm/signers/LighterReadOnlyTokenManager.js +5 -4
- package/dist/esm/signers/LighterReadOnlyTokenManager.js.map +1 -1
- package/dist/esm/signers/LighterSigner.d.ts +21 -6
- package/dist/esm/signers/LighterSigner.d.ts.map +1 -1
- package/dist/esm/signers/LighterSigner.js +42 -10
- package/dist/esm/signers/LighterSigner.js.map +1 -1
- package/dist/esm/signers/signActions.d.ts.map +1 -1
- package/dist/esm/signers/signActions.js +42 -0
- package/dist/esm/signers/signActions.js.map +1 -1
- package/dist/esm/signers/wasmLoader.d.ts +6 -2
- package/dist/esm/signers/wasmLoader.d.ts.map +1 -1
- package/dist/esm/signers/wasmLoader.js.map +1 -1
- package/dist/esm/websocket/LighterWsProvider.d.ts.map +1 -1
- package/dist/esm/websocket/LighterWsProvider.js +5 -5
- package/dist/esm/websocket/LighterWsProvider.js.map +1 -1
- package/dist/types/LighterProvider.d.ts +15 -0
- package/dist/types/LighterProvider.d.ts.map +1 -1
- package/dist/types/constants.d.ts +81 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/signers/LighterReadOnlyTokenManager.d.ts +9 -1
- package/dist/types/signers/LighterReadOnlyTokenManager.d.ts.map +1 -1
- package/dist/types/signers/LighterSigner.d.ts +21 -6
- package/dist/types/signers/LighterSigner.d.ts.map +1 -1
- package/dist/types/signers/signActions.d.ts.map +1 -1
- package/dist/types/signers/wasmLoader.d.ts +6 -2
- package/dist/types/signers/wasmLoader.d.ts.map +1 -1
- package/dist/types/websocket/LighterWsProvider.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/LighterProvider.ts +53 -40
- package/src/constants.ts +104 -1
- package/src/index.ts +12 -0
- package/src/signers/LighterReadOnlyTokenManager.ts +13 -5
- package/src/signers/LighterSigner.ts +67 -12
- package/src/signers/signActions.ts +57 -0
- package/src/signers/wasmLoader.ts +6 -2
- package/src/websocket/LighterWsProvider.ts +5 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PerpsProviderPlugin } from '@lifi/perps-sdk';
|
|
2
|
+
import type { LighterProviderKey } from '@lifi/perps-types';
|
|
2
3
|
import type { Address } from 'viem';
|
|
3
4
|
import type { LighterKeyStore } from './signers/LighterKeyStore.js';
|
|
4
5
|
import type { LighterReadOnlyTokenManagerOptions } from './signers/LighterReadOnlyTokenManager.js';
|
|
@@ -28,8 +29,22 @@ import type { LighterSigner } from './signers/LighterSigner.js';
|
|
|
28
29
|
* @public
|
|
29
30
|
*/
|
|
30
31
|
export interface LighterProviderOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Provider key: the plugin `type`, the `Provider.key` matched against the
|
|
34
|
+
* backend `/providers` response, and the namespace for this instance's market
|
|
35
|
+
* / asset registries and retry policy. Defaults to `'lighter'` (mainnet).
|
|
36
|
+
* Set a distinct key (e.g. `'lighter-rh'`) to register a second Lighter
|
|
37
|
+
* instance on the same client.
|
|
38
|
+
*/
|
|
39
|
+
providerKey?: LighterProviderKey;
|
|
31
40
|
/** Lighter REST base URL. Defaults to mainnet. */
|
|
32
41
|
restUrl?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Explorer tx base URL for transfer-activity links (`${base}${txHash}`).
|
|
44
|
+
* Defaults to the mainnet Lighter explorer for the default provider key, and
|
|
45
|
+
* to `undefined` (no transfer links) for any other key unless supplied.
|
|
46
|
+
*/
|
|
47
|
+
explorerTxBaseUrl?: string;
|
|
33
48
|
/** Pre-created Lighter read-only bearer. */
|
|
34
49
|
authToken?: string | (() => string | Promise<string>);
|
|
35
50
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LighterProvider.d.ts","sourceRoot":"","sources":["../../src/LighterProvider.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"LighterProvider.d.ts","sourceRoot":"","sources":["../../src/LighterProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,mBAAmB,EAczB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAWV,kBAAkB,EASnB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAgBnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,0CAA0C,CAAA;AAElG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AA6F/D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACrD;;;;OAIG;IACH,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,kCAAkC,CAAA;IACzD,4FAA4F;IAC5F,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,4FAA4F;IAC5F,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAQD;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D;;;;;OAKG;IACH,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAChE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAS,sBAA2B,KACnC,oBAsgCF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,aA9gCT,sBAAsB,KAC9B,oBA6gCmC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FeeTier } from '@lifi/perps-types';
|
|
1
|
+
import type { FeeTier, LighterProviderKey } from '@lifi/perps-types';
|
|
2
2
|
/**
|
|
3
3
|
* Lighter provider key as it appears on `Provider.key` from the backend.
|
|
4
4
|
*
|
|
@@ -20,6 +20,86 @@ export declare const LIGHTER_SPOT_CATEGORY_ID = "spot";
|
|
|
20
20
|
*/
|
|
21
21
|
export declare const DEFAULT_LIGHTER_REST_URL = "https://mainnet.zklighter.elliot.ai";
|
|
22
22
|
export declare const DEFAULT_LIGHTER_WS_URL = "wss://mainnet.zklighter.elliot.ai/stream";
|
|
23
|
+
/**
|
|
24
|
+
* zkLighter L2 signing chain id fed to {@link LighterSigner} on mainnet.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare const DEFAULT_LIGHTER_SIGNER_CHAIN_ID = 304;
|
|
29
|
+
/**
|
|
30
|
+
* Base URL the mainnet Lighter zkLighter explorer resolves a tx hash against
|
|
31
|
+
* (`${base}${txHash}`).
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEFAULT_LIGHTER_EXPLORER_TX_BASE_URL = "https://app.lighter.xyz/explorer/logs/";
|
|
36
|
+
/**
|
|
37
|
+
* The venue-specific facts that distinguish one Lighter deployment from
|
|
38
|
+
* another. One provider + WS pair is built per instance from these; a client
|
|
39
|
+
* may register several so long as their `providerKey`s differ.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export interface LighterInstanceConfig {
|
|
44
|
+
/** Wire-visible `Provider.key` and the plugin `type`; unique per instance. */
|
|
45
|
+
providerKey: LighterProviderKey;
|
|
46
|
+
restUrl: string;
|
|
47
|
+
wsUrl: string;
|
|
48
|
+
/**
|
|
49
|
+
* zkLighter L2 signing chain id to construct this instance's
|
|
50
|
+
* {@link LighterSigner} with.
|
|
51
|
+
*/
|
|
52
|
+
signerChainId: number;
|
|
53
|
+
/**
|
|
54
|
+
* Explorer tx base URL for transfer-activity links (`${base}${txHash}`).
|
|
55
|
+
* When omitted, transfer links are not emitted for this instance.
|
|
56
|
+
*/
|
|
57
|
+
explorerTxBaseUrl?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The built-in mainnet Lighter instance — the defaults `lighterProvider()` and
|
|
61
|
+
* `lighterWsProvider()` apply when constructed with no instance overrides.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare const LIGHTER_MAINNET_INSTANCE: LighterInstanceConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Provider key for the Lighter instance running on Robinhood chain.
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export declare const LIGHTER_RH_PROVIDER_KEY = "lighter-rh";
|
|
72
|
+
/** @public */
|
|
73
|
+
export declare const LIGHTER_RH_REST_URL = "https://api.rh.lighter.xyz";
|
|
74
|
+
/** @public */
|
|
75
|
+
export declare const LIGHTER_RH_WS_URL = "wss://api.rh.lighter.xyz/stream";
|
|
76
|
+
/**
|
|
77
|
+
* Deployment-supplied facts the RH instance cannot source from public
|
|
78
|
+
* documentation and the caller must confirm.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export interface LighterRhInstanceOverrides {
|
|
83
|
+
/**
|
|
84
|
+
* zkLighter L2 signing chain id for the RH instance. Unverified from public
|
|
85
|
+
* sources — must be the value confirmed against lighter-go / RH support, not
|
|
86
|
+
* mainnet's 304 nor the RH L1 chain id 4663.
|
|
87
|
+
*/
|
|
88
|
+
signerChainId: number;
|
|
89
|
+
/**
|
|
90
|
+
* RH zkLighter explorer tx base URL. Omit until confirmed; transfer links are
|
|
91
|
+
* then left unset rather than pointed at the mainnet explorer.
|
|
92
|
+
*/
|
|
93
|
+
explorerTxBaseUrl?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Build the `lighter-rh` {@link LighterInstanceConfig}. The signing chain id is
|
|
97
|
+
* a required argument because it is not verifiable from public sources — the
|
|
98
|
+
* caller must pass the value confirmed against lighter-go / RH support.
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
export declare const lighterRhInstance: (overrides: LighterRhInstanceOverrides) => LighterInstanceConfig;
|
|
23
103
|
/** @internal */
|
|
24
104
|
export declare const DEFAULT_TRADES_LIMIT = 50;
|
|
25
105
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEpE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,YAAY,CAAA;AAE7C;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,SAAS,CAAA;AAE9C;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,wCAAwC,CAAA;AAC7E,eAAO,MAAM,sBAAsB,6CAA6C,C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H,QAAA,MAAM,yBAAyB,QAAQ,CAAA;AAEvC;;;;;;GAMG;AACH,QAAA,MAAM,qBAAqB,aAAoB,CAAA;AAE/C;;;;;;GAMG;AACH,QAAA,MAAM,6BAA6B,MAAM,CAAA;AAEzC,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EACzB,6BAA6B,EAC7B,qBAAqB,GACtB,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export { projectLighterConfigSettings } from './accountConfig.js';
|
|
13
13
|
export { getAccountSummary } from './accountSummary.js';
|
|
14
|
-
export {
|
|
14
|
+
export type { 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_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';
|
|
15
16
|
export type { LighterPerpsProvider, LighterProviderOptions, } from './LighterProvider.js';
|
|
16
17
|
export { Lighter, lighterProvider } from './LighterProvider.js';
|
|
17
18
|
export * from './signers/index.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,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,
|
|
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,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,qBAAqB,EACrB,oCAAoC,EACpC,wBAAwB,EACxB,+BAA+B,EAC/B,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AACvB,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,5 +1,5 @@
|
|
|
1
1
|
import { type StorageAdapter } from '@lifi/perps-sdk';
|
|
2
|
-
import type { ApproveReadOnlyTokenParams, LighterAccountConfig } from '@lifi/perps-types';
|
|
2
|
+
import type { ApproveReadOnlyTokenParams, LighterAccountConfig, LighterProviderKey } from '@lifi/perps-types';
|
|
3
3
|
import type { Address } from 'viem';
|
|
4
4
|
/**
|
|
5
5
|
* Default token name persisted alongside Lighter's `tokens/create` row.
|
|
@@ -56,6 +56,13 @@ export type LighterTokenFetcher = (params: {
|
|
|
56
56
|
/** @public */
|
|
57
57
|
export interface LighterReadOnlyTokenManagerOptions {
|
|
58
58
|
storage?: StorageAdapter;
|
|
59
|
+
/**
|
|
60
|
+
* Provider instance key. Namespaces persisted tokens so two Lighter
|
|
61
|
+
* instances sharing a storage backend never serve each other's token for a
|
|
62
|
+
* coincident `(address, accountIndex)` pair, and stamps the `provider` of
|
|
63
|
+
* the {@link ApproveReadOnlyTokenResult} config. Defaults to `'lighter'`.
|
|
64
|
+
*/
|
|
65
|
+
providerKey?: LighterProviderKey;
|
|
59
66
|
/** Lighter API host. Defaults to {@link DEFAULT_LIGHTER_REST_URL}. */
|
|
60
67
|
lighterApiUrl?: string;
|
|
61
68
|
/** Override the multipart POST. Defaults to a `fetch`-based implementation. */
|
|
@@ -95,6 +102,7 @@ export interface ApproveReadOnlyTokenResult {
|
|
|
95
102
|
*/
|
|
96
103
|
export declare class LighterReadOnlyTokenManager {
|
|
97
104
|
private readonly storage;
|
|
105
|
+
private readonly providerKey;
|
|
98
106
|
private readonly lighterApiUrl;
|
|
99
107
|
private readonly fetcher;
|
|
100
108
|
private readonly now;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LighterReadOnlyTokenManager.d.ts","sourceRoot":"","sources":["../../../src/signers/LighterReadOnlyTokenManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,
|
|
1
|
+
{"version":3,"file":"LighterReadOnlyTokenManager.d.ts","sourceRoot":"","sources":["../../../src/signers/LighterReadOnlyTokenManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGnC;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,gBAAgB,CAAA;AAEzD;;;;;;GAMG;AACH,MAAM,WAAW,oB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|
}
|
|
30
30
|
/** @public */
|
|
31
|
+
export interface ApproveIntegratorResult extends LighterSignedBlob {
|
|
32
|
+
/** EIP-191 `L2ApproveIntegrator` L1 body the user's wallet must countersign to authorize the integrator approval. */
|
|
33
|
+
messageToSign: string;
|
|
34
|
+
}
|
|
35
|
+
/** @public */
|
|
31
36
|
export interface ApiKeyPair {
|
|
32
37
|
publicKey: string;
|
|
33
38
|
privateKey: string;
|
|
@@ -52,8 +57,9 @@ export declare class LighterSigner {
|
|
|
52
57
|
* `WasmBlobActionStep`. Returns the signed `{ txType, txInfo, txHash }`
|
|
53
58
|
* triple the backend forwards to Lighter's `sendTx` endpoint.
|
|
54
59
|
*
|
|
55
|
-
* For REGISTER_API_KEY use `signChangePubKey`
|
|
56
|
-
*
|
|
60
|
+
* For REGISTER_API_KEY use `signChangePubKey` and for APPROVE_INTEGRATOR
|
|
61
|
+
* use `signApproveIntegrator` instead — both return an additional
|
|
62
|
+
* `messageToSign` the L1 wallet must countersign.
|
|
57
63
|
*/
|
|
58
64
|
sign(action: ActionType, wasmSignParams: Record<string, unknown>, context: LighterSignerContext): Promise<LighterSignedBlob>;
|
|
59
65
|
/**
|
|
@@ -70,10 +76,19 @@ export declare class LighterSigner {
|
|
|
70
76
|
*/
|
|
71
77
|
signChangePubKey(pubKeyHex: string, privateKey: string, nonce: number, apiKeyIndex: number, accountIndex: number, skipNonce?: 0 | 1): Promise<ChangePubKeyResult>;
|
|
72
78
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
79
|
+
* Sign an APPROVE_INTEGRATOR action with the stored API key and return the
|
|
80
|
+
* signed blob alongside the EIP-191 `L2ApproveIntegrator` L1 message the
|
|
81
|
+
* user's Ethereum wallet must countersign. Unlike {@link sign}, this exposes
|
|
82
|
+
* `messageToSign`: Lighter requires `L1Sig` (injected via
|
|
83
|
+
* {@link embedL1Signature} before submission) when the integrator account
|
|
84
|
+
* belongs to a different L1 address with non-zero fee caps.
|
|
85
|
+
*/
|
|
86
|
+
signApproveIntegrator(wasmSignParams: Record<string, unknown>, context: LighterSignerContext): Promise<ApproveIntegratorResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Inject the L1 signature produced by the user's Ethereum wallet into a
|
|
89
|
+
* signed txInfo JSON. `L1Sig` is the only field that depends on the L1
|
|
90
|
+
* signature; txHash does NOT include it (so we do not recompute it). Shared
|
|
91
|
+
* by the REGISTER_API_KEY (ChangePubKey) and APPROVE_INTEGRATOR flows.
|
|
77
92
|
*/
|
|
78
93
|
embedL1Signature(txInfo: string, l1Signature: string): string;
|
|
79
94
|
/**
|
|
@@ -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;
|
|
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,cAAc;AACd,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,cAAc;AACd,MAAM,WAAW,mBAAoB,SAAQ,sBAAsB;IACjE,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,cAAc;AACd,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,c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AAC,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"}
|
|
@@ -105,9 +105,13 @@ export interface LighterWasmExports {
|
|
|
105
105
|
* 10 args: integratorAccountIndex, maxPerpsTakerFee, maxPerpsMakerFee,
|
|
106
106
|
* maxSpotTakerFee, maxSpotMakerFee, approvalExpiry, skipNonce, then the
|
|
107
107
|
* trailing three. Fees are uint32 ppm of `FeeTick` (1_000_000); a non-nil
|
|
108
|
-
* fee requires a non-nil integrator index.
|
|
108
|
+
* fee requires a non-nil integrator index. `messageToSign` is the EIP-191
|
|
109
|
+
* `L2ApproveIntegrator` L1 body the user's wallet must countersign — the
|
|
110
|
+
* venue rejects the tx without the resulting `L1Sig`.
|
|
109
111
|
*/
|
|
110
|
-
SignApproveIntegrator: (...args: unknown[]) => SignResult
|
|
112
|
+
SignApproveIntegrator: (...args: unknown[]) => SignResult & {
|
|
113
|
+
messageToSign?: string;
|
|
114
|
+
};
|
|
111
115
|
/**
|
|
112
116
|
* 5 args: accountTradingMode (0 = Classic/Simple, 1 = Unified), skipNonce,
|
|
113
117
|
* then the trailing three. `accountTradingMode` is validated to {0, 1} by
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasmLoader.d.ts","sourceRoot":"","sources":["../../../src/signers/wasmLoader.ts"],"names":[],"mappings":"AAkDA,cAAc;AACd,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,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K,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM;YA2B5B,cAAc;YAsFd,mBAAmB;YAqBnB,iBAAiB;IAK/B,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAqB1C,OAAO,CAAC,QAAQ;IAkFhB,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,eAAe;IA2BvB,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,sBAAsB;IAiC9B;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;IAuB1B,OAAO,CAAC,iBAAiB;IAuCzB,OAAO,CAAC,eAAe;IA+BvB,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,mBAAmB;CAc5B;AAkID;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,GAC3B,UAAU,wBAAwB,KAAG,iBAEmB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/perps-sdk-provider-lighter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Lighter provider plugin for @lifi/perps-sdk",
|
|
5
5
|
"homepage": "https://github.com/lifinance/perps-sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"big.js": "^7.0.1",
|
|
48
48
|
"viem": "^2.48.8",
|
|
49
|
-
"@lifi/perps-types": "^
|
|
49
|
+
"@lifi/perps-types": "^3.0.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@lifi/perps-sdk": "^
|
|
52
|
+
"@lifi/perps-sdk": "^4.0.0"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
package/src/LighterProvider.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
explorerTxUrl,
|
|
2
|
+
explorerTxUrlFromBase,
|
|
4
3
|
getAssetRegistry,
|
|
5
4
|
getMarketRegistry,
|
|
6
5
|
getProviders,
|
|
@@ -31,6 +30,7 @@ import type {
|
|
|
31
30
|
Balance,
|
|
32
31
|
FillsResponse,
|
|
33
32
|
LighterAccountConfig,
|
|
33
|
+
LighterProviderKey,
|
|
34
34
|
Order,
|
|
35
35
|
OrdersResponse,
|
|
36
36
|
Position,
|
|
@@ -46,6 +46,7 @@ import { projectLighterConfigSettings } from './accountConfig.js'
|
|
|
46
46
|
import { getAccountSummary } from './accountSummary.js'
|
|
47
47
|
import {
|
|
48
48
|
DEFAULT_API_KEY_INDEX,
|
|
49
|
+
DEFAULT_LIGHTER_EXPLORER_TX_BASE_URL,
|
|
49
50
|
DEFAULT_LIGHTER_REST_URL,
|
|
50
51
|
DEFAULT_TRADES_LIMIT,
|
|
51
52
|
LIGHTER_ALL_MARKETS_WILDCARD,
|
|
@@ -177,8 +178,22 @@ const normalizeLighterPublicKey = (key: string): string =>
|
|
|
177
178
|
* @public
|
|
178
179
|
*/
|
|
179
180
|
export interface LighterProviderOptions {
|
|
181
|
+
/**
|
|
182
|
+
* Provider key: the plugin `type`, the `Provider.key` matched against the
|
|
183
|
+
* backend `/providers` response, and the namespace for this instance's market
|
|
184
|
+
* / asset registries and retry policy. Defaults to `'lighter'` (mainnet).
|
|
185
|
+
* Set a distinct key (e.g. `'lighter-rh'`) to register a second Lighter
|
|
186
|
+
* instance on the same client.
|
|
187
|
+
*/
|
|
188
|
+
providerKey?: LighterProviderKey
|
|
180
189
|
/** Lighter REST base URL. Defaults to mainnet. */
|
|
181
190
|
restUrl?: string
|
|
191
|
+
/**
|
|
192
|
+
* Explorer tx base URL for transfer-activity links (`${base}${txHash}`).
|
|
193
|
+
* Defaults to the mainnet Lighter explorer for the default provider key, and
|
|
194
|
+
* to `undefined` (no transfer links) for any other key unless supplied.
|
|
195
|
+
*/
|
|
196
|
+
explorerTxBaseUrl?: string
|
|
182
197
|
/** Pre-created Lighter read-only bearer. */
|
|
183
198
|
authToken?: string | (() => string | Promise<string>)
|
|
184
199
|
/**
|
|
@@ -277,7 +292,13 @@ export const lighterProvider = (
|
|
|
277
292
|
return boundClient
|
|
278
293
|
}
|
|
279
294
|
|
|
295
|
+
const providerKey = options.providerKey ?? LIGHTER_PROVIDER_KEY
|
|
280
296
|
const restUrl = options.restUrl ?? DEFAULT_LIGHTER_REST_URL
|
|
297
|
+
const explorerTxBaseUrl =
|
|
298
|
+
options.explorerTxBaseUrl ??
|
|
299
|
+
(providerKey === LIGHTER_PROVIDER_KEY
|
|
300
|
+
? DEFAULT_LIGHTER_EXPLORER_TX_BASE_URL
|
|
301
|
+
: undefined)
|
|
281
302
|
const authTokenSource: (() => string | Promise<string>) | undefined =
|
|
282
303
|
typeof options.authToken === 'function'
|
|
283
304
|
? options.authToken
|
|
@@ -287,6 +308,7 @@ export const lighterProvider = (
|
|
|
287
308
|
const signer = options.signer
|
|
288
309
|
const keyStore = options.keyStore
|
|
289
310
|
const readOnlyTokenManager = new LighterReadOnlyTokenManager({
|
|
311
|
+
providerKey,
|
|
290
312
|
lighterApiUrl: restUrl,
|
|
291
313
|
...options.readOnlyTokenOptions,
|
|
292
314
|
})
|
|
@@ -309,7 +331,7 @@ export const lighterProvider = (
|
|
|
309
331
|
policy: resolveRetryPolicy(
|
|
310
332
|
LIGHTER_RETRY_DEFAULTS,
|
|
311
333
|
client.config.retry,
|
|
312
|
-
|
|
334
|
+
providerKey
|
|
313
335
|
),
|
|
314
336
|
fetchImpl: client.config.fetch,
|
|
315
337
|
})
|
|
@@ -644,7 +666,7 @@ export const lighterProvider = (
|
|
|
644
666
|
}
|
|
645
667
|
|
|
646
668
|
return {
|
|
647
|
-
type:
|
|
669
|
+
type: providerKey,
|
|
648
670
|
|
|
649
671
|
bind(client: PerpsSDKClient): void {
|
|
650
672
|
boundClient = client
|
|
@@ -664,11 +686,8 @@ export const lighterProvider = (
|
|
|
664
686
|
resolveAuthToken(opts, params.address),
|
|
665
687
|
])
|
|
666
688
|
|
|
667
|
-
const registry = getMarketRegistry(requireClient(),
|
|
668
|
-
const assetRegistry = getAssetRegistry(
|
|
669
|
-
requireClient(),
|
|
670
|
-
LIGHTER_PROVIDER_KEY
|
|
671
|
-
)
|
|
689
|
+
const registry = getMarketRegistry(requireClient(), providerKey)
|
|
690
|
+
const assetRegistry = getAssetRegistry(requireClient(), providerKey)
|
|
672
691
|
const [
|
|
673
692
|
{ providers },
|
|
674
693
|
,
|
|
@@ -725,7 +744,7 @@ export const lighterProvider = (
|
|
|
725
744
|
)
|
|
726
745
|
|
|
727
746
|
const categories =
|
|
728
|
-
providers.find((p) => p.key ===
|
|
747
|
+
providers.find((p) => p.key === providerKey)?.categories ?? []
|
|
729
748
|
const perpsCategory = categories.find((c) => c.quoteAsset !== null)
|
|
730
749
|
const spotCategoryId =
|
|
731
750
|
categories.find((c) => c.quoteAsset === null)?.id ??
|
|
@@ -737,7 +756,7 @@ export const lighterProvider = (
|
|
|
737
756
|
// carried by the positions' `marginUsed`.
|
|
738
757
|
const collateralBalances: Balance[] = [
|
|
739
758
|
{
|
|
740
|
-
categoryId: perpsCategory?.id ??
|
|
759
|
+
categoryId: perpsCategory?.id ?? providerKey,
|
|
741
760
|
asset: perpsCategory?.quoteAsset ?? lighterAsset('USDC', 'USDC'),
|
|
742
761
|
units: account.available_balance,
|
|
743
762
|
valueUsd: account.available_balance,
|
|
@@ -767,7 +786,7 @@ export const lighterProvider = (
|
|
|
767
786
|
)
|
|
768
787
|
|
|
769
788
|
const config: LighterAccountConfig = {
|
|
770
|
-
provider:
|
|
789
|
+
provider: providerKey,
|
|
771
790
|
accountIndex: account.index,
|
|
772
791
|
apiKeyIndex: DEFAULT_API_KEY_INDEX,
|
|
773
792
|
apiKeyRegistered,
|
|
@@ -785,7 +804,7 @@ export const lighterProvider = (
|
|
|
785
804
|
}
|
|
786
805
|
|
|
787
806
|
return {
|
|
788
|
-
provider:
|
|
807
|
+
provider: providerKey,
|
|
789
808
|
address: params.address,
|
|
790
809
|
balances,
|
|
791
810
|
collateralBalances,
|
|
@@ -823,7 +842,7 @@ export const lighterProvider = (
|
|
|
823
842
|
opts?: SDKRequestOptions
|
|
824
843
|
): Promise<PositionsResponse> {
|
|
825
844
|
const client = apiClient(opts)
|
|
826
|
-
const registry = getMarketRegistry(requireClient(),
|
|
845
|
+
const registry = getMarketRegistry(requireClient(), providerKey)
|
|
827
846
|
const [account] = await Promise.all([
|
|
828
847
|
fetchDetailedAccount(client, params.address),
|
|
829
848
|
registry.sync(),
|
|
@@ -838,7 +857,7 @@ export const lighterProvider = (
|
|
|
838
857
|
}
|
|
839
858
|
|
|
840
859
|
return {
|
|
841
|
-
provider:
|
|
860
|
+
provider: providerKey,
|
|
842
861
|
positions,
|
|
843
862
|
pagination: { limit: params.limit ?? positions.length, hasMore: false },
|
|
844
863
|
}
|
|
@@ -857,7 +876,7 @@ export const lighterProvider = (
|
|
|
857
876
|
const token = await resolveAuthToken(opts, params.address)
|
|
858
877
|
if (token === undefined) {
|
|
859
878
|
return {
|
|
860
|
-
provider:
|
|
879
|
+
provider: providerKey,
|
|
861
880
|
openOrders: [],
|
|
862
881
|
triggerOrders: [],
|
|
863
882
|
pagination: { limit: params.limit ?? 0, hasMore: false },
|
|
@@ -865,7 +884,7 @@ export const lighterProvider = (
|
|
|
865
884
|
}
|
|
866
885
|
|
|
867
886
|
const client = apiClient(opts)
|
|
868
|
-
const registry = getMarketRegistry(requireClient(),
|
|
887
|
+
const registry = getMarketRegistry(requireClient(), providerKey)
|
|
869
888
|
const [account] = await Promise.all([
|
|
870
889
|
fetchDetailedAccount(client, params.address),
|
|
871
890
|
registry.sync(),
|
|
@@ -891,7 +910,7 @@ export const lighterProvider = (
|
|
|
891
910
|
|
|
892
911
|
const total = openOrders.length + triggerOrders.length
|
|
893
912
|
return {
|
|
894
|
-
provider:
|
|
913
|
+
provider: providerKey,
|
|
895
914
|
openOrders,
|
|
896
915
|
triggerOrders,
|
|
897
916
|
pagination: { limit: total, hasMore: false },
|
|
@@ -913,7 +932,7 @@ export const lighterProvider = (
|
|
|
913
932
|
}
|
|
914
933
|
|
|
915
934
|
const client = apiClient(opts)
|
|
916
|
-
const registry = getMarketRegistry(requireClient(),
|
|
935
|
+
const registry = getMarketRegistry(requireClient(), providerKey)
|
|
917
936
|
const [account] = await Promise.all([
|
|
918
937
|
fetchDetailedAccount(client, params.address),
|
|
919
938
|
registry.sync(),
|
|
@@ -981,14 +1000,14 @@ export const lighterProvider = (
|
|
|
981
1000
|
const token = await resolveAuthToken(opts, params.address)
|
|
982
1001
|
if (token === undefined) {
|
|
983
1002
|
return {
|
|
984
|
-
provider:
|
|
1003
|
+
provider: providerKey,
|
|
985
1004
|
items: [],
|
|
986
1005
|
pagination: { limit: params.limit ?? 0, hasMore: false },
|
|
987
1006
|
}
|
|
988
1007
|
}
|
|
989
1008
|
|
|
990
1009
|
const client = apiClient(opts)
|
|
991
|
-
const registry = getMarketRegistry(requireClient(),
|
|
1010
|
+
const registry = getMarketRegistry(requireClient(), providerKey)
|
|
992
1011
|
const [account] = await Promise.all([
|
|
993
1012
|
fetchDetailedAccount(client, params.address),
|
|
994
1013
|
registry.sync(),
|
|
@@ -1017,7 +1036,7 @@ export const lighterProvider = (
|
|
|
1017
1036
|
)
|
|
1018
1037
|
|
|
1019
1038
|
return {
|
|
1020
|
-
provider:
|
|
1039
|
+
provider: providerKey,
|
|
1021
1040
|
items,
|
|
1022
1041
|
pagination: {
|
|
1023
1042
|
limit: params.limit ?? items.length,
|
|
@@ -1034,7 +1053,7 @@ export const lighterProvider = (
|
|
|
1034
1053
|
const token = await resolveAuthToken(opts, params.address)
|
|
1035
1054
|
if (token === undefined) {
|
|
1036
1055
|
return {
|
|
1037
|
-
provider:
|
|
1056
|
+
provider: providerKey,
|
|
1038
1057
|
items: [],
|
|
1039
1058
|
pagination: { limit: params.limit ?? 0, hasMore: false },
|
|
1040
1059
|
}
|
|
@@ -1043,14 +1062,8 @@ export const lighterProvider = (
|
|
|
1043
1062
|
const inputCursor = decodeActivityCursor(params.cursor)
|
|
1044
1063
|
const client = apiClient(opts)
|
|
1045
1064
|
const account = await fetchDetailedAccount(client, params.address)
|
|
1046
|
-
const marketRegistry = getMarketRegistry(
|
|
1047
|
-
|
|
1048
|
-
LIGHTER_PROVIDER_KEY
|
|
1049
|
-
)
|
|
1050
|
-
const assetRegistry = getAssetRegistry(
|
|
1051
|
-
requireClient(),
|
|
1052
|
-
LIGHTER_PROVIDER_KEY
|
|
1053
|
-
)
|
|
1065
|
+
const marketRegistry = getMarketRegistry(requireClient(), providerKey)
|
|
1066
|
+
const assetRegistry = getAssetRegistry(requireClient(), providerKey)
|
|
1054
1067
|
const [history] = await Promise.all([
|
|
1055
1068
|
retryOnRevoked(opts, params.address, token, (t) =>
|
|
1056
1069
|
fetchAllHistory(
|
|
@@ -1070,7 +1083,7 @@ export const lighterProvider = (
|
|
|
1070
1083
|
...history.deposits.deposits.map(
|
|
1071
1084
|
(d): ActivityItem => ({
|
|
1072
1085
|
id: d.id,
|
|
1073
|
-
provider:
|
|
1086
|
+
provider: providerKey,
|
|
1074
1087
|
timestamp: toIsoFromMs(d.timestamp),
|
|
1075
1088
|
type: ActivityType.DEPOSIT,
|
|
1076
1089
|
amount: d.amount,
|
|
@@ -1082,7 +1095,7 @@ export const lighterProvider = (
|
|
|
1082
1095
|
...history.withdraws.withdraws.map(
|
|
1083
1096
|
(w): ActivityItem => ({
|
|
1084
1097
|
id: w.id,
|
|
1085
|
-
provider:
|
|
1098
|
+
provider: providerKey,
|
|
1086
1099
|
timestamp: toIsoFromMs(w.timestamp),
|
|
1087
1100
|
type: ActivityType.WITHDRAWAL,
|
|
1088
1101
|
amount: w.amount,
|
|
@@ -1095,7 +1108,7 @@ export const lighterProvider = (
|
|
|
1095
1108
|
...history.fundings.position_fundings.map(
|
|
1096
1109
|
(f): ActivityItem => ({
|
|
1097
1110
|
id: `funding-${f.funding_id}`,
|
|
1098
|
-
provider:
|
|
1111
|
+
provider: providerKey,
|
|
1099
1112
|
timestamp: toIsoFromSeconds(f.timestamp),
|
|
1100
1113
|
type: ActivityType.FUNDING,
|
|
1101
1114
|
market: marketRegistry.require(String(f.market_id)),
|
|
@@ -1107,7 +1120,7 @@ export const lighterProvider = (
|
|
|
1107
1120
|
...history.liquidations.liquidations.map(
|
|
1108
1121
|
(l): ActivityItem => ({
|
|
1109
1122
|
id: `liquidation-${l.id}`,
|
|
1110
|
-
provider:
|
|
1123
|
+
provider: providerKey,
|
|
1111
1124
|
timestamp: toIsoFromMs(l.executed_at),
|
|
1112
1125
|
type: ActivityType.LIQUIDATION,
|
|
1113
1126
|
liquidatedNotionalPosition: '0',
|
|
@@ -1128,7 +1141,7 @@ export const lighterProvider = (
|
|
|
1128
1141
|
direction === 'OUT' ? t.to_account_index : t.from_account_index
|
|
1129
1142
|
return {
|
|
1130
1143
|
id: t.id,
|
|
1131
|
-
provider:
|
|
1144
|
+
provider: providerKey,
|
|
1132
1145
|
timestamp: toIsoFromMs(t.timestamp),
|
|
1133
1146
|
type: ActivityType.TRANSFER,
|
|
1134
1147
|
direction,
|
|
@@ -1137,7 +1150,7 @@ export const lighterProvider = (
|
|
|
1137
1150
|
assetRegistry.get(String(t.asset_id))?.displaySymbol ??
|
|
1138
1151
|
String(t.asset_id),
|
|
1139
1152
|
amount: t.amount,
|
|
1140
|
-
explorerLink:
|
|
1153
|
+
explorerLink: explorerTxUrlFromBase(explorerTxBaseUrl, t.tx_hash),
|
|
1141
1154
|
meta: {
|
|
1142
1155
|
transferType: t.type,
|
|
1143
1156
|
txHash: t.tx_hash,
|
|
@@ -1183,7 +1196,7 @@ export const lighterProvider = (
|
|
|
1183
1196
|
const hasMore = responseCursor !== undefined
|
|
1184
1197
|
|
|
1185
1198
|
return {
|
|
1186
|
-
provider:
|
|
1199
|
+
provider: providerKey,
|
|
1187
1200
|
items: emitted,
|
|
1188
1201
|
pagination: {
|
|
1189
1202
|
limit,
|
|
@@ -1199,7 +1212,7 @@ export const lighterProvider = (
|
|
|
1199
1212
|
): Promise<Quote> {
|
|
1200
1213
|
return resolveQuote(
|
|
1201
1214
|
requireClient(),
|
|
1202
|
-
|
|
1215
|
+
providerKey,
|
|
1203
1216
|
params,
|
|
1204
1217
|
LIGHTER_BASE_FEE_TIER,
|
|
1205
1218
|
opts
|
|
@@ -1224,7 +1237,7 @@ export const lighterProvider = (
|
|
|
1224
1237
|
setup: ProviderAction[],
|
|
1225
1238
|
options: ProviderAction[]
|
|
1226
1239
|
): AccountConfigSetting[] {
|
|
1227
|
-
if (config.provider !==
|
|
1240
|
+
if (config.provider !== providerKey) {
|
|
1228
1241
|
throw new PerpsError(
|
|
1229
1242
|
PerpsErrorCode.SDKError,
|
|
1230
1243
|
`lighterProvider.projectConfig received config for provider ` +
|