@lifi/perps-sdk 6.2.1 → 6.3.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/client/PerpsClient.d.ts +3 -1
- package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
- package/dist/cjs/client/PerpsClient.js +36 -0
- package/dist/cjs/client/PerpsClient.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/api.d.ts +4 -0
- package/dist/cjs/types/api.d.ts.map +1 -1
- package/dist/cjs/types/provider.d.ts +5 -0
- package/dist/cjs/types/provider.d.ts.map +1 -1
- package/dist/cjs/types/withdrawal.d.ts +13 -0
- package/dist/cjs/types/withdrawal.d.ts.map +1 -0
- package/dist/cjs/types/withdrawal.js +3 -0
- package/dist/cjs/types/withdrawal.js.map +1 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client/PerpsClient.d.ts +17 -1
- package/dist/esm/client/PerpsClient.d.ts.map +1 -1
- package/dist/esm/client/PerpsClient.js +47 -0
- package/dist/esm/client/PerpsClient.js.map +1 -1
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/api.d.ts +9 -0
- package/dist/esm/types/api.d.ts.map +1 -1
- package/dist/esm/types/provider.d.ts +20 -0
- package/dist/esm/types/provider.d.ts.map +1 -1
- package/dist/esm/types/withdrawal.d.ts +37 -0
- package/dist/esm/types/withdrawal.d.ts.map +1 -0
- package/dist/esm/types/withdrawal.js +2 -0
- package/dist/esm/types/withdrawal.js.map +1 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/client/PerpsClient.d.ts +17 -1
- package/dist/types/client/PerpsClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/api.d.ts +9 -0
- package/dist/types/types/api.d.ts.map +1 -1
- package/dist/types/types/provider.d.ts +20 -0
- package/dist/types/types/provider.d.ts.map +1 -1
- package/dist/types/types/withdrawal.d.ts +37 -0
- package/dist/types/types/withdrawal.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -3
- package/src/client/PerpsClient.ts +55 -0
- package/src/index.ts +7 -0
- package/src/types/api.ts +10 -0
- package/src/types/provider.ts +25 -0
- package/src/types/withdrawal.ts +39 -0
- package/src/version.ts +1 -1
package/src/types/api.ts
CHANGED
|
@@ -243,6 +243,16 @@ export interface GetDepositFlowParams {
|
|
|
243
243
|
address: Address
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
+
/**
|
|
247
|
+
* Parameters for {@link PerpsClient.getWithdrawableBalances}.
|
|
248
|
+
*
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
export interface GetWithdrawableBalancesParams {
|
|
252
|
+
provider: string
|
|
253
|
+
address: Address
|
|
254
|
+
}
|
|
255
|
+
|
|
246
256
|
/**
|
|
247
257
|
* Result from {@link PerpsClient.checkSetup}.
|
|
248
258
|
*
|
package/src/types/provider.ts
CHANGED
|
@@ -33,6 +33,7 @@ import type {
|
|
|
33
33
|
SDKRequestOptions,
|
|
34
34
|
} from './config.js'
|
|
35
35
|
import type { DepositFlow } from './deposit.js'
|
|
36
|
+
import type { ProviderWithdrawableBalance } from './withdrawal.js'
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Low-level SDK client: resolved config, the optional end-user wallet, and the
|
|
@@ -176,6 +177,15 @@ export interface ProviderGetDepositFlowParams {
|
|
|
176
177
|
address: Address
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Read params for {@link PerpsProviderPlugin.getWithdrawableBalances}.
|
|
182
|
+
*
|
|
183
|
+
* @public
|
|
184
|
+
*/
|
|
185
|
+
export interface ProviderGetWithdrawableBalancesParams {
|
|
186
|
+
address: Address
|
|
187
|
+
}
|
|
188
|
+
|
|
179
189
|
/**
|
|
180
190
|
* Read params for {@link PerpsProvider.getPositions}.
|
|
181
191
|
*
|
|
@@ -377,6 +387,21 @@ export interface PerpsProviderPlugin {
|
|
|
377
387
|
options?: SDKRequestOptions
|
|
378
388
|
): Promise<DepositFlow>
|
|
379
389
|
|
|
390
|
+
/**
|
|
391
|
+
* The `(asset, route)` pairs `params.address` currently has something to
|
|
392
|
+
* withdraw from, keyed by provider-native asset id. Only the venue knows how
|
|
393
|
+
* its balance payload splits across routes, so the split is owned here; the
|
|
394
|
+
* per-asset venue minimum is applied by `PerpsClient.getWithdrawableBalances`,
|
|
395
|
+
* which holds the core asset registry.
|
|
396
|
+
*
|
|
397
|
+
* Optional: a provider whose withdrawals are not a per-route selection omits
|
|
398
|
+
* it, and `PerpsClient.getWithdrawableBalances` then resolves `undefined`.
|
|
399
|
+
*/
|
|
400
|
+
getWithdrawableBalances?(
|
|
401
|
+
params: ProviderGetWithdrawableBalancesParams,
|
|
402
|
+
options?: SDKRequestOptions
|
|
403
|
+
): Promise<ProviderWithdrawableBalance[]>
|
|
404
|
+
|
|
380
405
|
getPositions(
|
|
381
406
|
params: ProviderGetPositionsParams,
|
|
382
407
|
options?: SDKRequestOptions
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Asset } from '@lifi/perps-types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Which of a venue's two balance routes a withdrawal is drawn from. Lighter's
|
|
5
|
+
* own vocabulary, carried in the signed tx as `AssetRouteType` (`perps` = 0,
|
|
6
|
+
* `spot` = 1); an account's mode changes what the two balances mean, never
|
|
7
|
+
* which route the tx names.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export type WithdrawalRoute = 'perps' | 'spot'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* One withdrawable `(asset, route)` selection as the provider reports it, keyed
|
|
15
|
+
* by provider-native asset id and awaiting the core asset-metadata join.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export interface ProviderWithdrawableBalance {
|
|
20
|
+
/** Provider-native `Asset.id`; never a display symbol. */
|
|
21
|
+
assetId: string
|
|
22
|
+
route: WithdrawalRoute
|
|
23
|
+
/** Withdrawable amount in the asset's own units. Always greater than zero. */
|
|
24
|
+
available: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* One withdrawable `(asset, route)` selection a caller can act on: the amount
|
|
29
|
+
* clears the asset's venue minimum, and `asset` carries the precision and
|
|
30
|
+
* minimum needed to scale and validate the withdrawal.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export interface WithdrawableBalance {
|
|
35
|
+
asset: Asset
|
|
36
|
+
route: WithdrawalRoute
|
|
37
|
+
/** Withdrawable amount in the asset's own units. */
|
|
38
|
+
available: string
|
|
39
|
+
}
|
package/src/version.ts
CHANGED