pub fn update_metrics(
oracle: Pubkey,
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,
) -> Instruction
Expand description
Builds an update community metrics instruction.
This function creates an instruction to update community health metrics used for the Enhanced Community-Driven Decay model. Only the oracle authority can execute this instruction.
§Parameters
oracle
: The oracle authority public key (must be a signer)weekly_active_users
: Number of active users in the past weekweekly_retention_rate
: Retention rate in basis points (0-10000, 0-100%)user_weight
: User weight in basis points (0-10000) for weighted geometric meanvolume_weight
: Volume weight in basis points (0-10000) for weighted geometric meanretention_weight
: Retention weight in basis points (0-10000) for weighted geometric mean
§Returns
An instruction that can be included in a transaction to update community metrics.
§Security
- The oracle must be a signer of the transaction
- Input validation occurs on-chain
- Only the authorized oracle can update metrics
§Example
use steel::Pubkey;
let oracle_pubkey = Pubkey::new_unique();
let instruction = miracle_api::sdk::update_metrics(
oracle_pubkey,
5000, // 5,000 active users
7500, // 75% retention rate
4000, // 40% user weight
3500, // 35% activity weight
2500, // 25% retention weight
50_000, // 50,000 transactions
7000, // 70% customer reward share
3000, // 30% merchant reward share
);