@lifi/perps-types 17.0.0 → 18.1.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 (81) hide show
  1. package/dist/cjs/account.d.ts +63 -60
  2. package/dist/cjs/account.d.ts.map +1 -1
  3. package/dist/cjs/action.d.ts +21 -20
  4. package/dist/cjs/action.d.ts.map +1 -1
  5. package/dist/cjs/asset.d.ts +2 -1
  6. package/dist/cjs/asset.d.ts.map +1 -1
  7. package/dist/cjs/decimal.d.ts +4 -0
  8. package/dist/cjs/decimal.d.ts.map +1 -0
  9. package/dist/cjs/decimal.js +9 -0
  10. package/dist/cjs/decimal.js.map +1 -0
  11. package/dist/cjs/index.d.ts +1 -0
  12. package/dist/cjs/index.d.ts.map +1 -1
  13. package/dist/cjs/index.js +1 -0
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/market.d.ts +25 -23
  16. package/dist/cjs/market.d.ts.map +1 -1
  17. package/dist/cjs/portfolioHistory.d.ts +5 -4
  18. package/dist/cjs/portfolioHistory.d.ts.map +1 -1
  19. package/dist/cjs/quote.d.ts +7 -6
  20. package/dist/cjs/quote.d.ts.map +1 -1
  21. package/dist/cjs/referral.d.ts +5 -4
  22. package/dist/cjs/referral.d.ts.map +1 -1
  23. package/dist/cjs/referral.js.map +1 -1
  24. package/dist/cjs/subscriptions.d.ts +2 -1
  25. package/dist/cjs/subscriptions.d.ts.map +1 -1
  26. package/dist/esm/account.d.ts +81 -68
  27. package/dist/esm/account.d.ts.map +1 -1
  28. package/dist/esm/action.d.ts +40 -28
  29. package/dist/esm/action.d.ts.map +1 -1
  30. package/dist/esm/asset.d.ts +2 -1
  31. package/dist/esm/asset.d.ts.map +1 -1
  32. package/dist/esm/decimal.d.ts +23 -0
  33. package/dist/esm/decimal.d.ts.map +1 -0
  34. package/dist/esm/decimal.js +17 -0
  35. package/dist/esm/decimal.js.map +1 -0
  36. package/dist/esm/index.d.ts +1 -0
  37. package/dist/esm/index.d.ts.map +1 -1
  38. package/dist/esm/index.js +1 -0
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/market.d.ts +29 -23
  41. package/dist/esm/market.d.ts.map +1 -1
  42. package/dist/esm/portfolioHistory.d.ts +5 -4
  43. package/dist/esm/portfolioHistory.d.ts.map +1 -1
  44. package/dist/esm/quote.d.ts +7 -6
  45. package/dist/esm/quote.d.ts.map +1 -1
  46. package/dist/esm/referral.d.ts +5 -5
  47. package/dist/esm/referral.d.ts.map +1 -1
  48. package/dist/esm/referral.js.map +1 -1
  49. package/dist/esm/subscriptions.d.ts +2 -1
  50. package/dist/esm/subscriptions.d.ts.map +1 -1
  51. package/dist/types/account.d.ts +81 -68
  52. package/dist/types/account.d.ts.map +1 -1
  53. package/dist/types/action.d.ts +40 -28
  54. package/dist/types/action.d.ts.map +1 -1
  55. package/dist/types/asset.d.ts +2 -1
  56. package/dist/types/asset.d.ts.map +1 -1
  57. package/dist/types/decimal.d.ts +23 -0
  58. package/dist/types/decimal.d.ts.map +1 -0
  59. package/dist/types/index.d.ts +1 -0
  60. package/dist/types/index.d.ts.map +1 -1
  61. package/dist/types/market.d.ts +29 -23
  62. package/dist/types/market.d.ts.map +1 -1
  63. package/dist/types/portfolioHistory.d.ts +5 -4
  64. package/dist/types/portfolioHistory.d.ts.map +1 -1
  65. package/dist/types/quote.d.ts +7 -6
  66. package/dist/types/quote.d.ts.map +1 -1
  67. package/dist/types/referral.d.ts +5 -5
  68. package/dist/types/referral.d.ts.map +1 -1
  69. package/dist/types/subscriptions.d.ts +2 -1
  70. package/dist/types/subscriptions.d.ts.map +1 -1
  71. package/package.json +1 -1
  72. package/src/account.ts +81 -68
  73. package/src/action.ts +41 -28
  74. package/src/asset.ts +3 -1
  75. package/src/decimal.ts +26 -0
  76. package/src/index.ts +1 -0
  77. package/src/market.ts +29 -23
  78. package/src/portfolioHistory.ts +6 -4
  79. package/src/quote.ts +7 -6
  80. package/src/referral.ts +5 -5
  81. package/src/subscriptions.ts +2 -1
