aftermath-ts-sdk 3.3.2 → 3.3.3-dev.f140328
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 +2 -3
- package/dist/index.js +29 -14
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
package/dist/index.d.ts
CHANGED
|
@@ -10597,9 +10597,8 @@ 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
|
-
*
|
|
10601
|
-
*
|
|
10602
|
-
* This is pragmatic but assumes stable field ordering and identical shapes.
|
|
10600
|
+
* Matching uses the stop-order object ID, so bigint fields and field ordering
|
|
10601
|
+
* do not affect classification.
|
|
10603
10602
|
*
|
|
10604
10603
|
* @param inputs.stopOrderDatas - Full array of stop-order ticket data.
|
|
10605
10604
|
* @returns An array of non-SL/TP stop orders, or `undefined` if none exist.
|
package/dist/index.js
CHANGED
|
@@ -11000,9 +11000,8 @@ 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
|
-
*
|
|
11004
|
-
*
|
|
11005
|
-
* This is pragmatic but assumes stable field ordering and identical shapes.
|
|
11003
|
+
* Matching uses the stop-order object ID, so bigint fields and field ordering
|
|
11004
|
+
* do not affect classification.
|
|
11006
11005
|
*
|
|
11007
11006
|
* @param inputs.stopOrderDatas - Full array of stop-order ticket data.
|
|
11008
11007
|
* @returns An array of non-SL/TP stop orders, or `undefined` if none exist.
|
|
@@ -11010,8 +11009,11 @@ var init_perpetualsAccount = __esm({
|
|
|
11010
11009
|
nonSlTpStopOrderDatas(inputs) {
|
|
11011
11010
|
const { stopOrderDatas } = inputs;
|
|
11012
11011
|
const slTpOrders = this.slTpStopOrderDatas(inputs);
|
|
11012
|
+
const slTpOrderIds = new Set(
|
|
11013
|
+
(slTpOrders ?? []).map((slTpOrder) => slTpOrder.objectId)
|
|
11014
|
+
);
|
|
11013
11015
|
const stopOrders = stopOrderDatas.filter(
|
|
11014
|
-
(stopOrder) => !
|
|
11016
|
+
(stopOrder) => !slTpOrderIds.has(stopOrder.objectId)
|
|
11015
11017
|
);
|
|
11016
11018
|
return stopOrders.length <= 0 ? void 0 : stopOrders;
|
|
11017
11019
|
}
|
|
@@ -11081,11 +11083,14 @@ var init_perpetualsAccount = __esm({
|
|
|
11081
11083
|
return void 0;
|
|
11082
11084
|
}
|
|
11083
11085
|
const { fullSlTpOrder, partialSlTpOrders } = this.slTpStopOrderDatasForPosition(inputs);
|
|
11084
|
-
const
|
|
11085
|
-
|
|
11086
|
+
const slTpOrderIds = new Set(
|
|
11087
|
+
[
|
|
11086
11088
|
...fullSlTpOrder ? [fullSlTpOrder] : [],
|
|
11087
11089
|
...partialSlTpOrders ?? []
|
|
11088
|
-
].map((slTpOrder) =>
|
|
11090
|
+
].map((slTpOrder) => slTpOrder.objectId)
|
|
11091
|
+
);
|
|
11092
|
+
const stopOrders = stopOrderDatas.filter(
|
|
11093
|
+
(stopOrder) => !(stopOrder.limitOrder || slTpOrderIds.has(stopOrder.objectId))
|
|
11089
11094
|
);
|
|
11090
11095
|
return stopOrders.length <= 0 ? void 0 : stopOrders;
|
|
11091
11096
|
}
|
|
@@ -11472,9 +11477,14 @@ var init_perpetualsMarket = __esm({
|
|
|
11472
11477
|
*/
|
|
11473
11478
|
this.roundToValidPriceBigInt = (inputs) => {
|
|
11474
11479
|
const scaledPrice = Number(inputs.price * Casting.Fixed.fixedOneN9);
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
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;
|
|
11478
11488
|
};
|
|
11479
11489
|
/**
|
|
11480
11490
|
* Round a base-asset size to the nearest valid lot size for this market.
|
|
@@ -11503,9 +11513,14 @@ var init_perpetualsMarket = __esm({
|
|
|
11503
11513
|
*/
|
|
11504
11514
|
this.roundToValidSizeBigInt = (inputs) => {
|
|
11505
11515
|
const scaledSize = Number(inputs.size * Casting.Fixed.fixedOneN9);
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
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;
|
|
11509
11524
|
};
|
|
11510
11525
|
/**
|
|
11511
11526
|
* Construct an "empty" position object for this market.
|
|
@@ -14063,7 +14078,7 @@ var init_router = __esm({
|
|
|
14063
14078
|
const { tx, ...otherInputs } = inputs;
|
|
14064
14079
|
const { tx: newTx, coinOutId } = await this.fetchApi("transactions/add-trade", {
|
|
14065
14080
|
...otherInputs,
|
|
14066
|
-
serializedTx:
|
|
14081
|
+
serializedTx: tx.serialize()
|
|
14067
14082
|
});
|
|
14068
14083
|
return {
|
|
14069
14084
|
tx: Transaction7.from(newTx),
|