M3 #27: Rust SDK: Instruction builders for transaction construction#67
Merged
Conversation
- Add instructions module to SDK with builders for all operations: - CreateMarketBuilder: Create new market with PDAs - CreateOpenOrdersBuilder: Create user's open orders account - DepositBuilder: Deposit tokens to open orders - WithdrawBuilder: Withdraw tokens from open orders - PlaceOrderBuilder: Place order with side/price/quantity - CancelOrderBuilder: Cancel specific order by ID - CancelAllOrdersBuilder: Cancel all orders with limit - MatchOrdersBuilder: Trigger order matching - ConsumeEventsBuilder: Process events from queue - Add PDA derivation utilities: - derive_market_address - derive_bids_address / derive_asks_address - derive_event_queue_address - derive_base_vault_address / derive_quote_vault_address - derive_open_orders_address - MarketPdas: derive all market PDAs at once - Builder pattern features: - Fluent API with method chaining - Automatic PDA derivation - Borsh serialization for instruction data - Error handling for missing required fields - Add solana-sdk and borsh to workspace dependencies - 54 unit tests for instruction builders
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 instruction builders that construct Solana transactions for all Matchbook operations. These builders handle account resolution, PDA derivation, and instruction serialization.
Changes
New Module:
sdk/src/instructions/mod.rspda.rscreate_market.rscreate_open_orders.rsdeposit.rswithdraw.rsplace_order.rscancel_order.rscancel_all_orders.rsmatch_orders.rsconsume_events.rsInstruction Builders
PDA Derivation Utilities
derive_market_address: Seeds[b"market", base_mint, quote_mint]derive_bids_address: Seeds[market, b"bids"]derive_asks_address: Seeds[market, b"asks"]derive_event_queue_address: Seeds[market, b"event_queue"]derive_base_vault_address: Seeds[market, b"base_vault"]derive_quote_vault_address: Seeds[market, b"quote_vault"]derive_open_orders_address: Seeds[b"open_orders", market, owner]MarketPdas: Derive all market PDAs at onceBuilder Pattern Features
Dependencies
solana-sdkv2.2 to workspaceborshv1.5 to workspaceTechnical Decisions
Testing
Checklist
.internalDoc/09-rust-guidelines.mdcargo clippycargo fmtpassesCloses #27