@nadohq/engine-client 0.1.0-alpha.1 → 0.1.0-alpha.11
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 +1 -2
- package/dist/EngineBaseClient.d.ts +1 -2
- 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 +33 -61
- package/dist/EngineExecuteBuilder.cjs.map +1 -1
- package/dist/EngineExecuteBuilder.d.cts +14 -25
- package/dist/EngineExecuteBuilder.d.ts +14 -25
- package/dist/EngineExecuteBuilder.js +25 -53
- package/dist/EngineExecuteBuilder.js.map +1 -1
- package/dist/EngineExecuteClient.cjs +12 -16
- package/dist/EngineExecuteClient.cjs.map +1 -1
- package/dist/EngineExecuteClient.d.cts +5 -6
- package/dist/EngineExecuteClient.d.ts +5 -6
- package/dist/EngineExecuteClient.js +12 -16
- package/dist/EngineExecuteClient.js.map +1 -1
- package/dist/EngineQueryClient.cjs +33 -57
- package/dist/EngineQueryClient.cjs.map +1 -1
- package/dist/EngineQueryClient.d.cts +4 -15
- package/dist/EngineQueryClient.d.ts +4 -15
- package/dist/EngineQueryClient.js +11 -35
- 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.d.cts +7 -8
- package/dist/index.d.ts +7 -8
- 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 +8 -16
- package/dist/types/clientExecuteTypes.d.ts +8 -16
- package/dist/types/clientQueryTypes.cjs.map +1 -1
- package/dist/types/clientQueryTypes.d.cts +15 -25
- package/dist/types/clientQueryTypes.d.ts +15 -25
- package/dist/types/index.d.cts +7 -8
- package/dist/types/index.d.ts +7 -8
- package/dist/types/serverExecuteTypes.cjs.map +1 -1
- package/dist/types/serverExecuteTypes.d.cts +10 -18
- package/dist/types/serverExecuteTypes.d.ts +10 -18
- 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 +8 -17
- package/dist/types/serverQueryTypes.d.ts +8 -17
- package/dist/types/serverSubscriptionEventTypes.cjs.map +1 -1
- package/dist/types/serverSubscriptionEventTypes.d.cts +83 -24
- package/dist/types/serverSubscriptionEventTypes.d.ts +83 -24
- 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 +1 -2
- package/dist/utils/index.d.ts +1 -2
- 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 +79 -90
- package/dist/utils/queryDataMappers.cjs.map +1 -1
- package/dist/utils/queryDataMappers.d.cts +1 -2
- package/dist/utils/queryDataMappers.d.ts +1 -2
- package/dist/utils/queryDataMappers.js +7 -19
- package/dist/utils/queryDataMappers.js.map +1 -1
- package/package.json +3 -4
- package/src/EngineBaseClient.ts +5 -3
- package/src/EngineExecuteBuilder.ts +30 -70
- package/src/EngineExecuteClient.ts +13 -21
- package/src/EngineQueryClient.ts +14 -42
- package/src/EngineWebClient.ts +0 -2
- package/src/endpoints.ts +4 -5
- package/src/types/EngineServerFailureError.ts +2 -2
- package/src/types/clientExecuteTypes.ts +13 -25
- package/src/types/clientQueryTypes.ts +21 -34
- package/src/types/serverExecuteTypes.ts +13 -24
- package/src/types/serverQueryModelTypes.ts +1 -1
- package/src/types/serverQueryTypes.ts +7 -20
- package/src/types/serverSubscriptionEventTypes.ts +130 -22
- package/src/types/serverSubscriptionTypes.ts +23 -3
- package/src/utils/productEngineTypeMappers.ts +1 -1
- package/src/utils/queryDataMappers.ts +7 -20
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.js';
|
|
2
|
-
import '@nadohq/
|
|
2
|
+
import '@nadohq/shared';
|
|
3
3
|
import '../types/clientQueryTypes.js';
|
|
4
|
-
import '@nadohq/utils';
|
|
5
4
|
import '../types/serverQueryTypes.js';
|
|
6
5
|
import '../types/serverQueryModelTypes.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":[]}
|
|
@@ -32,73 +32,62 @@ __export(queryDataMappers_exports, {
|
|
|
32
32
|
mapSubaccountSummary: () => mapSubaccountSummary
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(queryDataMappers_exports);
|
|
35
|
-
var
|
|
36
|
-
var import_utils = require("@nadohq/utils");
|
|
35
|
+
var import_shared = require("@nadohq/shared");
|
|
37
36
|
var import_productEngineTypeMappers = require("./productEngineTypeMappers.cjs");
|
|
38
37
|
function mapEngineServerTickLiquidity(tick) {
|
|
39
38
|
return {
|
|
40
|
-
price: (0,
|
|
41
|
-
liquidity: (0,
|
|
39
|
+
price: (0, import_shared.removeDecimals)(tick[0]),
|
|
40
|
+
liquidity: (0, import_shared.toBigDecimal)(tick[1])
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
function mapEngineServerOrder(order) {
|
|
45
|
-
const subaccount = (0,
|
|
44
|
+
const subaccount = (0, import_shared.subaccountFromHex)(order.sender);
|
|
46
45
|
return {
|
|
47
46
|
digest: order.digest,
|
|
48
|
-
expiration: (
|
|
47
|
+
expiration: Number(order.expiration),
|
|
49
48
|
nonce: order.nonce,
|
|
50
|
-
price: (0,
|
|
49
|
+
price: (0, import_shared.removeDecimals)(order.price_x18),
|
|
51
50
|
productId: order.product_id,
|
|
52
51
|
subaccountOwner: subaccount.subaccountOwner,
|
|
53
52
|
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
|
-
},
|
|
53
|
+
totalAmount: (0, import_shared.toBigDecimal)(order.amount),
|
|
54
|
+
unfilledAmount: (0, import_shared.toBigDecimal)(order.unfilled_amount),
|
|
67
55
|
placementTime: order.placed_at,
|
|
68
|
-
|
|
56
|
+
appendix: (0, import_shared.unpackOrderAppendix)(order.appendix)
|
|
69
57
|
};
|
|
70
58
|
}
|
|
71
59
|
function mapEngineServerSpotProduct(product) {
|
|
72
60
|
return {
|
|
73
|
-
type:
|
|
61
|
+
type: import_shared.ProductEngineType.SPOT,
|
|
74
62
|
productId: product.product_id,
|
|
75
|
-
minSize: (0,
|
|
76
|
-
priceIncrement: (0,
|
|
77
|
-
sizeIncrement: (0,
|
|
63
|
+
minSize: (0, import_shared.toBigDecimal)(product.book_info.min_size),
|
|
64
|
+
priceIncrement: (0, import_shared.removeDecimals)(product.book_info.price_increment_x18),
|
|
65
|
+
sizeIncrement: (0, import_shared.toBigDecimal)(product.book_info.size_increment),
|
|
78
66
|
product: {
|
|
79
67
|
productId: product.product_id,
|
|
80
|
-
type:
|
|
81
|
-
totalBorrowed: (0,
|
|
68
|
+
type: import_shared.ProductEngineType.SPOT,
|
|
69
|
+
totalBorrowed: (0, import_shared.calcTotalBorrowed)(
|
|
82
70
|
product.state.total_borrows_normalized,
|
|
83
71
|
product.state.cumulative_borrows_multiplier_x18
|
|
84
72
|
),
|
|
85
|
-
totalDeposited: (0,
|
|
73
|
+
totalDeposited: (0, import_shared.calcTotalDeposited)(
|
|
86
74
|
product.state.total_deposits_normalized,
|
|
87
75
|
product.state.cumulative_deposits_multiplier_x18
|
|
88
76
|
),
|
|
89
|
-
oraclePrice: (0,
|
|
90
|
-
interestFloor: (0,
|
|
91
|
-
interestInflectionUtil: (0,
|
|
77
|
+
oraclePrice: (0, import_shared.removeDecimals)(product.oracle_price_x18),
|
|
78
|
+
interestFloor: (0, import_shared.removeDecimals)(product.config.interest_floor_x18),
|
|
79
|
+
interestInflectionUtil: (0, import_shared.removeDecimals)(
|
|
92
80
|
product.config.interest_inflection_util_x18
|
|
93
81
|
),
|
|
94
|
-
interestLargeCap: (0,
|
|
95
|
-
interestSmallCap: (0,
|
|
96
|
-
|
|
97
|
-
|
|
82
|
+
interestLargeCap: (0, import_shared.removeDecimals)(product.config.interest_large_cap_x18),
|
|
83
|
+
interestSmallCap: (0, import_shared.removeDecimals)(product.config.interest_small_cap_x18),
|
|
84
|
+
minDepositRate: (0, import_shared.removeDecimals)(product.config.min_deposit_rate_x18),
|
|
85
|
+
longWeightInitial: (0, import_shared.removeDecimals)(product.risk.long_weight_initial_x18),
|
|
86
|
+
longWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
98
87
|
product.risk.long_weight_maintenance_x18
|
|
99
88
|
),
|
|
100
|
-
shortWeightInitial: (0,
|
|
101
|
-
shortWeightMaintenance: (0,
|
|
89
|
+
shortWeightInitial: (0, import_shared.removeDecimals)(product.risk.short_weight_initial_x18),
|
|
90
|
+
shortWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
102
91
|
product.risk.short_weight_maintenance_x18
|
|
103
92
|
),
|
|
104
93
|
tokenAddr: product.config.token
|
|
@@ -107,28 +96,28 @@ function mapEngineServerSpotProduct(product) {
|
|
|
107
96
|
}
|
|
108
97
|
function mapEngineServerPerpProduct(product) {
|
|
109
98
|
return {
|
|
110
|
-
type:
|
|
99
|
+
type: import_shared.ProductEngineType.PERP,
|
|
111
100
|
productId: product.product_id,
|
|
112
|
-
minSize: (0,
|
|
113
|
-
priceIncrement: (0,
|
|
114
|
-
sizeIncrement: (0,
|
|
101
|
+
minSize: (0, import_shared.toBigDecimal)(product.book_info.min_size),
|
|
102
|
+
priceIncrement: (0, import_shared.removeDecimals)(product.book_info.price_increment_x18),
|
|
103
|
+
sizeIncrement: (0, import_shared.toBigDecimal)(product.book_info.size_increment),
|
|
115
104
|
product: {
|
|
116
105
|
productId: product.product_id,
|
|
117
|
-
type:
|
|
118
|
-
oraclePrice: (0,
|
|
119
|
-
longWeightInitial: (0,
|
|
120
|
-
longWeightMaintenance: (0,
|
|
106
|
+
type: import_shared.ProductEngineType.PERP,
|
|
107
|
+
oraclePrice: (0, import_shared.removeDecimals)(product.oracle_price_x18),
|
|
108
|
+
longWeightInitial: (0, import_shared.removeDecimals)(product.risk.long_weight_initial_x18),
|
|
109
|
+
longWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
121
110
|
product.risk.long_weight_maintenance_x18
|
|
122
111
|
),
|
|
123
|
-
shortWeightInitial: (0,
|
|
124
|
-
shortWeightMaintenance: (0,
|
|
112
|
+
shortWeightInitial: (0, import_shared.removeDecimals)(product.risk.short_weight_initial_x18),
|
|
113
|
+
shortWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
125
114
|
product.risk.short_weight_maintenance_x18
|
|
126
115
|
),
|
|
127
|
-
openInterest: (0,
|
|
128
|
-
cumulativeFundingLong: (0,
|
|
116
|
+
openInterest: (0, import_shared.toBigDecimal)(product.state.open_interest),
|
|
117
|
+
cumulativeFundingLong: (0, import_shared.removeDecimals)(
|
|
129
118
|
product.state.cumulative_funding_long_x18
|
|
130
119
|
),
|
|
131
|
-
cumulativeFundingShort: (0,
|
|
120
|
+
cumulativeFundingShort: (0, import_shared.removeDecimals)(
|
|
132
121
|
product.state.cumulative_funding_short_x18
|
|
133
122
|
)
|
|
134
123
|
}
|
|
@@ -136,9 +125,9 @@ function mapEngineServerPerpProduct(product) {
|
|
|
136
125
|
}
|
|
137
126
|
function mapEngineServerBalanceHealthContributions(healthContributionsForBalance) {
|
|
138
127
|
return {
|
|
139
|
-
initial: (0,
|
|
140
|
-
maintenance: (0,
|
|
141
|
-
unweighted: (0,
|
|
128
|
+
initial: (0, import_shared.toBigDecimal)(healthContributionsForBalance[0]),
|
|
129
|
+
maintenance: (0, import_shared.toBigDecimal)(healthContributionsForBalance[1]),
|
|
130
|
+
unweighted: (0, import_shared.toBigDecimal)(healthContributionsForBalance[2])
|
|
142
131
|
};
|
|
143
132
|
}
|
|
144
133
|
function mapSubaccountSummary(baseResponse) {
|
|
@@ -151,7 +140,7 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
151
140
|
throw Error(`Could not find product ${spotBalance.product_id}`);
|
|
152
141
|
}
|
|
153
142
|
balances.push({
|
|
154
|
-
amount: (0,
|
|
143
|
+
amount: (0, import_shared.toBigDecimal)(spotBalance.balance.amount),
|
|
155
144
|
healthContributions: mapEngineServerBalanceHealthContributions(
|
|
156
145
|
baseResponse.health_contributions[spotBalance.product_id]
|
|
157
146
|
),
|
|
@@ -166,8 +155,8 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
166
155
|
throw Error(`Could not find product ${perpBalance.product_id}`);
|
|
167
156
|
}
|
|
168
157
|
balances.push({
|
|
169
|
-
amount: (0,
|
|
170
|
-
vQuoteBalance: (0,
|
|
158
|
+
amount: (0, import_shared.toBigDecimal)(perpBalance.balance.amount),
|
|
159
|
+
vQuoteBalance: (0, import_shared.toBigDecimal)(perpBalance.balance.v_quote_balance),
|
|
171
160
|
healthContributions: mapEngineServerBalanceHealthContributions(
|
|
172
161
|
baseResponse.health_contributions[perpBalance.product_id]
|
|
173
162
|
),
|
|
@@ -179,19 +168,19 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
179
168
|
exists: baseResponse.exists,
|
|
180
169
|
health: {
|
|
181
170
|
initial: {
|
|
182
|
-
health: (0,
|
|
183
|
-
assets: (0,
|
|
184
|
-
liabilities: (0,
|
|
171
|
+
health: (0, import_shared.toBigDecimal)(baseResponse.healths[0].health),
|
|
172
|
+
assets: (0, import_shared.toBigDecimal)(baseResponse.healths[0].assets),
|
|
173
|
+
liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[0].liabilities)
|
|
185
174
|
},
|
|
186
175
|
maintenance: {
|
|
187
|
-
health: (0,
|
|
188
|
-
assets: (0,
|
|
189
|
-
liabilities: (0,
|
|
176
|
+
health: (0, import_shared.toBigDecimal)(baseResponse.healths[1].health),
|
|
177
|
+
assets: (0, import_shared.toBigDecimal)(baseResponse.healths[1].assets),
|
|
178
|
+
liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[1].liabilities)
|
|
190
179
|
},
|
|
191
180
|
unweighted: {
|
|
192
|
-
health: (0,
|
|
193
|
-
assets: (0,
|
|
194
|
-
liabilities: (0,
|
|
181
|
+
health: (0, import_shared.toBigDecimal)(baseResponse.healths[2].health),
|
|
182
|
+
assets: (0, import_shared.toBigDecimal)(baseResponse.healths[2].assets),
|
|
183
|
+
liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[2].liabilities)
|
|
195
184
|
}
|
|
196
185
|
}
|
|
197
186
|
};
|
|
@@ -201,29 +190,29 @@ function mapEngineServerIsolatedPositions(baseResponse) {
|
|
|
201
190
|
const perpBalance = position.base_balance;
|
|
202
191
|
const quoteBalance = position.quote_balance;
|
|
203
192
|
return {
|
|
204
|
-
subaccount: (0,
|
|
193
|
+
subaccount: (0, import_shared.subaccountFromHex)(position.subaccount),
|
|
205
194
|
healths: {
|
|
206
|
-
initial: (0,
|
|
207
|
-
maintenance: (0,
|
|
208
|
-
unweighted: (0,
|
|
195
|
+
initial: (0, import_shared.toBigDecimal)(position.healths[0].health),
|
|
196
|
+
maintenance: (0, import_shared.toBigDecimal)(position.healths[1].health),
|
|
197
|
+
unweighted: (0, import_shared.toBigDecimal)(position.healths[2].health)
|
|
209
198
|
},
|
|
210
199
|
baseBalance: {
|
|
211
|
-
amount: (0,
|
|
212
|
-
vQuoteBalance: (0,
|
|
200
|
+
amount: (0, import_shared.toBigDecimal)(perpBalance.balance.amount),
|
|
201
|
+
vQuoteBalance: (0, import_shared.toBigDecimal)(perpBalance.balance.v_quote_balance),
|
|
213
202
|
// Health contributions === healths for an isolated position
|
|
214
203
|
healthContributions: {
|
|
215
|
-
initial: (0,
|
|
216
|
-
maintenance: (0,
|
|
217
|
-
unweighted: (0,
|
|
204
|
+
initial: (0, import_shared.toBigDecimal)(position.base_healths[0]),
|
|
205
|
+
maintenance: (0, import_shared.toBigDecimal)(position.base_healths[1]),
|
|
206
|
+
unweighted: (0, import_shared.toBigDecimal)(position.base_healths[2])
|
|
218
207
|
},
|
|
219
208
|
...mapEngineServerPerpProduct(position.base_product).product
|
|
220
209
|
},
|
|
221
210
|
quoteBalance: {
|
|
222
|
-
amount: (0,
|
|
211
|
+
amount: (0, import_shared.toBigDecimal)(quoteBalance.balance.amount),
|
|
223
212
|
healthContributions: {
|
|
224
|
-
initial: (0,
|
|
225
|
-
maintenance: (0,
|
|
226
|
-
unweighted: (0,
|
|
213
|
+
initial: (0, import_shared.toBigDecimal)(position.quote_healths[0]),
|
|
214
|
+
maintenance: (0, import_shared.toBigDecimal)(position.quote_healths[1]),
|
|
215
|
+
unweighted: (0, import_shared.toBigDecimal)(position.quote_healths[2])
|
|
227
216
|
},
|
|
228
217
|
...mapEngineServerSpotProduct(position.quote_product).product
|
|
229
218
|
}
|
|
@@ -231,7 +220,7 @@ function mapEngineServerIsolatedPositions(baseResponse) {
|
|
|
231
220
|
});
|
|
232
221
|
}
|
|
233
222
|
function mapEngineServerSymbols(baseResponse) {
|
|
234
|
-
const symbols = (0,
|
|
223
|
+
const symbols = (0, import_shared.mapValues)(
|
|
235
224
|
baseResponse.symbols,
|
|
236
225
|
mapEngineServerSymbol
|
|
237
226
|
);
|
|
@@ -244,25 +233,25 @@ function mapEngineServerSymbol(engineServerSymbol) {
|
|
|
244
233
|
type: (0, import_productEngineTypeMappers.mapEngineServerProductType)(engineServerSymbol.type),
|
|
245
234
|
productId: engineServerSymbol.product_id,
|
|
246
235
|
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,
|
|
236
|
+
priceIncrement: (0, import_shared.removeDecimals)(engineServerSymbol.price_increment_x18),
|
|
237
|
+
sizeIncrement: (0, import_shared.toBigDecimal)(engineServerSymbol.size_increment),
|
|
238
|
+
minSize: (0, import_shared.toBigDecimal)(engineServerSymbol.min_size),
|
|
239
|
+
minDepth: (0, import_shared.removeDecimals)(engineServerSymbol.min_depth_x18),
|
|
240
|
+
maxSpreadRate: (0, import_shared.removeDecimals)(engineServerSymbol.max_spread_rate_x18),
|
|
241
|
+
makerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.maker_fee_rate_x18),
|
|
242
|
+
takerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.taker_fee_rate_x18),
|
|
243
|
+
longWeightInitial: (0, import_shared.removeDecimals)(
|
|
255
244
|
engineServerSymbol.long_weight_initial_x18
|
|
256
245
|
),
|
|
257
|
-
longWeightMaintenance: (0,
|
|
246
|
+
longWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
258
247
|
engineServerSymbol.long_weight_maintenance_x18
|
|
259
248
|
)
|
|
260
249
|
};
|
|
261
250
|
}
|
|
262
251
|
function mapEngineMarketPrice(baseResponse) {
|
|
263
252
|
return {
|
|
264
|
-
ask: (0,
|
|
265
|
-
bid: (0,
|
|
253
|
+
ask: (0, import_shared.removeDecimals)(baseResponse.ask_x18),
|
|
254
|
+
bid: (0, import_shared.removeDecimals)(baseResponse.bid_x18),
|
|
266
255
|
productId: baseResponse.product_id
|
|
267
256
|
};
|
|
268
257
|
}
|
|
@@ -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(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBASO;AACP,mBAKO;AAmBP,sCAA2C;AAEpC,SAAS,6BACd,MAC0B;AAC1B,SAAO;AAAA,IACL,WAAO,6BAAe,KAAK,CAAC,CAAC;AAAA,IAC7B,eAAW,2BAAa,KAAK,CAAC,CAAC;AAAA,EACjC;AACF;AAEO,SAAS,qBACd,OACa;AACb,QAAM,iBAAa,oCAAkB,MAAM,MAAM;AACjD,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,gBAAY,2BAAa,MAAM,UAAU;AAAA,IACzC,OAAO,MAAM;AAAA,IACb,WAAO,6BAAe,MAAM,SAAS;AAAA,IACrC,WAAW,MAAM;AAAA,IACjB,iBAAiB,WAAW;AAAA,IAC5B,gBAAgB,WAAW;AAAA,IAC3B,iBAAa,2BAAa,MAAM,MAAM;AAAA,IACtC,oBAAgB,2BAAa,MAAM,eAAe;AAAA,IAClD,QAAQ,MAAM,aAAS,2BAAa,MAAM,MAAM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uB;AACvB,QAAM,cAAwC;AAAA,IAC5C,aAAa;AAAA,IACb;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,EACF;AACF;AAEO,SAAS,sBACd,oBACc;AACd,SAAO;AAAA,IACL,UAAM,4DAA2B,mBAAmB,IAAI;AAAA,IACxD,WAAW,mBAAmB;AAAA,IAC9B,QAAQ,mBAAmB;AAAA,IAC3B,oBAAgB,6BAAe,mBAAmB,mBAAmB;AAAA,IACrE,mBAAe,2BAAa,mBAAmB,cAAc;AAAA,IAC7D,aAAS,2BAAa,mBAAmB,QAAQ;AAAA,IACjD,cAAU,6BAAe,mBAAmB,aAAa;AAAA,IACzD,mBAAe,6BAAe,mBAAmB,mBAAmB;AAAA,IACpE,kBAAc,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 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: 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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otMarket, PerpMarket, BalanceHealthContributions } from '@nadohq/
|
|
1
|
+
import { SpotMarket, PerpMarket, BalanceHealthContributions } from '@nadohq/shared';
|
|
2
2
|
import { EnginePriceTickLiquidity, EngineOrder, GetEngineSubaccountSummaryResponse, GetEngineIsolatedPositionsResponse, EngineSymbolsResponse, EngineSymbol, EngineMarketPrice } from '../types/clientQueryTypes.cjs';
|
|
3
3
|
import { EngineServerPriceTickLiquidity, EngineServerOrderResponse, EngineServerSubaccountInfoResponse, EngineServerIsolatedPositionsResponse, EngineServerSymbolsResponse, EngineServerSymbol, EngineServerMarketPrice } from '../types/serverQueryTypes.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;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { SpotMarket, PerpMarket, BalanceHealthContributions } from '@nadohq/
|
|
1
|
+
import { SpotMarket, PerpMarket, BalanceHealthContributions } from '@nadohq/shared';
|
|
2
2
|
import { EnginePriceTickLiquidity, EngineOrder, GetEngineSubaccountSummaryResponse, GetEngineIsolatedPositionsResponse, EngineSymbolsResponse, EngineSymbol, EngineMarketPrice } from '../types/clientQueryTypes.js';
|
|
3
3
|
import { EngineServerPriceTickLiquidity, EngineServerOrderResponse, EngineServerSubaccountInfoResponse, EngineServerIsolatedPositionsResponse, EngineServerSymbolsResponse, EngineServerSymbol, EngineServerMarketPrice } from '../types/serverQueryTypes.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;
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
calcTotalBorrowed,
|
|
4
4
|
calcTotalDeposited,
|
|
5
|
-
ProductEngineType,
|
|
6
|
-
subaccountFromHex
|
|
7
|
-
} from "@nadohq/contracts";
|
|
8
|
-
import {
|
|
9
5
|
mapValues,
|
|
6
|
+
ProductEngineType,
|
|
10
7
|
removeDecimals,
|
|
8
|
+
subaccountFromHex,
|
|
11
9
|
toBigDecimal,
|
|
12
|
-
|
|
13
|
-
} from "@nadohq/
|
|
10
|
+
unpackOrderAppendix
|
|
11
|
+
} from "@nadohq/shared";
|
|
14
12
|
import { mapEngineServerProductType } from "./productEngineTypeMappers.js";
|
|
15
13
|
function mapEngineServerTickLiquidity(tick) {
|
|
16
14
|
return {
|
|
@@ -22,7 +20,7 @@ function mapEngineServerOrder(order) {
|
|
|
22
20
|
const subaccount = subaccountFromHex(order.sender);
|
|
23
21
|
return {
|
|
24
22
|
digest: order.digest,
|
|
25
|
-
expiration:
|
|
23
|
+
expiration: Number(order.expiration),
|
|
26
24
|
nonce: order.nonce,
|
|
27
25
|
price: removeDecimals(order.price_x18),
|
|
28
26
|
productId: order.product_id,
|
|
@@ -30,19 +28,8 @@ function mapEngineServerOrder(order) {
|
|
|
30
28
|
subaccountName: subaccount.subaccountName,
|
|
31
29
|
totalAmount: toBigDecimal(order.amount),
|
|
32
30
|
unfilledAmount: toBigDecimal(order.unfilled_amount),
|
|
33
|
-
margin: order.margin ? toBigDecimal(order.margin) : null,
|
|
34
|
-
// Standardizes from hex
|
|
35
|
-
// toFixed is required as toString gives values with `e`
|
|
36
|
-
orderParams: {
|
|
37
|
-
amount: toIntegerString(order.amount),
|
|
38
|
-
expiration: toIntegerString(order.expiration),
|
|
39
|
-
nonce: order.nonce,
|
|
40
|
-
price: toIntegerString(removeDecimals(order.price_x18)),
|
|
41
|
-
subaccountOwner: subaccount.subaccountOwner,
|
|
42
|
-
subaccountName: subaccount.subaccountName
|
|
43
|
-
},
|
|
44
31
|
placementTime: order.placed_at,
|
|
45
|
-
|
|
32
|
+
appendix: unpackOrderAppendix(order.appendix)
|
|
46
33
|
};
|
|
47
34
|
}
|
|
48
35
|
function mapEngineServerSpotProduct(product) {
|
|
@@ -70,6 +57,7 @@ function mapEngineServerSpotProduct(product) {
|
|
|
70
57
|
),
|
|
71
58
|
interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),
|
|
72
59
|
interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),
|
|
60
|
+
minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),
|
|
73
61
|
longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),
|
|
74
62
|
longWeightMaintenance: removeDecimals(
|
|
75
63
|
product.risk.long_weight_maintenance_x18
|
|
@@ -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(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EAGA;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;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K,eAAe,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 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: 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"],"mappings":";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAmBP,SAAS,kCAAkC;AAEpC,SAAS,6BACd,MAC0B;AAC1B,SAAO;AAAA,IACL,OAAO,eAAe,KAAK,CAAC,CAAC;AAAA,IAC7B,WAAW,aAAa,KAAK,CAAC,CAAC;AAAA,EACjC;AACF;AAEO,SAAS,qBACd,OACa;AACb,QAAM,aAAa,kBAAkB,MAAM,MAAM;AACjD,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,YAAY,OAAO,MAAM,UAAU;AAAA,IACnC,OAAO,MAAM;AAAA,IACb,OAAO,eAAe,MAAM,SAAS;AAAA,IACrC,WAAW,MAAM;AAAA,IACjB,iBAAiB,WAAW;AAAA,IAC5B,gBAAgB,WAAW;AAAA,IAC3B,aAAa,aAAa,MAAM,MAAM;AAAA,IACtC,gBAAgB,aAAa,MAAM,eAAe;AAAA,IAClD,eAAe,MAAM;AAAA,IACrB,UAAU,oBAAoB,MAAM,QAAQ;AAAA,EAC9C;AACF;AAEO,SAAS,2BACd,SACY;AACZ,SAAO;AAAA,IACL,MAAM,kBAAkB;AAAA,IACxB,WAAW,QAAQ;AAAA,IACnB,SAAS,aA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