Module transitions

Source
Expand description

Pure transition functions for the OpState machine.

These functions define how the vault’s operation state machine changes state in response to events. They are pure functions: no side effects, no storage access.

§Design Principles

  1. Pure Functions: Each transition takes the current state and inputs, returning a new state and a list of effects to execute.
  2. Explicit State Requirements: Transitions check that the machine is in the expected state before proceeding.
  3. Effect-Based Output: Side effects (transfers, burns, etc.) are returned as KernelEffect values rather than executed directly.

§State Machine

Idle -> Allocating (start_allocation)
Idle -> Withdrawing (start_withdrawal)
Idle -> Refreshing (start_refresh)
Allocating -> Withdrawing | Idle (complete_allocation)
Withdrawing -> Withdrawing (advance_withdrawal)
Withdrawing -> Payout (withdrawal_collected)
Withdrawing -> Idle (stop_withdrawal)
Refreshing -> Idle (complete_refresh)
Payout -> Idle (payout_complete)

Structs§

TransitionResult
Result of a successful state transition.
WithdrawalRequest
Request for a withdrawal operation.

Enums§

TransitionError
Error types for state transitions.

Functions§

allocation_step_callback
Process one step of allocation (callback from market).
complete_allocation
Complete allocation and transition to next state.
complete_refresh
Complete refresh and return to Idle.
payout_complete
Complete payout and return to Idle.
refresh_step_callback
Process one step of refresh (callback from target).
start_allocation
Start an allocation from Idle state.
start_refresh
Start a refresh operation from Idle state.
start_withdrawal
Start a withdrawal from Idle state.
stop_withdrawal
Stop withdrawal and refund escrow shares.
withdrawal_collected
Transition from Withdrawing to Payout when enough has been collected.
withdrawal_settled
withdrawal_step_callback
Advance withdrawal by recording collected funds.

Type Aliases§

TransitionRes
Type alias for transition function results.