validate_community_metrics

Function validate_community_metrics 

Source
pub fn validate_community_metrics(
    weekly_active_users: u32,
    weekly_retention_rate: u16,
    user_weight: u16,
    activity_weight: u16,
    retention_weight: u16,
    weekly_activity_count: u32,
    customer_reward_share: u16,
    merchant_reward_share: u16,
) -> Result<(), MiracleError>
Expand description

Validates community metrics parameters before creating an instruction.

This function helps oracles validate their inputs before submitting transactions, providing better error handling and user experience.

§Parameters

  • weekly_active_users: Number of active users in the past week
  • weekly_retention_rate: Retention rate in basis points (0-10000, 0-100%)
  • user_weight: User weight in basis points (0-10000) for weighted geometric mean
  • activity_weight: Activity weight in basis points (0-10000) for weighted geometric mean
  • retention_weight: Retention weight in basis points (0-10000) for weighted geometric mean
  • weekly_activity_count: Number of transactions in the past week
  • customer_reward_share: Customer reward percentage in basis points (0-10000)
  • merchant_reward_share: Merchant reward percentage in basis points (0-10000)

§Returns

  • Ok(()) if all parameters are valid
  • Err(MiracleError) with specific error if validation fails

§Validation Rules

  • Weights must sum to 10000 (100%)
  • Reward shares must sum to 10000 (100%)
  • Retention rate must be 0-10000 (0-100%)
  • Activity count must be reasonable (0-1M transactions per week)
  • All numeric values must be reasonable