Files

4.2 KiB

MODIFIED Requirements

Requirement: Wallet configuration belongs to service construction

The Hub SHALL supply the six PROD wallet addresses and one TEST wallet address specified in issue #98, a read-only Jupiter overview reader and a read-only Phoenix integration at construction. Each service SHALL retain immutable configuration and own its snapshot. Wallet addresses SHALL be used as stable identities and display labels. EMC SHALL neither own nor pass wallet configuration; reads SHALL remain parameterless. Existing Jupiter trading/alarm services SHALL retain their behavior.

Scenario: Separate configured instances

  • WHEN the Hub constructs and starts both instances
  • THEN each instance queries only its configured wallets through its injected integrations
  • AND the implementation does not define the wallet list internally

Requirement: Position mapping is stable and complete

The service SHALL preserve Jupiter position-account identities and its existing USD position-size basis. Phoenix SHALL preserve PDA/subaccount/symbol identities and absolute current notional. Isolated positions SHALL remain directly under venues; Cross accounts SHALL own their positions and shared balances separately. Wallet and position ordering SHALL be deterministic. No account membership SHALL be inferred from instrument labels.

Scenario: Same-market cross and isolated positions

  • WHEN a Phoenix wallet holds SOL in Cross and an isolated subaccount
  • THEN both positions retain distinct IDs and their actual account membership

Scenario: Changed and unknown positions

  • WHEN a successful read returns newly opened positions including an unknown token mint
  • THEN all returned positions appear with stable IDs and exact USD sizes, and the unknown mint is displayed rather than dropped

Requirement: Background Jupiter refresh

The service SHALL refresh immediately after startup and wait 60 seconds after completed cycles without overlap or dependence on EMC visibility. It SHALL use a dedicated read-only Jupiter overview and the Phoenix account reader. Snapshot reads SHALL make no integration calls. No signing or position-management operation SHALL occur; existing transaction/alarm reads SHALL retain their behavior.

Scenario: Background update while EMC is hidden

  • WHEN EMC is hidden and the next refresh is due
  • THEN the service refreshes configured wallets and publishes immutable snapshots
  • AND all UI snapshot reads remain in-memory

ADDED Requirements

Requirement: Complete gross and account-aware totals

Exposure and dollar price PnL SHALL sum through all levels. Exposure SHALL be gross, with positive absolute notionals. Capital and closing Value SHALL count isolated positions and shared Cross accounts once. Missing required components SHALL make only the affected total unavailable. Successfully read empty scopes SHALL total zero. Leverage and PnL percentages SHALL NOT be aggregated.

Scenario: Opposite directions and shared collateral

  • WHEN two Cross positions have notionals 100 USD Long and 100 USD Short, shared collateral 80 USD, combined PnL 5 USD and closing fees 1 USD
  • THEN exposure totals 200 USD, collateral 80 USD and Value 84 USD at account, venue, wallet and root levels
  • AND collapsing any UI group does not change totals

Scenario: First read fails

  • WHEN one configured venue has never been read successfully
  • THEN it remains unknown and cannot silently produce complete portfolio totals

Requirement: Retained observations communicate status

Each venue SHALL carry its last-success time and whether the latest attempt failed. Failure SHALL preserve positions and account balances independently per wallet/venue. A valid funded empty Cross account SHALL remain visible. Retained data SHALL NOT be described as fresh.

Scenario: Last Cross position closes

  • WHEN a successful refresh returns a Cross account with nonzero collateral and no positions
  • THEN its capital and Value remain included without synthetic positions

Scenario: Retained last success

  • WHEN a subsequent read fails
  • THEN its previous observations remain available with their original success time and failure indication