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
- Pure Functions: Each transition takes the current state and inputs, returning a new state and a list of effects to execute.
- Explicit State Requirements: Transitions check that the machine is in the expected state before proceeding.
- Effect-Based Output: Side effects (transfers, burns, etc.) are returned
as
KernelEffectvalues 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§
- Transition
Result - Result of a successful state transition.
- Withdrawal
Request - Request for a withdrawal operation.
Enums§
- Transition
Error - 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§
- Transition
Res - Type alias for transition function results.