-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathBlockRewardHBBFT.sol
78 lines (59 loc) · 2.74 KB
/
BlockRewardHBBFT.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
pragma solidity 0.5.7;
import "./abstracts/BlockRewardBase.sol";
import "./interfaces/IERC20Minting.sol";
import "./interfaces/IStaking.sol";
contract BlockRewardHBBFT is BlockRewardBase {
// ============================================== Constants =======================================================
// This value must be changed before deploy
uint256 public constant BLOCK_REWARD = 0 ether; // in ERC20 tokens
// ================================================ Events ========================================================
event RewardedERC20ByBlock(address[] receivers, uint256[] rewards);
// =============================================== Setters ========================================================
function reward(address[] calldata, uint16[] calldata)
external
onlySystem
returns (address[] memory, uint256[] memory)
{
/*
// Mint ERC20 tokens to validators and their delegators as block reward.
// This is not bridge's fee distribution.
// This call makes sense only if `BLOCK_REWARD` and `ERC20_TOKEN_CONTRACT`
// constants are not equal to zero.
_mintTokensForDelegators(benefactors);
*/
// Mint native coins by bridge if needed.
return _mintNativeCoinsByErcToNativeBridge(new address[](0), new uint256[](0), 25);
}
// =============================================== Private ========================================================
/*
// Mint ERC20 tokens for each delegator of each active validator
function _mintTokensForDelegators(address[] memory benefactors) internal {
IStaking stakingContract = IStaking(
IValidatorSet(VALIDATOR_SET_CONTRACT).stakingContract()
);
IERC20Minting erc20Contract = IERC20Minting(
stakingContract.erc20TokenContract()
);
if (BLOCK_REWARD == 0) return;
if (address(erc20Contract) == address(0)) return;
uint256 stakingEpoch = _getStakingEpoch();
if (stakingEpoch == 0) {
return;
}
uint256 poolReward = BLOCK_REWARD / snapshotStakingAddresses().length;
uint256 remainder = BLOCK_REWARD % snapshotStakingAddresses().length;
for (uint256 i = 0; i < benefactors.length; i++) {
(
address[] memory receivers,
uint256[] memory rewards
) = _distributePoolReward(
stakingEpoch,
IValidatorSet(VALIDATOR_SET_CONTRACT).stakingByMiningAddress(benefactors[i]),
i == 0 ? poolReward + remainder : poolReward
);
erc20Contract.mintReward(receivers, rewards);
emit RewardedERC20ByBlock(receivers, rewards);
}
}
*/
}