Skip to main content

Order

Struct Order 

Source
pub struct Order {
Show 33 fields pub uid: String, pub owner: Address, pub creation_date: String, pub status: OrderStatus, pub class: Option<OrderClass>, pub sell_token: Address, pub buy_token: Address, pub receiver: Option<Address>, pub sell_amount: String, pub buy_amount: String, pub valid_to: u32, pub app_data: String, pub full_app_data: Option<String>, pub fee_amount: String, pub kind: OrderKind, pub partially_fillable: bool, pub executed_sell_amount: String, pub executed_buy_amount: String, pub executed_sell_amount_before_fees: String, pub executed_fee_amount: String, pub invalidated: bool, pub is_liquidity_order: Option<bool>, pub signing_scheme: SigningScheme, pub signature: String, pub interactions: Option<OrderInteractions>, pub total_fee: Option<String>, pub full_fee_amount: Option<String>, pub available_balance: Option<String>, pub quote_id: Option<i64>, pub executed_fee: Option<String>, pub ethflow_data: Option<EthflowData>, pub onchain_order_data: Option<OnchainOrderData>, pub onchain_user: Option<Address>,
}
Expand description

A full order record returned by GET /api/v1/orders/{uid}.

Fields§

§uid: String

Unique order identifier.

§owner: Address

Owner / signer address.

§creation_date: String

When the order was submitted (ISO 8601).

§status: OrderStatus

Current lifecycle status.

§class: Option<OrderClass>

Market, limit, or liquidity.

§sell_token: Address

Token to sell.

§buy_token: Address

Token to buy.

§receiver: Option<Address>

Receiver address.

§sell_amount: String

Requested sell amount.

§buy_amount: String

Minimum buy amount.

§valid_to: u32

Order expiry.

§app_data: String

App-data hash (bytes32 hex).

§full_app_data: Option<String>

Full app-data JSON, if it was previously uploaded to the orderbook.

§fee_amount: String

Protocol fee.

§kind: OrderKind

Sell or buy.

§partially_fillable: bool

Partial fill flag.

§executed_sell_amount: String

Amount of sell token executed so far.

§executed_buy_amount: String

Amount of buy token executed so far.

§executed_sell_amount_before_fees: String

Sell amount executed before fees.

§executed_fee_amount: String

Fee amount executed so far.

§invalidated: bool

Whether the order has been invalidated on-chain.

§is_liquidity_order: Option<bool>

Whether this is a liquidity (solver-internal) order rather than an active user order.

§signing_scheme: SigningScheme

Signing scheme.

§signature: String

Hex-encoded signature.

§interactions: Option<OrderInteractions>

On-chain interaction hooks attached to this order.

§total_fee: Option<String>

Total fee paid by the order (network + protocol fees, in sell-token atoms).

Present on enriched order responses (EnrichedOrder in the TypeScript SDK).

§full_fee_amount: Option<String>

Unsubsidised fee amount (what the fee would be without CoW subsidies).

§available_balance: Option<String>

Available sell-token balance of the order owner at the time of query.

§quote_id: Option<i64>

Quote ID used when placing the order (for analytics / fee attribution).

§executed_fee: Option<String>

Fee actually executed by the solver (separate from executed_fee_amount for orders with both network and protocol fee components).

§ethflow_data: Option<EthflowData>

For EthFlow orders: metadata set by the EthFlow contract.

§onchain_order_data: Option<OnchainOrderData>

For on-chain placed orders: the sender address and any placement error.

§onchain_user: Option<Address>

For EthFlow orders: the true user address (the EthFlow contract is the technical owner; onchain_user is the human behind it).

Implementations§

Source§

impl Order

Source

pub const fn is_sell(&self) -> bool

Returns true if this is a sell order.

Source

pub const fn is_buy(&self) -> bool

Returns true if this is a buy order.

Source

pub fn effective_receiver(&self) -> Address

Returns the effective receiver: receiver if set, otherwise owner.

When an order omits the explicit receiver the protocol routes proceeds back to the order owner.

Source

pub fn has_interactions(&self) -> bool

Returns true if this order has at least one on-chain interaction hook.

Source

pub const fn has_surplus(&self) -> bool

Returns true if a surplus value is available (enriched order response).

Source

pub const fn has_executed_fee(&self) -> bool

