@liberfi.io/react-predict 0.3.60 → 0.3.61

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.mjs CHANGED
@@ -1771,7 +1771,8 @@ function getOpenOrderCount(snapshot) {
1771
1771
  function hasBothAccountFields(snapshot) {
1772
1772
  return snapshot.balance !== void 0 && snapshot.positions !== void 0;
1773
1773
  }
1774
- function isTradeResultConfirmed(expectation, baseline, current) {
1774
+ function isTradeResultConfirmed(input, baseline, current) {
1775
+ const expectation = input.expectation;
1775
1776
  const ordersChanged = didFieldChange("orders", baseline, current);
1776
1777
  const baselineOpenOrders = getOpenOrderCount(baseline);
1777
1778
  const currentOpenOrders = getOpenOrderCount(current);
@@ -1801,6 +1802,9 @@ function isTradeResultConfirmed(expectation, baseline, current) {
1801
1802
  case "sell-market":
1802
1803
  return balanceIncreased && positionsDecreased;
1803
1804
  case "redeem":
1805
+ if (input.expectedPayout !== void 0 && input.expectedPayout <= 0) {
1806
+ return positionsChanged;
1807
+ }
1804
1808
  return balanceChanged && positionsChanged;
1805
1809
  case "cancel-order":
1806
1810
  return false;
@@ -1955,7 +1959,7 @@ async function runFixedIntervalConfirmation({
1955
1959
  if (value === void 0 || settled) return;
1956
1960
  if (baseline[field] === void 0) {
1957
1961
  current[field] = value;
1958
- if (field === "orders" && isLimitExpectation(input.expectation) && isTradeResultConfirmed(input.expectation, baseline, current)) {
1962
+ if (field === "orders" && isLimitExpectation(input.expectation) && isTradeResultConfirmed(input, baseline, current)) {
1959
1963
  finishConfirmed();
1960
1964
  return;
1961
1965
  }
@@ -1963,7 +1967,7 @@ async function runFixedIntervalConfirmation({
1963
1967
  return;
1964
1968
  }
1965
1969
  current[field] = value;
1966
- if (isTradeResultConfirmed(input.expectation, baseline, current)) {
1970
+ if (isTradeResultConfirmed(input, baseline, current)) {
1967
1971
  finishConfirmed();
1968
1972
  }
1969
1973
  };