-
-
Notifications
You must be signed in to change notification settings - Fork 237
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(smart-contracts): UP token contract #13875
Merged
Changes from 11 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
fddde56
move UDT to its own folder
clemsos 6f70dae
OZ contracts to v5
clemsos 6b4af58
UP token draft
clemsos bf5ac5f
test for UP token setttings
clemsos ab8cb90
add votes to erc20
clemsos bcb7286
repurpose UDT votes test
clemsos 618a91e
gov + timelock
clemsos 0441590
Merge branch 'master' into up-token
clemsos c1883eb
Merge branch 'master' into up-token
julien51 7f8110c
fix governor settings tests
clemsos 13819ff
fix gov quorum event
clemsos 2a42e60
Update smart-contracts/test/UnlockProtocolToken/governor.js
julien51 4465c19
Update smart-contracts/contracts/tokens/UP/UPGovernor.sol
clemsos 24b6e4c
use seconds instead of blocks
clemsos 508b7c5
Merge branch 'up-token' of github.com:unlock-protocol/unlock into up-…
clemsos d1621d3
specifiy timelock admin in constructor
clemsos 340b58f
Merge branch 'master' into up-token
clemsos 796699c
use block timetsmp for revert test
clemsos cd71637
fix governor testst
clemsos 649f09d
`increaseTime` receives seconds instead of hours
clemsos 80833a2
Merge branch 'master' into up-token
clemsos 4c7195e
rename files to UPToken
clemsos 3f79de7
Merge branch 'up-token' of github.com:unlock-protocol/unlock into up-…
clemsos b40b440
Merge branch 'master' into up-token
clemsos 748e787
Merge branch 'master' into up-token
clemsos 68ebc08
Update governor.js
clemsos 82ffc30
Merge branch 'master' into up-token
clemsos File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,166 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Compatible with OpenZeppelin Contracts ^5.0.0 | ||
pragma solidity ^0.8.21; | ||
|
||
import "@openzeppelin/contracts-upgradeable5/governance/GovernorUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/governance/extensions/GovernorSettingsUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/governance/extensions/GovernorCountingSimpleUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/governance/extensions/GovernorVotesUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/governance/extensions/GovernorTimelockControlUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/proxy/utils/Initializable.sol"; | ||
|
||
/// @custom:security-contact hello@unlock-protocol.com | ||
contract UPGovernor is | ||
Initializable, | ||
GovernorUpgradeable, | ||
GovernorSettingsUpgradeable, | ||
GovernorCountingSimpleUpgradeable, | ||
GovernorVotesUpgradeable, | ||
GovernorTimelockControlUpgradeable | ||
{ | ||
uint private _quorum; | ||
|
||
// add custom event for quorum changes | ||
event QuorumSet(uint oldQuorum, uint newQuorum); | ||
|
||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize( | ||
IVotes _token, | ||
TimelockControllerUpgradeable _timelock | ||
) public initializer { | ||
__Governor_init("UnlockProtocolGovernor"); | ||
__GovernorSettings_init(43200 /* 6 day */, 43200 /* 6 days */, 0); | ||
__GovernorCountingSimple_init(); | ||
__GovernorVotes_init(_token); | ||
__GovernorTimelockControl_init(_timelock); | ||
|
||
// default quorum set to 30k | ||
_quorum = 30000e18; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nouvelle syntax? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quorum should be 3k NOT 30k. |
||
} | ||
|
||
// quorum set to 30k | ||
clemsos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
function quorum(uint256) public view override returns (uint256) { | ||
return _quorum; | ||
} | ||
|
||
// helper to change quorum | ||
function setQuorum(uint256 newQuorum) public onlyGovernance { | ||
uint256 oldQuorum = _quorum; | ||
_quorum = newQuorum; | ||
emit QuorumSet(oldQuorum, newQuorum); | ||
} | ||
|
||
// The following functions are overrides required by Solidity. | ||
clemsos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
function votingDelay() | ||
public | ||
view | ||
override(GovernorUpgradeable, GovernorSettingsUpgradeable) | ||
returns (uint256) | ||
{ | ||
return super.votingDelay(); | ||
} | ||
|
||
function votingPeriod() | ||
public | ||
view | ||
override(GovernorUpgradeable, GovernorSettingsUpgradeable) | ||
returns (uint256) | ||
{ | ||
return super.votingPeriod(); | ||
} | ||
|
||
function state( | ||
uint256 proposalId | ||
) | ||
public | ||
view | ||
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) | ||
returns (ProposalState) | ||
{ | ||
return super.state(proposalId); | ||
} | ||
|
||
function proposalNeedsQueuing( | ||
uint256 proposalId | ||
) | ||
public | ||
view | ||
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) | ||
returns (bool) | ||
{ | ||
return super.proposalNeedsQueuing(proposalId); | ||
} | ||
|
||
function proposalThreshold() | ||
public | ||
view | ||
override(GovernorUpgradeable, GovernorSettingsUpgradeable) | ||
returns (uint256) | ||
{ | ||
return super.proposalThreshold(); | ||
} | ||
|
||
function _queueOperations( | ||
uint256 proposalId, | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
bytes32 descriptionHash | ||
) | ||
internal | ||
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) | ||
returns (uint48) | ||
{ | ||
return | ||
super._queueOperations( | ||
proposalId, | ||
targets, | ||
values, | ||
calldatas, | ||
descriptionHash | ||
); | ||
} | ||
|
||
function _executeOperations( | ||
uint256 proposalId, | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
bytes32 descriptionHash | ||
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) { | ||
super._executeOperations( | ||
proposalId, | ||
targets, | ||
values, | ||
calldatas, | ||
descriptionHash | ||
); | ||
} | ||
|
||
function _cancel( | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
bytes32 descriptionHash | ||
) | ||
internal | ||
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) | ||
returns (uint256) | ||
{ | ||
return super._cancel(targets, values, calldatas, descriptionHash); | ||
} | ||
|
||
function _executor() | ||
internal | ||
view | ||
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) | ||
returns (address) | ||
{ | ||
return super._executor(); | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.21; | ||
|
||
import "@openzeppelin/contracts-upgradeable/governance/TimelockControllerUpgradeable.sol"; | ||
|
||
contract UPTimelock is TimelockControllerUpgradeable { | ||
function initialize( | ||
uint256 minDelay, | ||
address[] memory proposers, | ||
address[] memory executors | ||
) public initializer { | ||
__TimelockController_init(minDelay, proposers, executors, msg.sender); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
smart-contracts/contracts/tokens/UP/UnlockProtocolToken.sol
This file contains 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Compatible with OpenZeppelin Contracts ^5.0.0 | ||
pragma solidity ^0.8.21; | ||
|
||
import "@openzeppelin/contracts-upgradeable5/token/ERC20/ERC20Upgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/token/ERC20/extensions/ERC20VotesUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/access/OwnableUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable5/proxy/utils/Initializable.sol"; | ||
import {NoncesUpgradeable} from "@openzeppelin/contracts-upgradeable5/utils/NoncesUpgradeable.sol"; | ||
|
||
/// @custom:security-contact hello@unlock-protocol.com | ||
contract UnlockProtocolToken is | ||
Initializable, | ||
ERC20Upgradeable, | ||
ERC20PermitUpgradeable, | ||
ERC20VotesUpgradeable, | ||
OwnableUpgradeable | ||
{ | ||
uint public constant TOTAL_SUPPLY = 1_000_000_000; | ||
|
||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize( | ||
address initialOwner, | ||
address preMinter | ||
) public initializer { | ||
__ERC20_init("UnlockProtocolToken", "UP"); | ||
__ERC20Permit_init("UnlockProtocolToken"); | ||
__ERC20Votes_init(); | ||
__Ownable_init(initialOwner); | ||
|
||
// premint the supply | ||
_mint(preMinter, TOTAL_SUPPLY * 10 ** decimals()); | ||
} | ||
|
||
// The following functions are overrides required by Solidity. | ||
|
||
function _update( | ||
address from, | ||
address to, | ||
uint256 value | ||
) internal override(ERC20Upgradeable, ERC20VotesUpgradeable) { | ||
super._update(from, to, value); | ||
} | ||
|
||
function nonces( | ||
address owner | ||
) | ||
public | ||
view | ||
override(ERC20PermitUpgradeable, NoncesUpgradeable) | ||
returns (uint256) | ||
{ | ||
return super.nonces(owner); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
Is this in seconds? If so this is not 6 days! please use
6* 24 * 60 * 60
for clarty.