-
Notifications
You must be signed in to change notification settings - Fork 59
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: edit product grace period #409
Conversation
@@ -51,6 +51,7 @@ struct CoverSegment { | |||
uint96 amount; | |||
uint32 start; | |||
uint32 period; // seconds | |||
uint16 gracePeriodInDays; |
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.
Total current struct size:
96 + 32 + 32 + 16 + 16 + 8 + 24
224
Looks fine.
@@ -35,7 +35,7 @@ describe('getClaimsToDisplay', function () { | |||
coverOwner.address, | |||
0, // productId | |||
ASSET.ETH, | |||
[[coverAmount, timestamp + 1, coverPeriod, 0, false, 0]], | |||
[[coverAmount, timestamp + 1, coverPeriod, 7, 0, false, 0]], |
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.
consider using a constant test variable here for the test since it's the same throughout
@@ -24,7 +24,7 @@ describe('redeemClaimPayout', function () { | |||
coverOwner.address, | |||
0, // productId | |||
ASSET.ETH, | |||
[[coverAmount, timestamp + 1, coverPeriod, 0, false, 0]], | |||
[[coverAmount, timestamp + 1, coverPeriod, 7, 0, false, 0]], |
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.
same here use a named constant for the value 7 since it's the same in every test case
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.
Yea these are a bit tedious in the case that CoverSegment structure changes. I thought about storing this struct as a fixture somewhere and have each tests just modify which field it is adjusting?
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.
yeah agree with fixture
@@ -18,7 +18,7 @@ describe('redeemPayout', function () { | |||
coverOwner.address, | |||
2, // productId | |||
ASSET.ETH, | |||
[[parseEther('10000'), timestamp + 1, segmentPeriod, 0, false, 0]], | |||
[[parseEther('10000'), timestamp + 1, segmentPeriod, 7, 0, false, 0]], |
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.
use a constant
@@ -680,7 +681,7 @@ contract Cover is ICover, MasterAwareV2, IStakingPoolBeacon, ReentrancyGuard { | |||
Product memory product, | |||
uint32 _coverAssetsFallback, | |||
uint productTypesCount | |||
) internal { | |||
) internal pure { |
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.
馃憤
Add an assertion here for gracePeriod
|
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.
The changes mentioned above.
Otherwise looks good
@@ -400,7 +401,7 @@ contract Cover is ICover, MasterAwareV2, IStakingPoolBeacon, ReentrancyGuard { | |||
cover.productId, | |||
allocation.coverAmountInNXM, | |||
lastCoverSegment.period, | |||
_productTypes[product.productType].gracePeriodInDays * 1 days, | |||
uint(lastCoverSegment.gracePeriodInDays) * 1 days, |
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 had to cast gracePeriodInDays
as a uint here as it was overflowing.
test/unit/Cover/performStakeBurn.js
Outdated
|
||
describe('performStakeBurn', function () { | ||
describe.only('performStakeBurn', function () { |
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.
forgot an .only here
8fee40e
to
891708c
Compare
Missed a refactor from |
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
cf4bf9a
to
924e31f
Compare
Context
Resolves #287
Changes proposed in this pull request
This PR adds the ability to edit gracePeriodInDays. To do this
gracePeriodInDays
was added to the CoverSegments struct. Deallocation and claims should now use the grace period from the cover segment. Allocations should use the product level grace period.Test plan
Checklist
Review
When reviewing a PR, please indicate intention in comments using the following emojis: