@nadohq/engine-client 0.1.0-alpha.38 → 0.1.0-alpha.39
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/EngineQueryClient.cjs +3 -1
- package/dist/EngineQueryClient.cjs.map +1 -1
- package/dist/EngineQueryClient.js +3 -1
- package/dist/EngineQueryClient.js.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/types/clientQueryTypes.cjs.map +1 -1
- package/dist/types/clientQueryTypes.d.cts +6 -2
- package/dist/types/clientQueryTypes.d.ts +6 -2
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/serverQueryTypes.cjs.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +11 -6
- package/dist/types/serverQueryTypes.d.ts +11 -6
- package/dist/utils/queryDataMappers.cjs +30 -16
- package/dist/utils/queryDataMappers.cjs.map +1 -1
- package/dist/utils/queryDataMappers.js +30 -16
- package/dist/utils/queryDataMappers.js.map +1 -1
- package/package.json +3 -3
- package/src/EngineQueryClient.ts +3 -0
- package/src/types/clientQueryTypes.ts +7 -1
- package/src/types/serverQueryTypes.ts +14 -5
- package/src/utils/queryDataMappers.ts +41 -18
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
EngineServerPriceTickLiquidity,
|
|
26
26
|
EngineServerSpotProduct,
|
|
27
27
|
EngineServerSubaccountInfoResponse,
|
|
28
|
+
EngineServerSubaccountInfoState,
|
|
28
29
|
EngineServerSymbol,
|
|
29
30
|
EngineServerSymbolsResponse,
|
|
30
31
|
EngineSymbol,
|
|
@@ -33,6 +34,7 @@ import {
|
|
|
33
34
|
GetEngineNlpLockedBalancesResponse,
|
|
34
35
|
GetEngineNlpPoolInfoResponse,
|
|
35
36
|
GetEngineSubaccountSummaryResponse,
|
|
37
|
+
SubaccountSummaryState,
|
|
36
38
|
} from '../types';
|
|
37
39
|
import { mapEngineServerProductType } from './productEngineTypeMappers';
|
|
38
40
|
|
|
@@ -150,10 +152,32 @@ export function mapEngineServerBalanceHealthContributions(
|
|
|
150
152
|
export function mapSubaccountSummary(
|
|
151
153
|
baseResponse: EngineServerSubaccountInfoResponse,
|
|
152
154
|
): GetEngineSubaccountSummaryResponse {
|
|
153
|
-
|
|
155
|
+
return {
|
|
156
|
+
exists: baseResponse.exists,
|
|
157
|
+
...mapSubaccountSummaryState(
|
|
158
|
+
baseResponse,
|
|
159
|
+
baseResponse.spot_products,
|
|
160
|
+
baseResponse.perp_products,
|
|
161
|
+
),
|
|
162
|
+
preState: baseResponse.pre_state
|
|
163
|
+
? mapSubaccountSummaryState(
|
|
164
|
+
baseResponse.pre_state,
|
|
165
|
+
baseResponse.spot_products,
|
|
166
|
+
baseResponse.perp_products,
|
|
167
|
+
)
|
|
168
|
+
: undefined,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function mapSubaccountSummaryState(
|
|
173
|
+
state: EngineServerSubaccountInfoState,
|
|
174
|
+
spotProducts: EngineServerSubaccountInfoResponse['spot_products'],
|
|
175
|
+
perpProducts: EngineServerSubaccountInfoResponse['perp_products'],
|
|
176
|
+
): SubaccountSummaryState {
|
|
177
|
+
const balances: SubaccountSummaryState['balances'] = [];
|
|
154
178
|
|
|
155
|
-
|
|
156
|
-
const product =
|
|
179
|
+
state.spot_balances.forEach((spotBalance) => {
|
|
180
|
+
const product = spotProducts.find(
|
|
157
181
|
(product) => product.product_id === spotBalance.product_id,
|
|
158
182
|
);
|
|
159
183
|
if (!product) {
|
|
@@ -163,14 +187,14 @@ export function mapSubaccountSummary(
|
|
|
163
187
|
balances.push({
|
|
164
188
|
amount: toBigDecimal(spotBalance.balance.amount),
|
|
165
189
|
healthContributions: mapEngineServerBalanceHealthContributions(
|
|
166
|
-
|
|
190
|
+
state.health_contributions[spotBalance.product_id],
|
|
167
191
|
),
|
|
168
192
|
...mapEngineServerSpotProduct(product).product,
|
|
169
193
|
});
|
|
170
194
|
});
|
|
171
195
|
|
|
172
|
-
|
|
173
|
-
const product =
|
|
196
|
+
state.perp_balances.forEach((perpBalance) => {
|
|
197
|
+
const product = perpProducts.find(
|
|
174
198
|
(product) => product.product_id === perpBalance.product_id,
|
|
175
199
|
);
|
|
176
200
|
if (!product) {
|
|
@@ -181,30 +205,29 @@ export function mapSubaccountSummary(
|
|
|
181
205
|
amount: toBigDecimal(perpBalance.balance.amount),
|
|
182
206
|
vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),
|
|
183
207
|
healthContributions: mapEngineServerBalanceHealthContributions(
|
|
184
|
-
|
|
208
|
+
state.health_contributions[perpBalance.product_id],
|
|
185
209
|
),
|
|
186
210
|
...mapEngineServerPerpProduct(product).product,
|
|
187
211
|
});
|
|
188
212
|
});
|
|
189
213
|
|
|
190
214
|
return {
|
|
191
|
-
balances
|
|
192
|
-
exists: baseResponse.exists,
|
|
215
|
+
balances,
|
|
193
216
|
health: {
|
|
194
217
|
initial: {
|
|
195
|
-
health: toBigDecimal(
|
|
196
|
-
assets: toBigDecimal(
|
|
197
|
-
liabilities: toBigDecimal(
|
|
218
|
+
health: toBigDecimal(state.healths[0].health),
|
|
219
|
+
assets: toBigDecimal(state.healths[0].assets),
|
|
220
|
+
liabilities: toBigDecimal(state.healths[0].liabilities),
|
|
198
221
|
},
|
|
199
222
|
maintenance: {
|
|
200
|
-
health: toBigDecimal(
|
|
201
|
-
assets: toBigDecimal(
|
|
202
|
-
liabilities: toBigDecimal(
|
|
223
|
+
health: toBigDecimal(state.healths[1].health),
|
|
224
|
+
assets: toBigDecimal(state.healths[1].assets),
|
|
225
|
+
liabilities: toBigDecimal(state.healths[1].liabilities),
|
|
203
226
|
},
|
|
204
227
|
unweighted: {
|
|
205
|
-
health: toBigDecimal(
|
|
206
|
-
assets: toBigDecimal(
|
|
207
|
-
liabilities: toBigDecimal(
|
|
228
|
+
health: toBigDecimal(state.healths[2].health),
|
|
229
|
+
assets: toBigDecimal(state.healths[2].assets),
|
|
230
|
+
liabilities: toBigDecimal(state.healths[2].liabilities),
|
|
208
231
|
},
|
|
209
232
|
},
|
|
210
233
|
};
|