@lifi/perps-sdk-provider-lighter 34.0.0 → 35.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/dist/cjs/LighterProvider.d.ts +0 -1
- package/dist/cjs/LighterProvider.d.ts.map +1 -1
- package/dist/cjs/LighterProvider.js +50 -44
- package/dist/cjs/LighterProvider.js.map +1 -1
- package/dist/cjs/accountSummary.d.ts.map +1 -1
- package/dist/cjs/accountSummary.js +3 -6
- package/dist/cjs/accountSummary.js.map +1 -1
- package/dist/cjs/signers/createAuthToken.d.ts.map +1 -1
- package/dist/cjs/signers/createAuthToken.js.map +1 -1
- package/dist/cjs/utils/settlementPool.d.ts +6 -0
- package/dist/cjs/utils/settlementPool.d.ts.map +1 -0
- package/dist/cjs/utils/settlementPool.js +21 -0
- package/dist/cjs/utils/settlementPool.js.map +1 -0
- package/dist/esm/LighterProvider.d.ts +7 -11
- package/dist/esm/LighterProvider.d.ts.map +1 -1
- package/dist/esm/LighterProvider.js +60 -51
- package/dist/esm/LighterProvider.js.map +1 -1
- package/dist/esm/accountSummary.d.ts +2 -1
- package/dist/esm/accountSummary.d.ts.map +1 -1
- package/dist/esm/accountSummary.js +5 -7
- package/dist/esm/accountSummary.js.map +1 -1
- package/dist/esm/signers/createAuthToken.d.ts +1 -2
- package/dist/esm/signers/createAuthToken.d.ts.map +1 -1
- package/dist/esm/signers/createAuthToken.js +1 -2
- package/dist/esm/signers/createAuthToken.js.map +1 -1
- package/dist/esm/utils/settlementPool.d.ts +14 -0
- package/dist/esm/utils/settlementPool.d.ts.map +1 -0
- package/dist/esm/utils/settlementPool.js +23 -0
- package/dist/esm/utils/settlementPool.js.map +1 -0
- package/dist/types/LighterProvider.d.ts +7 -11
- package/dist/types/LighterProvider.d.ts.map +1 -1
- package/dist/types/accountSummary.d.ts +2 -1
- package/dist/types/accountSummary.d.ts.map +1 -1
- package/dist/types/signers/createAuthToken.d.ts +1 -2
- package/dist/types/signers/createAuthToken.d.ts.map +1 -1
- package/dist/types/utils/settlementPool.d.ts +14 -0
- package/dist/types/utils/settlementPool.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/LighterProvider.ts +98 -90
- package/src/accountSummary.ts +10 -10
- package/src/signers/createAuthToken.ts +1 -2
- package/src/utils/settlementPool.ts +36 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountSummary.js","sourceRoot":"","sources":["../../src/accountSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAO5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAAwB,EACF,EAAE;IACxB,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAC1B,IACE,MAAM,CAAC,QAAQ,KAAK,oBAAoB;QACxC,MAAM,CAAC,QAAQ,KAAK,uBAAuB,EAC3C,CAAC;QACD,MAAM,IAAI,UAAU,CAClB,cAAc,CAAC,QAAQ,EACvB,uCAAuC,MAAM,CAAC,QAAQ,kBAAkB,CACzE,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,WAAgB,EAChB,gBAAmC,EAC9B,EAAE,CACP,gBAAgB,CAAC,MAAM,CACrB,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC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interface CreateAuthTokenInputs {
|
|
|
25
25
|
* endpoints (`getOrders`, `getOrder`, `getActivity`, etc.).
|
|
26
26
|
*
|
|
27
27
|
* This utility carries no SDK-wide coupling — pass an explicit `signer` +
|
|
28
|
-
* `apiKey` and consume the returned bearer however the caller likes
|
|
29
|
-
* (per-call `options.lighterAuthToken`, persisted cache, etc.).
|
|
28
|
+
* `apiKey` and consume the returned bearer however the caller likes.
|
|
30
29
|
* @public
|
|
31
30
|
*/
|
|
32
31
|
export declare function createAuthToken(inputs: CreateAuthTokenInputs): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAuthToken.d.ts","sourceRoot":"","sources":["../../../src/signers/createAuthToken.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,aAAa,CAAA;IACrB,MAAM,EAAE,IAAI,CACV,aAAa,EACb,kBAAkB,GAAG,aAAa,GAAG,cAAc,CACpD,CAAA;IACD;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED
|
|
1
|
+
{"version":3,"file":"createAuthToken.d.ts","sourceRoot":"","sources":["../../../src/signers/createAuthToken.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,aAAa,CAAA;IACrB,MAAM,EAAE,IAAI,CACV,aAAa,EACb,kBAAkB,GAAG,aAAa,GAAG,cAAc,CACpD,CAAA;IACD;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,IAAI,EAC9C,gBAAgB,GAAE,MAAkC,EACpD,GAAG,GAAE,MAAM,MAAyB,GACnC,OAAO,CAST"}
|
|
@@ -6,8 +6,7 @@ const DEFAULT_THRESHOLD_SECONDS = 30 * 86_400;
|
|
|
6
6
|
* endpoints (`getOrders`, `getOrder`, `getActivity`, etc.).
|
|
7
7
|
*
|
|
8
8
|
* This utility carries no SDK-wide coupling — pass an explicit `signer` +
|
|
9
|
-
* `apiKey` and consume the returned bearer however the caller likes
|
|
10
|
-
* (per-call `options.lighterAuthToken`, persisted cache, etc.).
|
|
9
|
+
* `apiKey` and consume the returned bearer however the caller likes.
|
|
11
10
|
* @public
|
|
12
11
|
*/
|
|
13
12
|
export async function createAuthToken(inputs) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAuthToken.js","sourceRoot":"","sources":["../../../src/signers/createAuthToken.ts"],"names":[],"mappings":"AAIA,MAAM,wBAAwB,GAAG,EAAE,GAAG,EAAE,CAAA;AACxC,MAAM,yBAAyB,GAAG,EAAE,GAAG,MAAM,CAAA;AAwB7C
|
|
1
|
+
{"version":3,"file":"createAuthToken.js","sourceRoot":"","sources":["../../../src/signers/createAuthToken.ts"],"names":[],"mappings":"AAIA,MAAM,wBAAwB,GAAG,EAAE,GAAG,EAAE,CAAA;AACxC,MAAM,yBAAyB,GAAG,EAAE,GAAG,MAAM,CAAA;AAwB7C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAA6B;IAE7B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACjC,MAAM,QAAQ,GAAG,MAAM,CAAC,eAAe,IAAI,wBAAwB,CAAA;IACnE,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAA;IACpD,OAAO,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE;QACtC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;KAClC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAA8C,EAC9C,mBAA2B,yBAAyB,EACpD,MAAoB,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;IAEpC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;IACzD,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnB,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,SAAS,IAAI,gBAAgB,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type Big from 'big.js';
|
|
2
|
+
import type { LtAccountAsset } from '../types/account.js';
|
|
3
|
+
/** Both routes of a unified account's settlement asset, as one holding. */
|
|
4
|
+
export declare const pooledSettlementUnits: (asset: LtAccountAsset) => Big;
|
|
5
|
+
/**
|
|
6
|
+
* Spot units a unified account can spend from its settlement pool: the free
|
|
7
|
+
* spot route plus the margin route up to the account's `available_balance`.
|
|
8
|
+
* This is `computeSpotAvailableToTradeMarket` in Lighter's `lighter-ts` for an
|
|
9
|
+
* asset priced 1:1 with a `loan_to_value` of 1. The result can be negative.
|
|
10
|
+
*/
|
|
11
|
+
export declare const pooledSettlementSpendable: (asset: LtAccountAsset, availableBalance: Big) => Big;
|
|
12
|
+
/** Spot-route `balance` of the collateral asset; `'0'` when the account holds none. */
|
|
13
|
+
export declare const collateralSpotBalance: (assets: readonly LtAccountAsset[], settlementAssetIndex: number) => string;
|
|
14
|
+
//# sourceMappingURL=settlementPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlementPool.d.ts","sourceRoot":"","sources":["../../../src/utils/settlementPool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAGzD,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,GAAI,OAAO,cAAc,KAAG,GAG3D,CAAA;AAEH;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GACpC,OAAO,cAAc,EACrB,kBAAkB,GAAG,KACpB,GAKF,CAAA;AAED,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,GAChC,QAAQ,SAAS,cAAc,EAAE,EACjC,sBAAsB,MAAM,KAC3B,MAKF,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { toRequiredBig } from './decimal.js';
|
|
2
|
+
/** Both routes of a unified account's settlement asset, as one holding. */
|
|
3
|
+
export const pooledSettlementUnits = (asset) => toRequiredBig(asset.balance, 'balance').plus(toRequiredBig(asset.margin_balance, 'margin_balance'));
|
|
4
|
+
/**
|
|
5
|
+
* Spot units a unified account can spend from its settlement pool: the free
|
|
6
|
+
* spot route plus the margin route up to the account's `available_balance`.
|
|
7
|
+
* This is `computeSpotAvailableToTradeMarket` in Lighter's `lighter-ts` for an
|
|
8
|
+
* asset priced 1:1 with a `loan_to_value` of 1. The result can be negative.
|
|
9
|
+
*/
|
|
10
|
+
export const pooledSettlementSpendable = (asset, availableBalance) => {
|
|
11
|
+
const marginBalance = toRequiredBig(asset.margin_balance, 'margin_balance');
|
|
12
|
+
return toRequiredBig(asset.balance, 'balance')
|
|
13
|
+
.minus(toRequiredBig(asset.locked_balance, 'locked_balance'))
|
|
14
|
+
.plus(marginBalance.lt(availableBalance) ? marginBalance : availableBalance);
|
|
15
|
+
};
|
|
16
|
+
/** Spot-route `balance` of the collateral asset; `'0'` when the account holds none. */
|
|
17
|
+
export const collateralSpotBalance = (assets, settlementAssetIndex) => {
|
|
18
|
+
const asset = assets.find((a) => a.asset_id === settlementAssetIndex);
|
|
19
|
+
return asset === undefined
|
|
20
|
+
? '0'
|
|
21
|
+
: toRequiredBig(asset.balance, 'balance').toFixed();
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=settlementPool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlementPool.js","sourceRoot":"","sources":["../../../src/utils/settlementPool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAqB,EAAO,EAAE,CAClE,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,IAAI,CAC1C,aAAa,CAAC,KAAK,CAAC,cAAc,EAAE,gBAAgB,CAAC,CACtD,CAAA;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,KAAqB,EACrB,gBAAqB,EAChB,EAAE;IACP,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAA;IAC3E,OAAO,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC;SAC3C,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;SAC5D,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;AAChF,CAAC,CAAA;AAED,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,MAAiC,EACjC,oBAA4B,EACpB,EAAE;IACV,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,oBAAoB,CAAC,CAAA;IACrE,OAAO,KAAK,KAAK,SAAS;QACxB,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,OAAO,EAAE,CAAA;AACvD,CAAC,CAAA"}
|
|
@@ -9,11 +9,9 @@ import { type LighterDeployment } from './constants.js';
|
|
|
9
9
|
* manager are created per plugin instance.
|
|
10
10
|
*
|
|
11
11
|
* Auth-token resolution order for the auth-gated reads:
|
|
12
|
-
* 1.
|
|
13
|
-
* 2. Constructor `authToken` (string or async factory)
|
|
14
|
-
* 3. Persisted long-lived read-only token, keyed on the resolved Lighter
|
|
12
|
+
* 1. Persisted long-lived read-only token, keyed on the resolved Lighter
|
|
15
13
|
* `accountIndex`
|
|
16
|
-
*
|
|
14
|
+
* 2. Fresh 1h create via this instance's WASM signer + the user's registered
|
|
17
15
|
* API key
|
|
18
16
|
*
|
|
19
17
|
* Status reads report the account's state and do not throw for a missing
|
|
@@ -27,9 +25,9 @@ import { type LighterDeployment } from './constants.js';
|
|
|
27
25
|
* - `SetupRequired` when none of these sources yields a token. The SDK
|
|
28
26
|
* sends no venue request. `getOrders`, `getOrder`, `getFills`,
|
|
29
27
|
* `getPortfolioHistory` and `getActivity` need a token.
|
|
30
|
-
* - `Unauthorized` when Lighter rejects the token that was sent.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
28
|
+
* - `Unauthorized` when Lighter rejects the token that was sent. A
|
|
29
|
+
* read-only token that Lighter reports as revoked is replaced and the
|
|
30
|
+
* read retried once first.
|
|
33
31
|
* - `AccountNotFound` when the wallet has no Lighter account. This also
|
|
34
32
|
* applies to `getPositions`, `getWithdrawableBalances` and
|
|
35
33
|
* `getAvailableToTrade`, which need no token. `getAvailableToTrade`
|
|
@@ -52,8 +50,6 @@ export interface LighterProviderOptions {
|
|
|
52
50
|
* instance's signer and read-only token manager follow this URL.
|
|
53
51
|
*/
|
|
54
52
|
restUrl?: string;
|
|
55
|
-
/** Pre-created Lighter read-only bearer, bypassing SDK token resolution. */
|
|
56
|
-
authToken?: string | (() => string | Promise<string>);
|
|
57
53
|
/** Token lifetime for on-demand standard-token creates (Lighter caps at 8h). Default 1h. */
|
|
58
54
|
tokenLifetimeSeconds?: number;
|
|
59
55
|
/** Re-create when the cached standard token's remaining life is below this. Default 60s. */
|
|
@@ -71,8 +67,8 @@ export interface LighterProviderOptions {
|
|
|
71
67
|
export interface LighterPerpsProvider extends PerpsProviderPlugin {
|
|
72
68
|
/**
|
|
73
69
|
* Resolve a Lighter auth token for `address`, following the resolution order
|
|
74
|
-
* documented on {@link LighterProviderOptions}
|
|
75
|
-
*
|
|
70
|
+
* documented on {@link LighterProviderOptions}. Returns `undefined` when no
|
|
71
|
+
* source can produce a token.
|
|
76
72
|
*/
|
|
77
73
|
resolveAuthToken(address: Address): Promise<string | undefined>;
|
|
78
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LighterProvider.d.ts","sourceRoot":"","sources":["../../src/LighterProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAeL,KAAK,mBAAmB,EAqBxB,KAAK,cAAc,EAEpB,MAAM,iBAAiB,CAAA;AAmCxB,OAAO,KAAK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|
|
@@ -12,7 +12,8 @@ export declare const lighterConfig: (account: AccountResponse) => LighterAccount
|
|
|
12
12
|
export declare const lighterPortfolioValue: (perpsEquity: Big, holdingValuesUsd: readonly string[]) => Big;
|
|
13
13
|
/**
|
|
14
14
|
* Roll up settlement equity, spot holdings and non-settlement margin holdings.
|
|
15
|
-
*
|
|
15
|
+
* The settlement asset counts as `totalAssetValue` plus its spot-route balance,
|
|
16
|
+
* so a row that pools both routes is not counted again.
|
|
16
17
|
*
|
|
17
18
|
* @throws {PerpsError} `SDKError` when the account is not a Lighter one.
|
|
18
19
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountSummary.d.ts","sourceRoot":"","sources":["../../src/accountSummary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,QAAQ,EACT,MAAM,mBAAmB,CAAA;AAE1B,OAAO,GAAG,MAAM,QAAQ,CAAA;AASxB;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,eAAe,KACvB,oBAYF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAChC,aAAa,GAAG,EAChB,kBAAkB,SAAS,MAAM,EAAE,KAClC,GAIA,CAAA;AAEH
|
|
1
|
+
{"version":3,"file":"accountSummary.d.ts","sourceRoot":"","sources":["../../src/accountSummary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,QAAQ,EACT,MAAM,mBAAmB,CAAA;AAE1B,OAAO,GAAG,MAAM,QAAQ,CAAA;AASxB;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,eAAe,KACvB,oBAYF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAChC,aAAa,GAAG,EAChB,kBAAkB,SAAS,MAAM,EAAE,KAClC,GAIA,CAAA;AAEH;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,eAAe,EACxB,SAAS,EAAE,QAAQ,EAAE,GACpB,cAAc,CAkChB"}
|
|
@@ -25,8 +25,7 @@ export interface CreateAuthTokenInputs {
|
|
|
25
25
|
* endpoints (`getOrders`, `getOrder`, `getActivity`, etc.).
|
|
26
26
|
*
|
|
27
27
|
* This utility carries no SDK-wide coupling — pass an explicit `signer` +
|
|
28
|
-
* `apiKey` and consume the returned bearer however the caller likes
|
|
29
|
-
* (per-call `options.lighterAuthToken`, persisted cache, etc.).
|
|
28
|
+
* `apiKey` and consume the returned bearer however the caller likes.
|
|
30
29
|
* @public
|
|
31
30
|
*/
|
|
32
31
|
export declare function createAuthToken(inputs: CreateAuthTokenInputs): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAuthToken.d.ts","sourceRoot":"","sources":["../../../src/signers/createAuthToken.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,aAAa,CAAA;IACrB,MAAM,EAAE,IAAI,CACV,aAAa,EACb,kBAAkB,GAAG,aAAa,GAAG,cAAc,CACpD,CAAA;IACD;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED
|
|
1
|
+
{"version":3,"file":"createAuthToken.d.ts","sourceRoot":"","sources":["../../../src/signers/createAuthToken.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,aAAa,CAAA;IACrB,MAAM,EAAE,IAAI,CACV,aAAa,EACb,kBAAkB,GAAG,aAAa,GAAG,cAAc,CACpD,CAAA;IACD;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,IAAI,EAC9C,gBAAgB,GAAE,MAAkC,EACpD,GAAG,GAAE,MAAM,MAAyB,GACnC,OAAO,CAST"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type Big from 'big.js';
|
|
2
|
+
import type { LtAccountAsset } from '../types/account.js';
|
|
3
|
+
/** Both routes of a unified account's settlement asset, as one holding. */
|
|
4
|
+
export declare const pooledSettlementUnits: (asset: LtAccountAsset) => Big;
|
|
5
|
+
/**
|
|
6
|
+
* Spot units a unified account can spend from its settlement pool: the free
|
|
7
|
+
* spot route plus the margin route up to the account's `available_balance`.
|
|
8
|
+
* This is `computeSpotAvailableToTradeMarket` in Lighter's `lighter-ts` for an
|
|
9
|
+
* asset priced 1:1 with a `loan_to_value` of 1. The result can be negative.
|
|
10
|
+
*/
|
|
11
|
+
export declare const pooledSettlementSpendable: (asset: LtAccountAsset, availableBalance: Big) => Big;
|
|
12
|
+
/** Spot-route `balance` of the collateral asset; `'0'` when the account holds none. */
|
|
13
|
+
export declare const collateralSpotBalance: (assets: readonly LtAccountAsset[], settlementAssetIndex: number) => string;
|
|
14
|
+
//# sourceMappingURL=settlementPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlementPool.d.ts","sourceRoot":"","sources":["../../../src/utils/settlementPool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAGzD,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,GAAI,OAAO,cAAc,KAAG,GAG3D,CAAA;AAEH;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GACpC,OAAO,cAAc,EACrB,kBAAkB,GAAG,KACpB,GAKF,CAAA;AAED,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,GAChC,QAAQ,SAAS,cAAc,EAAE,EACjC,sBAAsB,MAAM,KAC3B,MAKF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/perps-sdk-provider-lighter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "35.0.0",
|
|
4
4
|
"description": "Lighter provider plugin for @lifi/perps-sdk",
|
|
5
5
|
"homepage": "https://github.com/lifinance/perps-sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"big.js": "^7.0.1",
|
|
46
46
|
"viem": "^2.55.18",
|
|
47
|
-
"@lifi/perps-types": "^20.
|
|
47
|
+
"@lifi/perps-types": "^20.1.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@lifi/perps-sdk": "^
|
|
50
|
+
"@lifi/perps-sdk": "^23.0.0"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|