-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename to delegation token
- Loading branch information
1 parent
82b7717
commit c5d8ae5
Showing
4 changed files
with
16 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.27; | ||
|
||
import {IERC20DelegatesUpgradeable} from "./interfaces/IERC20DelegatesUpgradeable.sol"; | ||
import {IDelegationToken} from "./interfaces/IDelegationToken.sol"; | ||
|
||
import {ERC20PermitUpgradeable} from | ||
"../lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; | ||
|
@@ -11,7 +11,7 @@ import {Ownable2StepUpgradeable} from | |
"../lib/openzeppelin-contracts-upgradeable/contracts/access/Ownable2StepUpgradeable.sol"; | ||
import {UUPSUpgradeable} from "../lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol"; | ||
|
||
/// @title Token | ||
/// @title DelegationToken | ||
/// @author Morpho Association | ||
/// @custom:contact [email protected] | ||
/// @dev Extension of ERC20 to support token delegation. | ||
|
@@ -23,9 +23,9 @@ import {UUPSUpgradeable} from "../lib/openzeppelin-contracts-upgradeable/contrac | |
/// | ||
/// By default, token balance does not account for voting power. This makes transfers cheaper. Whether an account | ||
/// has to self-delegate to vote depends on the voting contract implementation. | ||
abstract contract Token is | ||
abstract contract DelegationToken is | ||
IDelegationToken, | ||
ERC20PermitUpgradeable, | ||
IERC20DelegatesUpgradeable, | ||
Ownable2StepUpgradeable, | ||
UUPSUpgradeable | ||
{ | ||
|
@@ -34,13 +34,13 @@ abstract contract Token is | |
bytes32 internal constant DELEGATION_TYPEHASH = | ||
keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); | ||
|
||
// keccak256(abi.encode(uint256(keccak256("morpho.storage.ERC20Delegates")) - 1)) & ~bytes32(uint256(0xff)) | ||
// keccak256(abi.encode(uint256(keccak256("DelegationToken")) - 1)) & ~bytes32(uint256(0xff)) | ||
bytes32 internal constant ERC20DelegatesStorageLocation = | ||
0x1dc92b2c6e971ab6e08dfd7dcec0e9496d223ced663ba2a06543451548549500; | ||
0xd583ef41af40c9ecf9cd08176e1b50741710eaecf057b22e93a6b99fa47a6400; | ||
|
||
/* STORAGE LAYOUT */ | ||
|
||
/// @custom:storage-location erc7201:morpho.storage.ERC20Delegates | ||
/// @custom:storage-location erc7201:DelegationToken | ||
struct ERC20DelegatesStorage { | ||
mapping(address => address) _delegatee; | ||
mapping(address => uint256) _delegatedVotingPower; | ||
|
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity 0.8.27; | ||
|
||
import {Token} from "./Token.sol"; | ||
import {DelegationToken} from "./DelegationToken.sol"; | ||
|
||
/// @title MorphoTokenEthereum | ||
/// @author Morpho Association | ||
/// @custom:contact [email protected] | ||
/// @notice The Morpho token contract for Ethereum. | ||
contract MorphoTokenEthereum is Token { | ||
contract MorphoTokenEthereum is DelegationToken { | ||
/* CONSTANTS */ | ||
|
||
/// @dev The name of the token. | ||
|
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 |
---|---|---|
|
@@ -5,13 +5,13 @@ import {IOptimismMintableERC20} from "./interfaces/IOptimismMintableERC20.sol"; | |
import {IERC165} from | ||
"../lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol"; | ||
|
||
import {Token} from "./Token.sol"; | ||
import {DelegationToken} from "./DelegationToken.sol"; | ||
|
||
/// @title MorphoTokenOptimism | ||
/// @author Morpho Association | ||
/// @custom:contact [email protected] | ||
/// @notice The Morpho token contract for Optimism networks. | ||
contract MorphoTokenOptimism is Token, IOptimismMintableERC20 { | ||
contract MorphoTokenOptimism is DelegationToken, IOptimismMintableERC20 { | ||
/* CONSTANTS */ | ||
|
||
/// @dev The name of the token. | ||
|
7 changes: 5 additions & 2 deletions
7
...interfaces/IERC20DelegatesUpgradeable.sol → src/interfaces/IDelegationToken.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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity >=0.5.0; | ||
|
||
/// @title IDelegates | ||
import {IERC20} from | ||
"../../lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; | ||
|
||
/// @title IDelegationToken | ||
/// @author Morpho Association | ||
/// @custom:contact [email protected] | ||
interface IERC20DelegatesUpgradeable { | ||
interface IDelegationToken is IERC20 { | ||
function delegatedVotingPower(address account) external view returns (uint256); | ||
|
||
function delegatee(address account) external view returns (address); | ||
|