@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.d.mts CHANGED
@@ -511,6 +511,12 @@ interface StartTradeResultConfirmationInput {
511
511
  marketSlug?: string;
512
512
  eventSlug?: string;
513
513
  expectation: TradeResultExpectation;
514
+ /**
515
+ * Expected settlement payout for redeem confirmations. Winning redeems should
516
+ * wait for both balance and position changes; losing redeems only clear the
517
+ * position and may not change the cash balance.
518
+ */
519
+ expectedPayout?: number;
514
520
  orderId?: string;
515
521
  maxDurationMs?: number;
516
522
  getOrdersHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
package/dist/index.d.ts CHANGED
@@ -511,6 +511,12 @@ interface StartTradeResultConfirmationInput {
511
511
  marketSlug?: string;
512
512
  eventSlug?: string;
513
513
  expectation: TradeResultExpectation;
514
+ /**
515
+ * Expected settlement payout for redeem confirmations. Winning redeems should
516
+ * wait for both balance and position changes; losing redeems only clear the
517
+ * position and may not change the cash balance.
518
+ */
519
+ expectedPayout?: number;
514
520
  orderId?: string;
515
521
  maxDurationMs?: number;
516
522
  getOrdersHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
package/dist/index.js CHANGED
@@ -1773,7 +1773,8 @@ function getOpenOrderCount(snapshot) {
1773
1773
  function hasBothAccountFields(snapshot) {
1774
1774
  return snapshot.balance !== void 0 && snapshot.positions !== void 0;
1775
1775
  }
1776
- function isTradeResultConfirmed(expectation, baseline, current) {
1776
+ function isTradeResultConfirmed(input, baseline, current) {
1777
+ const expectation = input.expectation;
1777
1778
  const ordersChanged = didFieldChange("orders", baseline, current);
1778
1779
  const baselineOpenOrders = getOpenOrderCount(baseline);
1779
1780
  const currentOpenOrders = getOpenOrderCount(current);
@@ -1803,6 +1804,9 @@ function isTradeResultConfirmed(expectation, baseline, current) {
1803
1804
  case "sell-market":
1804
1805
  return balanceIncreased && positionsDecreased;
1805
1806
  case "redeem":
1807
+ if (input.expectedPayout !== void 0 && input.expectedPayout <= 0) {
1808
+ return positionsChanged;
1809
+ }
1806
1810
  return balanceChanged && positionsChanged;
1807
1811
  case "cancel-order":
1808
1812
  return false;
@@ -1957,7 +1961,7 @@ async function runFixedIntervalConfirmation({
1957
1961
  if (value === void 0 || settled) return;
1958
1962
  if (baseline[field] === void 0) {
1959
1963
  current[field] = value;
1960
- if (field === "orders" && isLimitExpectation(input.expectation) && isTradeResultConfirmed(input.expectation, baseline, current)) {
1964
+ if (field === "orders" && isLimitExpectation(input.expectation) && isTradeResultConfirmed(input, baseline, current)) {
1961
1965
  finishConfirmed();
1962
1966
  return;
1963
1967
  }
@@ -1965,7 +1969,7 @@ async function runFixedIntervalConfirmation({
1965
1969
  return;
1966
1970
  }
1967
1971
  current[field] = value;
1968
- if (isTradeResultConfirmed(input.expectation, baseline, current)) {
1972
+ if (isTradeResultConfirmed(input, baseline, current)) {
1969
1973
  finishConfirmed();
1970
1974
  }
1971
1975
  };