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

Lockup Volume Restrictions #290

Conversation

glitch003
Copy link
Contributor

@glitch003 glitch003 commented Sep 28, 2018

Please check if the PR fulfills these requirements

  • [ X ] The commit message follows our Submission guidelines
  • [ X ] Tests for the changes have been added (for bug fixes / features)
  • [ ? ] Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce?

#287

Does this PR introduce a breaking change?

No

Any Other information:

Some notes:

  • Users can have multiple lock ups. The amount they can withdraw at any given time is the sum of the allowed amounts for all their lock ups.
  • Evenly divisible parameters aren't enforced. You can create a lockup with 2 year total vesting period and 1.5 year release frequency. I can change this if desired but figured it might be enforced on a front end. Once the total vesting period has passed, the lock up is not enforced at all anymore.
  • Lock ups have a "start time". Before this time begins, users can't transfer their tokens.
  • Where should I add docs?

Thanks!

@glitch003
Copy link
Contributor Author

Heads up - this isn't ready yet. I'm adding some parameter checking.

// lets the owner / admin create a volume restriction lockup.
// takes a userAddress and lock up params, and creates a lockup for the user. See the LockUp struct def for info on what each parameter actually is
function addLockUp(address userAddress, uint lockUpPeriodSeconds, uint releaseFrequencySeconds, uint startTime, uint totalAmount) public withPerm(ADMIN) {

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to add some sanity checks for the input parameters

newLockUp.releaseFrequencySeconds = releaseFrequencySeconds;
newLockUp.startTime = startTime;
newLockUp.totalAmount = totalAmount;
userLockUps.push(newLockUp);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of the current approach, it can be re-write in a single line as
lockUps[userAddress].push(LockUP(lockUpPeriodSeconds, releaseFrequencySeconds, startTime , totalAmount))


enum LockUpOperationType { Add, Remove, Edit }

event LogModifyLockUp(
Copy link
Contributor

Choose a reason for hiding this comment

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

As we change our event naming convention, So please remove the Log prefix from the name.
and I prefer the new event for operation type so it is easily understandable with the name.
ex-
event addNewLockUp(...)
event removeLockUP(...)
event modifyLockUp(...)

userLockUps.length--;
}

function editLockUp(address userAddress, uint lockUpIndex, uint lockUpPeriodSeconds, uint releaseFrequencySeconds, uint startTime, uint totalAmount) public withPerm(ADMIN) {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename the function name to modifyLockUp()

if (startTime == 0) {
startTime = now;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

sanity checks are missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @satyamakgec - could you clarify this one? What kind of sanity check were you thinking?

It was my thinking that a startTime before "now" may be desired if you want to backdate someone's vesting, which I think is a common thing. And obviously a startTime after "now" could be desired if you're awarding tokens to an employee who, for example, starts working in 2 weeks or something.

@satyamakgec
Copy link
Contributor

@glitch003 I miss reading the Heads Up comment. But I left some of the comments over the PR. Hope these will help you to add more checks and improve the code.
Note: All functions missing natspec comments. So please add those as well.

@glitch003
Copy link
Contributor Author

@satyamakgec ok, this should be good to go. I made the requested changes, and now the withdrawn amounts are tracked inside the transfer module.

Let me know if there's anything else that needs to be changed

@glitch003
Copy link
Contributor Author

Hey @adamdossa thanks for those fixes to update my branch with dev-1.5.0. Much appreciated!

I put in one more fix, and now the tests pass.

Let me know if there are any more changes needed to get this merged.

Thanks!

@adamdossa adamdossa merged commit fff2ddd into PolymathNetwork:development-1.5.0 Oct 5, 2018
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.

4 participants