@nadohq/engine-client 0.1.0-alpha.8 → 0.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/EngineBaseClient.d.cts +2 -1
- package/dist/EngineBaseClient.d.ts +2 -1
- package/dist/EngineClient.d.cts +1 -0
- package/dist/EngineClient.d.ts +1 -0
- package/dist/EngineExecuteBuilder.cjs +9 -6
- package/dist/EngineExecuteBuilder.cjs.map +1 -1
- package/dist/EngineExecuteBuilder.d.cts +1 -0
- package/dist/EngineExecuteBuilder.d.ts +1 -0
- package/dist/EngineExecuteBuilder.js +9 -6
- package/dist/EngineExecuteBuilder.js.map +1 -1
- package/dist/EngineExecuteClient.cjs +6 -6
- package/dist/EngineExecuteClient.cjs.map +1 -1
- package/dist/EngineExecuteClient.d.cts +2 -1
- package/dist/EngineExecuteClient.d.ts +2 -1
- package/dist/EngineExecuteClient.js +6 -6
- package/dist/EngineExecuteClient.js.map +1 -1
- package/dist/EngineQueryClient.cjs +54 -11
- package/dist/EngineQueryClient.cjs.map +1 -1
- package/dist/EngineQueryClient.d.cts +19 -2
- package/dist/EngineQueryClient.d.ts +19 -2
- package/dist/EngineQueryClient.js +57 -12
- package/dist/EngineQueryClient.js.map +1 -1
- package/dist/EngineWebClient.d.cts +1 -0
- package/dist/EngineWebClient.d.ts +1 -0
- package/dist/endpoints.cjs +6 -6
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.js +6 -6
- package/dist/endpoints.js.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/clientExecuteTypes.cjs.map +1 -1
- package/dist/types/clientExecuteTypes.d.cts +8 -1
- package/dist/types/clientExecuteTypes.d.ts +8 -1
- package/dist/types/clientQueryTypes.cjs.map +1 -1
- package/dist/types/clientQueryTypes.d.cts +66 -33
- package/dist/types/clientQueryTypes.d.ts +66 -33
- package/dist/types/index.cjs +10 -10
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +6 -5
- package/dist/types/index.d.ts +6 -5
- package/dist/types/index.js +5 -5
- package/dist/types/index.js.map +1 -1
- package/dist/types/serverExecuteTypes.cjs.map +1 -1
- package/dist/types/serverExecuteTypes.d.cts +8 -1
- package/dist/types/serverExecuteTypes.d.ts +8 -1
- package/dist/types/serverQueryModelTypes.cjs.map +1 -1
- package/dist/types/serverQueryModelTypes.d.cts +24 -1
- package/dist/types/serverQueryModelTypes.d.ts +24 -1
- package/dist/types/serverQueryTypes.cjs +19 -0
- package/dist/types/serverQueryTypes.cjs.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +49 -23
- package/dist/types/serverQueryTypes.d.ts +49 -23
- package/dist/types/serverQueryTypes.js +12 -0
- package/dist/types/serverQueryTypes.js.map +1 -1
- package/dist/types/serverSubscriptionEventTypes.cjs.map +1 -1
- package/dist/types/serverSubscriptionEventTypes.d.cts +5 -0
- package/dist/types/serverSubscriptionEventTypes.d.ts +5 -0
- package/dist/types/serverSubscriptionTypes.cjs.map +1 -1
- package/dist/types/serverSubscriptionTypes.d.cts +4 -2
- package/dist/types/serverSubscriptionTypes.d.ts +4 -2
- package/dist/utils/index.d.cts +3 -2
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/queryDataMappers.cjs +95 -47
- package/dist/utils/queryDataMappers.cjs.map +1 -1
- package/dist/utils/queryDataMappers.d.cts +8 -5
- package/dist/utils/queryDataMappers.d.ts +8 -5
- package/dist/utils/queryDataMappers.js +94 -48
- package/dist/utils/queryDataMappers.js.map +1 -1
- package/package.json +13 -7
- package/src/EngineExecuteBuilder.ts +9 -6
- package/src/EngineExecuteClient.ts +7 -7
- package/src/EngineQueryClient.ts +73 -12
- package/src/endpoints.ts +6 -6
- package/src/index.ts +2 -2
- package/src/types/clientExecuteTypes.ts +9 -2
- package/src/types/clientQueryTypes.ts +76 -32
- package/src/types/index.ts +5 -5
- package/src/types/serverExecuteTypes.ts +9 -2
- package/src/types/serverQueryModelTypes.ts +25 -0
- package/src/types/serverQueryTypes.ts +74 -31
- package/src/types/serverSubscriptionEventTypes.ts +16 -20
- package/src/types/serverSubscriptionTypes.ts +4 -2
- package/src/utils/queryDataMappers.ts +115 -49
package/src/EngineQueryClient.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addDecimals,
|
|
3
|
-
BigDecimal,
|
|
4
3
|
encodeSignedOrder,
|
|
5
4
|
getOrderVerifyingAddress,
|
|
6
5
|
mapValues,
|
|
7
6
|
MarketWithProduct,
|
|
8
7
|
removeDecimals,
|
|
9
8
|
subaccountToHex,
|
|
10
|
-
|
|
9
|
+
toBigNumber,
|
|
11
10
|
toIntegerString,
|
|
12
11
|
} from '@nadohq/shared';
|
|
12
|
+
import BigNumber from 'bignumber.js';
|
|
13
13
|
import { EngineBaseClient } from './EngineBaseClient';
|
|
14
14
|
import {
|
|
15
15
|
EngineServerStatusResponse,
|
|
@@ -30,12 +30,17 @@ import {
|
|
|
30
30
|
GetEngineMarketPriceResponse,
|
|
31
31
|
GetEngineMarketPricesParams,
|
|
32
32
|
GetEngineMarketPricesResponse,
|
|
33
|
+
GetEngineMaxBurnNlpAmountParams,
|
|
34
|
+
GetEngineMaxBurnNlpAmountResponse,
|
|
33
35
|
GetEngineMaxMintNlpAmountParams,
|
|
34
36
|
GetEngineMaxMintNlpAmountResponse,
|
|
35
37
|
GetEngineMaxOrderSizeParams,
|
|
36
38
|
GetEngineMaxOrderSizeResponse,
|
|
37
39
|
GetEngineMaxWithdrawableParams,
|
|
38
40
|
GetEngineMaxWithdrawableResponse,
|
|
41
|
+
GetEngineNlpLockedBalancesParams,
|
|
42
|
+
GetEngineNlpLockedBalancesResponse,
|
|
43
|
+
GetEngineNlpPoolInfoResponse,
|
|
39
44
|
GetEngineOrderParams,
|
|
40
45
|
GetEngineOrderResponse,
|
|
41
46
|
GetEngineSubaccountFeeRatesParams,
|
|
@@ -56,6 +61,8 @@ import { mapProductEngineType } from './utils/productEngineTypeMappers';
|
|
|
56
61
|
import {
|
|
57
62
|
mapEngineMarketPrice,
|
|
58
63
|
mapEngineServerIsolatedPositions,
|
|
64
|
+
mapEngineServerNlpLockedBalances,
|
|
65
|
+
mapEngineServerNlpPoolInfo,
|
|
59
66
|
mapEngineServerOrder,
|
|
60
67
|
mapEngineServerPerpProduct,
|
|
61
68
|
mapEngineServerSpotProduct,
|
|
@@ -159,6 +166,9 @@ export class EngineQueryClient extends EngineBaseClient {
|
|
|
159
166
|
const baseResponse = await this.query('subaccount_info', {
|
|
160
167
|
subaccount: queryParams.subaccount,
|
|
161
168
|
txns: JSON.stringify(queryParams.txns),
|
|
169
|
+
// Backend expects string variants of booleans
|
|
170
|
+
pre_state:
|
|
171
|
+
params.preState !== undefined ? String(params.preState) : undefined,
|
|
162
172
|
});
|
|
163
173
|
|
|
164
174
|
return mapSubaccountSummary(baseResponse);
|
|
@@ -357,13 +367,13 @@ export class EngineQueryClient extends EngineBaseClient {
|
|
|
357
367
|
});
|
|
358
368
|
|
|
359
369
|
return {
|
|
360
|
-
healthCheckSequencerFee:
|
|
370
|
+
healthCheckSequencerFee: toBigNumber(
|
|
361
371
|
baseResponse.health_check_sequencer_fee,
|
|
362
372
|
),
|
|
363
|
-
liquidationSequencerFee:
|
|
373
|
+
liquidationSequencerFee: toBigNumber(
|
|
364
374
|
baseResponse.liquidation_sequencer_fee,
|
|
365
375
|
),
|
|
366
|
-
takerSequencerFee:
|
|
376
|
+
takerSequencerFee: toBigNumber(baseResponse.taker_sequencer_fee),
|
|
367
377
|
orders: baseResponse.taker_fee_rates_x18.reduce(
|
|
368
378
|
(acc, takerRateX18, currIndex) => {
|
|
369
379
|
acc[currIndex] = {
|
|
@@ -376,10 +386,10 @@ export class EngineQueryClient extends EngineBaseClient {
|
|
|
376
386
|
),
|
|
377
387
|
withdrawal: baseResponse.withdraw_sequencer_fees.reduce(
|
|
378
388
|
(acc, productFee, currIndex) => {
|
|
379
|
-
acc[currIndex] =
|
|
389
|
+
acc[currIndex] = toBigNumber(productFee);
|
|
380
390
|
return acc;
|
|
381
391
|
},
|
|
382
|
-
{} as Record<number,
|
|
392
|
+
{} as Record<number, BigNumber>,
|
|
383
393
|
),
|
|
384
394
|
feeTier: baseResponse.fee_tier,
|
|
385
395
|
};
|
|
@@ -445,12 +455,19 @@ export class EngineQueryClient extends EngineBaseClient {
|
|
|
445
455
|
subaccountOwner: params.subaccountOwner,
|
|
446
456
|
subaccountName: params.subaccountName,
|
|
447
457
|
}),
|
|
458
|
+
// Backend expects string variants of booleans
|
|
448
459
|
spot_leverage:
|
|
449
460
|
params.spotLeverage != null ? String(params.spotLeverage) : null,
|
|
450
461
|
reduce_only: params.reduceOnly != null ? String(params.reduceOnly) : null,
|
|
462
|
+
isolated: params.isolated != null ? String(params.isolated) : null,
|
|
463
|
+
borrow_margin:
|
|
464
|
+
// This field is only relevant for isolated orders
|
|
465
|
+
params.isolated && params.isoBorrowMargin != null
|
|
466
|
+
? String(params.isoBorrowMargin)
|
|
467
|
+
: null,
|
|
451
468
|
});
|
|
452
469
|
|
|
453
|
-
return
|
|
470
|
+
return toBigNumber(baseResponse.max_order_size);
|
|
454
471
|
}
|
|
455
472
|
|
|
456
473
|
/**
|
|
@@ -470,7 +487,7 @@ export class EngineQueryClient extends EngineBaseClient {
|
|
|
470
487
|
params.spotLeverage != null ? String(params.spotLeverage) : null,
|
|
471
488
|
});
|
|
472
489
|
|
|
473
|
-
return
|
|
490
|
+
return toBigNumber(baseResponse.max_withdrawable);
|
|
474
491
|
}
|
|
475
492
|
|
|
476
493
|
/**
|
|
@@ -490,7 +507,25 @@ export class EngineQueryClient extends EngineBaseClient {
|
|
|
490
507
|
params.spotLeverage != null ? String(params.spotLeverage) : null,
|
|
491
508
|
});
|
|
492
509
|
|
|
493
|
-
return
|
|
510
|
+
return toBigNumber(baseResponse.max_quote_amount);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Retrieves the max amount of NLP that can be burned.
|
|
515
|
+
*
|
|
516
|
+
* @param params
|
|
517
|
+
*/
|
|
518
|
+
async getMaxBurnNlpAmount(
|
|
519
|
+
params: GetEngineMaxBurnNlpAmountParams,
|
|
520
|
+
): Promise<GetEngineMaxBurnNlpAmountResponse> {
|
|
521
|
+
const baseResponse = await this.query('max_nlp_burnable', {
|
|
522
|
+
sender: subaccountToHex({
|
|
523
|
+
subaccountOwner: params.subaccountOwner,
|
|
524
|
+
subaccountName: params.subaccountName,
|
|
525
|
+
}),
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
return toBigNumber(baseResponse.max_nlp_amount);
|
|
494
529
|
}
|
|
495
530
|
|
|
496
531
|
/**
|
|
@@ -514,12 +549,38 @@ export class EngineQueryClient extends EngineBaseClient {
|
|
|
514
549
|
}
|
|
515
550
|
|
|
516
551
|
/**
|
|
517
|
-
* Gets the insurance funds in
|
|
552
|
+
* Gets the insurance funds in USDT.
|
|
518
553
|
* @returns
|
|
519
554
|
*/
|
|
520
555
|
public async getInsurance(): Promise<GetEngineInsuranceResponse> {
|
|
521
556
|
const baseResponse = await this.query('insurance', {});
|
|
522
557
|
|
|
523
|
-
return
|
|
558
|
+
return toBigNumber(baseResponse.insurance);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Retrieves the NLP locked and unlocked balances for a subaccount.
|
|
563
|
+
*
|
|
564
|
+
* @param params
|
|
565
|
+
*/
|
|
566
|
+
async getNlpLockedBalances(
|
|
567
|
+
params: GetEngineNlpLockedBalancesParams,
|
|
568
|
+
): Promise<GetEngineNlpLockedBalancesResponse> {
|
|
569
|
+
const baseResponse = await this.query('nlp_locked_balances', {
|
|
570
|
+
subaccount: subaccountToHex({
|
|
571
|
+
subaccountOwner: params.subaccountOwner,
|
|
572
|
+
subaccountName: params.subaccountName,
|
|
573
|
+
}),
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
return mapEngineServerNlpLockedBalances(baseResponse);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Retrieves information about all NLP sub-pools
|
|
581
|
+
*/
|
|
582
|
+
async getNlpPoolInfo(): Promise<GetEngineNlpPoolInfoResponse> {
|
|
583
|
+
const baseResponse = await this.query('nlp_pool_info', {});
|
|
584
|
+
return mapEngineServerNlpPoolInfo(baseResponse);
|
|
524
585
|
}
|
|
525
586
|
}
|
package/src/endpoints.ts
CHANGED
|
@@ -2,19 +2,19 @@ import { ChainEnv } from '@nadohq/shared';
|
|
|
2
2
|
|
|
3
3
|
export const ENGINE_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {
|
|
4
4
|
local: 'http://localhost:80',
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
inkTestnet: 'https://gateway.test.nado.xyz/v1',
|
|
6
|
+
inkMainnet: 'https://gateway.prod.nado.xyz/v1',
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export const ENGINE_WS_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {
|
|
10
10
|
local: 'ws://localhost:80',
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
inkTestnet: 'wss://gateway.test.nado.xyz/v1/ws',
|
|
12
|
+
inkMainnet: 'wss://gateway.prod.nado.xyz/v1/ws',
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export const ENGINE_WS_SUBSCRIPTION_CLIENT_ENDPOINTS: Record<ChainEnv, string> =
|
|
16
16
|
{
|
|
17
17
|
local: 'ws://localhost:80',
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
inkTestnet: 'wss://gateway.test.nado.xyz/v1/subscribe',
|
|
19
|
+
inkMainnet: 'wss://gateway.prod.nado.xyz/v1/subscribe',
|
|
20
20
|
};
|
package/src/index.ts
CHANGED
|
@@ -49,7 +49,7 @@ export type EnginePlaceOrderParams = WithBaseEngineExecuteParams<{
|
|
|
49
49
|
order: EngineOrderParams;
|
|
50
50
|
// If not given, engine defaults to true (leverage/borrow enabled)
|
|
51
51
|
spotLeverage?: boolean;
|
|
52
|
-
// For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative
|
|
52
|
+
// For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDT balance)
|
|
53
53
|
borrowMargin?: boolean;
|
|
54
54
|
}>;
|
|
55
55
|
|
|
@@ -84,7 +84,14 @@ export type EngineMintNlpParams = WithBaseEngineExecuteParams<
|
|
|
84
84
|
export type EngineBurnNlpParams =
|
|
85
85
|
WithBaseEngineExecuteParams<EIP712BurnNlpParams>;
|
|
86
86
|
|
|
87
|
-
export type EnginePlaceOrdersParams =
|
|
87
|
+
export type EnginePlaceOrdersParams = {
|
|
88
|
+
orders: EnginePlaceOrderParams[];
|
|
89
|
+
/**
|
|
90
|
+
* If `true`, aborts the batch after the first failed order; if `false`, remaining orders continue to execute.
|
|
91
|
+
* If not provided, the default value is `false`.
|
|
92
|
+
*/
|
|
93
|
+
stopOnFailure?: boolean;
|
|
94
|
+
};
|
|
88
95
|
|
|
89
96
|
export interface EngineExecuteRequestParamsByType {
|
|
90
97
|
burn_nlp: EngineBurnNlpParams;
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
BalanceHealthContributions,
|
|
3
3
|
BalanceSide,
|
|
4
4
|
BalanceWithProduct,
|
|
5
|
-
BigDecimal,
|
|
6
5
|
EIP712OrderParams,
|
|
7
6
|
HealthGroup,
|
|
8
7
|
HealthStatusByType,
|
|
@@ -14,16 +13,21 @@ import {
|
|
|
14
13
|
SpotBalanceWithProduct,
|
|
15
14
|
Subaccount,
|
|
16
15
|
} from '@nadohq/shared';
|
|
16
|
+
import BigNumber from 'bignumber.js';
|
|
17
17
|
import {
|
|
18
18
|
EngineServerNoncesParams,
|
|
19
19
|
EngineServerTimeResponse,
|
|
20
20
|
} from './serverQueryTypes';
|
|
21
21
|
|
|
22
|
-
export
|
|
22
|
+
export interface GetEngineSubaccountSummaryResponse extends SubaccountSummaryState {
|
|
23
23
|
exists: boolean;
|
|
24
|
+
preState?: SubaccountSummaryState;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SubaccountSummaryState {
|
|
24
28
|
balances: BalanceWithProduct[];
|
|
25
29
|
health: HealthStatusByType;
|
|
26
|
-
}
|
|
30
|
+
}
|
|
27
31
|
|
|
28
32
|
export type GetEngineSubaccountSummaryParams = Subaccount;
|
|
29
33
|
|
|
@@ -45,8 +49,8 @@ export type SubaccountTx = {
|
|
|
45
49
|
|
|
46
50
|
export interface SubaccountProductDeltaTx {
|
|
47
51
|
productId: number;
|
|
48
|
-
amountDelta:
|
|
49
|
-
vQuoteDelta:
|
|
52
|
+
amountDelta: BigNumber;
|
|
53
|
+
vQuoteDelta: BigNumber;
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
export interface GetEngineContractsResponse {
|
|
@@ -56,6 +60,7 @@ export interface GetEngineContractsResponse {
|
|
|
56
60
|
|
|
57
61
|
export type GetEngineEstimatedSubaccountSummaryParams = Subaccount & {
|
|
58
62
|
txs: SubaccountTx[];
|
|
63
|
+
preState?: boolean;
|
|
59
64
|
};
|
|
60
65
|
|
|
61
66
|
export type GetEngineNoncesParams = EngineServerNoncesParams;
|
|
@@ -79,15 +84,16 @@ export interface EngineSymbol {
|
|
|
79
84
|
type: ProductEngineType;
|
|
80
85
|
productId: number;
|
|
81
86
|
symbol: string;
|
|
82
|
-
priceIncrement:
|
|
83
|
-
sizeIncrement:
|
|
84
|
-
minSize:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
priceIncrement: BigNumber;
|
|
88
|
+
sizeIncrement: BigNumber;
|
|
89
|
+
minSize: BigNumber;
|
|
90
|
+
makerFeeRate: BigNumber;
|
|
91
|
+
takerFeeRate: BigNumber;
|
|
92
|
+
longWeightInitial: BigNumber;
|
|
93
|
+
longWeightMaintenance: BigNumber;
|
|
94
|
+
// undefined when there is no max open interest limit (always undefined for spot products)
|
|
95
|
+
maxOpenInterest: BigNumber | undefined;
|
|
96
|
+
isolatedOnly: boolean;
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
export type GetEngineAllMarketsResponse = MarketWithProduct[];
|
|
@@ -103,11 +109,11 @@ export interface GetEngineOrderParams {
|
|
|
103
109
|
|
|
104
110
|
export interface EngineOrder extends Subaccount {
|
|
105
111
|
productId: number;
|
|
106
|
-
price:
|
|
112
|
+
price: BigNumber;
|
|
107
113
|
// Amount initially requested
|
|
108
|
-
totalAmount:
|
|
114
|
+
totalAmount: BigNumber;
|
|
109
115
|
// Amount still unfilled
|
|
110
|
-
unfilledAmount:
|
|
116
|
+
unfilledAmount: BigNumber;
|
|
111
117
|
expiration: number;
|
|
112
118
|
nonce: string;
|
|
113
119
|
digest: string;
|
|
@@ -155,23 +161,23 @@ export interface GetEngineSubaccountProductOrdersResponse {
|
|
|
155
161
|
export type GetEngineSubaccountFeeRatesParams = Subaccount;
|
|
156
162
|
|
|
157
163
|
export interface SubaccountOrderFeeRates {
|
|
158
|
-
maker:
|
|
159
|
-
taker:
|
|
164
|
+
maker: BigNumber;
|
|
165
|
+
taker: BigNumber;
|
|
160
166
|
}
|
|
161
167
|
|
|
162
168
|
export interface GetEngineSubaccountFeeRatesResponse {
|
|
163
169
|
// By Product ID
|
|
164
170
|
orders: Record<number, SubaccountOrderFeeRates>;
|
|
165
|
-
withdrawal: Record<number,
|
|
166
|
-
liquidationSequencerFee:
|
|
167
|
-
healthCheckSequencerFee:
|
|
168
|
-
takerSequencerFee:
|
|
171
|
+
withdrawal: Record<number, BigNumber>;
|
|
172
|
+
liquidationSequencerFee: BigNumber;
|
|
173
|
+
healthCheckSequencerFee: BigNumber;
|
|
174
|
+
takerSequencerFee: BigNumber;
|
|
169
175
|
feeTier: number;
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
export interface EnginePriceTickLiquidity {
|
|
173
|
-
price:
|
|
174
|
-
liquidity:
|
|
179
|
+
price: BigNumber;
|
|
180
|
+
liquidity: BigNumber;
|
|
175
181
|
}
|
|
176
182
|
|
|
177
183
|
export interface GetEngineMarketLiquidityParams {
|
|
@@ -191,8 +197,8 @@ export interface GetEngineMarketPriceParams {
|
|
|
191
197
|
|
|
192
198
|
export interface EngineMarketPrice {
|
|
193
199
|
productId: number;
|
|
194
|
-
bid:
|
|
195
|
-
ask:
|
|
200
|
+
bid: BigNumber;
|
|
201
|
+
ask: BigNumber;
|
|
196
202
|
}
|
|
197
203
|
|
|
198
204
|
export type GetEngineMarketPriceResponse = EngineMarketPrice;
|
|
@@ -206,7 +212,7 @@ export interface GetEngineMarketPricesResponse {
|
|
|
206
212
|
}
|
|
207
213
|
|
|
208
214
|
export interface GetEngineMaxOrderSizeParams extends Subaccount {
|
|
209
|
-
price:
|
|
215
|
+
price: BigNumber;
|
|
210
216
|
productId: number;
|
|
211
217
|
// Note: When `reduceOnly` is true, `side` must be opposite of the current position, otherwise it returns 0.
|
|
212
218
|
side: BalanceSide;
|
|
@@ -216,9 +222,13 @@ export interface GetEngineMaxOrderSizeParams extends Subaccount {
|
|
|
216
222
|
// If not given, engine defaults to false. If true, the max order size will be capped to the subaccount's current position size;
|
|
217
223
|
// If no position exists, it will return 0.
|
|
218
224
|
reduceOnly?: boolean;
|
|
225
|
+
isolated?: boolean;
|
|
226
|
+
// If not given, engine defaults to true (do not borrow margin for isolated orders)
|
|
227
|
+
// Max order size query for `isolated` includes available transfer from the cross subaccount
|
|
228
|
+
isoBorrowMargin?: boolean;
|
|
219
229
|
}
|
|
220
230
|
|
|
221
|
-
export type GetEngineMaxOrderSizeResponse =
|
|
231
|
+
export type GetEngineMaxOrderSizeResponse = BigNumber;
|
|
222
232
|
|
|
223
233
|
export interface GetEngineMaxWithdrawableParams extends Subaccount {
|
|
224
234
|
productId: number;
|
|
@@ -226,7 +236,7 @@ export interface GetEngineMaxWithdrawableParams extends Subaccount {
|
|
|
226
236
|
spotLeverage?: boolean;
|
|
227
237
|
}
|
|
228
238
|
|
|
229
|
-
export type GetEngineMaxWithdrawableResponse =
|
|
239
|
+
export type GetEngineMaxWithdrawableResponse = BigNumber;
|
|
230
240
|
|
|
231
241
|
export type GetEngineTimeResponse = EngineServerTimeResponse;
|
|
232
242
|
|
|
@@ -236,7 +246,7 @@ export interface GetEngineLinkedSignerResponse {
|
|
|
236
246
|
signer: string;
|
|
237
247
|
}
|
|
238
248
|
|
|
239
|
-
export type GetEngineInsuranceResponse =
|
|
249
|
+
export type GetEngineInsuranceResponse = BigNumber;
|
|
240
250
|
|
|
241
251
|
/**
|
|
242
252
|
* Given an IP, backend will either:
|
|
@@ -251,4 +261,38 @@ export interface GetEngineMaxMintNlpAmountParams extends Subaccount {
|
|
|
251
261
|
spotLeverage?: boolean;
|
|
252
262
|
}
|
|
253
263
|
|
|
254
|
-
export type GetEngineMaxMintNlpAmountResponse =
|
|
264
|
+
export type GetEngineMaxMintNlpAmountResponse = BigNumber;
|
|
265
|
+
|
|
266
|
+
export type GetEngineMaxBurnNlpAmountParams = Subaccount;
|
|
267
|
+
|
|
268
|
+
export type GetEngineMaxBurnNlpAmountResponse = BigNumber;
|
|
269
|
+
|
|
270
|
+
export type GetEngineNlpLockedBalancesParams = Subaccount;
|
|
271
|
+
|
|
272
|
+
export interface EngineNlpBalance {
|
|
273
|
+
productId: number;
|
|
274
|
+
balance: BigNumber;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface EngineNlpLockedBalance extends EngineNlpBalance {
|
|
278
|
+
unlockedAt: number;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface GetEngineNlpLockedBalancesResponse {
|
|
282
|
+
lockedBalances: EngineNlpLockedBalance[];
|
|
283
|
+
balanceLocked: EngineNlpBalance;
|
|
284
|
+
balanceUnlocked: EngineNlpBalance;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface NlpPool {
|
|
288
|
+
poolId: number;
|
|
289
|
+
subaccountHex: string;
|
|
290
|
+
ownerAddress: string;
|
|
291
|
+
balanceWeight: BigNumber;
|
|
292
|
+
subaccountInfo: GetEngineSubaccountSummaryResponse;
|
|
293
|
+
openOrders: EngineOrder[];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface GetEngineNlpPoolInfoResponse {
|
|
297
|
+
nlpPools: NlpPool[];
|
|
298
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './clientQueryTypes';
|
|
2
1
|
export * from './clientExecuteTypes';
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
2
|
+
export * from './clientQueryTypes';
|
|
3
|
+
export * from './EngineServerFailureError';
|
|
5
4
|
export * from './serverExecuteTypes';
|
|
6
|
-
export * from './
|
|
5
|
+
export * from './serverQueryModelTypes';
|
|
6
|
+
export * from './serverQueryTypes';
|
|
7
7
|
export * from './serverSubscriptionEventTypes';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './serverSubscriptionTypes';
|
|
@@ -73,7 +73,7 @@ export interface EngineServerPlaceOrderParams {
|
|
|
73
73
|
signature: string;
|
|
74
74
|
// Engine defaults this to true
|
|
75
75
|
spot_leverage: boolean | null;
|
|
76
|
-
// For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative
|
|
76
|
+
// For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDT balance)
|
|
77
77
|
borrow_margin: boolean | null;
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -111,7 +111,14 @@ export interface EngineServerExecuteRequestByType {
|
|
|
111
111
|
liquidate_subaccount: SignedTx<EIP712LiquidateSubaccountValues>;
|
|
112
112
|
mint_nlp: WithSpotLeverage<SignedTx<EIP712MintNlpValues>>;
|
|
113
113
|
place_order: EngineServerPlaceOrderParams;
|
|
114
|
-
place_orders:
|
|
114
|
+
place_orders: {
|
|
115
|
+
orders: EngineServerPlaceOrderParams[];
|
|
116
|
+
/**
|
|
117
|
+
* If `true`, aborts the batch after the first failed order; if `false`, remaining orders continue to execute.
|
|
118
|
+
* If `null`, the default value is `false`.
|
|
119
|
+
*/
|
|
120
|
+
stop_on_failure: boolean | null;
|
|
121
|
+
};
|
|
115
122
|
transfer_quote: SignedTx<EIP712TransferQuoteValues>;
|
|
116
123
|
withdraw_collateral: WithSpotLeverage<
|
|
117
124
|
SignedTx<EIP712WithdrawCollateralValues>
|
|
@@ -81,3 +81,28 @@ export interface EngineServerPerpBalance {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export type EngineServerProductType = 'perp' | 'spot';
|
|
84
|
+
|
|
85
|
+
export interface EngineServerOrder {
|
|
86
|
+
product_id: number;
|
|
87
|
+
sender: string;
|
|
88
|
+
price_x18: string;
|
|
89
|
+
amount: string;
|
|
90
|
+
expiration: string;
|
|
91
|
+
nonce: string;
|
|
92
|
+
unfilled_amount: string;
|
|
93
|
+
digest: string;
|
|
94
|
+
placed_at: number;
|
|
95
|
+
order_type: string;
|
|
96
|
+
appendix: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface EngineServerNlpBalance {
|
|
100
|
+
product_id: number;
|
|
101
|
+
balance: {
|
|
102
|
+
amount: string;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export interface EngineServerNlpLockedBalance {
|
|
106
|
+
unlocked_at: number;
|
|
107
|
+
balance: EngineServerNlpBalance;
|
|
108
|
+
}
|