| Crates.io | kaccy-core |
| lib.rs | kaccy-core |
| version | 0.1.0 |
| created_at | 2026-01-18 22:28:16.236411+00 |
| updated_at | 2026-01-18 22:28:16.236411+00 |
| description | Core business logic for Kaccy Protocol - batching, fee optimization, and transaction management |
| homepage | https://github.com/cool-japan/kaccy |
| repository | https://github.com/cool-japan/kaccy |
| max_upload_size | |
| id | 2053234 |
| size | 3,661,913 |
Core business logic for Kaccy Protocol.
This crate contains the fundamental domain models, bonding curve calculations, order matching, and trade execution logic for the Kaccy personal token platform.
modelsDomain 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 balancespricingBonding curve implementations for automatic price discovery:
BondingCurve - Trait defining the bonding curve interfaceLinearBondingCurve - Linear price model: P(n) = initial_price + (n * increment)BancorCurve, SigmoidCurve, AdaptiveCurvetradingTrade execution logic:
TradeExecutor - Executes trades with ACID guaranteeserrorError types for the core module.
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);
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
rust_decimal - High-precision decimal arithmeticchrono - Date/time handlinguuid - UUID generationserde - Serialization/deserializationsqlx - Database typescargo test -p kaccy-core