@orderly.network/ui-tpsl 3.1.2 → 3.1.3-alpha.0

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.js CHANGED
@@ -1393,6 +1393,7 @@ var useTPSLBuilder = (options) => {
1393
1393
  symbol,
1394
1394
  position?.margin_mode ?? options.position?.margin_mode ?? types.MarginMode.CROSS
1395
1395
  );
1396
+ const effectivePositionType = triggerPrice ? types.PositionType.PARTIAL : positionType;
1396
1397
  react.useEffect(() => {
1397
1398
  if (!position) {
1398
1399
  options.close?.();
@@ -1421,7 +1422,7 @@ var useTPSLBuilder = (options) => {
1421
1422
  },
1422
1423
  {
1423
1424
  defaultOrder: order2,
1424
- positionType: triggerPrice ? types.PositionType.PARTIAL : positionType,
1425
+ positionType: effectivePositionType,
1425
1426
  // tpslEnable: {
1426
1427
  // tp_enable: !withTriggerPrice ? true : type === "tp",
1427
1428
  // sl_enable: !withTriggerPrice ? true : type === "sl",
@@ -1448,6 +1449,21 @@ var useTPSLBuilder = (options) => {
1448
1449
  () => Math.abs(Number(position?.position_qty)),
1449
1450
  [position?.position_qty]
1450
1451
  );
1452
+ react.useEffect(() => {
1453
+ if (!position || !Number.isFinite(maxQty)) {
1454
+ return;
1455
+ }
1456
+ const quantity = Number(tpslOrder.quantity);
1457
+ if (effectivePositionType === types.PositionType.FULL) {
1458
+ if (quantity !== maxQty) {
1459
+ setValue("quantity", maxQty);
1460
+ }
1461
+ return;
1462
+ }
1463
+ if (quantity > maxQty) {
1464
+ setValue("quantity", maxQty);
1465
+ }
1466
+ }, [effectivePositionType, maxQty, position, setValue, tpslOrder.quantity]);
1451
1467
  react.useMemo(() => {
1452
1468
  const quantity = order2?.algo_type === types.AlgoOrderRootType.POSITIONAL_TP_SL ? maxQty : order2?.quantity;
1453
1469
  let diff = 0;
@@ -1558,7 +1574,7 @@ var useTPSLBuilder = (options) => {
1558
1574
  content: /* @__PURE__ */ jsxRuntime.jsx(
1559
1575
  PositionTPSLConfirm,
1560
1576
  {
1561
- isPositionTPSL: positionType === types.PositionType.FULL,
1577
+ isPositionTPSL: effectivePositionType === types.PositionType.FULL,
1562
1578
  isEditing,
1563
1579
  symbol: order3.symbol,
1564
1580
  qty: Number(order3.quantity),