Returns true if the executed fee is available (enriched order response).

Source

pub const fn has_available_balance(&self) -> bool

Returns true if the available sell-token balance of the owner is populated.

Source

pub const fn is_invalidated(&self) -> bool

Returns true if this order has been invalidated on-chain.

Source

pub const fn has_full_app_data(&self) -> bool

Returns true if the full app-data JSON is available.

Source

pub const fn has_ethflow_data(&self) -> bool

Returns true if this order carries EthFlow metadata.

Source

pub const fn has_onchain_data(&self) -> bool

Returns true if this order carries on-chain placement metadata.

Source

pub const fn has_onchain_user(&self) -> bool

Returns true if the onchain_user address (real user behind an EthFlow order) is set.

Source

pub const fn has_receiver(&self) -> bool

Returns true if a custom receiver address is set.

When false, proceeds are routed to owner (see Self::effective_receiver).

Source

pub const fn has_class(&self) -> bool

Returns true if the order class is available.

Source

pub const fn has_quote_id(&self) -> bool

Returns true if a quote ID is attached to this order.

Source

pub const fn has_full_fee_amount(&self) -> bool

Returns true if the unsubsidised fee amount is available (enriched order response).

Source

pub const fn is_partially_fillable(&self) -> bool

Returns true if this order may be partially filled.

Source

pub fn is_liquidity_order(&self) -> bool

Returns true if this order is explicitly marked as a liquidity (solver-internal) order.

Returns false when the is_liquidity_order field is absent or false.

Source

pub const fn is_eth_flow(&self) -> bool

Returns true if this is an EthFlow (native sell) order.

An order is considered an EthFlow order when it carries on-chain placement metadata (Self::onchain_order_data is Some).

use alloy_primitives::Address;
use cow_orderbook::{OnchainOrderData, Order};

// Minimal Order construction is not possible without a full JSON fixture,
// so we just assert the predicate's behaviour here.
let data = OnchainOrderData::new(Address::ZERO);
assert!(!data.has_placement_error()); // just checking it's accessible
Source

pub fn total_executed_fee(&self) -> Option<Uint<256, 4>>

Compute the total executed fee for this order, if available.

Returns Some(executed_fee_amount + executed_fee) when both fields can be parsed as U256. Returns None when either field is missing or unparsable.

The executed fee is the sum of:

  • executed_fee_amount — the network (gas) fee taken from the sell token
  • executed_fee — the additional protocol fee (present on enriched responses)
use alloy_primitives::U256;
use cow_orderbook::Order;

// Verify we can access total_executed_fee without panicking.
// Full Order construction requires a JSON fixture; just check the return type.
fn _typecheck(order: &Order) -> Option<U256> {
    order.total_executed_fee()
}
Source

pub const fn transform_eth_flow(self, _chain_id: u64) -> Order

Normalise an EthFlow order so it looks like a regular order.

Applies the following transformations:

  • sell_token is replaced with the native-currency sentinel address for chain_id (currently always 0xEeee…EeEe).
  • owner is replaced with onchain_user (the real user behind the EthFlow contract), if present.

This mirrors transformEthFlowOrder from the TypeScript SDK. Non-EthFlow orders are returned unchanged.

use cow_orderbook::Order;

// Verify the method is accessible; full construction requires a JSON fixture.
fn _typecheck(order: Order) -> Order {
    order.transform_eth_flow(1)
}

Trait Implementations§

Source§

impl Clone for Order

Source§

fn clone(&self) -> Order

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Order

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Order

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Order, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Order

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Serialize for Order

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Order

§

impl RefUnwindSafe for Order

§

impl Send for Order

§

impl Sync for Order

§

impl Unpin for Order

§

impl UnsafeUnpin for Order

§

impl UnwindSafe for Order

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<'de, T> BorrowedRpcObject<'de> for T
where T: RpcBorrow<'de> + RpcSend,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

impl<'de, T> RpcBorrow<'de> for T
where T: Deserialize<'de> + Debug + Send + Sync + Unpin,

Source§

impl<T> RpcObject for T
where T: RpcSend + RpcRecv,

Source§

impl<T> RpcRecv for T
where T: DeserializeOwned + Debug + Send + Sync + Unpin + 'static,

Source§

impl<T> RpcSend for T
where T: Serialize + Clone + Debug + Send + Sync + Unpin,