package/src/account.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Asset, AssetDisplay } from './asset.js'
2
+ import type { DecimalString } from './decimal.js'
2
3
  import type {
3
4
  ActionType,
4
5
  ActivityType,
@@ -23,9 +24,9 @@ import type { Address, ProviderId } from './primitives.js'
23
24
  */
24
25
  export interface FeeTier {
25
26
  /** Decimal fraction charged to maker fills, represented as a string. */
26
- maker: string
27
+ maker: DecimalString
27
28
  /** Decimal fraction charged to taker fills, represented as a string. */
28
- taker: string
29
+ taker: DecimalString
29
30
  }
30
31
 
31
32
  /**
@@ -38,22 +39,22 @@ export interface Position {
38
39
  market: PerpsMarketDisplay
39
40
  side: PositionSide
40
41
  /** Position quantity in base-asset units. */
41
- size: string
42
+ size: DecimalString
42
43
  /** Average entry price in quote-asset units. */
43
- entryPrice: string
44
+ entryPrice: DecimalString
44
45
  /** Current provider mark price in quote-asset units. */
45
- markPrice: string
46
+ markPrice: DecimalString
46
47
  /** Estimated liquidation price in quote-asset units. */
47
- liquidationPrice: string
48
+ liquidationPrice: DecimalString
48
49
  /** Unrealized PnL in quote-currency units. */
49
- unrealizedPnl: string
50
+ unrealizedPnl: DecimalString
50
51
  /**
51
52
  * Funding this position accrued since it opened, in quote-currency units.
52
53
  * Positive means the account received funding and negative means the account
53
54
  * paid it, matching {@link FundingActivity} amounts. Every venue resets the
54
55
  * value when the position returns to flat.
55
56
  */
56
- accruedFunding: string
57
+ accruedFunding: DecimalString
57
58
  /** Position leverage as a numeric multiple. */
58
59
  leverage: number
59
60
  /**
@@ -62,12 +63,12 @@ export interface Position {
62
63
  * Hyperliquid isolated `marginUsed` includes the unrealized PnL of the
63
64
  * position; Lighter `allocated_margin` excludes it.
64
65
  */
65
- marginUsed: string
66
+ marginUsed: DecimalString
66
67
  /**
67
68
  * Exact initial margin the venue currently requires for this position.
68
69
  * Unlike `leverage`, this decimal string is safe for risk calculations.
69
70
  */
70
- initialMarginRequirement: string
71
+ initialMarginRequirement: DecimalString
71
72
  marginMode: MarginMode
72
73
  }
73
74
 
