Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deducted reward code #2

Open
wants to merge 4 commits into
base: stake
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions contracts/common/tokens/IWBTT.sol

This file was deleted.

15 changes: 6 additions & 9 deletions contracts/staking/stakeManager/StakeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {StakeManagerStorageExtension} from "./StakeManagerStorageExtension.sol";
import {IGovernance} from "../../common/governance/IGovernance.sol";
import {Initializable} from "../../common/mixin/Initializable.sol";
import {StakeManagerExtension} from "./StakeManagerExtension.sol";
import {IWBTT} from "../../common/tokens/IWBTT.sol";

contract StakeManager is
StakeManagerStorage,
Expand Down Expand Up @@ -86,7 +85,7 @@ contract StakeManager is
governance = IGovernance(_governance);
registry = _registry;
rootChain = _rootchain;
token = IWBTT(_token);
token = IERC20(_token);
NFTContract = StakingNFT(_NFTContract);
logger = StakingInfo(_stakingLogger);
validatorShareFactory = ValidatorShareFactory(_validatorShareFactory);
Expand Down Expand Up @@ -216,7 +215,7 @@ contract StakeManager is

function setStakingToken(address _token) public onlyGovernance {
require(_token != address(0x0));
token = IWBTT(_token);
token = IERC20(_token);
}

/**
Expand Down Expand Up @@ -849,9 +848,11 @@ contract StakeManager is
// require(signedStakePower >= currentTotalStake.mul(2).div(3).add(1), "2/3+1 non-majority!");

uint256 reward = _calculateCheckpointReward(blockInterval, signedStakePower, currentTotalStake);
// mint rewards
token.mint(address(this), reward);
totalRewards = totalRewards + reward;
// deduct rewards
uint256 deductedReward = reward.mul(10).div(100);
_transferToken(address(0x8be76AdD1360C2E35c58a72E8F4Ffd678D7e8502), deductedReward);
reward = reward.sub(deductedReward);

uint256 _proposerBonus = reward.mul(proposerBonus).div(MAX_PROPOSER_BONUS);
uint256 proposerId = signerToValidator[proposer];
Expand Down Expand Up @@ -1270,8 +1271,4 @@ contract StakeManager is
);
}

function transferTokenOwnership(address newOwner) public onlyGovernance {
token.transferOwnership(newOwner);
}

}
3 changes: 1 addition & 2 deletions contracts/staking/stakeManager/StakeManagerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {RootChainable} from "../../common/mixin/RootChainable.sol";
import {StakingInfo} from "../StakingInfo.sol";
import {StakingNFT} from "./StakingNFT.sol";
import {ValidatorShareFactory} from "../validatorShare/ValidatorShareFactory.sol";
import {IWBTT} from "../../common/tokens/IWBTT.sol";

contract StakeManagerStorage is GovernanceLockable, RootChainable {
enum Status {Inactive, Active, Locked, Unstaked}
Expand Down Expand Up @@ -53,7 +52,7 @@ contract StakeManagerStorage is GovernanceLockable, RootChainable {
uint256 internal constant INCORRECT_VALIDATOR_ID = 2**256 - 1;
uint256 internal constant INITIALIZED_AMOUNT = 1;

IWBTT public token;
IERC20 public token;
address public registry;
StakingInfo public logger;
StakingNFT public NFTContract;
Expand Down