kaccy-core

Crates.iokaccy-core
lib.rskaccy-core
version0.1.0
created_at2026-01-18 22:28:16.236411+00
updated_at2026-01-18 22:28:16.236411+00
descriptionCore business logic for Kaccy Protocol - batching, fee optimization, and transaction management
homepagehttps://github.com/cool-japan/kaccy
repositoryhttps://github.com/cool-japan/kaccy
max_upload_size
id2053234
size3,661,913
KitaSan (cool-japan)

documentation

https://docs.rs/kaccy

README

kaccy-core

Core business logic for Kaccy Protocol.

Overview

This crate contains the fundamental domain models, bonding curve calculations, order matching, and trade execution logic for the Kaccy personal token platform.

Modules

models

Domain models representing the core entities:

  • User - User account with DID, KYC status, and reputation score
  • Token - Personal FOT (Future Output Token) with bonding curve parameters
  • Order - Buy/sell orders with BTC payment information
  • Trade - Executed trade records
  • Balance - User token balances

pricing

Bonding curve implementations for automatic price discovery:

  • BondingCurve - Trait defining the bonding curve interface
  • LinearBondingCurve - Linear price model: P(n) = initial_price + (n * increment)
  • (Planned) BancorCurve, SigmoidCurve, AdaptiveCurve

trading

Trade execution logic:

  • TradeExecutor - Executes trades with ACID guarantees
  • Order matching engine (Phase 2: Limit orders)

error

Error types for the core module.

Usage

use kaccy_core::pricing::{BondingCurve, LinearBondingCurve};
use rust_decimal_macros::dec;

// Create a linear bonding curve
let curve = LinearBondingCurve::new(
    dec!(0.0001),  // Initial price: 0.0001 BTC
    dec!(0.00001), // Increment: 0.00001 BTC per token
);

// Calculate buy price for 10 tokens at supply 0
let cost = curve.buy_price(dec!(0), dec!(10));
println!("Cost to buy 10 tokens: {} BTC", cost);

// Get current spot price at supply 100
let price = curve.spot_price(dec!(100));
println!("Spot price at supply 100: {} BTC", price);

Architecture

kaccy-core/
├── src/
│   ├── lib.rs           # Crate root
│   ├── error.rs         # Error types
│   ├── models/
│   │   ├── mod.rs
│   │   ├── user.rs      # User model
│   │   ├── token.rs     # Token model
│   │   ├── order.rs     # Order model
│   │   ├── trade.rs     # Trade model
│   │   └── balance.rs   # Balance model
│   ├── pricing/
│   │   ├── mod.rs
│   │   └── bonding_curve.rs  # Bonding curve implementations
│   └── trading/
│       ├── mod.rs
│       └── executor.rs  # Trade execution
└── Cargo.toml

Dependencies

  • rust_decimal - High-precision decimal arithmetic
  • chrono - Date/time handling
  • uuid - UUID generation
  • serde - Serialization/deserialization
  • sqlx - Database types

Testing

cargo test -p kaccy-core
Commit count: 1

cargo fmt