pub enum OpState {
Idle,
Allocating(AllocatingState),
Withdrawing(WithdrawingState),
Refreshing(RefreshingState),
Payout(PayoutState),
}Expand description
Operation state machine for asynchronous allocation, withdrawal, and payout flows.
§State Machine
Allocating->Withdrawing(orIdlevia stop)Withdrawing->Withdrawing(advance) |Payout|Idle(refund)Refreshing->IdlePayout->Idle(success or failure)
§Invariants
idle_balanceincreases only when funds are received and decreases only on payout success.escrow_sharesare refunded on stop/failure or partially burned/refunded on payout success.
Variants§
Idle
No operation in-flight. The vault is ready to start a new allocation or withdrawal.
Allocating(AllocatingState)
Supplying idle underlying to targets according to a plan or queue.
§Transitions
- On completion of allocation:
Withdrawing(to satisfy pending user requests) orIdle(if stopped). - On stop/failure:
Idle.
Withdrawing(WithdrawingState)
Collecting liquidity from targets to satisfy a user withdrawal/redeem request.
§Transitions
- Advance within queue:
Withdrawing(index increments) while collecting funds. - When enough is collected to satisfy the request:
Payout. - If the op is stopped or cannot proceed and needs to refund:
Idle(escrow_shares refunded).
Refreshing(RefreshingState)
Read-only refresh of target principals to update stored AUM.
Payout(PayoutState)
Final step that transfers assets to the receiver and settles the share escrow.
§Transitions
- On success or failure:
Idle.
§Invariant hooks
idle_balancedecreases only on payout success byamount.- On success,
burn_sharesare burned fromescrow_shares; any remainder is refunded. - On failure, all
escrow_sharesare refunded.
Implementations§
Source§impl OpState
impl OpState
Sourcepub const fn is_idle(&self) -> bool
pub const fn is_idle(&self) -> bool
Returns true if this value is of type Idle. Returns false otherwise
Sourcepub const fn is_allocating(&self) -> bool
pub const fn is_allocating(&self) -> bool
Returns true if this value is of type Allocating. Returns false otherwise
Sourcepub const fn is_withdrawing(&self) -> bool
pub const fn is_withdrawing(&self) -> bool
Returns true if this value is of type Withdrawing. Returns false otherwise
Sourcepub const fn is_refreshing(&self) -> bool
pub const fn is_refreshing(&self) -> bool
Returns true if this value is of type Refreshing. Returns false otherwise
Source§impl OpState
impl OpState
Sourcepub const fn kind_name(&self) -> &'static str
pub const fn kind_name(&self) -> &'static str
Returns a human-readable name for the current op state.
Sourcepub const fn as_idle(&self) -> Option<&IdleState>
pub const fn as_idle(&self) -> Option<&IdleState>
Returns a reference to the idle state if this is Idle, otherwise None.
Sourcepub const fn as_allocating(&self) -> Option<&AllocatingState>
pub const fn as_allocating(&self) -> Option<&AllocatingState>
Returns a reference to the allocating state if this is Allocating, otherwise None.
Sourcepub const fn as_withdrawing(&self) -> Option<&WithdrawingState>
pub const fn as_withdrawing(&self) -> Option<&WithdrawingState>
Returns a reference to the withdrawing state if this is Withdrawing, otherwise None.
Sourcepub const fn as_refreshing(&self) -> Option<&RefreshingState>
pub const fn as_refreshing(&self) -> Option<&RefreshingState>
Returns a reference to the refreshing state if this is Refreshing, otherwise None.
Sourcepub const fn as_payout(&self) -> Option<&PayoutState>
pub const fn as_payout(&self) -> Option<&PayoutState>
Returns a reference to the payout state if this is Payout, otherwise None.