kuru-sdk-rs

Crates.iokuru-sdk-rs
lib.rskuru-sdk-rs
version0.1.1
sourcesrc
created_at2024-11-07 06:31:21.30972
updated_at2024-11-07 07:54:41.165344
descriptionRust SDK to interact with Kuru Contracts
homepage
repository
max_upload_size
id1439532
size270,144
(KuruTech)

documentation

README

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

    • Multi-threaded transaction processing
    • WebSocket event handling
    • Order state management
    • Real-time status updates
  • Orderbook

    • Limit order placement
    • Market order execution
    • Order cancellation
    • L2 book viewing
    • AMM integration
  • Margin Account

    • Deposit management
    • Withdrawal processing
    • Balance queries
    • Margin position tracking

Supporting Systems

๐Ÿš€ 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
Commit count: 0

cargo fmt