Skip to main content

tenzro_token/
lib.rs

1//! TNZO token, treasury management, staking, and governance for Tenzro Network
2//!
3//! This crate provides the core token economics functionality for Tenzro Network:
4//!
5//! - **TNZO Token**: Governance/utility token management with 18-decimal precision
6//! - **Treasury**: Multi-asset treasury accumulating network fees
7//! - **Staking**: Staking system for validators and service providers
8//! - **Governance**: On-chain governance with proposals and voting
9//! - **Rewards**: Reward distribution engine for stakers
10//! - **Fee Distribution**: Network fee processing and distribution
11//!
12//! # Architecture
13//!
14//! The token economics system uses `u128` for all token amounts to handle 18-decimal
15//! precision properly, and leverages `DashMap` for concurrent access patterns.
16//!
17//! # Example
18//!
19//! ```rust,no_run
20//! use tenzro_token::{
21//!     tnzo::TnzoToken,
22//!     staking::StakingManager,
23//!     governance::GovernanceEngine,
24//! };
25//! use tenzro_types::primitives::Address;
26//!
27//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
28//! // Create a TNZO token instance
29//! let token = TnzoToken::new();
30//!
31//! // Create staking and governance managers
32//! let staking = StakingManager::new();
33//! let governance = GovernanceEngine::new();
34//!
35//! // Use the token economics system...
36//! # Ok(())
37//! # }
38//! ```
39
40pub mod error;
41pub mod tnzo;
42pub mod treasury;
43pub mod staking;
44pub mod governance;
45pub mod rewards;
46pub mod fee_distribution;
47pub mod liquid_staking;
48pub mod cross_vm;
49pub mod registry;
50pub mod erc7802;
51pub mod erc3643;
52pub mod bond;
53pub mod compute_bond;
54pub mod burn_quota;
55pub mod adaptive_burn;
56pub mod seed_agent;
57pub mod seed_agent_daemon;
58pub mod seed_agent_gossip;
59pub mod validator_registry;
60
61// Re-export commonly used types
62pub use error::{TokenError, Result};
63pub use tnzo::{TnzoToken, TokenStats, CircuitBreaker};
64pub use treasury::{NetworkTreasury, FeeDistributionConfig, TreasuryStats, TreasuryStorageBackend};
65pub use staking::{
66    StakingManager, StakeInfo, SlashEvent, RestoreEvent, StakeStatus,
67    DEFAULT_MIN_STAKE, DEFAULT_UNBONDING_PERIOD_MS
68};
69pub use governance::{GovernanceEngine, VotingRecord};
70pub use rewards::{RewardDistributor, EpochRewards, RewardClaim};
71pub use fee_distribution::{FeeProcessor, FeeStats, DistributionHistory};
72pub use liquid_staking::{LiquidStakingPool, LiquidStakingConfig, LiquidStakingStats};
73pub use cross_vm::{
74    TokenVmType, VmAddresses, TokenPermissions, TokenMetadata, TokenId,
75    TokenType, TokenDefinition, CrossVmTransfer,
76    NATIVE_DECIMALS, SPL_DECIMALS, NATIVE_UNIT, SPL_UNIT, DECIMAL_SHIFT,
77    native_to_spl, spl_to_native, truncation_dust,
78};
79pub use registry::TokenRegistry;
80pub use erc7802::{CrosschainTokenManager, CrosschainMintEvent, CrosschainBurnEvent, BridgeAuthorization, BridgeInfo};
81pub use erc3643::{
82    ComplianceRegistry, ComplianceRules, ComplianceCheckResult, ComplianceViolation,
83    IdentityClaim, TrustedIssuer, FreezeInfo, RecoveryEvent, TransferRestrictions, SupplyLimits,
84    CLAIM_TOPIC_KYC, CLAIM_TOPIC_ACCREDITED_INVESTOR, CLAIM_TOPIC_COUNTRY, CLAIM_TOPIC_QUALIFIED_PURCHASER,
85};
86pub use bond::{
87    BondManager, AgentBondState, BondLifecycle, BondEvent,
88    ClaimRecord, ClaimStatus, InsurancePoolState,
89    derive_bond_vault_address, derive_insurance_pool_address, derive_claim_id,
90    DEFAULT_COOLDOWN_MS, DEFAULT_MIN_RESIDUAL, DEFAULT_MAX_SINGLE_SLASH_BPS,
91};
92pub use compute_bond::{
93    ComputeBondManager, ComputeBondState, ComputeBondStatus, ComputeBondEvent,
94    derive_compute_bond_vault_address,
95    DEFAULT_COMPUTE_BOND_COOLDOWN_MS, DEFAULT_COMPUTE_BOND_MIN,
96};
97pub use burn_quota::{
98    BurnQuota, BurnQuotaManager, RefillReceipt,
99    BURN_QUOTA_KEY, DEFAULT_DAILY_REFILL_TARGET, DEFAULT_CAP, DEFAULT_MIN_RESERVE_BPS,
100};
101pub use adaptive_burn::{
102    compute_recommendation, AutoProposalGenerator, AutoProposalGeneratorConfig, BurnBreakdown,
103    BurnRateConfig, BurnRateConfigManager, BurnRateRecommendation, EmissionBreakdown,
104    RecommendationAction, SupplyMetricsSnapshot, SupplyTargets, BURN_RATE_CONFIG_KEY,
105    DEFAULT_ALARM_FAST_TRACK_ENABLED, DEFAULT_ALARM_TIMELOCK_HOURS,
106    DEFAULT_AUTO_PROPOSAL_DEBOUNCE_SECS, DEFAULT_AUTO_PROPOSAL_MIN_MAGNITUDE_BPS,
107    DEFAULT_AUTO_PROPOSAL_NORMAL_VOTING_HOURS, DEFAULT_AUTO_PROPOSAL_POLL_INTERVAL_SECS,
108    DEFAULT_BASE_FEE_BURN_BPS, DEFAULT_DEFLATION_ALARM_BPS, DEFAULT_GAIN_BPS_PER_PCT,
109    DEFAULT_INFLATION_ALARM_BPS, DEFAULT_LOCAL_FEE_BURN_BPS,
110    DEFAULT_MAGNITUDE_CAP_ALARM_BPS, DEFAULT_MAGNITUDE_CAP_NORMAL_BPS,
111    DEFAULT_NEUTRAL_BAND_BPS, DEFAULT_PAYMASTER_BURN_BPS, DEFAULT_ROLLING_WINDOW_EPOCHS,
112    DEFAULT_TARGET_ANNUAL_SUPPLY_BPS, SUPPLY_METRICS_KEY, SUPPLY_TARGETS_KEY,
113};
114pub use seed_agent::{
115    Charter, CounterpartyFilter, DecayPoint, DecaySchedule, OperationKind,
116    RefillResult, SeedAgentEarmarkManager, SeedAgentRecord, SeedAgentStatus,
117    SpendCaps, SurplusDisposition, TargetThroughput, TreasuryEarmark,
118    WindDownReport, DEFAULT_BOOTSTRAP_MONTHS, DEFAULT_QUARANTINE_GRACE_MS,
119    DEFAULT_SURPLUS_BURN_BPS, MONTH_MILLIS, SEED_AGENT_PREFIX,
120    SEED_CHARTER_PREFIX, SEED_EARMARK_KEY,
121};
122pub use seed_agent_daemon::{
123    SeedAgentDaemon, SeedAgentDaemonConfig, SurplusDispositionFn,
124    TickAuthorityFn, TickOutcome, DEFAULT_DAEMON_POLL_INTERVAL_SECS,
125    DEFAULT_DAEMON_QUARANTINE_GRACE_MS, DEFAULT_MIN_REFILL_INTERVAL_MS,
126};
127pub use seed_agent_gossip::{
128    decode_for_topic as decode_seed_agent_for_topic, encode_agent_registered,
129    encode_agent_status_changed, encode_charter_upserted, encode_earmark_updated,
130    encode_monthly_refill_completed, SeedAgentGossipMessage, SEED_AGENTS_TOPIC,
131};
132pub use validator_registry::{
133    EpochTransitionPlan, ValidatorRegistry, ValidatorRegistryConfig, ValidatorRegistryEntry,
134    ValidatorRegistryStatus, ACTIVATION_EFFECTIVE_DELAY_BLOCKS, DEFAULT_ACTIVATION_CHURN_BPS,
135    DEFAULT_EXIT_CHURN_BPS, DEFAULT_MIN_VALIDATOR_SELF_STAKE, DEFAULT_REENTRY_COOLDOWN_EPOCHS,
136    MIN_CHURN_PER_EPOCH, VALIDATOR_CONFIG_KEY, VALIDATOR_INDEX_KEY, VALIDATOR_PREFIX,
137};