2 releases
0.1.1 | Nov 7, 2024 |
---|---|
0.1.0 | Nov 7, 2024 |
#888 in Magic Beans
244 downloads per month
100KB
2.5K
SLoC
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
-
- Multi-threaded transaction processing
- WebSocket event handling
- Order state management
- Real-time status updates
-
- Limit order placement
- Market order execution
- Order cancellation
- L2 book viewing
- AMM integration
-
- Deposit management
- Withdrawal processing
- Balance queries
- Margin position tracking
Supporting Systems
-
- Order state tracking
- WebSocket event processing
- Transaction monitoring
- Status updates
-
- ERC20 interactions
- Balance checking
- Allowance management
-
- Gasless transactions
- Request signing
- Transaction relaying
-
- Value conversion
- Data formatting
- Blockchain helpers
๐ Quick Start
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
# Run all tests
cargo test
Dependencies
~23โ39MB
~673K SLoC