Skip to content

Fix incorrect weighted loser stake slashing calculation #59

@dDevAhmed

Description

@dDevAhmed

📚 Overview

The current staking settlement logic approximates loser raw stake using weighted ratios instead of actual stake totals.

This leads to incorrect economic outcomes.


🌊 Drips Context

This issue fixes a core economic invariant of the protocol.

Incorrect slashing breaks:

  • Fair reward distribution
  • Economic integrity
  • Trust in verification outcomes

❗ Problem

Current logic:
claim.totalStakeAmount * loserWeighted / totalWeighted

This is incorrect when reputation multipliers differ.


✅ Expected Behavior

  • Track exact raw stake:
    • totalRawFor
    • totalRawAgainst
  • Use exact loser raw stake in settlement

🧠 Implementation Guidelines

  • Modify staking structure to track per-side raw stake
  • Update _calculateSettlement
  • Add invariant tests for:
    • mixed reputation
    • uneven stake distribution

✅ Acceptance Criteria

  • Exact loser raw stake is used
  • Rewards/slashes match expected math
  • Invariant tests pass

⏳ Complexity

High


🏷 Labels

audit, protocol, high-priority, drips-wave

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave program

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions