From 2bc360a596dacc15d4263bf9a8910480bf6bbbb5 Mon Sep 17 00:00:00 2001 From: Xanoutas <168182118+Xanoutas@users.noreply.github.com> Date: Mon, 30 Mar 2026 19:03:16 +0300 Subject: [PATCH] fix: Implement DAO-compatible Slashing Module (closes #1) --- fix_1.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 fix_1.py diff --git a/fix_1.py b/fix_1.py new file mode 100644 index 0000000..a842f57 --- /dev/null +++ b/fix_1.py @@ -0,0 +1,37 @@ +// contracts/modules/SlashingModule.sol + +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/access/Ownable.sol"; +import "./StakingModule.sol"; + +contract SlashingModule is Ownable { + StakingModule public stakingModule; + mapping(address => uint256) public trustScores; + uint256 public trustDecayRate = 10; // 10% decay per day + + event Slashed(address indexed staker, uint256 amount, string reason); + + constructor(address _stakingModuleAddress) { + stakingModule = StakingModule(_stakingModuleAddress); + } + + function slash(address staker, uint256 amount, string memory reason) external onlyOwner { + require(amount > 0, "Amount must be greater than zero"); + require(stakingModule.balanceOf(staker) >= amount, "Insufficient staking balance"); + + stakingModule.burn(staker, amount); + emit Slashed(staker, amount, reason); + + // Update trust score + trustScores[staker] = trustScores[staker] > amount ? trustScores[staker] - amount : 0; + } + + function applyTrustDecay(address staker) external { + trustScores[staker] = trustScores[staker] * (100 - trustDecayRate) / 100; + } + + function getTrustScore(address staker) external view returns (uint256) { + return trustScores[staker]; + } +} \ No newline at end of file