@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.
- package/dist/cjs/account.d.ts +63 -60
- package/dist/cjs/account.d.ts.map +1 -1
- package/dist/cjs/action.d.ts +21 -20
- package/dist/cjs/action.d.ts.map +1 -1
- package/dist/cjs/asset.d.ts +2 -1
- package/dist/cjs/asset.d.ts.map +1 -1
- package/dist/cjs/decimal.d.ts +4 -0
- package/dist/cjs/decimal.d.ts.map +1 -0
- package/dist/cjs/decimal.js +9 -0
- package/dist/cjs/decimal.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/market.d.ts +25 -23
- package/dist/cjs/market.d.ts.map +1 -1
- package/dist/cjs/portfolioHistory.d.ts +5 -4
- package/dist/cjs/portfolioHistory.d.ts.map +1 -1
- package/dist/cjs/quote.d.ts +7 -6
- package/dist/cjs/quote.d.ts.map +1 -1
- package/dist/cjs/referral.d.ts +5 -4
- package/dist/cjs/referral.d.ts.map +1 -1
- package/dist/cjs/referral.js.map +1 -1
- package/dist/cjs/subscriptions.d.ts +2 -1
- package/dist/cjs/subscriptions.d.ts.map +1 -1
- package/dist/esm/account.d.ts +81 -68
- package/dist/esm/account.d.ts.map +1 -1
- package/dist/esm/action.d.ts +40 -28
- package/dist/esm/action.d.ts.map +1 -1
- package/dist/esm/asset.d.ts +2 -1
- package/dist/esm/asset.d.ts.map +1 -1
- package/dist/esm/decimal.d.ts +23 -0
- package/dist/esm/decimal.d.ts.map +1 -0
- package/dist/esm/decimal.js +17 -0
- package/dist/esm/decimal.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/market.d.ts +29 -23
- package/dist/esm/market.d.ts.map +1 -1
- package/dist/esm/portfolioHistory.d.ts +5 -4
- package/dist/esm/portfolioHistory.d.ts.map +1 -1
- package/dist/esm/quote.d.ts +7 -6
- package/dist/esm/quote.d.ts.map +1 -1
- package/dist/esm/referral.d.ts +5 -5
- package/dist/esm/referral.d.ts.map +1 -1
- package/dist/esm/referral.js.map +1 -1
- package/dist/esm/subscriptions.d.ts +2 -1
- package/dist/esm/subscriptions.d.ts.map +1 -1
- package/dist/types/account.d.ts +81 -68
- package/dist/types/account.d.ts.map +1 -1
- package/dist/types/action.d.ts +40 -28
- package/dist/types/action.d.ts.map +1 -1
- package/dist/types/asset.d.ts +2 -1
- package/dist/types/asset.d.ts.map +1 -1
- package/dist/types/decimal.d.ts +23 -0
- package/dist/types/decimal.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/market.d.ts +29 -23
- package/dist/types/market.d.ts.map +1 -1
- package/dist/types/portfolioHistory.d.ts +5 -4
- package/dist/types/portfolioHistory.d.ts.map +1 -1
- package/dist/types/quote.d.ts +7 -6
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/referral.d.ts +5 -5
- package/dist/types/referral.d.ts.map +1 -1
- package/dist/types/subscriptions.d.ts +2 -1
- package/dist/types/subscriptions.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/account.ts +81 -68
- package/src/action.ts +41 -28
- package/src/asset.ts +3 -1
- package/src/decimal.ts +26 -0
- package/src/index.ts +1 -0
- package/src/market.ts +29 -23
- package/src/portfolioHistory.ts +6 -4
- package/src/quote.ts +7 -6
- package/src/referral.ts +5 -5
- 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:
|
|
27
|
+
maker: DecimalString
|
|
27
28
|
/** Decimal fraction charged to taker fills, represented as a string. */
|
|
28
|
-
taker:
|
|
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:
|
|
42
|
+
size: DecimalString
|
|
42
43
|
/** Average entry price in quote-asset units. */
|
|
43
|
-
entryPrice:
|
|
44
|
+
entryPrice: DecimalString
|
|
44
45
|
/** Current provider mark price in quote-asset units. */
|
|
45
|
-
markPrice:
|
|
46
|
+
markPrice: DecimalString
|
|
46
47
|
/** Estimated liquidation price in quote-asset units. */
|
|
47
|
-
liquidationPrice:
|
|
48
|
+
liquidationPrice: DecimalString
|
|
48
49
|
/** Unrealized PnL in quote-currency units. */
|
|
49
|
-
unrealizedPnl:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
86
|
-
remainingSize:
|
|
87
|
-
filledSize:
|
|
88
|
-
averagePrice?:
|
|
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?:
|
|
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:
|
|
114
|
+
triggerPrice: DecimalString
|
|
114
115
|
triggerCondition: TriggerCondition
|
|
115
|
-
limitPrice?:
|
|
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:
|
|
139
|
+
units: DecimalString
|
|
139
140
|
/** USD value the SDK fills from the prices map; consumers render with zero math. */
|
|
140
|
-
valueUsd:
|
|
141
|
+
valueUsd: DecimalString
|
|
141
142
|
/** USD price of one unit. Absent when the provider holds no price for the asset. */
|
|
142
|
-
price?:
|
|
143
|
+
price?: DecimalString
|
|
143
144
|
/**
|
|
144
|
-
* Part of `units` the venue releases from this category
|
|
145
|
-
*
|
|
146
|
-
*
|
|
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?:
|
|
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:
|
|
174
|
+
marginUsed: DecimalString
|
|
173
175
|
/** Unrealized account PnL, represented as a decimal string. */
|
|
174
|
-
unrealizedPnl:
|
|
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:
|
|
189
|
+
portfolioValue: DecimalString
|
|
188
190
|
/** Margin currently available for new orders in USD. */
|
|
189
|
-
availableMargin:
|
|
191
|
+
availableMargin: DecimalString
|
|
190
192
|
/** Margin currently reserved by open positions/orders in USD. */
|
|
191
|
-
marginUsed:
|
|
193
|
+
marginUsed: DecimalString
|
|
192
194
|
/** Aggregate unrealized PnL in USD. */
|
|
193
|
-
unrealizedPnl:
|
|
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:
|
|
212
|
+
buy: DecimalString
|
|
211
213
|
/** Amount the account can still sell, represented as a decimal string. */
|
|
212
|
-
sell:
|
|
214
|
+
sell: DecimalString
|
|
213
215
|
}
|
|
214
216
|
|
|
215
217
|
/**
|
|
216
|
-
* The user's complete venue-side settings for one market: the margin
|
|
217
|
-
* and display leverage the next order on it will use.
|
|
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:
|
|
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:
|
|
280
|
-
price:
|
|
280
|
+
size: DecimalString
|
|
281
|
+
price: DecimalString
|
|
281
282
|
liquidity: LiquidityRole
|
|
282
|
-
filledSize?:
|
|
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?:
|
|
304
|
-
startPosition?:
|
|
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:
|
|
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:
|
|
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?:
|
|
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?:
|
|
406
|
+
liquidatedNotionalPosition?: DecimalString
|
|
406
407
|
/** Absent when the venue reports no account value at liquidation time. */
|
|
407
|
-
accountValue?:
|
|
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:
|
|
436
|
-
positionSize:
|
|
437
|
-
fundingRate:
|
|
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:
|
|
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:
|
|
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:
|
|
525
|
-
totalNtlPos:
|
|
526
|
-
totalRawUsd:
|
|
527
|
-
totalMarginUsed:
|
|
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:
|
|
543
|
-
withdrawable:
|
|
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?:
|
|
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`:
|
|
613
|
-
*
|
|
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:
|
|
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:
|
|
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:
|
|
661
|
-
unrealizedPnl:
|
|
673
|
+
walletBalance: DecimalString
|
|
674
|
+
unrealizedPnl: DecimalString
|
|
662
675
|
/** Total equity. */
|
|
663
|
-
marginBalance:
|
|
664
|
-
usedMargin:
|
|
676
|
+
marginBalance: DecimalString
|
|
677
|
+
usedMargin: DecimalString
|
|
665
678
|
/** Venue buying power. */
|
|
666
|
-
availableMargin:
|
|
679
|
+
availableMargin: DecimalString
|
|
667
680
|
/** Venue withdrawable figure, at or below {@link OndoAccountBalance.availableMargin}. */
|
|
668
|
-
withdrawableMargin:
|
|
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:
|
|
275
|
-
limitPrice?:
|
|
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?:
|
|
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?:
|
|
291
|
-
size?:
|
|
292
|
-
triggerPrice?:
|
|
293
|
-
limitPrice?:
|
|
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:
|
|
306
|
-
price?:
|
|
306
|
+
size: DecimalString
|
|
307
|
+
price?: DecimalString
|
|
307
308
|
leverage?: number
|
|
308
|
-
/**
|
|
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:
|
|
348
|
+
size: DecimalString
|
|
345
349
|
/** Total execution window in seconds. */
|
|
346
350
|
durationSeconds: number
|
|
347
351
|
reduceOnly?: boolean
|
|
348
|
-
/** Hyperliquid: randomize sub-order
|
|
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?:
|
|
357
|
+
minPrice?: DecimalString
|
|
354
358
|
/** Ondo: highest acceptable child-order price, as a decimal string. */
|
|
355
|
-
maxPrice?:
|
|
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
|
-
/**
|
|
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:
|
|
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:
|
|
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 (
|
|
455
|
-
amount:
|
|
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
|
|
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:
|
|
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?:
|
|
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