Skip to content

Implement Reputation & Incentive Contract#37

Open
Sandijigs wants to merge 1 commit intoGalactiGuild:mainfrom
Sandijigs:feat/implement-reputation-and-incentive-contract
Open

Implement Reputation & Incentive Contract#37
Sandijigs wants to merge 1 commit intoGalactiGuild:mainfrom
Sandijigs:feat/implement-reputation-and-incentive-contract

Conversation

@Sandijigs
Copy link

@Sandijigs Sandijigs commented Jan 28, 2026

Implement Reputation & Incentive Contract

Summary

This PR implements a comprehensive reputation and incentive system for the Stellar Guilds platform, enabling contributor reputation tracking, achievement awards, and reputation-based payment incentives.

Changes

  • Reputation Module: Complete implementation with 9 core functions
  • Scoring System: Task completion, milestone tracking, dispute resolution, and time decay
  • Tier System: 5-tier progression (Bronze → Diamond) with automatic upgrades
  • Achievement System: 8 default achievements with eligibility checking
  • Incentive Multipliers: Reputation-based payment bonuses (1.0x - 2.0x)
  • Guild Leaderboards: Top contributor tracking per guild
  • Contract Integration: Added 11 public functions to main contract

Files Added

contract/src/reputation/
├── mod.rs                    # Core reputation functions
├── types.rs                  # Data structures and events
├── scoring.rs                # Reputation scoring logic
├── achievements.rs           # Achievement management
├── storage.rs                # On-chain storage operations
├── tests.rs                  # Unit tests (33+ tests)
└── integration_tests.rs      # Integration tests (11 tests)

Key Features

✅ Reputation score tracking per contributor
✅ 5 reputation tiers with automatic progression
✅ 8 default achievements (First Steps, Task Veteran, Perfect Record, etc.)
✅ Reputation-based incentive multipliers (1.0x to 2.0x)
✅ Guild leaderboard system
✅ Success rate tracking
✅ Time decay for inactivity
✅ Event emission for all reputation changes

Reputation Scoring

  • Task completion: +10 to +50 points
  • Milestone completion: +20 to +100 points
  • Dispute won: +5 points
  • Dispute lost: -20 points
  • Task failed: -10 points
  • Time decay: -1% per month (max 50%)

Tier Thresholds

Tier Score Range Multiplier
Bronze 0-99 1.0x
Silver 100-499 1.1x
Gold 500-1499 1.25x
Platinum 1500-4999 1.5x
Diamond 5000+ 2.0x

Testing

  • Unit Tests: 33+ comprehensive tests covering all core functionality
  • Integration Tests: 11 tests for cross-contract interactions
  • Coverage: >90% estimated
  • Edge Cases: Comprehensive coverage (overflow, underflow, bounds checking)

Usage Example

// Complete a bounty and update reputation
update_reputation(&env, contributor, ReputationEvent::TaskCompleted, 3);

// Calculate payment with reputation bonus
let multiplier = calculate_multiplier(&env, contributor);
let bonus_payment = (base_payment * multiplier) / 100;

// Award achievement
if check_achievement_eligibility(&env, contributor, 1) {
    award_achievement(&env, contributor, 1);
}

Closes #6

@gabito1451
Copy link
Contributor

@Sandijigs

Thanks for the contribution. The branch currently does not compile and is also 20 commits behind main. Please rebase or merge main before continuing.

Blocking issues:

  1. Duplicate tests module
    In src/reputation/mod.rs, tests is defined twice (mod tests; and an inline mod tests {})., please Keep only one

  2. Contract function name too long
    calculate_contributor_incentive_multiplier exceeds Soroban’s 32-character limit. please Rename to a shorter function name and update references.

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.

[CONTRACT] Implement Reputation & Incentive Contract

2 participants