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

Commit

Permalink
Merge pull request #593 from keep-network/3m-cap
Browse files Browse the repository at this point in the history
ECDSA staker rewards cap set to 3M keep tokens per interval
  • Loading branch information
dimpar authored Nov 3, 2020
2 parents 6ad79be + 4ee2d01 commit c61e67f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
8 changes: 4 additions & 4 deletions solidity/contracts/ECDSARewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ import "./BondedECDSAKeep.sol";
/// Reporting a terminated keep returns its allocated reward to the pool of
/// unallocated rewards.
contract ECDSARewards is Rewards {
// The amount of tokens each individual beneficiary address
// can receive in a single interval is capped to 3M tokens.
uint256 public beneficiaryRewardCap = 3000000 * 10**18;

// BondedECDSAKeepFactory deployment date, Sep-14-2020 interval started.
// https://etherscan.io/address/0xA7d9E842EFB252389d613dA88EDa3731512e40bD
uint256 internal constant ecdsaFirstIntervalStart = 1600041600;
Expand Down Expand Up @@ -87,10 +91,6 @@ contract ECDSARewards is Rewards {

uint256 internal constant minimumECDSAKeepsPerInterval = 1000;

// The amount of tokens each individual beneficiary address
// can receive in a single interval is capped.
// TODO: set actual value
uint256 internal beneficiaryRewardCap = 400000 * 10**18;
// The total amount of rewards allocated to the given beneficiary address,
// in the given interval.
// `allocatedRewards[beneficiary][interval] -> amount`
Expand Down
4 changes: 1 addition & 3 deletions solidity/contracts/test/ECDSARewardsStub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import "../../contracts/ECDSARewards.sol";
/// @dev This contract is for testing purposes only.
contract ECDSARewardsStub is ECDSARewards {

uint256 internal tokenDecimalMultiplier = 10**18;

constructor(
address _token,
address payable _factoryAddress,
Expand All @@ -22,6 +20,6 @@ contract ECDSARewardsStub is ECDSARewards {
{}

function setBeneficiaryRewardCap(uint256 _beneficiaryRewardCap) public {
beneficiaryRewardCap = _beneficiaryRewardCap.mul(tokenDecimalMultiplier);
beneficiaryRewardCap = _beneficiaryRewardCap;
}
}
13 changes: 11 additions & 2 deletions solidity/test/rewards/TestECDSARewards.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe("ECDSARewards", () => {

const tokenDecimalMultiplier = web3.utils.toBN(10).pow(web3.utils.toBN(18))
const firstIntervalStart = 1600041600 // Sep 14 2020
const beneficiaryRewardCap = 10000

// 1,000,000,000 - total KEEP supply
// 200,000,000 - 20% of the total supply goes to staker rewards
Expand Down Expand Up @@ -51,7 +50,6 @@ describe("ECDSARewards", () => {
)

await fund(keepToken, rewardsContract, totalRewardsAllocation)
await rewardsContract.setBeneficiaryRewardCap(beneficiaryRewardCap)
})

beforeEach(async () => {
Expand Down Expand Up @@ -240,6 +238,12 @@ describe("ECDSARewards", () => {
})

it("should cap the maximum reward per beneficiary", async () => {
// There is currently no way to implement a test with the original
// 3M KEEP cap for beneficiary given block gas limit and test execution
// time. Hence, we set the limit to 10k KEEP for test purposes.
const rewardsCap = web3.utils.toBN(10000).mul(tokenDecimalMultiplier)
await rewardsContract.setBeneficiaryRewardCap(rewardsCap)

for (let i = 0; i < 10; i++) {
await keepFactory.stubOpenKeep(owner, operators, firstIntervalStart)
}
Expand Down Expand Up @@ -280,6 +284,11 @@ describe("ECDSARewards", () => {

expect(actualUnallocatedRewards).to.eq.BN(expectedUnallocatedRewards)
})

it("should keep per-interval beneficiary reward cap at 3M KEEP", async () => {
const cap = await rewardsContract.beneficiaryRewardCap()
expect(cap).to.eq.BN(web3.utils.toBN(3000000).mul(tokenDecimalMultiplier))
})
})

describe("rewards withdrawal", async () => {
Expand Down

0 comments on commit c61e67f

Please sign in to comment.