M3 #26: Rust SDK: Core types and shared definitions#66
Merged
Conversation
- Create new sdk crate with core types for client library: - error.rs: SdkError for SDK operations - types/primitives.rs: Price, Quantity, Side with arithmetic - types/order.rs: OrderType, TimeInForce, OrderStatus, Order - types/market.rs: Market with conversion utilities - types/book.rs: BookLevel, OrderBook, BookChange - types/trade.rs: Trade type - types/balance.rs: Balance type - Core value types: - Price: newtype wrapper with checked/saturating arithmetic - Quantity: newtype wrapper with min/max operations - Side: Bid/Ask enum with opposite() method - Order types: - OrderType: Limit, PostOnly, ImmediateOrCancel, FillOrKill - TimeInForce: GTC, IOC, FOK, PostOnly - OrderStatus: Open, PartiallyFilled, Filled, Cancelled, Expired - SelfTradeBehavior: CancelTaker, CancelMaker, DecrementTake, Allow - PlaceOrderParams: builder pattern for order parameters - Order: full order details with fill tracking - Entity types: - Market: addresses, tick/lot sizes, decimals, fees - Market conversion: price_to_ticks, ticks_to_price, etc. - BookLevel: price, quantity, order count - OrderBook: bids/asks with spread/midpoint calculations - OrderBookUpdate: Snapshot and Delta variants - Trade: executed trade with buyer/seller helpers - Balance: free/locked balances with totals - Features: - Full serde support with camelCase for JSON - Display implementations for human-readable output - TryFrom<u8> for enum conversions - rust_decimal for precise price calculations - 89 unit tests for all types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the core types for the Rust SDK that mirror the on-chain types and provide a foundation for client-side operations. These types are shared across HTTP and WebSocket clients.
Changes
New Crate:
sdk/Cargo.tomlsrc/lib.rssrc/error.rssrc/types/mod.rssrc/types/primitives.rssrc/types/order.rssrc/types/market.rssrc/types/book.rssrc/types/trade.rssrc/types/balance.rsCore Value Types
opposite()methodOrder Types
Entity Types
price_to_ticks,ticks_to_price, etc.calculate_taker_fee,calculate_maker_feeFeatures
Technical Decisions
Testing
Checklist
.internalDoc/09-rust-guidelines.mdcargo clippycargo fmtpassesCloses #26