|
| 1 | +//! Centralized configuration for the TeachLink contract. |
| 2 | +//! |
| 3 | +//! All tunable constants live here. Modules import from this file instead of |
| 4 | +//! defining their own `pub const` values, ensuring a single source of truth. |
| 5 | +//! |
| 6 | +//! # Sections |
| 7 | +//! - [Analytics](#analytics) |
| 8 | +//! - [Atomic Swaps](#atomic-swaps) |
| 9 | +//! - [Audit & Compliance](#audit--compliance) |
| 10 | +//! - [BFT Consensus](#bft-consensus) |
| 11 | +//! - [Emergency & Circuit Breaker](#emergency--circuit-breaker) |
| 12 | +//! - [Ledger Time](#ledger-time) |
| 13 | +//! - [Liquidity & Fees](#liquidity--fees) |
| 14 | +//! - [Message Passing](#message-passing) |
| 15 | +//! - [Multichain](#multichain) |
| 16 | +//! - [Network Recovery](#network-recovery) |
| 17 | +//! - [Notifications](#notifications) |
| 18 | +//! - [Performance Cache](#performance-cache) |
| 19 | +//! - [Rate Limiting](#rate-limiting) |
| 20 | +//! - [Slashing](#slashing) |
| 21 | +//! - [Sustainability](#sustainability) |
| 22 | +//! - [Upgrade](#upgrade) |
| 23 | +
|
| 24 | +// ===== Analytics ===== |
| 25 | + |
| 26 | +/// How often bridge metrics may be updated (seconds). Default: 1 hour. |
| 27 | +pub const METRICS_UPDATE_INTERVAL: u64 = 3_600; |
| 28 | + |
| 29 | +// ===== Atomic Swaps ===== |
| 30 | + |
| 31 | +/// Minimum timelock duration for an atomic swap (seconds). Default: 1 hour. |
| 32 | +pub const SWAP_MIN_TIMELOCK: u64 = 3_600; |
| 33 | + |
| 34 | +/// Maximum timelock duration for an atomic swap (seconds). Default: 7 days. |
| 35 | +pub const SWAP_MAX_TIMELOCK: u64 = 604_800; |
| 36 | + |
| 37 | +/// Required byte length of a hashlock preimage hash. |
| 38 | +pub const SWAP_HASH_LENGTH: u32 = 32; |
| 39 | + |
| 40 | +// ===== Audit & Compliance ===== |
| 41 | + |
| 42 | +/// Maximum number of audit records retained before circular-buffer wrap. |
| 43 | +pub const AUDIT_MAX_RECORDS: u64 = 100_000; |
| 44 | + |
| 45 | +/// Default compliance report period (seconds). Default: 7 days. |
| 46 | +pub const AUDIT_COMPLIANCE_PERIOD: u64 = 604_800; |
| 47 | + |
| 48 | +// ===== BFT Consensus ===== |
| 49 | + |
| 50 | +/// Minimum validator stake (stroops, 6-decimal). Default: 100 tokens. |
| 51 | +pub const BFT_MIN_VALIDATOR_STAKE: i128 = 100_000_000; |
| 52 | + |
| 53 | +/// Proposal expiry window (seconds). Default: 24 hours. |
| 54 | +pub const BFT_PROPOSAL_TIMEOUT: u64 = 86_400; |
| 55 | + |
| 56 | +/// Number of consensus rounds per validator rotation epoch. |
| 57 | +pub const BFT_ROTATION_EPOCH_ROUNDS: u64 = 100; |
| 58 | + |
| 59 | +/// Minimum reputation score for a validator to remain active (0-100). |
| 60 | +pub const BFT_MIN_ACTIVE_REPUTATION: u32 = 40; |
| 61 | + |
| 62 | +// ===== Emergency & Circuit Breaker ===== |
| 63 | + |
| 64 | +/// Number of seats on the security council. |
| 65 | +pub const EMERGENCY_SECURITY_COUNCIL_SIZE: u32 = 5; |
| 66 | + |
| 67 | +/// Daily volume tracking window (seconds). Default: 24 hours. |
| 68 | +pub const EMERGENCY_DAILY_VOLUME_RESET: u64 = 86_400; |
| 69 | + |
| 70 | +// ===== Ledger Time ===== |
| 71 | + |
| 72 | +/// Estimated seconds per Stellar ledger (used for lag calculations). |
| 73 | +pub const LEDGER_EST_SECS: u64 = 5; |
| 74 | + |
| 75 | +// ===== Liquidity & Fees ===== |
| 76 | + |
| 77 | +/// Base bridge fee in basis points. Default: 0.10%. |
| 78 | +pub const LIQUIDITY_BASE_FEE_BPS: i128 = 10; |
| 79 | + |
| 80 | +/// Maximum bridge fee in basis points. Default: 5%. |
| 81 | +pub const LIQUIDITY_MAX_FEE_BPS: i128 = 500; |
| 82 | + |
| 83 | +/// Minimum bridge fee in basis points. Default: 0.01%. |
| 84 | +pub const LIQUIDITY_MIN_FEE_BPS: i128 = 1; |
| 85 | + |
| 86 | +/// Pool utilization threshold (basis points) above which dynamic fees apply. |
| 87 | +pub const LIQUIDITY_UTILIZATION_THRESHOLD: u32 = 8_000; |
| 88 | + |
| 89 | +// ===== Message Passing ===== |
| 90 | + |
| 91 | +/// Default cross-chain packet timeout (seconds). Default: 24 hours. |
| 92 | +pub const MSG_DEFAULT_PACKET_TIMEOUT: u64 = 86_400; |
| 93 | + |
| 94 | +/// Maximum packet delivery retry attempts. |
| 95 | +pub const MSG_MAX_RETRY_ATTEMPTS: u32 = 5; |
| 96 | + |
| 97 | +/// Base delay between packet retries (seconds). Default: 5 minutes. |
| 98 | +pub const MSG_RETRY_DELAY_BASE: u64 = 300; |
| 99 | + |
| 100 | +// ===== Multichain ===== |
| 101 | + |
| 102 | +/// Maximum number of supported external chains. |
| 103 | +pub const MULTICHAIN_MAX_CHAINS: u32 = 100; |
| 104 | + |
| 105 | +/// Maximum number of registered multi-chain assets. |
| 106 | +pub const MULTICHAIN_MAX_ASSETS: u32 = 1_000; |
| 107 | + |
| 108 | +// ===== Network Recovery ===== |
| 109 | + |
| 110 | +/// Maximum automatic retry attempts for a failed operation. |
| 111 | +pub const RECOVERY_MAX_RETRY_ATTEMPTS: u32 = 5; |
| 112 | + |
| 113 | +/// Initial exponential-backoff delay (seconds). Default: 1 minute. |
| 114 | +pub const RECOVERY_INITIAL_BACKOFF_SECS: u64 = 60; |
| 115 | + |
| 116 | +/// Maximum backoff delay (seconds). Default: 1 hour. |
| 117 | +pub const RECOVERY_MAX_BACKOFF_SECS: u64 = 3_600; |
| 118 | + |
| 119 | +/// Backoff multiplier applied on each retry. |
| 120 | +pub const RECOVERY_BACKOFF_MULTIPLIER: u64 = 2; |
| 121 | + |
| 122 | +// ===== Notifications ===== |
| 123 | + |
| 124 | +/// Sentinel value indicating immediate (non-scheduled) delivery. |
| 125 | +pub const NOTIF_IMMEDIATE_DELIVERY: u64 = 0; |
| 126 | + |
| 127 | +/// Minimum scheduling delay for a notification (seconds). Default: 1 minute. |
| 128 | +pub const NOTIF_MIN_DELAY_SECS: u64 = 60; |
| 129 | + |
| 130 | +/// Maximum scheduling delay for a notification (seconds). Default: 30 days. |
| 131 | +pub const NOTIF_MAX_DELAY_SECS: u64 = 86_400 * 30; |
| 132 | + |
| 133 | +/// Maximum notifications processed per batch. |
| 134 | +pub const NOTIF_BATCH_SIZE: u32 = 100; |
| 135 | + |
| 136 | +/// Default TTL for notification event storage (seconds). Default: 7 days. |
| 137 | +pub const NOTIF_DEFAULT_EVENT_TTL_SECS: u64 = 86_400 * 7; |
| 138 | + |
| 139 | +// ===== Performance Cache ===== |
| 140 | + |
| 141 | +/// Bridge summary cache TTL (seconds). Default: 1 hour. |
| 142 | +pub const PERF_CACHE_TTL_SECS: u64 = 3_600; |
| 143 | + |
| 144 | +/// Maximum chains included in the cached top-by-volume list. |
| 145 | +pub const PERF_MAX_TOP_CHAINS: u32 = 20; |
| 146 | + |
| 147 | +// ===== Rate Limiting ===== |
| 148 | + |
| 149 | +/// Default maximum calls allowed per rate-limit window. |
| 150 | +pub const RATE_LIMIT_DEFAULT_MAX_CALLS: u32 = 100; |
| 151 | + |
| 152 | +/// Default rate-limit window size in ledgers. |
| 153 | +pub const RATE_LIMIT_DEFAULT_WINDOW_LEDGERS: u32 = 600; |
| 154 | + |
| 155 | +// ===== Slashing ===== |
| 156 | + |
| 157 | +/// Slash percentage for double-vote offence (basis points). Default: 50%. |
| 158 | +pub const SLASH_DOUBLE_VOTE_BPS: u32 = 5_000; |
| 159 | + |
| 160 | +/// Slash percentage for invalid-signature offence (basis points). Default: 10%. |
| 161 | +pub const SLASH_INVALID_SIGNATURE_BPS: u32 = 1_000; |
| 162 | + |
| 163 | +/// Slash percentage for inactivity offence (basis points). Default: 5%. |
| 164 | +pub const SLASH_INACTIVITY_BPS: u32 = 500; |
| 165 | + |
| 166 | +/// Slash percentage for byzantine behaviour (basis points). Default: 100%. |
| 167 | +pub const SLASH_BYZANTINE_BPS: u32 = 10_000; |
| 168 | + |
| 169 | +/// Slash percentage for malicious behaviour (basis points). Default: 100%. |
| 170 | +pub const SLASH_MALICIOUS_BPS: u32 = 10_000; |
| 171 | + |
| 172 | +// ===== Sustainability ===== |
| 173 | + |
| 174 | +/// Minimum content tokens minted to reach full content-creation score. |
| 175 | +pub const SUSTAIN_CONTENT_SCORE_CAP: u64 = 1_000; |
| 176 | + |
| 177 | +/// Minimum active users to reach full user-adoption score. |
| 178 | +pub const SUSTAIN_USER_SCORE_CAP: u64 = 1_000; |
| 179 | + |
| 180 | +// ===== Upgrade ===== |
| 181 | + |
| 182 | +/// Window within which a contract upgrade may be rolled back (seconds). |
| 183 | +/// Default: 30 days. |
| 184 | +pub const UPGRADE_ROLLBACK_WINDOW_SECS: u64 = 86_400 * 30; |
0 commit comments