Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ mod bridge {
chain_name: format!("Chain-{}", chain_id),
bridge_contract_address: None,
is_active: true,
gas_multiplier: 100, // 1.0x multiplier
confirmation_blocks: 6, // 6 block confirmations
gas_multiplier: propchain_traits::constants::DEFAULT_GAS_MULTIPLIER,
confirmation_blocks: propchain_traits::constants::DEFAULT_CONFIRMATION_BLOCKS,
supported_tokens: Vec::new(),
};
bridge.chain_info.insert(chain_id, &chain_info);
Expand Down
6 changes: 3 additions & 3 deletions contracts/oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ mod propchain_oracle {
location_adjustments: Mapping::default(),
market_trends: Mapping::default(),
comparable_cache: Mapping::default(),
max_price_staleness: 3600, // 1 hour
min_sources_required: 2,
outlier_threshold: 2, // 2 standard deviations
max_price_staleness: propchain_traits::constants::DEFAULT_MAX_PRICE_STALENESS,
min_sources_required: propchain_traits::constants::DEFAULT_MIN_SOURCES_REQUIRED,
outlier_threshold: propchain_traits::constants::DEFAULT_OUTLIER_THRESHOLD,
source_reputations: Mapping::default(),
source_stakes: Mapping::default(),
pending_requests: Mapping::default(),
Expand Down
86 changes: 86 additions & 0 deletions contracts/traits/src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/// Centralized configuration constants for PropChain contracts.
///
/// All magic numbers are extracted here with documentation explaining
/// their purpose and valid ranges. Contracts import from this module
/// instead of using inline literals.

// ── Oracle Constants ─────────────────────────────────────────────────────────

/// Maximum age (in seconds) before a price is considered stale.
/// Default: 3600 (1 hour).
pub const DEFAULT_MAX_PRICE_STALENESS: u64 = 3600;

/// Minimum number of oracle sources required for a valid valuation.
pub const DEFAULT_MIN_SOURCES_REQUIRED: u32 = 2;

/// Number of standard deviations beyond which a price is an outlier.
pub const DEFAULT_OUTLIER_THRESHOLD: u32 = 2;

/// Initial reputation score assigned to new oracle sources (0-1000 scale).
pub const ORACLE_INITIAL_REPUTATION: u32 = 500;

/// Maximum reputation score an oracle source can achieve.
pub const ORACLE_MAX_REPUTATION: u32 = 1000;

/// Minimum reputation required for an oracle source to participate.
pub const ORACLE_MIN_REPUTATION_THRESHOLD: u32 = 200;

/// Reputation points gained on a successful price submission.
pub const ORACLE_REPUTATION_GAIN: u32 = 10;

/// Reputation points lost on a failed/inaccurate submission.
pub const ORACLE_REPUTATION_PENALTY: u32 = 50;

/// Multiplier for coefficient of variance calculations (basis points).
pub const COEFFICIENT_VARIANCE_MULTIPLIER: u32 = 10_000;

// ── Bridge Constants ─────────────────────────────────────────────────────────

/// Default gas multiplier for bridge operations (100 = 1.0x).
/// Expressed as percentage: 100 = 100% = 1x, 150 = 150% = 1.5x.
pub const DEFAULT_GAS_MULTIPLIER: u32 = 100;

/// Default number of block confirmations before a bridge tx is final.
pub const DEFAULT_CONFIRMATION_BLOCKS: u32 = 6;

/// Base gas cost for a bridge operation (in gas units).
pub const BRIDGE_BASE_GAS: u64 = 100_000;

// ── IPFS / Metadata Constants ────────────────────────────────────────────────

/// Maximum length for property location strings.
pub const MAX_LOCATION_LENGTH: u32 = 500;

/// Minimum property size in square meters.
pub const MIN_PROPERTY_SIZE: u64 = 1;

/// Maximum property size in square meters (1 billion).
pub const MAX_PROPERTY_SIZE: u64 = 1_000_000_000;

/// Maximum length for legal description text.
pub const MAX_LEGAL_DESCRIPTION_LENGTH: u32 = 5_000;

/// Minimum valuation amount (in smallest token unit).
pub const MIN_VALUATION: u128 = 1;

/// Maximum file size for IPFS uploads (100 MB).
pub const MAX_FILE_SIZE: u64 = 100_000_000;

/// Maximum number of documents per property.
pub const MAX_DOCUMENTS_PER_PROPERTY: u32 = 100;

/// Maximum total pinned size per property (500 MB).
pub const MAX_PINNED_SIZE_PER_PROPERTY: u64 = 500_000_000;

// ── Token Constants ──────────────────────────────────────────────────────────

/// Precision scaling factor for token amounts (1e12).
pub const TOKEN_SCALING_FACTOR: u128 = 1_000_000_000_000;

// ── Analytics Constants ──────────────────────────────────────────────────────

/// Default bull/bear ratio in basis points (50% = 5000 bps).
pub const DEFAULT_BULL_BEAR_RATIO_BPS: u32 = 5_000;

/// Basis points denominator (100% = 10000 bps).
pub const BASIS_POINTS_DENOMINATOR: u32 = 10_000;
1 change: 1 addition & 0 deletions contracts/traits/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub mod constants;
pub mod errors;

use ink::prelude::string::String;
Expand Down
Loading