Skip to content

Commit

Permalink
refactor: rename to delegation token
Browse files Browse the repository at this point in the history
  • Loading branch information
MerlinEgalite committed Oct 22, 2024
1 parent 82b7717 commit c5d8ae5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/Token.sol → src/DelegationToken.sol
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";
Expand All @@ -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.
Expand All @@ -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
{
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/MorphoTokenEthereum.sol
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.
Expand Down
4 changes: 2 additions & 2 deletions src/MorphoTokenOptimism.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
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);
Expand Down

0 comments on commit c5d8ae5

Please sign in to comment.