@metamask-previews/perps-controller 16.1.0-preview-6eff555ee → 16.1.0-preview-abca9bcea

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/CHANGELOG.md CHANGED
@@ -9,14 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Fixed
11
11
 
12
- - Keep the terminal HyperLiquid TWAP record when a completing fill ties `lastUpdated` with the activation, so a finished schedule is no longer reported as live. ([#10122](https://github.com/MetaMask/core/pull/10122))
13
- - The venue reports one lifecycle as several `twapHistory` entries, an activation plus a terminal record, and slice fills are looked up by `twapId` so every entry of a schedule receives the same fills. `entry.time` is a whole-second value, so when the final fill is what completed the schedule its millisecond timestamp outranks both entries' own timestamps and both derive an identical `lastUpdated`.
14
- - Collapsing entries with `>=` admitted that tie. The venue returns the terminal record first, so the activation was iterated last and overwrote it, `resolveTwapOrderStatus` mapped `activated` to `Active`, and the schedule stayed listed as live carrying the activation's zero executed size while offering a cancel the venue can no longer act on. Schedules that were `terminated` stop seconds after their last fill, never tie, and were unaffected.
15
- - Terminality is now decided before timestamps, and `lastUpdated` is compared strictly so an equal value keeps the record already collapsed. Termination is still only ever taken from venue status and never inferred from elapsed time, so collateral cannot be reclaimed from a live TWAP. Both the polled read and the subscription adapter are corrected.
16
12
  - Handle zero minimum order amounts and margin fractions reported by Lighter for inactive markets by omitting unusable retired rows, while keeping valid delisted metadata and active market values strict. ([#10110](https://github.com/MetaMask/core/pull/10110))
17
- - Resolve Lighter accounts from sparse address-discovery rows and every API-key slot, settle confirmed missing accounts to an empty state, and preserve the last authoritative state across transport, authentication, and malformed-response failures. ([#10119](https://github.com/MetaMask/core/pull/10119))
18
- - Accept Lighter trade rows that omit the counterparty's realized PnL while continuing to require a valid PnL for the selected account. ([#10119](https://github.com/MetaMask/core/pull/10119))
19
- - Stop emitting a debug log for every Lighter price-stream frame. ([#10119](https://github.com/MetaMask/core/pull/10119))
20
13
 
21
14
  ## [16.1.0]
22
15
 
@@ -548,31 +548,6 @@ const resolveTwapOrderStatus = (historyEntry, executedSize, totalSize) => {
548
548
  return PerpsTwapLifecycleStatus.Active;
549
549
  }
550
550
  };
551
- /**
552
- * Decide whether a newly adapted schedule replaces the one already collapsed
553
- * under the same order id.
554
- *
555
- * The venue reports one lifecycle as several history entries — an activation
556
- * plus a terminal record — and `lastUpdated` folds in slice fills that every
557
- * entry sharing a `twapId` receives. A schedule whose final fill completed it
558
- * therefore derives the same `lastUpdated` on both entries, because that fill
559
- * outranks each entry's own whole-second timestamp. Ordering on `lastUpdated`
560
- * alone admits that tie, letting the activation overwrite the terminal record
561
- * so the schedule reads as live long after it ended. Terminality decides
562
- * first, and an equal `lastUpdated` keeps the entry already collapsed.
563
- *
564
- * @param candidate - Schedule adapted from the current history entry.
565
- * @param existing - Schedule already collapsed under this order id.
566
- * @returns True when the candidate replaces the existing schedule.
567
- */
568
- const supersedesCollapsedTwapOrder = (candidate, existing) => {
569
- const candidateIsTerminal = candidate.status !== PerpsTwapLifecycleStatus.Active;
570
- const existingIsTerminal = existing.status !== PerpsTwapLifecycleStatus.Active;
571
- if (candidateIsTerminal !== existingIsTerminal) {
572
- return candidateIsTerminal;
573
- }
574
- return candidate.lastUpdated > existing.lastUpdated;
575
- };
576
551
  const adaptTwapOrderFill = (entry) => ({
577
552
  fillId: entry.fill.tid.toString(),
578
553
  orderId: entry.fill.oid.toString(),
@@ -1331,7 +1306,7 @@ class HyperLiquidProvider {
1331
1306
  continue;
1332
1307
  }
1333
1308
  const existing = ordersById.get(order.orderId);
1334
- if (!existing || supersedesCollapsedTwapOrder(order, existing)) {
1309
+ if (!existing || order.lastUpdated >= existing.lastUpdated) {
1335
1310
  ordersById.set(order.orderId, order);
1336
1311
  }
1337
1312
  }
@@ -4873,7 +4848,7 @@ class HyperLiquidProvider {
4873
4848
  continue;
4874
4849
  }
4875
4850
  const existing = ordersById.get(order.orderId);
4876
- if (!existing || supersedesCollapsedTwapOrder(order, existing)) {
4851
+ if (!existing || order.lastUpdated >= existing.lastUpdated) {
4877
4852
  ordersById.set(order.orderId, order);
4878
4853
  }
4879
4854
  }