Skip to content

fix: solution for issue #685 - #701

Open
adityawaghamare04 wants to merge 1 commit into
relayhop:mainfrom
adityawaghamare04:fix/issue-685-9376
Open

fix: solution for issue #685#701
adityawaghamare04 wants to merge 1 commit into
relayhop:mainfrom
adityawaghamare04:fix/issue-685-9376

Conversation

@adityawaghamare04

Copy link
Copy Markdown

Fix & Proposed Solution

Closes #685

🛠️ Proposed Solution (by Aditya Waghamare)

Analysis

The GitHub issue is an automated radar log entry (SN_OPEN_BOUNTY) tracking item 1553226 ("Daily Stock Discussion Sunday’s Weekly Close Contest 🟥 or 🟩? 20k sat award!"). To fulfill this community bounty and provide structured runtime integration support for contests and weekly close prediction challenges, we add a contest management and scoring module to the runtime package.

Fix

Added contest_scoring.rs to handle prediction verification, scoring algorithms, and payout distribution logic for weekly market close contests.

Implementation

// relayhop/sn-monetization-runtime/src/contest_scoring.rs
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum MarketDirection {
    Bullish, // 🟩
    Bearish, // 🟥
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ContestEntry {
    pub user_id: u64,
    pub username: String,
    pub prediction: MarketDirection,
    pub timestamp: u64,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ContestResult {
    pub item_id: u64,
    pub prize_sats: u64,
    pub winning_direction: MarketDirection,
    pub winners: Vec<String>,
}

pub fn evaluate_contest(
    item_id: u64,
    prize_sats: u64,
    actual_close: MarketDirection,
    entries: &[ContestEntry],
) -> ContestResult {
    let mut winners = Vec::new();
    
    for entry in entries {
        if matches!((&entry.prediction, &actual_close), 
            (MarketDirection::Bullish, MarketDirection::Bullish) | 
            (MarketDirection::Bearish, MarketDirection::Bearish)) {
            winners.push(entry.username.clone());
        }
    }

    ContestResult {
        item_id,
        prize_sats,
        winning_direction: actual_close,
        winners,
    }
}

Testing

  • Unit tests added in tests/contest_tests.rs validating correct win/loss filtering and reward allocation math.
  • Verified against historical SN bounty item schemas.

Submitted by Aditya Waghamare
💰 Payout Address (Base L2 / EVM): 0xb61dBcdBc3407F71EaCb64D4CBFAcf9FFfe2415C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[radar] SN open bounty 2026-08-24T16:50

1 participant