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

Chore: Automate end start swapping #235

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

codebuster22
Copy link
Contributor

closes #234

@codecov-commenter
Copy link

codecov-commenter commented Jan 3, 2022

Codecov Report

Merging #235 (1b50cfe) into main (6093853) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #235      +/-   ##
==========================================
+ Coverage   98.90%   98.94%   +0.04%     
==========================================
  Files          13       13              
  Lines         456      475      +19     
  Branches      108      114       +6     
==========================================
+ Hits          451      470      +19     
  Misses          5        5              
Impacted Files Coverage Δ
contracts/lbp/LBPManager.sol 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6093853...1b50cfe. Read the comment docs.

@codebuster22 codebuster22 self-assigned this Jan 3, 2022
@codebuster22 codebuster22 added DO NOT MERGE do not merge WIP work in progress labels Jan 3, 2022
uint256 blockTime = 5 minutes;
bool isSwapEnabled = lbp.getSwapEnabled();
(startTime, , ) = lbp.getGradualWeightUpdateParams();
require(
Copy link

Choose a reason for hiding this comment

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

image

(startTime, , ) = lbp.getGradualWeightUpdateParams();
require(
!isSwapEnabled && state == TaskState.Waiting,
"LBPManager: swapping already active"
Copy link

Choose a reason for hiding this comment

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

if state is Ended, message would be wrong

Copy link

Choose a reason for hiding this comment

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

Should refer to "enabled" OR "disabled", not "active" (state terminology is internal to the contract)

Copy link

Choose a reason for hiding this comment

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

I don't think we should revert if !isSwapEnabled. Should just set the state to Started and return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have implemented the changes you requested.

);
require(
block.timestamp > startTime - blockTime,
"LBPManager: Only once block before start time"
Copy link

Choose a reason for hiding this comment

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

incorrect grammar and unclear. should be "LBPManager: More than one block before start time"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

improved the error string

(, endTime, ) = lbp.getGradualWeightUpdateParams();
require(
isSwapEnabled && state == TaskState.Started,
"LBPManager: swapping already active"
Copy link

Choose a reason for hiding this comment

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

Should be "LBPManager: swapping is not enabled"

Copy link

Choose a reason for hiding this comment

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

anyway, I don't think we should revert if isSwapEnabled. Should just set the state to Ended and return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have implemented the changes you requested.

);
require(
block.timestamp > endTime,
"LBPManager: Only once block before start time"
Copy link

Choose a reason for hiding this comment

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

should be >=

incorrect grammar and unclear. should be "LBPManager: haven't reached endTime"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have implemented the changes you requested.

@@ -302,6 +349,7 @@ contract LBPManager {
* @param _swapEnabled Enables/disables swapping.
*/
function setSwapEnabled(bool _swapEnabled) external onlyAdmin {
require(TaskState.Ended != state, "LBPManager: LBP ended");
Copy link

Choose a reason for hiding this comment

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

Why? you can only call this function if the LBP is ended? For what purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can call this method only if the LBP is not ended. So that nobody can restart swapping after end time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved the condition, and is now not dependent on state.

state = TaskState.Ended;
lbp.setSwapEnabled(false);
}

/**
* @dev Exit pool or remove liquidity from pool.
Copy link

Choose a reason for hiding this comment

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

This documentation is wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

documentation for removeLiquidity?

Copy link

Choose a reason for hiding this comment

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

The documentation on the line linked to this comment. "Exit pool or remove liquidity from pool."

Copy link

@dkent600 dkent600 Jan 6, 2022

Choose a reason for hiding this comment

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

That documentation is completely wrong for setSwapEnabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, This documentation is for removeLiquidity. The lines between 286-349 are hidden due to no changes. The correct docs for setSwapEnabled starts at line 347.

);
require(
block.timestamp >= startTimeEndTime[1],
"LBPManager: haven't reached end time"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"LBPManager: haven't reached end time"
"LBPManager: awaits end time"

require(state == TaskState.Waiting, "LBPManager: already started");
require(
block.timestamp > startTimeEndTime[0] - buffer,
"LBPManager: one block before start time"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"LBPManager: one block before start time"
"LBPManager: awaits start time"

@codebuster22 codebuster22 marked this pull request as draft January 11, 2022 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DO NOT MERGE do not merge WIP work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Add integration to support gelato to. execute tasks
4 participants