-
Notifications
You must be signed in to change notification settings - Fork 23
Conversation
Used by ECDSAKeepRewards to get the owner of the keep, and the time it was opened.
Track all created keeps and timestamps. These are used for rewards and will be utilized furhter in the future.
Expose functions to get basic info on keeps and timestamps from the internal data structures.
stubOpenKeep is an easy way to open a keep with no extra requirements. It's beneficial when mny keeps are needed and the initializatoin logic is not important.
Draft of ECDSAKeepRewards. findInterval not implemented.
Test the binary search custom functinality.
Arbitrary timestamps permit the creation of data to deliberately exercise edge cases.
Importing via `@openzeppelin` makes Go bindings code generation fails as the path for `@openzeppelin` is not configured in the Makefile. I could add `@openzeppelin` path to the Makefile but since all other contracts use `openzeppelin-solidity` import, I altered the single `@openzeppelin` import to `openzeppeling-solidity for consistency.
KeepTerminated event is handled the same way as KeepClosed event exept that it logs warning on the console.
Tested off-chain client against the changes, everything works as expected. Test log
On the client:
On the client:
I still need to go through the Rewards contract. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add more docs and explain in the PR description how this mechanism works.
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; | ||
import "openzeppelin-solidity/contracts/math/SafeMath.sol"; | ||
|
||
contract ECDSAKeepRewards { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth adding some documentation to this contract.
_processKeep(true, keepAddress); | ||
} | ||
|
||
function reportTermination(address keepAddress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add documentation to this function.
Do we expect it's called by parties interested in eventually claiming something from unallocated rewards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes; the rewards allocated for that keep will be returned to the pool of unallocated rewards.
// Rewards that haven't been allocated to finished intervals | ||
uint256 unallocatedRewards; | ||
|
||
// Length of one interval. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... in seconds
?
// Total number of intervals. (Implicit in intervalWeights) | ||
// uint256 termCount = intervalWeights.length; | ||
|
||
// mapping of keeps to booleans. True if the keep has been used to calim a reward. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/calim/claim
let keepAddress = await keepFactory.getKeepAtIndex(0) | ||
let eligible = await rewards.eligibleForReward(keepAddress) | ||
expect(eligible).to.equal(false) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should cover the following cases as well:
- keep not recognized by the factory,
- reward already claimed.
} | ||
} | ||
|
||
function _getIntervalWeight(uint256 interval) internal view returns (uint256) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is interval weight and why is it 100% for the interval above their count?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interval weight is the percentage of remaining unallocated rewards that are to be allocated for that interval. Once the defined schedule is over, any leftover rewards (e.g. from terminated keeps or division remainders) are allocated to the earliest available interval.
50, // 40:40 | ||
25, // 10:30 | ||
50, // 15:15 | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do understand allocated : remaining
relation but I have no idea how does it relate to interval weights. Shouldn't weights add up to 100%?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No; weights are how much of the remaining unallocated rewards are allocated for that interval. After the initially allocated schedule is over, the allocation jumps to 100% meaning that all remaining unallocated rewards are allocated for each closing interval.
solidity/test/RewardsTest.js
Outdated
let bondedSortitionPoolFactory | ||
let keepBonding | ||
let randomBeacon | ||
let signerPool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used
solidity/test/RewardsTest.js
Outdated
const aliceBeneficiary = accounts[2] | ||
const bobBeneficiary = accounts[3] | ||
|
||
let factory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used
|
||
/// @notice Sends the reward for a keep to the keep members. | ||
/// @param keepAddress ECDSA keep factory address. | ||
function receiveReward(address keepAddress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who will call this function? From what I understand, it does not make sense to call this function before all previous keeps are closed or terminated. If there is a lot of active keeps, we never know if some of them will be terminated and rewards potentially increased.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of how rewards are allocated for the intervals, the outcome for keeps in a closed interval won't change even if the unallocated amount increases. That means that keeps can call receiveReward
as soon as the keep is closed and the interval is over, without needing to wait for other keeps.
Closing in favor of #513 |
Refs: #446
ECDSAKeep Rewards to distribute KEEP tokens to keep owners based on a predetermined curve separated by intervals.
Draft until: