pub struct OrderRequest { /* private fields */ }Expand description
Request to post/modify an order.
Implementations§
Source§impl OrderRequest
impl OrderRequest
Sourcepub fn new(
request_id: RequestId,
perp_id: PerpetualId,
type: RequestType,
order_id: Option<OrderId>,
price: UD64,
size: UD64,
expiry_block: Option<u64>,
post_only: bool,
fill_or_kill: bool,
immediate_or_cancel: bool,
max_matches: Option<u32>,
leverage: UD64,
last_exec_block: Option<u64>,
amount: Option<UD128>,
max_neg_pnl_collat_bps: u16,
) -> Self
pub fn new( request_id: RequestId, perp_id: PerpetualId, type: RequestType, order_id: Option<OrderId>, price: UD64, size: UD64, expiry_block: Option<u64>, post_only: bool, fill_or_kill: bool, immediate_or_cancel: bool, max_matches: Option<u32>, leverage: UD64, last_exec_block: Option<u64>, amount: Option<UD128>, max_neg_pnl_collat_bps: u16, ) -> Self
Create a new order request with provided parameters.
Provided [request_id] is stored as [client_order_id] once the order
gets placed.
Use Self::prepare_v2 to get an OrderDesc with its order
extension and then issue transactions with
crate::abi::dex::Exchange::ExchangeInstance::execOrdersV2 calls, or
Self::prepare for the builder-blind V1
crate::abi::dex::Exchange::ExchangeInstance::execOrders.
Sourcepub fn with_builder(self, builder: BuilderAttribution) -> Self
pub fn with_builder(self, builder: BuilderAttribution) -> Self
Attributes the order to a builder, which charges its own additive fee on the size the order adds.
Only the V2 entrypoints carry attribution: use Self::prepare_v2 to
get the corresponding order extension envelope. Attribution is silently
dropped by Self::prepare, as the V1 entrypoints have nothing to
carry it in.
Sourcepub fn builder(&self) -> Option<BuilderAttribution>
pub fn builder(&self) -> Option<BuilderAttribution>
Builder attribution of the request, if any.
Sourcepub fn prepare(&self, exchange: &Exchange) -> OrderDesc
pub fn prepare(&self, exchange: &Exchange) -> OrderDesc
Prepare order request for execution via the V1 entrypoints
(execOrder/execOrders), which cannot carry builder attribution.
§Panics
If the perpetual contract of the request is not tracked by exchange.
Sourcepub fn prepare_v2(
&self,
exchange: &Exchange,
) -> Result<(OrderDesc, Bytes), DexError>
pub fn prepare_v2( &self, exchange: &Exchange, ) -> Result<(OrderDesc, Bytes), DexError>
Prepare order request for execution via the V2 entrypoints
(execOrderV2/execOrdersV2), returning the order descriptor along
with its order extension envelope.
The envelope is empty for a request without builder attribution, which
is the V1-identical fast path on-chain. A batch where no order
carries attribution can omit the extensions array entirely.
Fails if the request carries builder attribution the deployed contract
does not support, or a builder fee rate the contract’s decoder would
reject - which reverts execOrderV2 and skips the order on the batched
path.
Sourcepub fn to_order_extension(&self) -> Result<Bytes, OrderExtensionError>
pub fn to_order_extension(&self) -> Result<Bytes, OrderExtensionError>
Order extension envelope of the request, empty without builder attribution.
Trait Implementations§
Source§impl Clone for OrderRequest
impl Clone for OrderRequest
Source§fn clone(&self) -> OrderRequest
fn clone(&self) -> OrderRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for OrderRequest
impl RefUnwindSafe for OrderRequest
impl Send for OrderRequest
impl Sync for OrderRequest
impl Unpin for OrderRequest
impl UnsafeUnpin for OrderRequest
impl UnwindSafe for OrderRequest
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 more