Skip to content
This repository was archived by the owner on May 22, 2023. It is now read-only.

Commit d3623cd

Browse files
committed
Merge branch 'master' into rewards-cap-tests
2 parents 1650858 + 7827b53 commit d3623cd

1 file changed

Lines changed: 25 additions & 23 deletions

File tree

solidity/contracts/ECDSARewards.sol

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ contract ECDSARewards is Rewards {
8787

8888
uint256 internal constant minimumECDSAKeepsPerInterval = 1000;
8989

90-
BondedECDSAKeepFactory factory;
91-
TokenStaking tokenStaking;
92-
9390
// The amount of tokens each individual beneficiary address
9491
// can receive in a single interval is capped.
9592
// TODO: set actual value
9693
uint256 internal beneficiaryRewardCap = 400000 * 10**18;
9794
// The total amount of rewards allocated to the given beneficiary address,
9895
// in the given interval.
9996
// `allocatedRewards[beneficiary][interval] -> amount`
100-
mapping(address => mapping(uint256 => uint256)) allocatedRewards;
97+
mapping(address => mapping(uint256 => uint256)) internal allocatedRewards;
10198
// The amount of interval rewards withdrawn to the given beneficiary.
102-
mapping(address => mapping(uint256 => uint256)) withdrawnRewards;
99+
mapping(address => mapping(uint256 => uint256)) internal withdrawnRewards;
100+
101+
BondedECDSAKeepFactory internal factory;
102+
TokenStaking internal tokenStaking;
103103

104104
constructor(
105105
address _token,
@@ -125,7 +125,10 @@ contract ECDSARewards is Rewards {
125125
/// @param operator The operator
126126
/// @return The amount allocated
127127
function getAllocatedRewards(uint256 interval, address operator)
128-
external view returns (uint256) {
128+
external
129+
view
130+
returns (uint256)
131+
{
129132
address beneficiary = tokenStaking.beneficiaryOf(operator);
130133
return allocatedRewards[beneficiary][interval];
131134
}
@@ -136,7 +139,10 @@ contract ECDSARewards is Rewards {
136139
/// @param operator The operator
137140
/// @return The amount already withdrawn
138141
function getWithdrawnRewards(uint256 interval, address operator)
139-
external view returns (uint256) {
142+
external
143+
view
144+
returns (uint256)
145+
{
140146
address beneficiary = tokenStaking.beneficiaryOf(operator);
141147
return withdrawnRewards[beneficiary][interval];
142148
}
@@ -147,7 +153,10 @@ contract ECDSARewards is Rewards {
147153
/// @param operator The operator
148154
/// @return The amount withdrawable
149155
function getWithdrawableRewards(uint256 interval, address operator)
150-
external view returns (uint256) {
156+
external
157+
view
158+
returns (uint256)
159+
{
151160
address beneficiary = tokenStaking.beneficiaryOf(operator);
152161
uint256 allocated = allocatedRewards[beneficiary][interval];
153162
uint256 withdrawn = withdrawnRewards[beneficiary][interval];
@@ -161,20 +170,14 @@ contract ECDSARewards is Rewards {
161170
function withdrawRewards(uint256 interval, address operator) external {
162171
address beneficiary = tokenStaking.beneficiaryOf(operator);
163172

164-
uint256 allocatedForBeneficiary
165-
= allocatedRewards[beneficiary][interval];
173+
uint256 allocated = allocatedRewards[beneficiary][interval];
166174
uint256 alreadyWithdrawn = withdrawnRewards[beneficiary][interval];
167175

168-
require(
169-
allocatedForBeneficiary > alreadyWithdrawn,
170-
"No rewards to withdraw"
171-
);
176+
require(allocated > alreadyWithdrawn, "No rewards to withdraw");
172177

173-
uint256 withdrawableRewards = allocatedForBeneficiary.sub(
174-
alreadyWithdrawn
175-
);
178+
uint256 withdrawableRewards = allocated.sub(alreadyWithdrawn);
176179

177-
withdrawnRewards[beneficiary][interval] = allocatedForBeneficiary;
180+
withdrawnRewards[beneficiary][interval] = allocated;
178181

179182
token.safeTransfer(beneficiary, withdrawableRewards);
180183
}
@@ -235,11 +238,10 @@ contract ECDSARewards is Rewards {
235238
return factory.getKeepOpenedTimestamp(toAddress(_keep)) != 0;
236239
}
237240

238-
// Get the members of the specified keep,
239-
// and distribute the reward amount between them.
240-
// The reward isn't paid out immediately,
241-
// but is instead kept in the reward contract
242-
// until each operator individually requests to withdraw the rewards.
241+
/// @notice Get the members of the specified keep, and distribute the reward
242+
/// amount between them. The reward isn't paid out immediately,
243+
/// but is instead kept in the reward contract until each operator
244+
/// individually requests to withdraw the rewards.
243245
function _distributeReward(bytes32 _keep, uint256 amount)
244246
internal
245247
isAddress(_keep)

0 commit comments

Comments
 (0)