-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split ERC20Votes and ERC20VotesComp (#2706)
Co-authored-by: Francisco Giordano <[email protected]>
- Loading branch information
Showing
11 changed files
with
749 additions
and
118 deletions.
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
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,25 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
|
||
import "../token/ERC20/extensions/ERC20VotesComp.sol"; | ||
|
||
contract ERC20VotesCompMock is ERC20VotesComp { | ||
constructor (string memory name, string memory symbol) | ||
ERC20(name, symbol) | ||
ERC20Permit(name) | ||
{} | ||
|
||
function mint(address account, uint256 amount) public { | ||
_mint(account, amount); | ||
} | ||
|
||
function burn(address account, uint256 amount) public { | ||
_burn(account, amount); | ||
} | ||
|
||
function getChainId() external view returns (uint256) { | ||
return block.chainid; | ||
} | ||
} |
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
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
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
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,46 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "./ERC20Votes.sol"; | ||
|
||
/** | ||
* @dev Extension of ERC20 to support Compound's voting and delegation. This version exactly matches Compound's | ||
* interface, with the drawback of only supporting supply up to (2^96^ - 1). | ||
* | ||
* NOTE: You should use this contract if you need exact compatibility with COMP (for example in order to use your token | ||
* with Governor Alpha or Bravo) and if you are sure the supply cap of 2^96^ is enough for you. Otherwise, use the | ||
* {ERC20Votes} variant of this module. | ||
* | ||
* This extensions keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either | ||
* by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting | ||
* power can be queried through the public accessors {getCurrentVotes} and {getPriorVotes}. | ||
* | ||
* By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it | ||
* requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked. | ||
* Enabling self-delegation can easily be done by overriding the {delegates} function. Keep in mind however that this | ||
* will significantly increase the base gas cost of transfers. | ||
* | ||
* _Available since v4.2._ | ||
*/ | ||
abstract contract ERC20VotesComp is ERC20Votes { | ||
/** | ||
* @dev Comp version of the {getVotes} accessor, with `uint96` return type. | ||
*/ | ||
function getCurrentVotes(address account) external view returns (uint96) { | ||
return SafeCast.toUint96(getVotes(account)); | ||
} | ||
/** | ||
* @dev Comp version of the {getPastVotes} accessor, with `uint96` return type. | ||
*/ | ||
function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96) { | ||
return SafeCast.toUint96(getPastVotes(account, blockNumber)); | ||
} | ||
|
||
/** | ||
* @dev Maximum token supply. Reduced to `type(uint96).max` (2^96^ - 1) to fit COMP interface. | ||
*/ | ||
function _maxSupply() internal view virtual override returns (uint224) { | ||
return type(uint96).max; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.