@nadohq/engine-client 0.1.0-alpha.2 → 0.1.0-alpha.20
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.cjs +8 -7
- package/dist/EngineBaseClient.cjs.map +1 -1
- package/dist/EngineBaseClient.d.cts +2 -3
- package/dist/EngineBaseClient.d.ts +2 -3
- package/dist/EngineBaseClient.js +7 -5
- package/dist/EngineBaseClient.js.map +1 -1
- package/dist/EngineClient.d.cts +1 -2
- package/dist/EngineClient.d.ts +1 -2
- package/dist/EngineExecuteBuilder.cjs +23 -51
- package/dist/EngineExecuteBuilder.cjs.map +1 -1
- package/dist/EngineExecuteBuilder.d.cts +6 -17
- package/dist/EngineExecuteBuilder.d.ts +6 -17
- package/dist/EngineExecuteBuilder.js +13 -41
- package/dist/EngineExecuteBuilder.js.map +1 -1
- package/dist/EngineExecuteClient.cjs +6 -10
- package/dist/EngineExecuteClient.cjs.map +1 -1
- package/dist/EngineExecuteClient.d.cts +3 -4
- package/dist/EngineExecuteClient.d.ts +3 -4
- package/dist/EngineExecuteClient.js +6 -10
- package/dist/EngineExecuteClient.js.map +1 -1
- package/dist/EngineQueryClient.cjs +62 -52
- package/dist/EngineQueryClient.cjs.map +1 -1
- package/dist/EngineQueryClient.d.cts +12 -11
- package/dist/EngineQueryClient.d.ts +12 -11
- package/dist/EngineQueryClient.js +41 -30
- package/dist/EngineQueryClient.js.map +1 -1
- package/dist/EngineWebClient.cjs +0 -2
- package/dist/EngineWebClient.cjs.map +1 -1
- package/dist/EngineWebClient.d.cts +1 -2
- package/dist/EngineWebClient.d.ts +1 -2
- package/dist/EngineWebClient.js +0 -2
- package/dist/EngineWebClient.js.map +1 -1
- package/dist/endpoints.cjs +6 -6
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.d.cts +1 -1
- package/dist/endpoints.d.ts +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 +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/EngineServerFailureError.cjs +1 -1
- package/dist/types/EngineServerFailureError.cjs.map +1 -1
- package/dist/types/EngineServerFailureError.d.cts +2 -2
- package/dist/types/EngineServerFailureError.d.ts +2 -2
- package/dist/types/EngineServerFailureError.js +1 -1
- package/dist/types/EngineServerFailureError.js.map +1 -1
- package/dist/types/clientExecuteTypes.cjs.map +1 -1
- package/dist/types/clientExecuteTypes.d.cts +4 -12
- package/dist/types/clientExecuteTypes.d.ts +4 -12
- package/dist/types/clientQueryTypes.cjs.map +1 -1
- package/dist/types/clientQueryTypes.d.cts +30 -23
- package/dist/types/clientQueryTypes.d.ts +30 -23
- package/dist/types/index.cjs +10 -10
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +8 -9
- package/dist/types/index.d.ts +8 -9
- 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 +6 -14
- package/dist/types/serverExecuteTypes.d.ts +6 -14
- package/dist/types/serverQueryModelTypes.cjs.map +1 -1
- package/dist/types/serverQueryModelTypes.d.cts +1 -1
- package/dist/types/serverQueryModelTypes.d.ts +1 -1
- package/dist/types/serverQueryTypes.cjs.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +33 -13
- package/dist/types/serverQueryTypes.d.ts +33 -13
- package/dist/types/serverSubscriptionEventTypes.cjs.map +1 -1
- package/dist/types/serverSubscriptionEventTypes.d.cts +87 -23
- package/dist/types/serverSubscriptionEventTypes.d.ts +87 -23
- package/dist/types/serverSubscriptionTypes.cjs.map +1 -1
- package/dist/types/serverSubscriptionTypes.d.cts +21 -4
- package/dist/types/serverSubscriptionTypes.d.ts +21 -4
- package/dist/utils/index.d.cts +3 -4
- package/dist/utils/index.d.ts +3 -4
- package/dist/utils/productEngineTypeMappers.cjs +5 -5
- package/dist/utils/productEngineTypeMappers.cjs.map +1 -1
- package/dist/utils/productEngineTypeMappers.d.cts +1 -1
- package/dist/utils/productEngineTypeMappers.d.ts +1 -1
- package/dist/utils/productEngineTypeMappers.js +1 -1
- package/dist/utils/productEngineTypeMappers.js.map +1 -1
- package/dist/utils/queryDataMappers.cjs +99 -90
- package/dist/utils/queryDataMappers.cjs.map +1 -1
- package/dist/utils/queryDataMappers.d.cts +5 -5
- package/dist/utils/queryDataMappers.d.ts +5 -5
- package/dist/utils/queryDataMappers.js +26 -19
- package/dist/utils/queryDataMappers.js.map +1 -1
- package/package.json +3 -4
- package/src/EngineBaseClient.ts +5 -3
- package/src/EngineExecuteBuilder.ts +14 -54
- package/src/EngineExecuteClient.ts +7 -15
- package/src/EngineQueryClient.ts +51 -31
- package/src/EngineWebClient.ts +0 -2
- package/src/endpoints.ts +4 -5
- package/src/index.ts +2 -2
- package/src/types/EngineServerFailureError.ts +2 -2
- package/src/types/clientExecuteTypes.ts +5 -17
- package/src/types/clientQueryTypes.ts +44 -32
- package/src/types/index.ts +5 -5
- package/src/types/serverExecuteTypes.ts +7 -18
- package/src/types/serverQueryModelTypes.ts +1 -1
- package/src/types/serverQueryTypes.ts +40 -16
- package/src/types/serverSubscriptionEventTypes.ts +131 -21
- package/src/types/serverSubscriptionTypes.ts +23 -3
- package/src/utils/productEngineTypeMappers.ts +1 -1
- package/src/utils/queryDataMappers.ts +33 -20
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface EngineServerOrderUpdateStreamParams {
|
|
2
|
-
|
|
2
|
+
/** when not provided, subscribes to all products */
|
|
3
|
+
product_id?: number;
|
|
3
4
|
subaccount: string;
|
|
4
5
|
}
|
|
5
6
|
interface EngineServerTradeStreamParams {
|
|
@@ -9,16 +10,29 @@ interface EngineServerBestBidOfferStreamParams {
|
|
|
9
10
|
product_id: number;
|
|
10
11
|
}
|
|
11
12
|
interface EngineServerFillStreamParams {
|
|
12
|
-
|
|
13
|
+
/** when not provided, subscribes to all products */
|
|
14
|
+
product_id?: number;
|
|
13
15
|
subaccount: string;
|
|
14
16
|
}
|
|
15
17
|
interface EngineServerPositionChangeStreamParams {
|
|
16
|
-
|
|
18
|
+
/** when not provided, subscribes to all products */
|
|
19
|
+
product_id?: number;
|
|
17
20
|
subaccount: string;
|
|
18
21
|
}
|
|
19
22
|
interface EngineServerBookDepthStreamParams {
|
|
20
23
|
product_id: number;
|
|
21
24
|
}
|
|
25
|
+
interface EngineServerLatestCandlestickStreamParams {
|
|
26
|
+
product_id: number;
|
|
27
|
+
granularity: number;
|
|
28
|
+
}
|
|
29
|
+
interface EngineServerLiquidationStreamParams {
|
|
30
|
+
/** when not provided, subscribes to all products */
|
|
31
|
+
product_id?: number;
|
|
32
|
+
}
|
|
33
|
+
interface EngineServerFundingPaymentStreamParams {
|
|
34
|
+
product_id: number;
|
|
35
|
+
}
|
|
22
36
|
/**
|
|
23
37
|
* Available subscription streams
|
|
24
38
|
*/
|
|
@@ -29,6 +43,9 @@ interface EngineServerSubscriptionStreamParamsByType {
|
|
|
29
43
|
fill: EngineServerFillStreamParams;
|
|
30
44
|
position_change: EngineServerPositionChangeStreamParams;
|
|
31
45
|
book_depth: EngineServerBookDepthStreamParams;
|
|
46
|
+
liquidation: EngineServerLiquidationStreamParams;
|
|
47
|
+
latest_candlestick: EngineServerLatestCandlestickStreamParams;
|
|
48
|
+
funding_payment: EngineServerFundingPaymentStreamParams;
|
|
32
49
|
}
|
|
33
50
|
type EngineServerSubscriptionStreamParamsType = keyof EngineServerSubscriptionStreamParamsByType;
|
|
34
51
|
/**
|
|
@@ -60,4 +77,4 @@ type EngineServerSubscriptionRequest<TRequestType extends EngineServerSubscripti
|
|
|
60
77
|
method: TRequestType;
|
|
61
78
|
} & EngineServerSubscriptionRequestByType[TRequestType];
|
|
62
79
|
|
|
63
|
-
export type { EngineServerBestBidOfferStreamParams, EngineServerBookDepthStreamParams, EngineServerFillStreamParams, EngineServerOrderUpdateStreamParams, EngineServerPositionChangeStreamParams, EngineServerSubscriptionParams, EngineServerSubscriptionRequest, EngineServerSubscriptionRequestByType, EngineServerSubscriptionRequestType, EngineServerSubscriptionStream, EngineServerSubscriptionStreamParamsByType, EngineServerSubscriptionStreamParamsType, EngineServerTradeStreamParams };
|
|
80
|
+
export type { EngineServerBestBidOfferStreamParams, EngineServerBookDepthStreamParams, EngineServerFillStreamParams, EngineServerFundingPaymentStreamParams, EngineServerLatestCandlestickStreamParams, EngineServerLiquidationStreamParams, EngineServerOrderUpdateStreamParams, EngineServerPositionChangeStreamParams, EngineServerSubscriptionParams, EngineServerSubscriptionRequest, EngineServerSubscriptionRequestByType, EngineServerSubscriptionRequestType, EngineServerSubscriptionStream, EngineServerSubscriptionStreamParamsByType, EngineServerSubscriptionStreamParamsType, EngineServerTradeStreamParams };
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.cjs';
|
|
2
|
-
import '@nadohq/
|
|
3
|
-
import '../types/clientQueryTypes.cjs';
|
|
4
|
-
import '@nadohq/utils';
|
|
1
|
+
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.cjs';
|
|
2
|
+
import '@nadohq/shared';
|
|
5
3
|
import '../types/serverQueryTypes.cjs';
|
|
6
4
|
import '../types/serverQueryModelTypes.cjs';
|
|
5
|
+
import '../types/clientQueryTypes.cjs';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.js';
|
|
2
|
-
import '@nadohq/
|
|
3
|
-
import '../types/clientQueryTypes.js';
|
|
4
|
-
import '@nadohq/utils';
|
|
1
|
+
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.js';
|
|
2
|
+
import '@nadohq/shared';
|
|
5
3
|
import '../types/serverQueryTypes.js';
|
|
6
4
|
import '../types/serverQueryModelTypes.js';
|
|
5
|
+
import '../types/clientQueryTypes.js';
|
|
@@ -24,21 +24,21 @@ __export(productEngineTypeMappers_exports, {
|
|
|
24
24
|
mapProductEngineType: () => mapProductEngineType
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(productEngineTypeMappers_exports);
|
|
27
|
-
var
|
|
27
|
+
var import_shared = require("@nadohq/shared");
|
|
28
28
|
function mapProductEngineType(productEngineType) {
|
|
29
29
|
switch (productEngineType) {
|
|
30
|
-
case
|
|
30
|
+
case import_shared.ProductEngineType.SPOT:
|
|
31
31
|
return "spot";
|
|
32
|
-
case
|
|
32
|
+
case import_shared.ProductEngineType.PERP:
|
|
33
33
|
return "perp";
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
function mapEngineServerProductType(productEngineServerType) {
|
|
37
37
|
switch (productEngineServerType) {
|
|
38
38
|
case "spot":
|
|
39
|
-
return
|
|
39
|
+
return import_shared.ProductEngineType.SPOT;
|
|
40
40
|
case "perp":
|
|
41
|
-
return
|
|
41
|
+
return import_shared.ProductEngineType.PERP;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/productEngineTypeMappers.ts"],"sourcesContent":["import { ProductEngineType } from '@nadohq/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/productEngineTypeMappers.ts"],"sourcesContent":["import { ProductEngineType } from '@nadohq/shared';\nimport { EngineServerProductType } from '../types';\n\nexport function mapProductEngineType(\n productEngineType: ProductEngineType,\n): EngineServerProductType {\n switch (productEngineType) {\n case ProductEngineType.SPOT:\n return 'spot';\n case ProductEngineType.PERP:\n return 'perp';\n }\n}\n\nexport function mapEngineServerProductType(\n productEngineServerType: EngineServerProductType,\n): ProductEngineType {\n switch (productEngineServerType) {\n case 'spot':\n return ProductEngineType.SPOT;\n case 'perp':\n return ProductEngineType.PERP;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAkC;AAG3B,SAAS,qBACd,mBACyB;AACzB,UAAQ,mBAAmB;AAAA,IACzB,KAAK,gCAAkB;AACrB,aAAO;AAAA,IACT,KAAK,gCAAkB;AACrB,aAAO;AAAA,EACX;AACF;AAEO,SAAS,2BACd,yBACmB;AACnB,UAAQ,yBAAyB;AAAA,IAC/B,KAAK;AACH,aAAO,gCAAkB;AAAA,IAC3B,KAAK;AACH,aAAO,gCAAkB;AAAA,EAC7B;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductEngineType } from '@nadohq/
|
|
1
|
+
import { ProductEngineType } from '@nadohq/shared';
|
|
2
2
|
import { EngineServerProductType } from '../types/serverQueryModelTypes.cjs';
|
|
3
3
|
|
|
4
4
|
declare function mapProductEngineType(productEngineType: ProductEngineType): EngineServerProductType;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductEngineType } from '@nadohq/
|
|
1
|
+
import { ProductEngineType } from '@nadohq/shared';
|
|
2
2
|
import { EngineServerProductType } from '../types/serverQueryModelTypes.js';
|
|
3
3
|
|
|
4
4
|
declare function mapProductEngineType(productEngineType: ProductEngineType): EngineServerProductType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/productEngineTypeMappers.ts"],"sourcesContent":["import { ProductEngineType } from '@nadohq/
|
|
1
|
+
{"version":3,"sources":["../../src/utils/productEngineTypeMappers.ts"],"sourcesContent":["import { ProductEngineType } from '@nadohq/shared';\nimport { EngineServerProductType } from '../types';\n\nexport function mapProductEngineType(\n productEngineType: ProductEngineType,\n): EngineServerProductType {\n switch (productEngineType) {\n case ProductEngineType.SPOT:\n return 'spot';\n case ProductEngineType.PERP:\n return 'perp';\n }\n}\n\nexport function mapEngineServerProductType(\n productEngineServerType: EngineServerProductType,\n): ProductEngineType {\n switch (productEngineServerType) {\n case 'spot':\n return ProductEngineType.SPOT;\n case 'perp':\n return ProductEngineType.PERP;\n }\n}\n"],"mappings":";AAAA,SAAS,yBAAyB;AAG3B,SAAS,qBACd,mBACyB;AACzB,UAAQ,mBAAmB;AAAA,IACzB,KAAK,kBAAkB;AACrB,aAAO;AAAA,IACT,KAAK,kBAAkB;AACrB,aAAO;AAAA,EACX;AACF;AAEO,SAAS,2BACd,yBACmB;AACnB,UAAQ,yBAAyB;AAAA,IAC/B,KAAK;AACH,aAAO,kBAAkB;AAAA,IAC3B,KAAK;AACH,aAAO,kBAAkB;AAAA,EAC7B;AACF;","names":[]}
|
|
@@ -23,6 +23,7 @@ __export(queryDataMappers_exports, {
|
|
|
23
23
|
mapEngineMarketPrice: () => mapEngineMarketPrice,
|
|
24
24
|
mapEngineServerBalanceHealthContributions: () => mapEngineServerBalanceHealthContributions,
|
|
25
25
|
mapEngineServerIsolatedPositions: () => mapEngineServerIsolatedPositions,
|
|
26
|
+
mapEngineServerNlpLockedBalances: () => mapEngineServerNlpLockedBalances,
|
|
26
27
|
mapEngineServerOrder: () => mapEngineServerOrder,
|
|
27
28
|
mapEngineServerPerpProduct: () => mapEngineServerPerpProduct,
|
|
28
29
|
mapEngineServerSpotProduct: () => mapEngineServerSpotProduct,
|
|
@@ -32,73 +33,62 @@ __export(queryDataMappers_exports, {
|
|
|
32
33
|
mapSubaccountSummary: () => mapSubaccountSummary
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(queryDataMappers_exports);
|
|
35
|
-
var
|
|
36
|
-
var import_utils = require("@nadohq/utils");
|
|
36
|
+
var import_shared = require("@nadohq/shared");
|
|
37
37
|
var import_productEngineTypeMappers = require("./productEngineTypeMappers.cjs");
|
|
38
38
|
function mapEngineServerTickLiquidity(tick) {
|
|
39
39
|
return {
|
|
40
|
-
price: (0,
|
|
41
|
-
liquidity: (0,
|
|
40
|
+
price: (0, import_shared.removeDecimals)(tick[0]),
|
|
41
|
+
liquidity: (0, import_shared.toBigDecimal)(tick[1])
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
function mapEngineServerOrder(order) {
|
|
45
|
-
const subaccount = (0,
|
|
45
|
+
const subaccount = (0, import_shared.subaccountFromHex)(order.sender);
|
|
46
46
|
return {
|
|
47
47
|
digest: order.digest,
|
|
48
|
-
expiration: (
|
|
48
|
+
expiration: Number(order.expiration),
|
|
49
49
|
nonce: order.nonce,
|
|
50
|
-
price: (0,
|
|
50
|
+
price: (0, import_shared.removeDecimals)(order.price_x18),
|
|
51
51
|
productId: order.product_id,
|
|
52
52
|
subaccountOwner: subaccount.subaccountOwner,
|
|
53
53
|
subaccountName: subaccount.subaccountName,
|
|
54
|
-
totalAmount: (0,
|
|
55
|
-
unfilledAmount: (0,
|
|
56
|
-
margin: order.margin ? (0, import_utils.toBigDecimal)(order.margin) : null,
|
|
57
|
-
// Standardizes from hex
|
|
58
|
-
// toFixed is required as toString gives values with `e`
|
|
59
|
-
orderParams: {
|
|
60
|
-
amount: (0, import_utils.toIntegerString)(order.amount),
|
|
61
|
-
expiration: (0, import_utils.toIntegerString)(order.expiration),
|
|
62
|
-
nonce: order.nonce,
|
|
63
|
-
price: (0, import_utils.toIntegerString)((0, import_utils.removeDecimals)(order.price_x18)),
|
|
64
|
-
subaccountOwner: subaccount.subaccountOwner,
|
|
65
|
-
subaccountName: subaccount.subaccountName
|
|
66
|
-
},
|
|
54
|
+
totalAmount: (0, import_shared.toBigDecimal)(order.amount),
|
|
55
|
+
unfilledAmount: (0, import_shared.toBigDecimal)(order.unfilled_amount),
|
|
67
56
|
placementTime: order.placed_at,
|
|
68
|
-
|
|
57
|
+
appendix: (0, import_shared.unpackOrderAppendix)(order.appendix)
|
|
69
58
|
};
|
|
70
59
|
}
|
|
71
60
|
function mapEngineServerSpotProduct(product) {
|
|
72
61
|
return {
|
|
73
|
-
type:
|
|
62
|
+
type: import_shared.ProductEngineType.SPOT,
|
|
74
63
|
productId: product.product_id,
|
|
75
|
-
minSize: (0,
|
|
76
|
-
priceIncrement: (0,
|
|
77
|
-
sizeIncrement: (0,
|
|
64
|
+
minSize: (0, import_shared.toBigDecimal)(product.book_info.min_size),
|
|
65
|
+
priceIncrement: (0, import_shared.removeDecimals)(product.book_info.price_increment_x18),
|
|
66
|
+
sizeIncrement: (0, import_shared.toBigDecimal)(product.book_info.size_increment),
|
|
78
67
|
product: {
|
|
79
68
|
productId: product.product_id,
|
|
80
|
-
type:
|
|
81
|
-
totalBorrowed: (0,
|
|
69
|
+
type: import_shared.ProductEngineType.SPOT,
|
|
70
|
+
totalBorrowed: (0, import_shared.calcTotalBorrowed)(
|
|
82
71
|
product.state.total_borrows_normalized,
|
|
83
72
|
product.state.cumulative_borrows_multiplier_x18
|
|
84
73
|
),
|
|
85
|
-
totalDeposited: (0,
|
|
74
|
+
totalDeposited: (0, import_shared.calcTotalDeposited)(
|
|
86
75
|
product.state.total_deposits_normalized,
|
|
87
76
|
product.state.cumulative_deposits_multiplier_x18
|
|
88
77
|
),
|
|
89
|
-
oraclePrice: (0,
|
|
90
|
-
interestFloor: (0,
|
|
91
|
-
interestInflectionUtil: (0,
|
|
78
|
+
oraclePrice: (0, import_shared.removeDecimals)(product.oracle_price_x18),
|
|
79
|
+
interestFloor: (0, import_shared.removeDecimals)(product.config.interest_floor_x18),
|
|
80
|
+
interestInflectionUtil: (0, import_shared.removeDecimals)(
|
|
92
81
|
product.config.interest_inflection_util_x18
|
|
93
82
|
),
|
|
94
|
-
interestLargeCap: (0,
|
|
95
|
-
interestSmallCap: (0,
|
|
96
|
-
|
|
97
|
-
|
|
83
|
+
interestLargeCap: (0, import_shared.removeDecimals)(product.config.interest_large_cap_x18),
|
|
84
|
+
interestSmallCap: (0, import_shared.removeDecimals)(product.config.interest_small_cap_x18),
|
|
85
|
+
minDepositRate: (0, import_shared.removeDecimals)(product.config.min_deposit_rate_x18),
|
|
86
|
+
longWeightInitial: (0, import_shared.removeDecimals)(product.risk.long_weight_initial_x18),
|
|
87
|
+
longWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
98
88
|
product.risk.long_weight_maintenance_x18
|
|
99
89
|
),
|
|
100
|
-
shortWeightInitial: (0,
|
|
101
|
-
shortWeightMaintenance: (0,
|
|
90
|
+
shortWeightInitial: (0, import_shared.removeDecimals)(product.risk.short_weight_initial_x18),
|
|
91
|
+
shortWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
102
92
|
product.risk.short_weight_maintenance_x18
|
|
103
93
|
),
|
|
104
94
|
tokenAddr: product.config.token
|
|
@@ -107,28 +97,28 @@ function mapEngineServerSpotProduct(product) {
|
|
|
107
97
|
}
|
|
108
98
|
function mapEngineServerPerpProduct(product) {
|
|
109
99
|
return {
|
|
110
|
-
type:
|
|
100
|
+
type: import_shared.ProductEngineType.PERP,
|
|
111
101
|
productId: product.product_id,
|
|
112
|
-
minSize: (0,
|
|
113
|
-
priceIncrement: (0,
|
|
114
|
-
sizeIncrement: (0,
|
|
102
|
+
minSize: (0, import_shared.toBigDecimal)(product.book_info.min_size),
|
|
103
|
+
priceIncrement: (0, import_shared.removeDecimals)(product.book_info.price_increment_x18),
|
|
104
|
+
sizeIncrement: (0, import_shared.toBigDecimal)(product.book_info.size_increment),
|
|
115
105
|
product: {
|
|
116
106
|
productId: product.product_id,
|
|
117
|
-
type:
|
|
118
|
-
oraclePrice: (0,
|
|
119
|
-
longWeightInitial: (0,
|
|
120
|
-
longWeightMaintenance: (0,
|
|
107
|
+
type: import_shared.ProductEngineType.PERP,
|
|
108
|
+
oraclePrice: (0, import_shared.removeDecimals)(product.oracle_price_x18),
|
|
109
|
+
longWeightInitial: (0, import_shared.removeDecimals)(product.risk.long_weight_initial_x18),
|
|
110
|
+
longWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
121
111
|
product.risk.long_weight_maintenance_x18
|
|
122
112
|
),
|
|
123
|
-
shortWeightInitial: (0,
|
|
124
|
-
shortWeightMaintenance: (0,
|
|
113
|
+
shortWeightInitial: (0, import_shared.removeDecimals)(product.risk.short_weight_initial_x18),
|
|
114
|
+
shortWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
125
115
|
product.risk.short_weight_maintenance_x18
|
|
126
116
|
),
|
|
127
|
-
openInterest: (0,
|
|
128
|
-
cumulativeFundingLong: (0,
|
|
117
|
+
openInterest: (0, import_shared.toBigDecimal)(product.state.open_interest),
|
|
118
|
+
cumulativeFundingLong: (0, import_shared.removeDecimals)(
|
|
129
119
|
product.state.cumulative_funding_long_x18
|
|
130
120
|
),
|
|
131
|
-
cumulativeFundingShort: (0,
|
|
121
|
+
cumulativeFundingShort: (0, import_shared.removeDecimals)(
|
|
132
122
|
product.state.cumulative_funding_short_x18
|
|
133
123
|
)
|
|
134
124
|
}
|
|
@@ -136,9 +126,9 @@ function mapEngineServerPerpProduct(product) {
|
|
|
136
126
|
}
|
|
137
127
|
function mapEngineServerBalanceHealthContributions(healthContributionsForBalance) {
|
|
138
128
|
return {
|
|
139
|
-
initial: (0,
|
|
140
|
-
maintenance: (0,
|
|
141
|
-
unweighted: (0,
|
|
129
|
+
initial: (0, import_shared.toBigDecimal)(healthContributionsForBalance[0]),
|
|
130
|
+
maintenance: (0, import_shared.toBigDecimal)(healthContributionsForBalance[1]),
|
|
131
|
+
unweighted: (0, import_shared.toBigDecimal)(healthContributionsForBalance[2])
|
|
142
132
|
};
|
|
143
133
|
}
|
|
144
134
|
function mapSubaccountSummary(baseResponse) {
|
|
@@ -151,7 +141,7 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
151
141
|
throw Error(`Could not find product ${spotBalance.product_id}`);
|
|
152
142
|
}
|
|
153
143
|
balances.push({
|
|
154
|
-
amount: (0,
|
|
144
|
+
amount: (0, import_shared.toBigDecimal)(spotBalance.balance.amount),
|
|
155
145
|
healthContributions: mapEngineServerBalanceHealthContributions(
|
|
156
146
|
baseResponse.health_contributions[spotBalance.product_id]
|
|
157
147
|
),
|
|
@@ -166,8 +156,8 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
166
156
|
throw Error(`Could not find product ${perpBalance.product_id}`);
|
|
167
157
|
}
|
|
168
158
|
balances.push({
|
|
169
|
-
amount: (0,
|
|
170
|
-
vQuoteBalance: (0,
|
|
159
|
+
amount: (0, import_shared.toBigDecimal)(perpBalance.balance.amount),
|
|
160
|
+
vQuoteBalance: (0, import_shared.toBigDecimal)(perpBalance.balance.v_quote_balance),
|
|
171
161
|
healthContributions: mapEngineServerBalanceHealthContributions(
|
|
172
162
|
baseResponse.health_contributions[perpBalance.product_id]
|
|
173
163
|
),
|
|
@@ -179,19 +169,19 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
179
169
|
exists: baseResponse.exists,
|
|
180
170
|
health: {
|
|
181
171
|
initial: {
|
|
182
|
-
health: (0,
|
|
183
|
-
assets: (0,
|
|
184
|
-
liabilities: (0,
|
|
172
|
+
health: (0, import_shared.toBigDecimal)(baseResponse.healths[0].health),
|
|
173
|
+
assets: (0, import_shared.toBigDecimal)(baseResponse.healths[0].assets),
|
|
174
|
+
liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[0].liabilities)
|
|
185
175
|
},
|
|
186
176
|
maintenance: {
|
|
187
|
-
health: (0,
|
|
188
|
-
assets: (0,
|
|
189
|
-
liabilities: (0,
|
|
177
|
+
health: (0, import_shared.toBigDecimal)(baseResponse.healths[1].health),
|
|
178
|
+
assets: (0, import_shared.toBigDecimal)(baseResponse.healths[1].assets),
|
|
179
|
+
liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[1].liabilities)
|
|
190
180
|
},
|
|
191
181
|
unweighted: {
|
|
192
|
-
health: (0,
|
|
193
|
-
assets: (0,
|
|
194
|
-
liabilities: (0,
|
|
182
|
+
health: (0, import_shared.toBigDecimal)(baseResponse.healths[2].health),
|
|
183
|
+
assets: (0, import_shared.toBigDecimal)(baseResponse.healths[2].assets),
|
|
184
|
+
liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[2].liabilities)
|
|
195
185
|
}
|
|
196
186
|
}
|
|
197
187
|
};
|
|
@@ -201,29 +191,29 @@ function mapEngineServerIsolatedPositions(baseResponse) {
|
|
|
201
191
|
const perpBalance = position.base_balance;
|
|
202
192
|
const quoteBalance = position.quote_balance;
|
|
203
193
|
return {
|
|
204
|
-
subaccount: (0,
|
|
194
|
+
subaccount: (0, import_shared.subaccountFromHex)(position.subaccount),
|
|
205
195
|
healths: {
|
|
206
|
-
initial: (0,
|
|
207
|
-
maintenance: (0,
|
|
208
|
-
unweighted: (0,
|
|
196
|
+
initial: (0, import_shared.toBigDecimal)(position.healths[0].health),
|
|
197
|
+
maintenance: (0, import_shared.toBigDecimal)(position.healths[1].health),
|
|
198
|
+
unweighted: (0, import_shared.toBigDecimal)(position.healths[2].health)
|
|
209
199
|
},
|
|
210
200
|
baseBalance: {
|
|
211
|
-
amount: (0,
|
|
212
|
-
vQuoteBalance: (0,
|
|
201
|
+
amount: (0, import_shared.toBigDecimal)(perpBalance.balance.amount),
|
|
202
|
+
vQuoteBalance: (0, import_shared.toBigDecimal)(perpBalance.balance.v_quote_balance),
|
|
213
203
|
// Health contributions === healths for an isolated position
|
|
214
204
|
healthContributions: {
|
|
215
|
-
initial: (0,
|
|
216
|
-
maintenance: (0,
|
|
217
|
-
unweighted: (0,
|
|
205
|
+
initial: (0, import_shared.toBigDecimal)(position.base_healths[0]),
|
|
206
|
+
maintenance: (0, import_shared.toBigDecimal)(position.base_healths[1]),
|
|
207
|
+
unweighted: (0, import_shared.toBigDecimal)(position.base_healths[2])
|
|
218
208
|
},
|
|
219
209
|
...mapEngineServerPerpProduct(position.base_product).product
|
|
220
210
|
},
|
|
221
211
|
quoteBalance: {
|
|
222
|
-
amount: (0,
|
|
212
|
+
amount: (0, import_shared.toBigDecimal)(quoteBalance.balance.amount),
|
|
223
213
|
healthContributions: {
|
|
224
|
-
initial: (0,
|
|
225
|
-
maintenance: (0,
|
|
226
|
-
unweighted: (0,
|
|
214
|
+
initial: (0, import_shared.toBigDecimal)(position.quote_healths[0]),
|
|
215
|
+
maintenance: (0, import_shared.toBigDecimal)(position.quote_healths[1]),
|
|
216
|
+
unweighted: (0, import_shared.toBigDecimal)(position.quote_healths[2])
|
|
227
217
|
},
|
|
228
218
|
...mapEngineServerSpotProduct(position.quote_product).product
|
|
229
219
|
}
|
|
@@ -231,7 +221,7 @@ function mapEngineServerIsolatedPositions(baseResponse) {
|
|
|
231
221
|
});
|
|
232
222
|
}
|
|
233
223
|
function mapEngineServerSymbols(baseResponse) {
|
|
234
|
-
const symbols = (0,
|
|
224
|
+
const symbols = (0, import_shared.mapValues)(
|
|
235
225
|
baseResponse.symbols,
|
|
236
226
|
mapEngineServerSymbol
|
|
237
227
|
);
|
|
@@ -244,33 +234,52 @@ function mapEngineServerSymbol(engineServerSymbol) {
|
|
|
244
234
|
type: (0, import_productEngineTypeMappers.mapEngineServerProductType)(engineServerSymbol.type),
|
|
245
235
|
productId: engineServerSymbol.product_id,
|
|
246
236
|
symbol: engineServerSymbol.symbol,
|
|
247
|
-
priceIncrement: (0,
|
|
248
|
-
sizeIncrement: (0,
|
|
249
|
-
minSize: (0,
|
|
250
|
-
minDepth: (0,
|
|
251
|
-
maxSpreadRate: (0,
|
|
252
|
-
makerFeeRate: (0,
|
|
253
|
-
takerFeeRate: (0,
|
|
254
|
-
longWeightInitial: (0,
|
|
237
|
+
priceIncrement: (0, import_shared.removeDecimals)(engineServerSymbol.price_increment_x18),
|
|
238
|
+
sizeIncrement: (0, import_shared.toBigDecimal)(engineServerSymbol.size_increment),
|
|
239
|
+
minSize: (0, import_shared.toBigDecimal)(engineServerSymbol.min_size),
|
|
240
|
+
minDepth: (0, import_shared.removeDecimals)(engineServerSymbol.min_depth_x18),
|
|
241
|
+
maxSpreadRate: (0, import_shared.removeDecimals)(engineServerSymbol.max_spread_rate_x18),
|
|
242
|
+
makerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.maker_fee_rate_x18),
|
|
243
|
+
takerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.taker_fee_rate_x18),
|
|
244
|
+
longWeightInitial: (0, import_shared.removeDecimals)(
|
|
255
245
|
engineServerSymbol.long_weight_initial_x18
|
|
256
246
|
),
|
|
257
|
-
longWeightMaintenance: (0,
|
|
247
|
+
longWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
258
248
|
engineServerSymbol.long_weight_maintenance_x18
|
|
259
249
|
)
|
|
260
250
|
};
|
|
261
251
|
}
|
|
262
252
|
function mapEngineMarketPrice(baseResponse) {
|
|
263
253
|
return {
|
|
264
|
-
ask: (0,
|
|
265
|
-
bid: (0,
|
|
254
|
+
ask: (0, import_shared.removeDecimals)(baseResponse.ask_x18),
|
|
255
|
+
bid: (0, import_shared.removeDecimals)(baseResponse.bid_x18),
|
|
266
256
|
productId: baseResponse.product_id
|
|
267
257
|
};
|
|
268
258
|
}
|
|
259
|
+
function mapEngineServerNlpLockedBalances(baseResponse) {
|
|
260
|
+
const lockedBalances = baseResponse.locked_balances.map((lockedBalance) => ({
|
|
261
|
+
productId: lockedBalance.product_id,
|
|
262
|
+
balance: (0, import_shared.toBigDecimal)(lockedBalance.balance.amount),
|
|
263
|
+
unlockedAt: lockedBalance.unlocked_at
|
|
264
|
+
}));
|
|
265
|
+
return {
|
|
266
|
+
lockedBalances,
|
|
267
|
+
balanceLocked: {
|
|
268
|
+
productId: baseResponse.balance_locked.product_id,
|
|
269
|
+
balance: (0, import_shared.toBigDecimal)(baseResponse.balance_locked.balance.amount)
|
|
270
|
+
},
|
|
271
|
+
balanceUnlocked: {
|
|
272
|
+
productId: baseResponse.balance_unlocked.product_id,
|
|
273
|
+
balance: (0, import_shared.toBigDecimal)(baseResponse.balance_unlocked.balance.amount)
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
269
277
|
// Annotate the CommonJS export names for ESM import in node:
|
|
270
278
|
0 && (module.exports = {
|
|
271
279
|
mapEngineMarketPrice,
|
|
272
280
|
mapEngineServerBalanceHealthContributions,
|
|
273
281
|
mapEngineServerIsolatedPositions,
|
|
282
|
+
mapEngineServerNlpLockedBalances,
|
|
274
283
|
mapEngineServerOrder,
|
|
275
284
|
mapEngineServerPerpProduct,
|
|
276
285
|
mapEngineServerSpotProduct,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/queryDataMappers.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n calcTotalBorrowed,\n calcTotalDeposited,\n OrderExpirationType,\n PerpMarket,\n ProductEngineType,\n SpotMarket,\n subaccountFromHex,\n} from '@nadohq/contracts';\nimport {\n mapValues,\n removeDecimals,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/utils';\nimport {\n EngineMarketPrice,\n EngineOrder,\n EnginePriceTickLiquidity,\n EngineServerIsolatedPositionsResponse,\n EngineServerMarketPrice,\n EngineServerOrderResponse,\n EngineServerPerpProduct,\n EngineServerPriceTickLiquidity,\n EngineServerSpotProduct,\n EngineServerSubaccountInfoResponse,\n EngineServerSymbol,\n EngineServerSymbolsResponse,\n EngineSymbol,\n EngineSymbolsResponse,\n GetEngineIsolatedPositionsResponse,\n GetEngineSubaccountSummaryResponse,\n} from '../types';\nimport { mapEngineServerProductType } from './productEngineTypeMappers';\n\nexport function mapEngineServerTickLiquidity(\n tick: EngineServerPriceTickLiquidity,\n): EnginePriceTickLiquidity {\n return {\n price: removeDecimals(tick[0]),\n liquidity: toBigDecimal(tick[1]),\n };\n}\n\nexport function mapEngineServerOrder(\n order: EngineServerOrderResponse,\n): EngineOrder {\n const subaccount = subaccountFromHex(order.sender);\n return {\n digest: order.digest,\n expiration: toBigDecimal(order.expiration),\n nonce: order.nonce,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n totalAmount: toBigDecimal(order.amount),\n unfilledAmount: toBigDecimal(order.unfilled_amount),\n margin: order.margin ? toBigDecimal(order.margin) : null,\n // Standardizes from hex\n // toFixed is required as toString gives values with `e`\n orderParams: {\n amount: toIntegerString(order.amount),\n expiration: toIntegerString(order.expiration),\n nonce: order.nonce,\n price: toIntegerString(removeDecimals(order.price_x18)),\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n },\n placementTime: order.placed_at,\n orderType: order.order_type as OrderExpirationType,\n };\n}\n\nexport function mapEngineServerSpotProduct(\n product: EngineServerSpotProduct,\n): SpotMarket {\n return {\n type: ProductEngineType.SPOT,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.SPOT,\n totalBorrowed: calcTotalBorrowed(\n product.state.total_borrows_normalized,\n product.state.cumulative_borrows_multiplier_x18,\n ),\n totalDeposited: calcTotalDeposited(\n product.state.total_deposits_normalized,\n product.state.cumulative_deposits_multiplier_x18,\n ),\n oraclePrice: removeDecimals(product.oracle_price_x18),\n interestFloor: removeDecimals(product.config.interest_floor_x18),\n interestInflectionUtil: removeDecimals(\n product.config.interest_inflection_util_x18,\n ),\n interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),\n interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n tokenAddr: product.config.token,\n },\n };\n}\n\nexport function mapEngineServerPerpProduct(\n product: EngineServerPerpProduct,\n): PerpMarket {\n return {\n type: ProductEngineType.PERP,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.PERP,\n oraclePrice: removeDecimals(product.oracle_price_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n openInterest: toBigDecimal(product.state.open_interest),\n cumulativeFundingLong: removeDecimals(\n product.state.cumulative_funding_long_x18,\n ),\n cumulativeFundingShort: removeDecimals(\n product.state.cumulative_funding_short_x18,\n ),\n },\n };\n}\n\nexport function mapEngineServerBalanceHealthContributions(\n healthContributionsForBalance: string[],\n): BalanceHealthContributions {\n return {\n initial: toBigDecimal(healthContributionsForBalance[0]),\n maintenance: toBigDecimal(healthContributionsForBalance[1]),\n unweighted: toBigDecimal(healthContributionsForBalance[2]),\n };\n}\n\nexport function mapSubaccountSummary(\n baseResponse: EngineServerSubaccountInfoResponse,\n): GetEngineSubaccountSummaryResponse {\n const balances: GetEngineSubaccountSummaryResponse['balances'] = [];\n\n baseResponse.spot_balances.forEach((spotBalance) => {\n const product = baseResponse.spot_products.find(\n (product) => product.product_id === spotBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${spotBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(spotBalance.balance.amount),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[spotBalance.product_id],\n ),\n ...mapEngineServerSpotProduct(product).product,\n });\n });\n\n baseResponse.perp_balances.forEach((perpBalance) => {\n const product = baseResponse.perp_products.find(\n (product) => product.product_id === perpBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${perpBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[perpBalance.product_id],\n ),\n ...mapEngineServerPerpProduct(product).product,\n });\n });\n\n return {\n balances: balances,\n exists: baseResponse.exists,\n health: {\n initial: {\n health: toBigDecimal(baseResponse.healths[0].health),\n assets: toBigDecimal(baseResponse.healths[0].assets),\n liabilities: toBigDecimal(baseResponse.healths[0].liabilities),\n },\n maintenance: {\n health: toBigDecimal(baseResponse.healths[1].health),\n assets: toBigDecimal(baseResponse.healths[1].assets),\n liabilities: toBigDecimal(baseResponse.healths[1].liabilities),\n },\n unweighted: {\n health: toBigDecimal(baseResponse.healths[2].health),\n assets: toBigDecimal(baseResponse.healths[2].assets),\n liabilities: toBigDecimal(baseResponse.healths[2].liabilities),\n },\n },\n };\n}\n\nexport function mapEngineServerIsolatedPositions(\n baseResponse: EngineServerIsolatedPositionsResponse,\n): GetEngineIsolatedPositionsResponse {\n return baseResponse.isolated_positions.map((position) => {\n const perpBalance = position.base_balance;\n const quoteBalance = position.quote_balance;\n\n return {\n subaccount: subaccountFromHex(position.subaccount),\n healths: {\n initial: toBigDecimal(position.healths[0].health),\n maintenance: toBigDecimal(position.healths[1].health),\n unweighted: toBigDecimal(position.healths[2].health),\n },\n baseBalance: {\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n // Health contributions === healths for an isolated position\n healthContributions: {\n initial: toBigDecimal(position.base_healths[0]),\n maintenance: toBigDecimal(position.base_healths[1]),\n unweighted: toBigDecimal(position.base_healths[2]),\n },\n ...mapEngineServerPerpProduct(position.base_product).product,\n },\n quoteBalance: {\n amount: toBigDecimal(quoteBalance.balance.amount),\n healthContributions: {\n initial: toBigDecimal(position.quote_healths[0]),\n maintenance: toBigDecimal(position.quote_healths[1]),\n unweighted: toBigDecimal(position.quote_healths[2]),\n },\n ...mapEngineServerSpotProduct(position.quote_product).product,\n },\n };\n });\n}\n\nexport function mapEngineServerSymbols(\n baseResponse: EngineServerSymbolsResponse,\n): EngineSymbolsResponse {\n const symbols: Record<string, EngineSymbol> = mapValues(\n baseResponse.symbols,\n mapEngineServerSymbol,\n );\n\n return {\n symbols,\n };\n}\n\nexport function mapEngineServerSymbol(\n engineServerSymbol: EngineServerSymbol,\n): EngineSymbol {\n return {\n type: mapEngineServerProductType(engineServerSymbol.type),\n productId: engineServerSymbol.product_id,\n symbol: engineServerSymbol.symbol,\n priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),\n sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),\n minSize: toBigDecimal(engineServerSymbol.min_size),\n minDepth: removeDecimals(engineServerSymbol.min_depth_x18),\n maxSpreadRate: removeDecimals(engineServerSymbol.max_spread_rate_x18),\n makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(\n engineServerSymbol.long_weight_initial_x18,\n ),\n longWeightMaintenance: removeDecimals(\n engineServerSymbol.long_weight_maintenance_x18,\n ),\n };\n}\n\nexport function mapEngineMarketPrice(\n baseResponse: EngineServerMarketPrice,\n): EngineMarketPrice {\n return {\n ask: removeDecimals(ba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c,6BAAe,mBAAmB,kBAAkB;AAAA,IAClE,kBAAc,6BAAe,mBAAmB,kBAAkB;AAAA,IAClE,uBAAmB;AAAA,MACjB,mBAAmB;AAAA,IACrB;AAAA,IACA,2BAAuB;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAAA,EACF;AACF;AAEO,SAAS,qBACd,cACmB;AACnB,SAAO;AAAA,IACL,SAAK,6BAAe,aAAa,OAAO;AAAA,IACxC,SAAK,6BAAe,aAAa,OAAO;AAAA,IACxC,WAAW,aAAa;AAAA,EAC1B;AACF;","names":["product"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/queryDataMappers.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n calcTotalBorrowed,\n calcTotalDeposited,\n mapValues,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n EngineMarketPrice,\n EngineNlpLockedBalance,\n EngineOrder,\n EnginePriceTickLiquidity,\n EngineServerIsolatedPositionsResponse,\n EngineServerMarketPrice,\n EngineServerNlpLockedBalancesResponse,\n EngineServerOrderResponse,\n EngineServerPerpProduct,\n EngineServerPriceTickLiquidity,\n EngineServerSpotProduct,\n EngineServerSubaccountInfoResponse,\n EngineServerSymbol,\n EngineServerSymbolsResponse,\n EngineSymbol,\n EngineSymbolsResponse,\n GetEngineIsolatedPositionsResponse,\n GetEngineNlpLockedBalancesResponse,\n GetEngineSubaccountSummaryResponse,\n} from '../types';\nimport { mapEngineServerProductType } from './productEngineTypeMappers';\n\nexport function mapEngineServerTickLiquidity(\n tick: EngineServerPriceTickLiquidity,\n): EnginePriceTickLiquidity {\n return {\n price: removeDecimals(tick[0]),\n liquidity: toBigDecimal(tick[1]),\n };\n}\n\nexport function mapEngineServerOrder(\n order: EngineServerOrderResponse,\n): EngineOrder {\n const subaccount = subaccountFromHex(order.sender);\n return {\n digest: order.digest,\n expiration: Number(order.expiration),\n nonce: order.nonce,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n totalAmount: toBigDecimal(order.amount),\n unfilledAmount: toBigDecimal(order.unfilled_amount),\n placementTime: order.placed_at,\n appendix: unpackOrderAppendix(order.appendix),\n };\n}\n\nexport function mapEngineServerSpotProduct(\n product: EngineServerSpotProduct,\n): SpotMarket {\n return {\n type: ProductEngineType.SPOT,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.SPOT,\n totalBorrowed: calcTotalBorrowed(\n product.state.total_borrows_normalized,\n product.state.cumulative_borrows_multiplier_x18,\n ),\n totalDeposited: calcTotalDeposited(\n product.state.total_deposits_normalized,\n product.state.cumulative_deposits_multiplier_x18,\n ),\n oraclePrice: removeDecimals(product.oracle_price_x18),\n interestFloor: removeDecimals(product.config.interest_floor_x18),\n interestInflectionUtil: removeDecimals(\n product.config.interest_inflection_util_x18,\n ),\n interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),\n interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),\n minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n tokenAddr: product.config.token,\n },\n };\n}\n\nexport function mapEngineServerPerpProduct(\n product: EngineServerPerpProduct,\n): PerpMarket {\n return {\n type: ProductEngineType.PERP,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.PERP,\n oraclePrice: removeDecimals(product.oracle_price_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n openInterest: toBigDecimal(product.state.open_interest),\n cumulativeFundingLong: removeDecimals(\n product.state.cumulative_funding_long_x18,\n ),\n cumulativeFundingShort: removeDecimals(\n product.state.cumulative_funding_short_x18,\n ),\n },\n };\n}\n\nexport function mapEngineServerBalanceHealthContributions(\n healthContributionsForBalance: string[],\n): BalanceHealthContributions {\n return {\n initial: toBigDecimal(healthContributionsForBalance[0]),\n maintenance: toBigDecimal(healthContributionsForBalance[1]),\n unweighted: toBigDecimal(healthContributionsForBalance[2]),\n };\n}\n\nexport function mapSubaccountSummary(\n baseResponse: EngineServerSubaccountInfoResponse,\n): GetEngineSubaccountSummaryResponse {\n const balances: GetEngineSubaccountSummaryResponse['balances'] = [];\n\n baseResponse.spot_balances.forEach((spotBalance) => {\n const product = baseResponse.spot_products.find(\n (product) => product.product_id === spotBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${spotBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(spotBalance.balance.amount),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[spotBalance.product_id],\n ),\n ...mapEngineServerSpotProduct(product).product,\n });\n });\n\n baseResponse.perp_balances.forEach((perpBalance) => {\n const product = baseResponse.perp_products.find(\n (product) => product.product_id === perpBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${perpBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[perpBalance.product_id],\n ),\n ...mapEngineServerPerpProduct(product).product,\n });\n });\n\n return {\n balances: balances,\n exists: baseResponse.exists,\n health: {\n initial: {\n health: toBigDecimal(baseResponse.healths[0].health),\n assets: toBigDecimal(baseResponse.healths[0].assets),\n liabilities: toBigDecimal(baseResponse.healths[0].liabilities),\n },\n maintenance: {\n health: toBigDecimal(baseResponse.healths[1].health),\n assets: toBigDecimal(baseResponse.healths[1].assets),\n liabilities: toBigDecimal(baseResponse.healths[1].liabilities),\n },\n unweighted: {\n health: toBigDecimal(baseResponse.healths[2].health),\n assets: toBigDecimal(baseResponse.healths[2].assets),\n liabilities: toBigDecimal(baseResponse.healths[2].liabilities),\n },\n },\n };\n}\n\nexport function mapEngineServerIsolatedPositions(\n baseResponse: EngineServerIsolatedPositionsResponse,\n): GetEngineIsolatedPositionsResponse {\n return baseResponse.isolated_positions.map((position) => {\n const perpBalance = position.base_balance;\n const quoteBalance = position.quote_balance;\n\n return {\n subaccount: subaccountFromHex(position.subaccount),\n healths: {\n initial: toBigDecimal(position.healths[0].health),\n maintenance: toBigDecimal(position.healths[1].health),\n unweighted: toBigDecimal(position.healths[2].health),\n },\n baseBalance: {\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n // Health contributions === healths for an isolated position\n healthContributions: {\n initial: toBigDecimal(position.base_healths[0]),\n maintenance: toBigDecimal(position.base_healths[1]),\n unweighted: toBigDecimal(position.base_healths[2]),\n },\n ...mapEngineServerPerpProduct(position.base_product).product,\n },\n quoteBalance: {\n amount: toBigDecimal(quoteBalance.balance.amount),\n healthContributions: {\n initial: toBigDecimal(position.quote_healths[0]),\n maintenance: toBigDecimal(position.quote_healths[1]),\n unweighted: toBigDecimal(position.quote_healths[2]),\n },\n ...mapEngineServerSpotProduct(position.quote_product).product,\n },\n };\n });\n}\n\nexport function mapEngineServerSymbols(\n baseResponse: EngineServerSymbolsResponse,\n): EngineSymbolsResponse {\n const symbols: Record<string, EngineSymbol> = mapValues(\n baseResponse.symbols,\n mapEngineServerSymbol,\n );\n\n return {\n symbols,\n };\n}\n\nexport function mapEngineServerSymbol(\n engineServerSymbol: EngineServerSymbol,\n): EngineSymbol {\n return {\n type: mapEngineServerProductType(engineServerSymbol.type),\n productId: engineServerSymbol.product_id,\n symbol: engineServerSymbol.symbol,\n priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),\n sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),\n minSize: toBigDecimal(engineServerSymbol.min_size),\n minDepth: removeDecimals(engineServerSymbol.min_depth_x18),\n maxSpreadRate: removeDecimals(engineServerSymbol.max_spread_rate_x18),\n makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(\n engineServerSymbol.long_weight_initial_x18,\n ),\n longWeightMaintenance: removeDecimals(\n engineServerSymbol.long_weight_maintenance_x18,\n ),\n };\n}\n\nexport function mapEngineMarketPrice(\n baseResponse: EngineServerMarketPrice,\n): EngineMarketPrice {\n return {\n ask: removeDecimals(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n\nexport function mapEngineServerNlpLockedBalances(\n baseResponse: EngineServerNlpLockedBalancesResponse,\n): GetEngineNlpLockedBalancesResponse {\n const lockedBalances: EngineNlpLockedBalance[] =\n baseResponse.locked_balances.map((lockedBalance) => ({\n productId: lockedBalance.product_id,\n balance: toBigDecimal(lockedBalance.balance.amount),\n unlockedAt: lockedBalance.unlocked_at,\n }));\n\n return {\n lockedBalances,\n balanceLocked: {\n productId: baseResponse.balance_locked.product_id,\n balance: toBigDecimal(baseResponse.balance_locked.balance.amount),\n },\n balanceUnlocked: {\n productId: baseResponse.balance_unlocked.product_id,\n balance: toBigDecimal(baseResponse.balance_unlocked.balance.amount),\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAA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ACoC;AACpC,QAAM,iBACJ,aAAa,gBAAgB,IAAI,CAAC,mBAAmB;AAAA,IACnD,WAAW,cAAc;AAAA,IACzB,aAAS,4BAAa,cAAc,QAAQ,MAAM;AAAA,IAClD,YAAY,cAAc;AAAA,EAC5B,EAAE;AAEJ,SAAO;AAAA,IACL;AAAA,IACA,eAAe;AAAA,MACb,WAAW,aAAa,eAAe;AAAA,MACvC,aAAS,4BAAa,aAAa,eAAe,QAAQ,MAAM;AAAA,IAClE;AAAA,IACA,iBAAiB;AAAA,MACf,WAAW,aAAa,iBAAiB;AAAA,MACzC,aAAS,4BAAa,aAAa,iBAAiB,QAAQ,MAAM;AAAA,IACpE;AAAA,EACF;AACF;","names":["product"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { SpotMarket, PerpMarket, BalanceHealthContributions } from '@nadohq/
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { SpotMarket, PerpMarket, BalanceHealthContributions } from '@nadohq/shared';
|
|
2
|
+
import { EngineServerPriceTickLiquidity, EngineServerOrderResponse, EngineServerSubaccountInfoResponse, EngineServerIsolatedPositionsResponse, EngineServerSymbolsResponse, EngineServerSymbol, EngineServerMarketPrice, EngineServerNlpLockedBalancesResponse } from '../types/serverQueryTypes.cjs';
|
|
3
|
+
import { EnginePriceTickLiquidity, EngineOrder, GetEngineSubaccountSummaryResponse, GetEngineIsolatedPositionsResponse, EngineSymbolsResponse, EngineSymbol, EngineMarketPrice, GetEngineNlpLockedBalancesResponse } from '../types/clientQueryTypes.cjs';
|
|
4
4
|
import { EngineServerSpotProduct, EngineServerPerpProduct } from '../types/serverQueryModelTypes.cjs';
|
|
5
|
-
import '@nadohq/utils';
|
|
6
5
|
|
|
7
6
|
declare function mapEngineServerTickLiquidity(tick: EngineServerPriceTickLiquidity): EnginePriceTickLiquidity;
|
|
8
7
|
declare function mapEngineServerOrder(order: EngineServerOrderResponse): EngineOrder;
|
|
@@ -14,5 +13,6 @@ declare function mapEngineServerIsolatedPositions(baseResponse: EngineServerIsol
|
|
|
14
13
|
declare function mapEngineServerSymbols(baseResponse: EngineServerSymbolsResponse): EngineSymbolsResponse;
|
|
15
14
|
declare function mapEngineServerSymbol(engineServerSymbol: EngineServerSymbol): EngineSymbol;
|
|
16
15
|
declare function mapEngineMarketPrice(baseResponse: EngineServerMarketPrice): EngineMarketPrice;
|
|
16
|
+
declare function mapEngineServerNlpLockedBalances(baseResponse: EngineServerNlpLockedBalancesResponse): GetEngineNlpLockedBalancesResponse;
|
|
17
17
|
|
|
18
|
-
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary };
|
|
18
|
+
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { SpotMarket, PerpMarket, BalanceHealthContributions } from '@nadohq/
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { SpotMarket, PerpMarket, BalanceHealthContributions } from '@nadohq/shared';
|
|
2
|
+
import { EngineServerPriceTickLiquidity, EngineServerOrderResponse, EngineServerSubaccountInfoResponse, EngineServerIsolatedPositionsResponse, EngineServerSymbolsResponse, EngineServerSymbol, EngineServerMarketPrice, EngineServerNlpLockedBalancesResponse } from '../types/serverQueryTypes.js';
|
|
3
|
+
import { EnginePriceTickLiquidity, EngineOrder, GetEngineSubaccountSummaryResponse, GetEngineIsolatedPositionsResponse, EngineSymbolsResponse, EngineSymbol, EngineMarketPrice, GetEngineNlpLockedBalancesResponse } from '../types/clientQueryTypes.js';
|
|
4
4
|
import { EngineServerSpotProduct, EngineServerPerpProduct } from '../types/serverQueryModelTypes.js';
|
|
5
|
-
import '@nadohq/utils';
|
|
6
5
|
|
|
7
6
|
declare function mapEngineServerTickLiquidity(tick: EngineServerPriceTickLiquidity): EnginePriceTickLiquidity;
|
|
8
7
|
declare function mapEngineServerOrder(order: EngineServerOrderResponse): EngineOrder;
|
|
@@ -14,5 +13,6 @@ declare function mapEngineServerIsolatedPositions(baseResponse: EngineServerIsol
|
|
|
14
13
|
declare function mapEngineServerSymbols(baseResponse: EngineServerSymbolsResponse): EngineSymbolsResponse;
|
|
15
14
|
declare function mapEngineServerSymbol(engineServerSymbol: EngineServerSymbol): EngineSymbol;
|
|
16
15
|
declare function mapEngineMarketPrice(baseResponse: EngineServerMarketPrice): EngineMarketPrice;
|
|
16
|
+
declare function mapEngineServerNlpLockedBalances(baseResponse: EngineServerNlpLockedBalancesResponse): GetEngineNlpLockedBalancesResponse;
|
|
17
17
|
|
|
18
|
-
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary };
|
|
18
|
+
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary };
|