Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolate state tracking of multi-hop trades into discrete state machines #5740

Closed
woodenfurniture opened this issue Nov 30, 2023 · 0 comments · Fixed by #5745
Closed

Isolate state tracking of multi-hop trades into discrete state machines #5740

woodenfurniture opened this issue Nov 30, 2023 · 0 comments · Fixed by #5745
Assignees

Comments

@woodenfurniture
Copy link
Member

Overview

The task involves refactoring the state management of a React Redux application with a complex, multi-layered state machine. The current state architecture is overly complicated due to redundant states and logic in the upper layers, leading to a need for simplification and deduplication. The aim is to streamline the state machine, reduce complexity, and improve maintainability.

Specifically, you will be consolidating the state management from a structure with duplicated states across two levels (top-level and second-level state machines for first and second hop processes) into a more efficient and less repetitive structure. The proposed structure involves having a top-level TradeState with nested HopStates (FirstHop and SecondHop) that encapsulate the various states and transitions of the trading process (Approval, Swap, etc.) along with their respective TransactionStates and TxStatuses. This approach centralizes and simplifies the state management by removing duplicate states and focusing on nesting and orchestration of state machines at lower levels.

References and additional details

Example structure of nested states without duplication:

TradeState.Previewing
TradeState.FirstHop
  |- HopState.Pending
  |- HopState.Approval
  |  |- TransactionState.Pending
  |  |-TransactionState.AwaitingConfirmation
  |  |-TransactionState.AwaitingExecution
  |  |  |-TxStatus.Unknown
  |  |  |-TxStatus.Pending
  |  |  |-TxStatus.Complete
  |  |-TransactionState.Complete
  |- HopState.Swap
  |  |- TransactionState.Pending
  |  |-TransactionState.AwaitingConfirmation
  |  |-TransactionState.AwaitingExecution
  |  |  |-TxStatus.Unknown
  |  |  |-TxStatus.Pending
  |  |  |-TxStatus.Complete
  |  |-TransactionState.Complete
  |- HopState.Complete
TradeState.SecondHop
  |- HopState.Pending
  |- HopState.Approval
  |  |- TransactionState.Pending
  |  |-TransactionState.AwaitingConfirmation
  |  |-TransactionState.AwaitingExecution
  |  |  |-TxStatus.Unknown
  |  |  |-TxStatus.Pending
  |  |  |-TxStatus.Complete
  |  |-TransactionState.Complete
  |- HopState.Swap
  |  |- TransactionState.Pending
  |  |-TransactionState.AwaitingConfirmation
  |  |-TransactionState.AwaitingExecution
  |  |  |-TxStatus.Unknown
  |  |  |-TxStatus.Pending
  |  |  |-TxStatus.Complete
  |  |-TransactionState.Complete
  |- HopState.Complete
TradeState.TradeComplete

Acceptance Criteria

  1. State Deduplication: The refactored state machine should eliminate all duplicate states and logic, ensuring each state is unique and purpose-specific.

  2. Nested State Management: Implement nested state management where the top-level TradeState contains FirstHop and SecondHop as sub-states, each with its own HopState, TransactionState, and TxStatus.

  3. Consistency and Integrity: The new state structure must maintain consistency and integrity of data across all levels of the state machine.

Need By Date

No response

Screenshots/Mockups

image

Estimated effort

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
1 participant