Skip to main content

DydxError

Enum DydxError 

Source
pub enum DydxError {
Show 16 variants Http(DydxHttpError), WebSocket(DydxWsError), Grpc(Box<Status>), Signing(String), Encoding(EncodeError), Decoding(DecodeError), Json { message: String, raw: Option<String>, }, Config(String), InvalidData(String), InvalidOrderSide(String), UnsupportedOrderType(String), NotImplemented(String), Order(String), Parse(String), Wallet(String), Nautilus(Error),
}
Expand description

The main error type for all dYdX adapter operations.

Variants§

§

Http(DydxHttpError)

HTTP client errors.

§

WebSocket(DydxWsError)

WebSocket connection errors.

§

Grpc(Box<Status>)

gRPC errors from Cosmos SDK node.

§

Signing(String)

Transaction signing errors.

§

Encoding(EncodeError)

Protocol buffer encoding errors.

§

Decoding(DecodeError)

Protocol buffer decoding errors.

§

Json

JSON serialization/deserialization errors.

Fields

§message: String
§raw: Option<String>

The raw JSON that failed to parse, if available.

§

Config(String)

Configuration errors.

§

InvalidData(String)

Invalid data errors.

§

InvalidOrderSide(String)

Invalid order side error.

§

UnsupportedOrderType(String)

Unsupported order type error.

§

NotImplemented(String)

Feature not yet implemented.

§

Order(String)

Order construction and submission errors.

§

Parse(String)

Parsing errors (e.g., string to number conversions).

§

Wallet(String)

Wallet and account derivation errors.

§

Nautilus(Error)

Nautilus core errors.

Implementations§

Source§

impl DydxError

Source

pub fn is_sequence_mismatch(&self) -> bool

Returns true if this error is a sequence mismatch (code=32 or code=104 with sequence hint).

Sequence mismatch occurs when:

  • Multiple transactions race for the same sequence number
  • A transaction was submitted but not yet included in a block
  • The local sequence counter is out of sync with chain state

On dYdX v4, sequence mismatches can manifest as either:

  • code=32: Standard Cosmos SDK “account sequence mismatch”
  • code=104: dYdX authenticator “signature verification failed; please verify sequence”

These errors are typically recoverable by resyncing the sequence from chain and rebuilding the transaction.

Source

pub fn is_tx_in_mempool(&self) -> bool

Returns true if this error indicates the transaction is already in the mempool (code=19).

This is benign for short-term orders – the transaction was already accepted by the mempool on a previous submission and will be processed. Callers can safely treat this as success.

Source

pub fn is_cancel_already_in_memclob(&self) -> bool

Returns true if this error indicates a duplicate cancel already in the memclob (code=9).

dYdX rejects cancel messages when an existing cancel for the same order has a greater-than-or-equal GoodTilBlock. The original cancel will be processed.

Source

pub fn is_order_does_not_exist(&self) -> bool

Returns true if this error indicates the order to cancel does not exist (code=3006).

The order was already filled, expired, or previously cancelled.

Source

pub fn is_benign_cancel_error(&self) -> bool

Returns true if this error is benign for short-term cancel operations.

Benign cancel errors occur during overlapping cancel waves (common in grid MM):

  • code=19: Transaction already in mempool cache (duplicate tx bytes)
  • code=9: Cancel already exists in memclob with >= GoodTilBlock
  • code=3006: Order to cancel does not exist (already filled/expired/cancelled)
Source

pub fn is_transient(&self) -> bool

Returns true if this error is likely transient and worth retrying.

Transient errors include:

  • Sequence mismatch (recoverable by resync)
  • Network timeouts
  • Temporary node unavailability
Source

pub fn is_definitive_broadcast_rejection(&self) -> bool

Returns true if this error is a definitive CheckTx rejection of the broadcast transaction.

broadcast_tx uses sync mode, so a code=N failure is the node’s verdict: the transaction never entered the mempool and no message in it executed. Benign codes (tx already in mempool, duplicate cancel, order already gone) mean the command was already handled, and transient errors (sequence mismatch, timeouts) are never a final verdict; both return false, as do transport failures that leave the outcome unknown.

Trait Implementations§

Source§

impl Debug for DydxError

Source§

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

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

impl Display for DydxError

Source§

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

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

impl Error for DydxError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Box<Status>> for DydxError

Source§

fn from(source: Box<Status>) -> Self

Converts to this type from the input type.
Source§

impl From<DecodeError> for DydxError

Source§

fn from(source: DecodeError) -> Self

Converts to this type from the input type.
Source§

impl From<DydxHttpError> for DydxError

Source§

fn from(source: DydxHttpError) -> Self

Converts to this type from the input type.
Source§

impl From<DydxWsError> for DydxError

Source§

fn from(source: DydxWsError) -> Self

Converts to this type from the input type.
Source§

impl From<EncodeError> for DydxError

Source§

fn from(source: EncodeError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for DydxError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, 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.
§

impl<T> Ungil for T
where T: Send,

§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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