| Crates.io | qudag-exchange-core |
| lib.rs | qudag-exchange-core |
| version | 0.4.0 |
| created_at | 2025-06-23 00:35:35.685499+00 |
| updated_at | 2025-06-23 20:55:00.426538+00 |
| description | Core QuDAG Exchange library with quantum-resistant rUv token system |
| homepage | |
| repository | https://github.com/ruvnet/QuDAG |
| max_upload_size | |
| id | 1722066 |
| size | 305,459 |
Core library for the QuDAG Exchange system with quantum-resistant rUv (Resource Utilization Voucher) token functionality and business plan payout streams.
Add this to your Cargo.toml:
[dependencies]
qudag-exchange-core = "0.3.0"
use qudag_exchange_core::{
ExchangeConfig, ExchangeConfigBuilder, BusinessPlanConfig,
rUv, AccountId, types::Timestamp
};
// Create basic exchange configuration
let config = ExchangeConfig::new()?;
// Enable business plan features
let config = ExchangeConfigBuilder::new()
.with_basic_business_plan()
.build()?;
// Create and transfer rUv tokens
let sender = AccountId::new("sender_vault");
let receiver = AccountId::new("receiver_vault");
let amount = rUv::new(1000);
use qudag_exchange_core::{
PayoutConfig, FeeRouter, ContributorRole, ContributorInfo
};
// Configure automatic payouts
let payout_config = PayoutConfig {
enabled: true,
min_payout_threshold: rUv::new(50),
system_fee_percentage: 0.002,
..Default::default()
};
let mut fee_router = FeeRouter::new(payout_config);
// Register a contributor
let contributor = ContributorInfo {
vault_id: AccountId::new("contributor_vault"),
role: ContributorRole::AgentProvider {
agent_id: "agent_123".to_string(),
resource_consumed: 100,
},
custom_percentage: Some(0.90), // 90% instead of default 95%
registered_at: Timestamp::now(),
total_earnings: rUv::new(0),
last_payout: None,
};
fee_router.register_contributor("agent_123".to_string(), contributor)?;
// Distribute fees automatically
let roles = vec![ContributorRole::AgentProvider {
agent_id: "agent_123".to_string(),
resource_consumed: 100,
}];
let payout_tx = fee_router.distribute_fees(
"tx_001".to_string(),
rUv::new(1000), // Total fee collected
roles,
Timestamp::now(),
)?;
The business plan implements a vault-based payout stream system:
let config = ExchangeConfigBuilder::new()
.with_chain_id(1)
.with_network_name("qudag-mainnet")
.build()?;
let bp_config = BusinessPlanConfig {
enabled: true,
enable_auto_distribution: true,
enable_vault_management: true,
enable_role_earnings: true,
enable_bounty_rewards: true,
payout_config: PayoutConfig {
enabled: true,
min_payout_threshold: rUv::new(100),
system_fee_percentage: 0.001,
..Default::default()
},
..Default::default()
};
let config = ExchangeConfigBuilder::new()
.with_business_plan(bp_config)
.build()?;
For command-line interaction, use the standalone CLI:
cargo install qudag-exchange-standalone-cli
# Enable business plan features
qudag-exchange-cli business-plan enable --auto-distribution --role-earnings
# Register contributors
qudag-exchange-cli business-plan contributors register agent-123 agent-provider vault-abc
# View status and history
qudag-exchange-cli business-plan status
qudag-exchange-cli business-plan payouts --limit 10
The library supports WebAssembly deployment with no_std:
[dependencies]
qudag-exchange-core = { version = "0.3.0", default-features = false }
See the examples directory for complete usage examples.
Run the comprehensive test suite:
cargo test
cargo test business_plan_integration
Licensed under the MIT License. See LICENSE for details.
Contributions are welcome! Please see the contributing guidelines.
Part of the QuDAG quantum-resistant distributed ledger ecosystem.