# Kuru SDK A comprehensive Rust SDK for interacting with the Kuru Protocol, providing orderbook management, margin trading, and meta-transaction capabilities. ## Overview The Kuru SDK enables seamless interaction with Kuru Protocol's smart contracts, offering: - Order management (limit & market orders) - Margin trading capabilities - Meta-transaction support - Real-time order tracking - Asset management ## ๐Ÿ“š Module Documentation ### Core Components - [**Order Processing System**](./docs/KuruSDK.md) - Multi-threaded transaction processing - WebSocket event handling - Order state management - Real-time status updates - [**Orderbook**](./docs/Orderbook.md) - Limit order placement - Market order execution - Order cancellation - L2 book viewing - AMM integration - [**Margin Account**](./docs/MarginAccount.md) - Deposit management - Withdrawal processing - Balance queries - Margin position tracking ### Supporting Systems - [**Inventory System**](./docs/Inventory.md) - Order state tracking - WebSocket event processing - Transaction monitoring - Status updates - [**Token Management**](./docs/Token.md) - ERC20 interactions - Balance checking - Allowance management - [**Meta-Transaction Forwarder**](./docs/KuruForwarder.md) - Gasless transactions - Request signing - Transaction relaying - [**Utility Functions**](./docs/Util.md) - Value conversion - Data formatting - Blockchain helpers ## ๐Ÿš€ Quick Start ```rust use kuru_sdk::{Orderbook, MarginAccount, Token, KuruForwarder}; // Initialize core components let orderbook = Orderbook::new("0x...", provider.clone())?; let margin_account = MarginAccount::new("main", "0x...", provider.clone())?; let token = Token::new("USDC", "0x...", provider.clone())?; // Place a limit order let (tx_hash, order_id) = orderbook.add_buy_order( "100.5", // price "1.5", // size false, // post_only None, // gas_price None // gas_limit ).await?; // Deposit to margin account let tx_hash = margin_account.deposit( &user_address, &token, &amount ).await?; ``` ## ๐Ÿ—๏ธ Architecture ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Kuru SDK โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Orderbook โ”‚ โ”‚ Margin โ”‚ โ”‚ Meta โ”‚ โ”‚ โ”‚ โ”‚ System โ”‚โ—„โ”€โ”ค Account โ”‚โ—„โ”€โ”ค TX โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ–ฒ โ–ฒ โ–ฒ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ Order Processing System โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ” โ”‚ โ”‚ โ”‚ Inventory โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ## ๐Ÿ“‹ Features - **Order Management** - Limit orders - Market orders - Post-only orders - Order cancellation - Batch operations - **Margin Trading** - Deposit/withdrawal - Position management - Balance tracking - Risk monitoring - **Meta Transactions** - Gasless trading - Signature verification - Transaction relaying - **Real-time Updates** - WebSocket integration - Order status tracking - Event processing - State management ## ๐Ÿงช Testing ```bash # Run all tests cargo test ```