-
Notifications
You must be signed in to change notification settings - Fork 10
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
RewardsManager test refactor and cleanup #718
Conversation
assertEq(bETimestamp, timestamp); | ||
assertEq(bEInterest, interest); | ||
assertEq(bEBurned, burned); | ||
assertEq(burned, tokensToBurn); |
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.
@MikeHathaway I was curious on how you would reccomend I compare these. The equation should be rewardsToClaimer
+ rewardsToUpdater
= burned * 0.9
is that correct?
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 quite. The claimer has a 5% claim factor, and the updaters have a 5% claim factor, but the claim must actually be made so it's unclear how much rewards will actually be distributed. Also, there's a bit of a first come first serve element as total rewards are capped at burned * 0.8
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.
After a discussion with Mike I deceided to not go through the cumbersome effort of attempting to compute the rewards in _assertBurn()
. Updated things accordingly.
/***********************/ | ||
|
||
// need to retrieve the position managers index set since positionIndexes are stored unordered in EnnumerableSets | ||
secondIndexes = _positionManager.getPositionIndexes(tokenIdOne); //TODO: investigate why commenting this out or keeping it doesn't do anything |
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.
@MikeHathaway noticing that by removing this, the function still passes. Wanted to confirm I'm not missing something here.
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.
You should need that line in order to pass as otherwise it should attempt to make the same set of movements that were made in the previous movement (secondIndexes) not updated. The comment is about getting the current order from the contract since the contract's order won't maintain order
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 am able to pass without this line in the tests... Here are the two outputs:
commented out, uses original secondIndexes
variable above:
secondIndexes[0] = 2556;
secondIndexes[1] = 2557;
secondIndexes[2] = 2558;
secondIndexes[3] = 2559;
secondIndexes[4] = 2560;
Tests still pass / no change needed if I comment it out.
uncommented:
Logs:
secondInd[0]: 2559
secondInd[1]: 2556
secondInd[2]: 2557
secondInd[3]: 2558
I will uncomment them as requested but want you to know it doesn't have an effect on the test.
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.
Few comments, but looks good.
|
||
|
||
|
||
|
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.
nit: doge says "much blank, very whitespace"
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.
; ) 🐶 that he does. Fixed -> a636196
uint256 tokenId, | ||
uint256 reward, | ||
uint256[] memory epochsClaimed | ||
) internal { |
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.
nit: indentation
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.
fixed -> a636196
deal(address(quote), minter, mintAmount * indexes.length); | ||
|
||
// approve tokens | ||
collateral.approve(address(pool), type(uint256).max); |
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.
Why does the minter need collateral?
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.
nope! fixed -> a636196
uint256 randomIndex = randomInRange(0, copyOfArray.length - i - 1); | ||
subsetArray[i] = copyOfArray[randomIndex]; | ||
copyOfArray[randomIndex] = copyOfArray[copyOfArray.length - i - 1]; | ||
} |
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.
This algorithm copies an element from the back of the array into the random index you plucked from copyOfArray
? Is this a strategy to avoid duplicates?
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.
This existed in the previous versions of the tests... I merely copied it over.
After some review it looks like it does in fact limit duplicates from existing in the subsetArray
ill be it in a very confusing way.
Also noticed that randomInRange
appears to not reproduce random results when I tested it in a unit test...
However I think this work should be done in a separate PR as it's outside of scope of this change. Let me know if you see it differently.
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.
LGTM. Much cleaner like this
Description of change
High level
RewardsManager.t.sol
intoRewards/RewardsManager.t.sol
&Rewards/RewadsDSTestPlus.t.sol