pub enum ConditionalOrderKind {
Twap(TwapOrder),
StopLoss(StopLossOrder),
GoodAfterTime(GatOrder),
Unknown(ConditionalOrderParams),
}Expand description
A conditional order decoded from on-chain ConditionalOrderParams.
Variants§
Twap(TwapOrder)
A TWAP (Time-Weighted Average Price) order.
StopLoss(StopLossOrder)
A stop-loss order that triggers when the price falls below a strike price.
GoodAfterTime(GatOrder)
A GoodAfterTime order that becomes valid only after a given timestamp.
Unknown(ConditionalOrderParams)
An order whose handler is not recognised by this factory.
Implementations§
Source§impl ConditionalOrderKind
impl ConditionalOrderKind
Sourcepub const fn as_str(&self) -> &'static str
pub const fn as_str(&self) -> &'static str
Returns a short string label for the order kind.
§Returns
A &'static str identifying the variant: "twap", "stop-loss",
"good-after-time", or "unknown".
Sourcepub const fn is_twap(&self) -> bool
pub const fn is_twap(&self) -> bool
Returns true if this is a TWAP conditional order.
use alloy_primitives::B256;
use cow_rs::composable::{
ConditionalOrderFactory, ConditionalOrderParams, TWAP_HANDLER_ADDRESS,
};
let params = ConditionalOrderParams {
handler: TWAP_HANDLER_ADDRESS,
salt: B256::ZERO,
static_input: vec![],
};
// An unknown handler resolves to Unknown, not Twap.
use alloy_primitives::Address;
let unknown = cow_rs::composable::ConditionalOrderKind::Unknown(ConditionalOrderParams {
handler: Address::ZERO,
salt: B256::ZERO,
static_input: vec![],
});
assert!(!unknown.is_twap());
assert!(unknown.is_unknown());Sourcepub const fn is_stop_loss(&self) -> bool
pub const fn is_stop_loss(&self) -> bool
Returns true if this is a stop-loss conditional order.
use alloy_primitives::{Address, B256};
use cow_rs::composable::{ConditionalOrderKind, ConditionalOrderParams};
let unknown = ConditionalOrderKind::Unknown(ConditionalOrderParams {
handler: Address::ZERO,
salt: B256::ZERO,
static_input: vec![],
});
assert!(!unknown.is_stop_loss());Sourcepub const fn is_good_after_time(&self) -> bool
pub const fn is_good_after_time(&self) -> bool
Returns true if this is a GoodAfterTime conditional order.
use alloy_primitives::{Address, B256};
use cow_rs::composable::{ConditionalOrderKind, ConditionalOrderParams};
let unknown = ConditionalOrderKind::Unknown(ConditionalOrderParams {
handler: Address::ZERO,
salt: B256::ZERO,
static_input: vec![],
});
assert!(!unknown.is_good_after_time());Sourcepub const fn is_unknown(&self) -> bool
pub const fn is_unknown(&self) -> bool
Returns true if this order’s handler is not recognised by the factory.
§Returns
true when the variant is ConditionalOrderKind::Unknown, meaning the
handler address did not match any known conditional order type.
Trait Implementations§
Source§impl Clone for ConditionalOrderKind
impl Clone for ConditionalOrderKind
Source§fn clone(&self) -> ConditionalOrderKind
fn clone(&self) -> ConditionalOrderKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConditionalOrderKind
impl Debug for ConditionalOrderKind
Auto Trait Implementations§
impl Freeze for ConditionalOrderKind
impl RefUnwindSafe for ConditionalOrderKind
impl Send for ConditionalOrderKind
impl Sync for ConditionalOrderKind
impl Unpin for ConditionalOrderKind
impl UnsafeUnpin for ConditionalOrderKind
impl UnwindSafe for ConditionalOrderKind
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.