-
Notifications
You must be signed in to change notification settings - Fork 0
Create vlPUFFER #3
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
cb07bf6
add vlPUFFER contract
bxmmm1 b416316
change casing
bxmmm1 7611dde
update readme
bxmmm1 91d919d
update kickUser to kickUsers
bxmmm1 8d0385e
add more tests
bxmmm1 66e804b
update snapshot
bxmmm1 71b129b
write delegation test
bxmmm1 ab46b21
remove permit, token is not transferrable
bxmmm1 441a430
update multiplier and unlock time
bxmmm1 163c02e
update gas snapshot
bxmmm1 9c955ec
address pr comments
bxmmm1 20734c2
update config and fmt
bxmmm1 45c31e0
code style
bxmmm1 67eb0fa
update comment
bxmmm1 ee7fb2e
minor changes
bxmmm1 5a391dc
gas snapshot
bxmmm1 4bce0f5
update vlPUFFER
bxmmm1 488c9a1
update formatting
bxmmm1 c4aa253
update readme
bxmmm1 3894d4b
update locker to use multiplier instead of unlockTime
bxmmm1 08acc8e
updage snasphot
bxmmm1 459575f
snapshot 7702 test
bxmmm1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,8 +71,9 @@ contract vlPUFFER is ERC20, ERC20Votes, Ownable2Step, Pausable { | |
| uint256 internal constant _GRACE_PERIOD = 1 weeks; | ||
| // 1% in basis points | ||
| uint256 internal constant _KICKER_FEE_BPS = 100; | ||
| // 10000 in basis points | ||
| uint256 internal constant _KICKER_FEE_DENOMINATOR = 10_000; | ||
| // 100% in basis points | ||
| // forgefmt: disable-next-line | ||
| uint256 internal constant _KICKER_FEE_DENOMINATOR = 100_00; | ||
| // Multiplier for vlPUFFER amount calculation | ||
| uint256 internal constant _LOCK_TIME_MULTIPLIER = 30 days; | ||
| // The minimum amount of PUFFER (PUFFER has 18 decimals, so this is 10 PUFFER) tokens that can be locked to receive vlPUFFER | ||
|
|
@@ -88,6 +89,17 @@ contract vlPUFFER is ERC20, ERC20Votes, Ownable2Step, Pausable { | |
| uint256 unlockTime; | ||
| } | ||
|
|
||
| /** | ||
| * @dev notice Permit struct | ||
| */ | ||
| struct Permit { | ||
| uint256 deadline; | ||
| uint256 amount; | ||
| uint8 v; | ||
| bytes32 r; | ||
| bytes32 s; | ||
| } | ||
|
|
||
| /** | ||
| * @notice Mapping of user addresses to their lock information | ||
| * @dev The key is the user address, and the value is a LockInfo struct containing: | ||
|
|
@@ -120,25 +132,25 @@ contract vlPUFFER is ERC20, ERC20Votes, Ownable2Step, Pausable { | |
| * @param unlockTime Timestamp (in seconds) when the lock will expire | ||
| */ | ||
| function createLock(uint256 amount, uint256 unlockTime) external { | ||
| // Transfer PUFFER tokens to this contract using SafeERC20 | ||
| PUFFER.safeTransferFrom(msg.sender, address(this), amount); | ||
|
|
||
| _createLock(amount, unlockTime); | ||
| } | ||
|
|
||
| /** | ||
| * @notice Create a new lock with permit, allowing approval and locking in a single transaction | ||
| * @param value Amount of PUFFER tokens to lock | ||
| * @param unlockTime Timestamp (in seconds) when the lock will expire | ||
| * @param deadline Timestamp until which the signature is valid | ||
| * @param v Recovery byte of the signature | ||
| * @param r First 32 bytes of the signature | ||
| * @param s Second 32 bytes of the signature | ||
| * @param permitData Permit struct containing the signature | ||
| */ | ||
| function createLockWithPermit(uint256 value, uint256 unlockTime, uint256 deadline, uint8 v, bytes32 r, bytes32 s) | ||
| external | ||
| { | ||
| IERC20Permit(address(PUFFER)).permit(msg.sender, address(this), value, deadline, v, r, s); | ||
| function createLockWithPermit(uint256 value, uint256 unlockTime, Permit calldata permitData) external { | ||
| IERC20Permit(address(PUFFER)).permit({ | ||
| owner: msg.sender, | ||
| spender: address(this), | ||
| value: permitData.amount, | ||
| deadline: permitData.deadline, | ||
| v: permitData.v, | ||
| s: permitData.s, | ||
| r: permitData.r | ||
| }); | ||
|
|
||
| _createLock(value, unlockTime); | ||
| } | ||
|
|
@@ -150,13 +162,16 @@ contract vlPUFFER is ERC20, ERC20Votes, Ownable2Step, Pausable { | |
| { | ||
| multiplier = ((unlockTime - block.timestamp) / _LOCK_TIME_MULTIPLIER); | ||
| // Round down the unlockTime to the nearest 30-day multiplier | ||
| roundedUnlockTime = block.timestamp + (multiplier * _LOCK_TIME_MULTIPLIER); | ||
| roundedUnlockTime = uint256(block.timestamp) + (multiplier * _LOCK_TIME_MULTIPLIER); | ||
| } | ||
|
|
||
| function _createLock(uint256 amount, uint256 unlockTime) internal onlyValidLockDuration(unlockTime) whenNotPaused { | ||
|
||
| require(amount >= _MIN_LOCK_AMOUNT, InvalidAmount()); | ||
| require(lockInfos[msg.sender].pufferAmount == 0, LockAlreadyExists()); | ||
|
|
||
| // Transfer PUFFER tokens to this contract using SafeERC20 | ||
| PUFFER.safeTransferFrom(msg.sender, address(this), amount); | ||
|
|
||
| (uint256 roundedUnlockTime, uint256 multiplier) = _calculateUnlockTimeAndMultiplier(unlockTime); | ||
|
|
||
| // Calculate vlPUFFER amount based on the lock duration | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
100_00 ? it should be 10_000
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.
actually we don't even need this as a constant. the term BPS already implies 10,000
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.
true, but since it is not upgradeable contract, and we are hardcoding it. it might as well be a readable. this suggestion was made by @eladiosch because 10k bps = 100 %, so i just followed up on it