@rabby-wallet/hyperliquid-sdk 1.0.8-beta3 → 1.0.8-beta4

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.
@@ -211,7 +211,8 @@ class ExchangeClient {
211
211
  return __awaiter(this, void 0, void 0, function* () {
212
212
  try {
213
213
  const slippage = params.slippage || constants_1.SLIPPAGE;
214
- const px = this.getSlippagePx((0, number_1.removeTrailingZeros)(params.midPx), slippage, params.isBuy);
214
+ const szDecimals = yield this.symbolConversion.getAssetSzDecimals(params.coin);
215
+ const px = this.getSlippagePx((0, number_1.removeTrailingZeros)(params.midPx), slippage, params.isBuy, szDecimals);
215
216
  const orders = [{
216
217
  coin: params.coin,
217
218
  isBuy: params.isBuy,
@@ -269,7 +270,8 @@ class ExchangeClient {
269
270
  return __awaiter(this, void 0, void 0, function* () {
270
271
  try {
271
272
  const slippage = params.slippage || constants_1.SLIPPAGE;
272
- const px = this.getSlippagePx(params.midPx, slippage, params.isBuy);
273
+ const szDecimals = yield this.symbolConversion.getAssetSzDecimals(params.coin);
274
+ const px = this.getSlippagePx(params.midPx, slippage, params.isBuy, szDecimals);
273
275
  const orders = [{
274
276
  coin: params.coin,
275
277
  isBuy: params.isBuy,
@@ -294,6 +296,7 @@ class ExchangeClient {
294
296
  */
295
297
  multiOrder(params) {
296
298
  return __awaiter(this, void 0, void 0, function* () {
299
+ var _a, _b, _c;
297
300
  const nonce = Date.now();
298
301
  const assetIndexCache = new Map();
299
302
  const orderWires = yield Promise.all(params.orders.map((order) => __awaiter(this, void 0, void 0, function* () {
@@ -323,22 +326,29 @@ class ExchangeClient {
323
326
  };
324
327
  }
325
328
  const signature = (0, signer_1.signL1AgentAction)(this.getAgentPrivateKey(), action, this.isTestnet, nonce);
326
- return this.httpClient.exchange({
329
+ const res = yield this.httpClient.exchange({
327
330
  action,
328
331
  nonce,
329
332
  signature,
330
333
  });
334
+ (_c = (_b = (_a = res === null || res === void 0 ? void 0 : res.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.statuses) === null || _c === void 0 ? void 0 : _c.forEach((status, index) => {
335
+ if (status.error) {
336
+ throw new Error(status.error);
337
+ }
338
+ });
339
+ return res;
331
340
  });
332
341
  }
333
342
  bindTpslByOrderId(params) {
334
343
  return __awaiter(this, void 0, void 0, function* () {
335
344
  let orders = [];
345
+ const szDecimals = yield this.symbolConversion.getAssetSzDecimals(params.coin);
336
346
  if (params.tpTriggerPx) {
337
347
  orders.push({
338
348
  coin: params.coin,
339
349
  isBuy: !params.isBuy,
340
350
  sz: '0',
341
- limitPx: this.getSlippagePx((0, number_1.removeTrailingZeros)(params.tpTriggerPx), constants_1.SLIPPAGE, !params.isBuy),
351
+ limitPx: this.getSlippagePx((0, number_1.removeTrailingZeros)(params.tpTriggerPx), constants_1.SLIPPAGE, !params.isBuy, szDecimals),
342
352
  reduceOnly: true,
343
353
  orderType: {
344
354
  trigger: {
@@ -354,7 +364,7 @@ class ExchangeClient {
354
364
  coin: params.coin,
355
365
  isBuy: !params.isBuy,
356
366
  sz: '0',
357
- limitPx: this.getSlippagePx((0, number_1.removeTrailingZeros)(params.slTriggerPx), constants_1.SLIPPAGE, !params.isBuy),
367
+ limitPx: this.getSlippagePx((0, number_1.removeTrailingZeros)(params.slTriggerPx), constants_1.SLIPPAGE, !params.isBuy, szDecimals),
358
368
  reduceOnly: true,
359
369
  orderType: {
360
370
  trigger: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/hyperliquid-sdk",
3
- "version": "1.0.8-beta3",
3
+ "version": "1.0.8-beta4",
4
4
  "description": "Simplified Hyperliquid Perpetuals Trading SDK for Frontend Applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",