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.
Trait Implementations§
Source§impl BorshDeserialize for OpState
impl BorshDeserialize for OpState
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSchema for OpState
impl BorshSchema for OpState
Source§fn declaration() -> Declaration
fn declaration() -> Declaration
Source§fn add_definitions_recursively(
definitions: &mut BTreeMap<Declaration, Definition>,
)
fn add_definitions_recursively( definitions: &mut BTreeMap<Declaration, Definition>, )
Source§impl<'de> Deserialize<'de> for OpState
impl<'de> Deserialize<'de> for OpState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<AllocatingState> for OpState
impl From<AllocatingState> for OpState
Source§fn from(value: AllocatingState) -> Self
fn from(value: AllocatingState) -> Self
Source§impl From<PayoutState> for OpState
impl From<PayoutState> for OpState
Source§fn from(value: PayoutState) -> Self
fn from(value: PayoutState) -> Self
Source§impl From<RefreshingState> for OpState
impl From<RefreshingState> for OpState
Source§fn from(value: RefreshingState) -> Self
fn from(value: RefreshingState) -> Self
Source§impl From<WithdrawingState> for OpState
impl From<WithdrawingState> for OpState
Source§fn from(value: WithdrawingState) -> Self
fn from(value: WithdrawingState) -> Self
impl Eq for OpState
impl StructuralPartialEq for OpState
Auto Trait Implementations§
impl Freeze for OpState
impl RefUnwindSafe for OpState
impl Send for OpState
impl Sync for OpState
impl Unpin for OpState
impl UnwindSafe for OpState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.