pub struct OrderSubmitter { /* private fields */ }Implementations§
Source§impl OrderSubmitter
impl OrderSubmitter
pub fn new( grpc_client: DydxGrpcClient, http_client: DydxHttpClient, wallet_address: String, subaccount_number: u32, chain_id: ChainId, authenticator_ids: Vec<u64>, ) -> Self
Sourcepub async fn submit_market_order(
&self,
wallet: &Wallet,
instrument_id: InstrumentId,
client_order_id: u32,
side: OrderSide,
quantity: Quantity,
block_height: u32,
) -> Result<(), DydxError>
pub async fn submit_market_order( &self, wallet: &Wallet, instrument_id: InstrumentId, client_order_id: u32, side: OrderSide, quantity: Quantity, block_height: u32, ) -> Result<(), DydxError>
Submits a market order to dYdX via gRPC.
Market orders execute immediately at the best available price.
§Errors
Returns DydxError if gRPC submission fails.
Sourcepub async fn submit_limit_order(
&self,
wallet: &Wallet,
instrument_id: InstrumentId,
client_order_id: u32,
side: OrderSide,
price: Price,
quantity: Quantity,
time_in_force: TimeInForce,
post_only: bool,
reduce_only: bool,
block_height: u32,
expire_time: Option<i64>,
) -> Result<(), DydxError>
pub async fn submit_limit_order( &self, wallet: &Wallet, instrument_id: InstrumentId, client_order_id: u32, side: OrderSide, price: Price, quantity: Quantity, time_in_force: TimeInForce, post_only: bool, reduce_only: bool, block_height: u32, expire_time: Option<i64>, ) -> Result<(), DydxError>
Submits a limit order to dYdX via gRPC.
Limit orders execute only at the specified price or better.
§Errors
Returns DydxError if gRPC submission fails.
Sourcepub async fn cancel_order(
&self,
wallet: &Wallet,
instrument_id: InstrumentId,
client_order_id: u32,
block_height: u32,
) -> Result<(), DydxError>
pub async fn cancel_order( &self, wallet: &Wallet, instrument_id: InstrumentId, client_order_id: u32, block_height: u32, ) -> Result<(), DydxError>
Cancels an order on dYdX via gRPC.
Requires instrument_id to retrieve correct clob_pair_id from market params. For now, assumes short-term orders (order_flags=0). Future enhancement: track order_flags when placing orders to handle long-term cancellations.
§Errors
Returns DydxError if gRPC cancellation fails or market params not found.
Sourcepub async fn cancel_orders_batch(
&self,
wallet: &Wallet,
orders: &[(InstrumentId, u32)],
block_height: u32,
) -> Result<(), DydxError>
pub async fn cancel_orders_batch( &self, wallet: &Wallet, orders: &[(InstrumentId, u32)], block_height: u32, ) -> Result<(), DydxError>
Cancels multiple orders in a single blockchain transaction.
Batches all cancellation messages into one transaction for efficiency. This is more efficient than sequential cancellation as it requires only one account lookup and one transaction broadcast.
§Arguments
wallet- The wallet for signing transactionsorders- Slice of (InstrumentId, client_order_id) tuples to cancelblock_height- Current block height for order expiration
§Errors
Returns DydxError if transaction broadcast fails or market params not found.
Sourcepub async fn submit_conditional_order(
&self,
wallet: &Wallet,
instrument_id: InstrumentId,
client_order_id: u32,
order_type: ConditionalOrderType,
side: OrderSide,
trigger_price: Price,
limit_price: Option<Price>,
quantity: Quantity,
time_in_force: Option<TimeInForce>,
post_only: bool,
reduce_only: bool,
expire_time: Option<i64>,
) -> Result<(), DydxError>
pub async fn submit_conditional_order( &self, wallet: &Wallet, instrument_id: InstrumentId, client_order_id: u32, order_type: ConditionalOrderType, side: OrderSide, trigger_price: Price, limit_price: Option<Price>, quantity: Quantity, time_in_force: Option<TimeInForce>, post_only: bool, reduce_only: bool, expire_time: Option<i64>, ) -> Result<(), DydxError>
Submits a conditional order (stop or take-profit) to dYdX via gRPC.
This is the unified implementation for all conditional order types. Market variants execute immediately when triggered; limit variants place a limit order at the specified price.
§Errors
Returns DydxError if gRPC submission fails or limit_price missing for limit orders.
Sourcepub async fn submit_stop_market_order(
&self,
wallet: &Wallet,
instrument_id: InstrumentId,
client_order_id: u32,
side: OrderSide,
trigger_price: Price,
quantity: Quantity,
reduce_only: bool,
expire_time: Option<i64>,
) -> Result<(), DydxError>
pub async fn submit_stop_market_order( &self, wallet: &Wallet, instrument_id: InstrumentId, client_order_id: u32, side: OrderSide, trigger_price: Price, quantity: Quantity, reduce_only: bool, expire_time: Option<i64>, ) -> Result<(), DydxError>
Submits a stop market order to dYdX via gRPC.
Stop market orders are triggered when the price reaches trigger_price.
§Errors
Returns DydxError if gRPC submission fails.
Sourcepub async fn submit_stop_limit_order(
&self,
wallet: &Wallet,
instrument_id: InstrumentId,
client_order_id: u32,
side: OrderSide,
trigger_price: Price,
limit_price: Price,
quantity: Quantity,
time_in_force: TimeInForce,
post_only: bool,
reduce_only: bool,
expire_time: Option<i64>,
) -> Result<(), DydxError>
pub async fn submit_stop_limit_order( &self, wallet: &Wallet, instrument_id: InstrumentId, client_order_id: u32, side: OrderSide, trigger_price: Price, limit_price: Price, quantity: Quantity, time_in_force: TimeInForce, post_only: bool, reduce_only: bool, expire_time: Option<i64>, ) -> Result<(), DydxError>
Submits a stop limit order to dYdX via gRPC.
Stop limit orders are triggered when the price reaches trigger_price,
then placed as a limit order at limit_price.
§Errors
Returns DydxError if gRPC submission fails.
Sourcepub async fn submit_take_profit_market_order(
&self,
wallet: &Wallet,
instrument_id: InstrumentId,
client_order_id: u32,
side: OrderSide,
trigger_price: Price,
quantity: Quantity,
reduce_only: bool,
expire_time: Option<i64>,
) -> Result<(), DydxError>
pub async fn submit_take_profit_market_order( &self, wallet: &Wallet, instrument_id: InstrumentId, client_order_id: u32, side: OrderSide, trigger_price: Price, quantity: Quantity, reduce_only: bool, expire_time: Option<i64>, ) -> Result<(), DydxError>
Submits a take profit market order to dYdX via gRPC.
Take profit market orders are triggered when the price reaches trigger_price,
then executed as a market order.
§Errors
Returns DydxError if gRPC submission fails.
Sourcepub async fn submit_take_profit_limit_order(
&self,
wallet: &Wallet,
instrument_id: InstrumentId,
client_order_id: u32,
side: OrderSide,
trigger_price: Price,
limit_price: Price,
quantity: Quantity,
time_in_force: TimeInForce,
post_only: bool,
reduce_only: bool,
expire_time: Option<i64>,
) -> Result<(), DydxError>
pub async fn submit_take_profit_limit_order( &self, wallet: &Wallet, instrument_id: InstrumentId, client_order_id: u32, side: OrderSide, trigger_price: Price, limit_price: Price, quantity: Quantity, time_in_force: TimeInForce, post_only: bool, reduce_only: bool, expire_time: Option<i64>, ) -> Result<(), DydxError>
Submits a take profit limit order to dYdX via gRPC.
Take profit limit orders are triggered when the price reaches trigger_price,
then placed as a limit order at limit_price.
§Errors
Returns DydxError if gRPC submission fails.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for OrderSubmitter
impl !RefUnwindSafe for OrderSubmitter
impl Send for OrderSubmitter
impl Sync for OrderSubmitter
impl Unpin for OrderSubmitter
impl !UnwindSafe for OrderSubmitter
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].