@@ -82,10 +83,10 @@ export interface OrderBase {
82
83
  status: OrderStatus
83
84
  /** Venue text for a REJECTED or CANCELLED order, when the venue gives one. */
84
85
  statusReason?: string
85
- originalSize: string
86
- remainingSize: string
87
- filledSize: string
88
- averagePrice?: string
86
+ originalSize: DecimalString
87
+ remainingSize: DecimalString
88
+ filledSize: DecimalString
89
+ averagePrice?: DecimalString
89
90
  reduceOnly: boolean
90
91
  /** Parent of a placement TP/SL leg or TWAP child; absent on position-level triggers. */
91
92
  parentOrderId?: string
@@ -98,7 +99,7 @@ export interface OrderBase {
98
99
  /** Market or limit order with a time-in-force policy. */
99
100
  export interface RegularOrder extends OrderBase {
100
101
  type: OrderType.MARKET | OrderType.LIMIT
101
- price?: string
102
+ price?: DecimalString
102
103
  timeInForce: TimeInForce
103
104
  expiresAt?: string
104
105
  }
@@ -110,9 +111,9 @@ export interface TriggerOrder extends OrderBase {
110
111
  | OrderType.STOP_LIMIT
111
112
  | OrderType.TAKE_PROFIT_MARKET
112
113
  | OrderType.TAKE_PROFIT_LIMIT
113
- triggerPrice: string
114
+ triggerPrice: DecimalString
114
115
  triggerCondition: TriggerCondition
115
- limitPrice?: string
116
+ limitPrice?: DecimalString
116
117
  }
117
118
 
118
119
  /** Time-weighted execution parent. */
@@ -135,17 +136,18 @@ export interface Balance {
135
136
  /** Which category/venue this balance sits in — references a {@link ProviderCategory}. */
136
137
  categoryId: string
137
138
  asset: Asset
138
- units: string
139
+ units: DecimalString
139
140
  /** USD value the SDK fills from the prices map; consumers render with zero math. */
140
- valueUsd: string
141
+ valueUsd: DecimalString
141
142
  /** USD price of one unit. Absent when the provider holds no price for the asset. */
142
- price?: string
143
+ price?: DecimalString
143
144
  /**
144
- * Part of `units` the venue releases from this category in a category
145
- * transfer, as a decimal string from `0` to `units`. Set on each
146
- * perps-category collateral row; absent on every other row.
145
+ * Part of `units` the venue releases from this category, as a decimal
146
+ * string clamped to `[0, units]`. Every collateral row and every spot row
147
+ * carries it. It is not the withdrawal ceiling: read
148
+ * `PerpsClient.getWithdrawableBalances` for that.
147
149
  */
148
- transferable?: string
150
+ transferable?: DecimalString
149
151
  }
150
152
 
151
153
  /**
@@ -169,9 +171,9 @@ export interface AccountResponse {
169
171
  /** Open positions the snapshot already computed; equals the unfiltered `getPositions` output. */
170
172
  positions: Position[]
171
173
  /** Margin reserved across the account, represented as a decimal string. */
172
- marginUsed: string
174
+ marginUsed: DecimalString
173
175
  /** Unrealized account PnL, represented as a decimal string. */
174
- unrealizedPnl: string
176
+ unrealizedPnl: DecimalString
175
177
  feeTier: FeeTier
176
178
  config: AccountConfig
177
179
  }
@@ -184,13 +186,13 @@ export interface AccountResponse {
184
186
  */
185
187
  export interface AccountSummary {
186
188
  /** Total account portfolio value in USD. */
187
- portfolioValue: string
189
+ portfolioValue: DecimalString
188
190
  /** Margin currently available for new orders in USD. */
189
- availableMargin: string
191
+ availableMargin: DecimalString
190
192
  /** Margin currently reserved by open positions/orders in USD. */
191
- marginUsed: string
193
+ marginUsed: DecimalString
192
194
  /** Aggregate unrealized PnL in USD. */
193
- unrealizedPnl: string
195
+ unrealizedPnl: DecimalString
194
196
  }
195
197
 
196
198
  /**
@@ -207,15 +209,14 @@ export interface AvailableToTrade {
207
209
  /** The market's margin asset, which both amounts are denominated in. */
208
210
  asset: AssetDisplay
209
211
  /** Amount the account can still buy, represented as a decimal string. */
210
- buy: string
212
+ buy: DecimalString
211
213
  /** Amount the account can still sell, represented as a decimal string. */
212
- sell: string
214
+ sell: DecimalString
213
215
  }
214
216
 
215
217
  /**
216
- * The user's complete venue-side settings for one market: the margin mode
217
- * and display leverage the next order on it will use. A provider returns
218
- * `undefined` when it cannot read both values.
218
+ * The user's complete venue-side settings for one perps market: the margin
219
+ * mode and display leverage the next order on it will use.
219
220
  * @public
220
221
  */
221
222
  export interface MarketSettings {
@@ -251,7 +252,7 @@ export interface OrdersResponse {
251
252
  */
252
253
  export interface Fee {
253
254
  /** Decimal string in `asset`'s units. */
254
- amount: string
255
+ amount: DecimalString
255
256
  /**
256
257
  * Display symbol the fee is denominated in, resolved by the provider
257
258
  * adapter. Falls back to the venue's own asset id when the registry knows no
@@ -276,10 +277,10 @@ export interface Fill {
276
277
  * Hyperliquid taker fill, which may be a market or an aggressive limit order).
277
278
  */
278
279
  type?: OrderType
279
- size: string
280
- price: string
280
+ size: DecimalString
281
+ price: DecimalString
281
282
  liquidity: LiquidityRole
282
- filledSize?: string
283
+ filledSize?: DecimalString
283
284
  /** Absent when the venue reports no fee for the fill. */
284
285
  fee?: Fee
285
286
  /**
@@ -300,8 +301,8 @@ export interface Fill {
300
301
  * a sentinel value.
301
302
  */
302
303
  leverage?: number
303
- realizedPnl?: string | null
304
- startPosition?: string
304
+ realizedPnl?: DecimalString | null
305
+ startPosition?: DecimalString
305
306
  classification: FillClassification
306
307
  createdAt: string
307
308
  /** Fully-resolved block-explorer URL for the settling on-chain tx. Absent when
@@ -354,7 +355,7 @@ export interface BaseActivity {
354
355
  export interface DepositActivity extends BaseActivity {
355
356
  type: ActivityType.DEPOSIT
356
357
  asset: Asset
357
- amount: string
358
+ amount: DecimalString
358
359
  /**
359
360
  * Address the deposited funds came from, as the venue reports it. Absent
360
361
  * when the venue's deposit payload names no source address.
@@ -373,7 +374,7 @@ export interface DepositActivity extends BaseActivity {
373
374
  export interface WithdrawalActivity extends BaseActivity {
374
375
  type: ActivityType.WITHDRAWAL
375
376
  asset: Asset
376
- amount: string
377
+ amount: DecimalString
377
378
  /** Absent when the venue reports no fee for the withdrawal. */
378
379
  fee?: Fee
379
380
  /** Fully-resolved block-explorer URL for the on-chain withdrawal tx. */
@@ -388,7 +389,7 @@ export interface WithdrawalActivity extends BaseActivity {
388
389
  export interface LiquidatedPosition {
389
390
  market: MarketDisplay
390
391
  /** Absent when the venue reports no liquidated size for the position. */
391
- size?: string
392
+ size?: DecimalString
392
393
  }
393
394
 
394
395
  /**
@@ -402,9 +403,9 @@ export interface LiquidatedPosition {
402
403
  export interface LiquidationActivity extends BaseActivity {
403
404
  type: ActivityType.LIQUIDATION
404
405
  /** Absent when the venue reports no liquidated notional. */
405
- liquidatedNotionalPosition?: string
406
+ liquidatedNotionalPosition?: DecimalString
406
407
  /** Absent when the venue reports no account value at liquidation time. */
407
- accountValue?: string
408
+ accountValue?: DecimalString
408
409
  /**
409
410
  * Margin mode the liquidated account ran under, in the venue's own
410
411
  * vocabulary — typically `cross` or `isolated`, but the venue may report
@@ -432,9 +433,9 @@ export interface FundingActivity extends BaseActivity {
432
433
  * Signed, in quote-currency units. Positive means the account received
433
434
  * funding; negative means the account paid it.
434
435
  */
435
- amount: string
436
- positionSize: string
437
- fundingRate: string
436
+ amount: DecimalString
437
+ positionSize: DecimalString
438
+ fundingRate: DecimalString
438
439
  }
439
440
 
440
441
  // At least one of `counterpartyAccountIndex` / `counterpartyAddress` is always
@@ -451,7 +452,7 @@ export type TransferActivity = BaseActivity & {
451
452
  type: ActivityType.TRANSFER
452
453
  direction: 'IN' | 'OUT'
453
454
  asset: Asset
454
- amount: string
455
+ amount: DecimalString
455
456
  /**
456
457
  * Every fee the venue charged for the transfer, in the order the venue
457
458
  * reports them. A venue may charge several fees for one transfer, each in a
@@ -509,7 +510,7 @@ export type HyperliquidAgent = Record<string, unknown>
509
510
  export interface HyperliquidBuilderFeeApproval {
510
511
  builderAddress: string
511
512
  /** Basis points as a string. */
512
- maxFeeRate: string
513
+ maxFeeRate: DecimalString
513
514
  approved: boolean
514
515
  }
515
516
 
@@ -521,10 +522,10 @@ export interface HyperliquidBuilderFeeApproval {
521
522
  */
522
523
  export interface HyperliquidMarginSummary {
523
524
  /** Total equity: locked margin and unrealized PnL included. */
524
- accountValue: string
525
- totalNtlPos: string
526
- totalRawUsd: string
527
- totalMarginUsed: string
525
+ accountValue: DecimalString
526
+ totalNtlPos: DecimalString
527
+ totalRawUsd: DecimalString
528
+ totalMarginUsed: DecimalString
528
529
  }
529
530
 
530
531
  /**
@@ -539,8 +540,8 @@ export interface HyperliquidDexAccountState {
539
540
  marginSummary: HyperliquidMarginSummary
540
541
  /** Cross-margin subset of {@link HyperliquidDexAccountState.marginSummary}. */
541
542
  crossMarginSummary: HyperliquidMarginSummary
542
- crossMaintenanceMarginUsed: string
543
- withdrawable: string
543
+ crossMaintenanceMarginUsed: DecimalString
544
+ withdrawable: DecimalString
544
545
  }
545
546
 
546
547
  /**
@@ -561,7 +562,7 @@ export interface HyperliquidAccountConfig {
561
562
  * `tokenToAvailableAfterMaintenance` list. Unified and portfolio-margin
562
563
  * accounts only; other modes derive buying power from `marginSummary`.
563
564
  */
564
- availableAfterMaintenance?: string
565
+ availableAfterMaintenance?: DecimalString
565
566
  }
566
567
 
567
568
  /**
@@ -609,16 +610,28 @@ export interface LighterAccountConfig {
609
610
  */
610
611
  accountType: number
611
612
  /**
612
- * Lighter `available_balance`: venue buying power for the whole account,
613
- * already marked to market. A decimal string in quote-asset units.
613
+ * Lighter `available_balance`: the withdrawable total, already marked to
614
+ * market. It is not the buying power: it adds each isolated position's
615
+ * equity above its initial margin requirement and subtracts the shortfall
616
+ * below it. A decimal string in quote-asset units.
614
617
  */
615
- availableBalance: string
618
+ availableBalance: DecimalString
619
+ /**
620
+ * Lighter `cross_asset_value`: cross-margin collateral plus the unrealized
621
+ * PnL of the cross positions. A decimal string in quote-asset units.
622
+ */
623
+ crossAssetValue: DecimalString
624
+ /**
625
+ * Lighter `cross_initial_margin_requirement`: the initial margin the cross
626
+ * positions lock. A decimal string in quote-asset units.
627
+ */
628
+ crossInitialMarginRequirement: DecimalString
616
629
  /**
617
630
  * Lighter `total_asset_value`: perps-route equity, isolated allocations and
618
631
  * unrealized PnL included. It excludes the spot-route balances. A decimal
619
632
  * string in quote-asset units.
620
633
  */
621
- totalAssetValue: string
634
+ totalAssetValue: DecimalString
622
635
  /**
623
636
  * Lighter `user_tier_name` from `/accountLimits`, in the tier vocabulary
624
637
  * `changeAccountTier` accepts. Absent on an unauthenticated read, which
@@ -657,15 +670,15 @@ export interface LighterAccountConfig {
657
670
  */
658
671
  export interface OndoAccountBalance {
659
672
  /** Collateral only: locked margin included, unrealized PnL excluded. */
660
- walletBalance: string
661
- unrealizedPnl: string
673
+ walletBalance: DecimalString
674
+ unrealizedPnl: DecimalString
662
675
  /** Total equity. */
663
- marginBalance: string
664
- usedMargin: string
676
+ marginBalance: DecimalString
677
+ usedMargin: DecimalString
665
678
  /** Venue buying power. */
666
- availableMargin: string
679
+ availableMargin: DecimalString
667
680
  /** Venue withdrawable figure, at or below {@link OndoAccountBalance.availableMargin}. */
668
- withdrawableMargin: string
681
+ withdrawableMargin: DecimalString
669
682
  }
670
683
 
671
684
  /**
package/src/action.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { AcceptTermsParams } from './acceptTerms.js'
2
+ import type { DecimalString } from './decimal.js'
2
3
  import type {
3
4
  ActionType,
4
5
  MarginMode,
@@ -271,13 +272,13 @@ export type ActionResult =
271
272
  * @public
272
273
  */
273
274
  export interface TriggerOrderInput {
274
- triggerPrice: string
275
- limitPrice?: string
275
+ triggerPrice: DecimalString
276
+ limitPrice?: DecimalString
276
277
  /**
277
278
  * Base-asset size the trigger closes. Omitted covers the entire position,
278
279
  * tracking later size changes; set, it is a fixed partial amount.
279
280
  */
280
- size?: string
281
+ size?: DecimalString
281
282
  }
282
283
 
283
284
  /**
@@ -287,10 +288,10 @@ export interface TriggerOrderInput {
287
288
  */
288
289
  export interface ModifyOrderInput {
289
290
  id: string
290
- price?: string
291
- size?: string
292
- triggerPrice?: string
293
- limitPrice?: string
291
+ price?: DecimalString
292
+ size?: DecimalString
293
+ triggerPrice?: DecimalString
294
+ limitPrice?: DecimalString
294
295
  }
295
296
 
296
297
  /**
@@ -302,10 +303,13 @@ export interface PlaceOrderParams {
302
303
  market: MarketRef
303
304
  side: OrderSide
304
305
  type?: Exclude<OrderType, OrderType.TWAP>
305
- size: string
306
- price?: string
306
+ size: DecimalString
307
+ price?: DecimalString
307
308
  leverage?: number
308
- /** Omitted falls back to the provider's default (currently CROSS). */
309
+ /**
310
+ * Hyperliquid: requires `leverage`. Omitted leaves the market's current
311
+ * margin mode unchanged.
312
+ */
309
313
  marginMode?: MarginMode
310
314
  reduceOnly?: boolean
311
315
  timeInForce?: TimeInForce
@@ -341,18 +345,18 @@ export interface PlaceTwapOrderParams {
341
345
  market: MarketRef
342
346
  side: OrderSide
343
347
  /** Total base-asset size executed across the TWAP's lifetime, as a decimal string. */
344
- size: string
348
+ size: DecimalString
345
349
  /** Total execution window in seconds. */
346
350
  durationSeconds: number
347
351
  reduceOnly?: boolean
348
- /** Hyperliquid: randomize sub-order timing within the execution window. */
352
+ /** Hyperliquid: randomize each sub-order size by up to 20 percent. */
349
353
  randomize?: boolean
350
354
  /** Ondo: interval between child orders in seconds. */
351
355
  frequencySeconds?: number
352
356
  /** Ondo: lowest acceptable child-order price, as a decimal string. */
353
- minPrice?: string
357
+ minPrice?: DecimalString
354
358
  /** Ondo: highest acceptable child-order price, as a decimal string. */
355
- maxPrice?: string
359
+ maxPrice?: DecimalString
356
360
  }
357
361
 
358
362
  /**
@@ -401,7 +405,7 @@ export interface ModifyOrderParams {
401
405
  export interface UpdateLeverageParams {
402
406
  market: MarketRef
403
407
  leverage: number
404
- /** Omitted falls back to the provider's default (currently CROSS). */
408
+ /** Hyperliquid: omitted is sent as isolated. */
405
409
  marginMode?: MarginMode
406
410
  }
407
411
 
@@ -414,7 +418,7 @@ export interface UpdateLeverageParams {
414
418
  export interface UpdatePositionMarginParams {
415
419
  market: MarketRef
416
420
  action: 'add' | 'remove'
417
- amount: string
421
+ amount: DecimalString
418
422
  }
419
423
 
420
424
  /**
@@ -429,6 +433,16 @@ export interface UpdateAssetCollateralParams {
429
433
  enabled: boolean
430
434
  }
431
435
 
436
+ /**
437
+ * Which of a venue's two balance routes a withdrawal is drawn from. Lighter's
438
+ * own vocabulary, carried in the signed tx as `AssetRouteType` (`perps` = 0,
439
+ * `spot` = 1); an account's mode changes what the two balances mean, never
440
+ * which route the tx names.
441
+ *
442
+ * @public
443
+ */
444
+ export type WithdrawalRoute = 'perps' | 'spot'
445
+
432
446
  /**
433
447
  * Parameters for withdrawing a decimal-string amount to an EVM address.
434
448
  *
@@ -436,7 +450,11 @@ export interface UpdateAssetCollateralParams {
436
450
  */
437
451
  export interface WithdrawalParams {
438
452
  destination: Address
439
- amount: string
453
+ amount: DecimalString
454
+ /** Lighter: provider-native `Asset.id` to withdraw. Omitted withdraws the quote asset. */
455
+ assetId?: string
456
+ /** Lighter: balance route to draw from. Omitted is `perps`. */
457
+ route?: WithdrawalRoute
440
458
  /**
441
459
  * The venue-native account identifier, as a string. The provider plugin
442
460
  * supplies it; callers omit it. A string because Ondo's 20-digit accountID
@@ -451,8 +469,8 @@ export interface WithdrawalParams {
451
469
  * @public
452
470
  */
453
471
  export interface DepositParams {
454
- /** Amount of the token to deposit (human-readable, e.g. "100.5"). */
455
- amount: string
472
+ /** Amount of the token to deposit, as an integer string in the token's base units (e.g. "100500000" for 100.5 USDC). */
473
+ amount: DecimalString
456
474
  /** ERC-20 token address on the source chain. */
457
475
  tokenAddress: Address
458
476
  /** Chain ID of the source chain (e.g. 1 for Ethereum, 42161 for Arbitrum). */
@@ -471,17 +489,12 @@ export interface ApproveAgentParams {
471
489
  }
472
490
 
473
491
  /**
474
- * Parameters for deregistering an account agent.
492
+ * Parameters for deregistering an account agent. The action takes no
493
+ * parameters: the backend picks the agent to revoke and the user confirms it.
475
494
  *
476
495
  * @public
477
496
  */
478
- export interface RevokeAgentParams {
479
- address: Address
480
- /** The name the venue holds for the agent. HyperCore identifies a named API
481
- * wallet by name, not by address, so a revoke that omits the exact stored
482
- * name leaves the slot occupied. */
483
- name: string
484
- }
497
+ export type RevokeAgentParams = Record<string, never>
485
498
 
486
499
  /**
487
500
  * Parameters for removing the session agent the SDK signs with, targeted by
@@ -522,7 +535,7 @@ export interface SendAssetParams {
522
535
  collateral: string
523
536
  sourceDex: string
524
537
  destinationDex: string
525
- amount: string
538
+ amount: DecimalString
526
539
  }
527
540
 
528
541
  /**
package/src/asset.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { DecimalString } from './decimal.js'
2
+
1
3
  /**
2
4
  * Underlying token/registry entry. The base entity of the perps taxonomy:
3
5
  * a tradable unit referenced by markets (as base/quote legs) and held by
@@ -32,7 +34,7 @@ export interface Asset {
32
34
  /** L1 token contract; the zero address denotes native gas. */
33
35
  l1Address?: string
34
36
  /** Venue minimum for a single withdrawal, denominated in this asset — not USD. */
35
- minWithdrawalAmount?: string
37
+ minWithdrawalAmount?: DecimalString
36
38
  }
37
39
 
38
40
  /**
package/src/decimal.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Plain decimal string: optional `-`, digits, optional fraction. No grouping,
3
+ * exponent, currency sign or whitespace; matches {@link DECIMAL_PATTERN}. Build
4
+ * it with an SDK `snap*`/`calculate*` helper or a provider, not `.toString()`.
5
+ *
6
+ * @public
7
+ */
8
+ export type DecimalString = string
9
+
10
+ /**
11
+ * The single spelling rule for a {@link DecimalString}. It stays byte-identical
12
+ * to the pattern `lifi-perps-backend` matches every stored decimal against, so
13
+ * one amount has exactly one spelling in all three repositories.
14
+ *
15
+ * @public
16
+ */
17
+ export const DECIMAL_PATTERN = /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/
18
+
19
+ /**
20
+ * Narrows an unknown value to a {@link DecimalString}.
21
+ *
22
+ * @public
23
+ */
24
+ export function isDecimalString(value: unknown): value is DecimalString {
25
+ return typeof value === 'string' && DECIMAL_PATTERN.test(value)
26
+ }
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ export * from './acceptTerms.js'
11
11
  export * from './account.js'
12
12
  export * from './action.js'
13
13
  export * from './asset.js'
14
+ export * from './decimal.js'
14
15
  export * from './enums.js'
15
16
  export * from './errors.js'
16
17
  export * from './market.js'