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 scoreToken- Personal FOT (Future Output Token) with bonding curve parametersOrder- Buy/sell orders with BTC payment informationTrade- Executed trade recordsBalance- User token balances
pricing
Bonding curve implementations for automatic price discovery:
BondingCurve- Trait defining the bonding curve interfaceLinearBondingCurve- 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 ;
use dec;
// Create a linear bonding curve
let curve = new;
// Calculate buy price for 10 tokens at supply 0
let cost = curve.buy_price;
println!;
// Get current spot price at supply 100
let price = curve.spot_price;
println!;
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 arithmeticchrono- Date/time handlinguuid- UUID generationserde- Serialization/deserializationsqlx- Database types
Testing