-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feat/vesting work #357
Feat/vesting work #357
Conversation
Feat/vesting work
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
uint256 public totalAmountToLock; | ||
uint256 public totalUnlockedTokens; | ||
|
||
constructor( |
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.
what do you think about deploying VestingLock contracts from a factory? So we can keep track of all contracts in a single place and don't need to pass _hedgeyVestingContract and _veMentoLockingContract everytime, we can call with mentoToken address from the factory. And deploying a new contract is simple as calling a function.
@@ -10,3 +19,63 @@ interface ILocking { | |||
uint32 cliff | |||
) external returns (uint256); | |||
} | |||
|
|||
interface ILockingExtended { |
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 think it is fine to just add these function in ILocking, instead of creating ILockingExtended
|
||
function setWithdraw(uint256 amount, address token) external { | ||
withdrawAmount = amount; | ||
withdrawToken = token; |
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 would move this line to constructor. because of this, we call setWithdraw with 0 amount in every skipWeek()
import { ILockingExtended } from "../governance/locking/interfaces/ILocking.sol"; | ||
import { IERC20 } from "openzeppelin-contracts-next/contracts/token/ERC20/IERC20.sol"; | ||
|
||
contract VestingLock { |
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.
can we add natspec comments that explains the contract and also function params
mockTokenVestingPlans.setRedeemableTokens(withdrawable); | ||
mockLocking.setWeek(numberOfWeeks); | ||
|
||
mockLocking.setWithdraw(0, mentoTokenAddr); |
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 think we can remove this. see my comment on the MockLocking.sol
uint256 public totalUnlockedTokens; | ||
|
||
constructor( | ||
address _beneficiary, |
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.
lets change params to have trailing underscore for convention
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.
Similar to the underscore in front of internal functions I was trying to follow how it's done in other Mento contracts e.g BreakerBox and the breakers but I am more than happy to change it if we want trailing underscores
function initializeVestingPlan() public { | ||
require(planId == 0, "VestingLock: plan id already set"); | ||
require( | ||
ITokenVestingPlans(hedgeyVestingContract).balanceOf(address(this)) == 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.
as we discussed, this is vulnerable to griefing as initializeVestingPlan can be frontrunned by creating a vesting plan for this contract. I don't see any problems with this since it has no financial impact or gain for the attacker as long as we can revoke any plans we have on hedgey side.
a straightforward solution would be, we make this function to take planId as param and is onlyOwner but not sure if it worths it
Yes, generally we should emit events for all non-view operations |
Closing this as we will no longer need this contract. If it turns out we do need this then we can re-open. |
Description
This PR adds the new VestingLock contract between a hedgey vesting plan and a beneficiary.
The contract will lock/relock all tokens released in Years 1&2 into the veMento contract, redeem all potential withdrawable tokens from a lock and transfer them with redeemable tokens from Year 3&4 to the beneficiary.
Other changes
Tested
Open Questions:
redeemed(amountLocked, amountWithdrawn, lockID)
Let me know what you think @bowd @baroooo
this could look something like this:
if(amountToLock > 0 && lockingCliffEndWeek < currentWeek):
uint256 denominator = lockingSlopeEnd - lockingCliffEnd
uint256 numerator = lockingSlopeEnd - currentWeek
amountToLock = (amountToLock * numerator) / denominator
Related issues
Backwards compatibility
Documentation