aftermath-ts-sdk 3.3.3-dev.f140328 → 3.3.3

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/index.d.ts CHANGED
@@ -10597,8 +10597,9 @@ declare class PerpetualsAccount extends Caller {
10597
10597
  * A stop order is considered SL/TP if it appears in the combined set of
10598
10598
  * SL/TP orders across **all** markets (see {@link slTpStopOrderDatas}).
10599
10599
  *
10600
- * Matching uses the stop-order object ID, so bigint fields and field ordering
10601
- * do not affect classification.
10600
+ * Note:
10601
+ * - This implementation uses JSON string equality to compare objects.
10602
+ * This is pragmatic but assumes stable field ordering and identical shapes.
10602
10603
  *
10603
10604
  * @param inputs.stopOrderDatas - Full array of stop-order ticket data.
10604
10605
  * @returns An array of non-SL/TP stop orders, or `undefined` if none exist.
package/dist/index.js CHANGED
@@ -11000,8 +11000,9 @@ var init_perpetualsAccount = __esm({
11000
11000
  * A stop order is considered SL/TP if it appears in the combined set of
11001
11001
  * SL/TP orders across **all** markets (see {@link slTpStopOrderDatas}).
11002
11002
  *
11003
- * Matching uses the stop-order object ID, so bigint fields and field ordering
11004
- * do not affect classification.
11003
+ * Note:
11004
+ * - This implementation uses JSON string equality to compare objects.
11005
+ * This is pragmatic but assumes stable field ordering and identical shapes.
11005
11006
  *
11006
11007
  * @param inputs.stopOrderDatas - Full array of stop-order ticket data.
11007
11008
  * @returns An array of non-SL/TP stop orders, or `undefined` if none exist.
@@ -11009,11 +11010,8 @@ var init_perpetualsAccount = __esm({
11009
11010
  nonSlTpStopOrderDatas(inputs) {
11010
11011
  const { stopOrderDatas } = inputs;
11011
11012
  const slTpOrders = this.slTpStopOrderDatas(inputs);
11012
- const slTpOrderIds = new Set(
11013
- (slTpOrders ?? []).map((slTpOrder) => slTpOrder.objectId)
11014
- );
11015
11013
  const stopOrders = stopOrderDatas.filter(
11016
- (stopOrder) => !slTpOrderIds.has(stopOrder.objectId)
11014
+ (stopOrder) => !(slTpOrders ?? []).map((slTpOrder) => JSON.stringify(slTpOrder)).includes(JSON.stringify(stopOrder))
11017
11015
  );
11018
11016
  return stopOrders.length <= 0 ? void 0 : stopOrders;
11019
11017
  }
@@ -11083,14 +11081,11 @@ var init_perpetualsAccount = __esm({
11083
11081
  return void 0;
11084
11082
  }
11085
11083
  const { fullSlTpOrder, partialSlTpOrders } = this.slTpStopOrderDatasForPosition(inputs);
11086
- const slTpOrderIds = new Set(
11087
- [
11084
+ const stopOrders = stopOrderDatas.filter(
11085
+ (stopOrder) => !(stopOrder.limitOrder || [
11088
11086
  ...fullSlTpOrder ? [fullSlTpOrder] : [],
11089
11087
  ...partialSlTpOrders ?? []
11090
- ].map((slTpOrder) => slTpOrder.objectId)
11091
- );
11092
- const stopOrders = stopOrderDatas.filter(
11093
- (stopOrder) => !(stopOrder.limitOrder || slTpOrderIds.has(stopOrder.objectId))
11088
+ ].map((slTpOrder) => JSON.stringify(slTpOrder)).includes(JSON.stringify(stopOrder)))
11094
11089
  );
11095
11090
  return stopOrders.length <= 0 ? void 0 : stopOrders;
11096
11091
  }
@@ -11477,14 +11472,9 @@ var init_perpetualsMarket = __esm({
11477
11472
  */
11478
11473
  this.roundToValidPriceBigInt = (inputs) => {
11479
11474
  const scaledPrice = Number(inputs.price * Casting.Fixed.fixedOneN9);
11480
- const ticks = scaledPrice / Number(this.marketParams.tickSize);
11481
- let roundedTicks = Math.round(ticks);
11482
- if (inputs.floor) {
11483
- roundedTicks = Math.floor(ticks);
11484
- } else if (inputs.ceil) {
11485
- roundedTicks = Math.ceil(ticks);
11486
- }
11487
- return BigInt(roundedTicks) * this.marketParams.tickSize;
11475
+ return BigInt(
11476
+ inputs.floor ? Math.floor(scaledPrice) : inputs.ceil ? Math.ceil(scaledPrice) : Math.round(scaledPrice)
11477
+ ) / this.marketParams.tickSize * this.marketParams.tickSize;
11488
11478
  };
11489
11479
  /**
11490
11480
  * Round a base-asset size to the nearest valid lot size for this market.
@@ -11513,14 +11503,9 @@ var init_perpetualsMarket = __esm({
11513
11503
  */
11514
11504
  this.roundToValidSizeBigInt = (inputs) => {
11515
11505
  const scaledSize = Number(inputs.size * Casting.Fixed.fixedOneN9);
11516
- const lots = scaledSize / Number(this.marketParams.lotSize);
11517
- let roundedLots = Math.round(lots);
11518
- if (inputs.floor) {
11519
- roundedLots = Math.floor(lots);
11520
- } else if (inputs.ceil) {
11521
- roundedLots = Math.ceil(lots);
11522
- }
11523
- return BigInt(roundedLots) * this.marketParams.lotSize;
11506
+ return BigInt(
11507
+ inputs.floor ? Math.floor(scaledSize) : inputs.ceil ? Math.ceil(scaledSize) : Math.round(scaledSize)
11508
+ ) / this.marketParams.lotSize * this.marketParams.lotSize;
11524
11509
  };
11525
11510
  /**
11526
11511
  * Construct an "empty" position object for this market.