Skip to content
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

make getWeeklySpend more sensitive to future programs. #40

Closed
wants to merge 2 commits into from

Conversation

Tritium-VLK
Copy link
Member

Include future spend when checking, to ensure that at no point will more than the max amount ever be spent.
Fixes #33

Include future spend when checking, to ensure that at no point will more than the max amount ever be spent.
@Tritium-VLK
Copy link
Member Author

Not sure this is needed but if you think it is better/more clear we can merge it.

@@ -270,8 +270,8 @@ KeeperCompatibleInterface
target.periodNumber = 0;
target.programStartTimestamp = doNotStartBeforeTimestamp;
GaugeConfigs[recipients[i]] = target;
if (MaxGlobalAmountPerPeriod > 0 && MaxGlobalAmountPerPeriod < getWeeklySpend()) {
revert ExceedsWeeklySpend(getWeeklySpend());
if (MaxGlobalAmountPerPeriod > 0 && MaxGlobalAmountPerPeriod < getWeeklySpend(true)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall it is a great addition, but it is unclear why would you include here also the future schedules?

mind elaborating why you think on the comparison against MaxGlobalAmountPerPeriod is important to also consider the future ones?. since the future ones could be in 2 weeks or in a month time etc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is important that getGlobalAmountSchedule ensures that more than that amount is never paid. It would be too complex to write logic to ensure that otherwise. This may be a little bit "over-protective" but that's ok. If someone get's stuck they can figure that out.

Future scheduling isn't something we expect to do often, and one should think more about the whole thing if you're gtting close to a defined max anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, can see that this may fall more into corner case and that future scheduling of injections is something internally to be considered rare

Only consideration to keep in mind at least while operating as an admin this contract is that on the rare case that future schedules are set for new gauges/recipients besides whatever injections schedules may be running in parallel, that it could lead into revert in case that it's bigger that defined MaxGlobalAmountPerPeriod

As long as internally there is awareness of that should not lead into reverts while operating the injector

Worth adding a minor note/comment around that line of code, from an outside pov it seems a very intricacy detail that can be forgotten

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (MaxGlobalAmountPerPeriod > 0 && MaxGlobalAmountPerPeriod < getWeeklySpend(true)) {
/// @dev adding recipients which have starting date in the future and summing up those with current running schedules
/// @dev if greater than `MaxGlobalAmountPerPeriod` may lead to operational reverts
if (MaxGlobalAmountPerPeriod > 0 && MaxGlobalAmountPerPeriod < getWeeklySpend(true)) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to include our @dev comment suggestion or use different language as you may see best fit to highlight this small intricacy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the point of the whole thing is for the contract to break/revert before sending out more money than intended.

The point of the revert is to make someone think. The error message clearly explains why this configuration action is being taken. I don't think that the @dev notice above helps to clarify things. This is better documented in user guides/in the UI.

In the end after further assessment I think it would make the most sense to not merge this PR. It just adds more complexity to the code without really adding clarity for the folks that would be using it or functionality that I can see likely to be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Low risk (L5): getWeeklySpend should consider the programStartTimestamp variable for each active gauge
3 participants