Expand description
Transaction manager for dYdX v4 protocol.
This module provides centralized transaction management including:
- Atomic sequence number tracking for stateful (long-term/conditional) orders
- Transaction building and signing
- Chain synchronization for sequence recovery
§Sequence Management
dYdX has two transaction types with different sequence behavior:
- Stateful orders (long-term, conditional): Use Cosmos SDK sequences for replay protection. Each transaction requires a unique, incrementing sequence number.
- Short-term orders: Use Good-Til-Block (GTB) for replay protection. The chain’s
ClobDecoratorante handler skips sequence checking, so sequences are not consumed. UseTransactionManager::get_cached_sequencefor these — it returns the current value without incrementing.
For stateful orders, this module provides:
AtomicU64for lock-free sequence allocation viaTransactionManager::allocate_sequence- Lazy initialization from chain on first use
TransactionManager::resync_sequencefor recovery after mismatch errors- Batch allocation via
TransactionManager::allocate_sequencesfor parallel stateful broadcasts
Structs§
- Transaction
Manager - Transaction manager responsible for wallet, sequence tracking, and transaction building.
Constants§
- SEQUENCE_
UNINITIALIZED - Sentinel value indicating sequence is uninitialized.