From a5531611fc095bffa0e7ae795fbf3253c2978b63 Mon Sep 17 00:00:00 2001 From: dd0sxx Date: Fri, 8 Dec 2023 14:44:07 -0500 Subject: [PATCH] changed language --- README.md | 2 +- script/DeployLlamaTokenVotingFactory.s.sol | 40 +++--- .../ERC20TokenholderActionCreator.sol | 10 +- src/token-voting/ERC20TokenholderCaster.sol | 10 +- .../ERC721TokenholderActionCreator.sol | 10 +- src/token-voting/ERC721TokenholderCaster.sol | 10 +- src/token-voting/LlamaTokenVotingFactory.sol | 114 +++++++++--------- src/token-voting/TokenholderActionCreator.sol | 12 +- src/token-voting/TokenholderCaster.sol | 66 +++++----- 9 files changed, 134 insertions(+), 140 deletions(-) diff --git a/README.md b/README.md index 15af30d..76dc6c6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ repository. ## Modules -- **Token Voting:** smart contract policies that allow `ERC20Votes` or `ERC721Votes` tokenholders to create actions enforced by delegated token thresholds or collectively approve or disapprove an action through token voting. +- **Token Voting:** smart contract policies that allow `ERC20Votes` or `ERC721Votes` tokenHolders to create actions enforced by delegated token thresholds or collectively approve or disapprove an action through token voting. ## Prerequisites diff --git a/script/DeployLlamaTokenVotingFactory.s.sol b/script/DeployLlamaTokenVotingFactory.s.sol index bd28a24..4942f6d 100644 --- a/script/DeployLlamaTokenVotingFactory.s.sol +++ b/script/DeployLlamaTokenVotingFactory.s.sol @@ -4,18 +4,18 @@ pragma solidity 0.8.23; import {Script} from "forge-std/Script.sol"; import {DeployUtils} from "script/DeployUtils.sol"; -import {ERC20TokenholderActionCreator} from "src/token-voting/ERC20TokenholderActionCreator.sol"; -import {ERC20TokenholderCaster} from "src/token-voting/ERC20TokenholderCaster.sol"; -import {ERC721TokenholderActionCreator} from "src/token-voting/ERC721TokenholderActionCreator.sol"; -import {ERC721TokenholderCaster} from "src/token-voting/ERC721TokenholderCaster.sol"; +import {ERC20TokenHolderActionCreator} from "src/token-voting/ERC20TokenHolderActionCreator.sol"; +import {ERC20TokenHolderCaster} from "src/token-voting/ERC20TokenHolderCaster.sol"; +import {ERC721TokenHolderActionCreator} from "src/token-voting/ERC721TokenHolderActionCreator.sol"; +import {ERC721TokenHolderCaster} from "src/token-voting/ERC721TokenHolderCaster.sol"; import {LlamaTokenVotingFactory} from "src/token-voting/LlamaTokenVotingFactory.sol"; contract DeployLlamaTokenVotingFactory is Script { // Logic contracts. - ERC20TokenholderActionCreator erc20TokenholderActionCreatorLogic; - ERC20TokenholderCaster erc20TokenholderCasterLogic; - ERC721TokenholderActionCreator erc721TokenholderActionCreatorLogic; - ERC721TokenholderCaster erc721TokenholderCasterLogic; + ERC20TokenHolderActionCreator erc20TokenHolderActionCreatorLogic; + ERC20TokenHolderCaster erc20TokenHolderCasterLogic; + ERC721TokenHolderActionCreator erc721TokenHolderActionCreatorLogic; + ERC721TokenHolderCaster erc721TokenHolderCasterLogic; // Factory contracts. LlamaTokenVotingFactory tokenVotingFactory; @@ -26,37 +26,37 @@ contract DeployLlamaTokenVotingFactory is Script { ); vm.broadcast(); - erc20TokenholderActionCreatorLogic = new ERC20TokenholderActionCreator(); + erc20TokenHolderActionCreatorLogic = new ERC20TokenHolderActionCreator(); DeployUtils.print( - string.concat(" ERC20TokenholderActionCreatorLogic: ", vm.toString(address(erc20TokenholderActionCreatorLogic))) + string.concat(" ERC20TokenHolderActionCreatorLogic: ", vm.toString(address(erc20TokenHolderActionCreatorLogic))) ); vm.broadcast(); - erc20TokenholderCasterLogic = new ERC20TokenholderCaster(); + erc20TokenHolderCasterLogic = new ERC20TokenHolderCaster(); DeployUtils.print( - string.concat(" ERC20TokenholderCasterLogic: ", vm.toString(address(erc20TokenholderCasterLogic))) + string.concat(" ERC20TokenHolderCasterLogic: ", vm.toString(address(erc20TokenHolderCasterLogic))) ); vm.broadcast(); - erc721TokenholderActionCreatorLogic = new ERC721TokenholderActionCreator(); + erc721TokenHolderActionCreatorLogic = new ERC721TokenHolderActionCreator(); DeployUtils.print( string.concat( - " ERC721TokenholderActionCreatorLogic: ", vm.toString(address(erc721TokenholderActionCreatorLogic)) + " ERC721TokenHolderActionCreatorLogic: ", vm.toString(address(erc721TokenHolderActionCreatorLogic)) ) ); vm.broadcast(); - erc721TokenholderCasterLogic = new ERC721TokenholderCaster(); + erc721TokenHolderCasterLogic = new ERC721TokenHolderCaster(); DeployUtils.print( - string.concat(" ERC721TokenholderCasterLogic: ", vm.toString(address(erc721TokenholderCasterLogic))) + string.concat(" ERC721TokenHolderCasterLogic: ", vm.toString(address(erc721TokenHolderCasterLogic))) ); vm.broadcast(); tokenVotingFactory = new LlamaTokenVotingFactory( - erc20TokenholderActionCreatorLogic, - erc20TokenholderCasterLogic, - erc721TokenholderActionCreatorLogic, - erc721TokenholderCasterLogic + erc20TokenHolderActionCreatorLogic, + erc20TokenHolderCasterLogic, + erc721TokenHolderActionCreatorLogic, + erc721TokenHolderCasterLogic ); DeployUtils.print(string.concat(" LlamaTokenVotingFactory: ", vm.toString(address(tokenVotingFactory)))); } diff --git a/src/token-voting/ERC20TokenholderActionCreator.sol b/src/token-voting/ERC20TokenholderActionCreator.sol index 1ff0962..f5bdf91 100644 --- a/src/token-voting/ERC20TokenholderActionCreator.sol +++ b/src/token-voting/ERC20TokenholderActionCreator.sol @@ -2,14 +2,14 @@ pragma solidity ^0.8.23; import {ILlamaCore} from "src/interfaces/ILlamaCore.sol"; -import {TokenholderActionCreator} from "src/token-voting/TokenholderActionCreator.sol"; +import {TokenHolderActionCreator} from "src/token-voting/TokenHolderActionCreator.sol"; import {ERC20Votes} from "@openzeppelin/token/ERC20/extensions/ERC20Votes.sol"; -/// @title ERC20TokenholderActionCreator +/// @title ERC20TokenHolderActionCreator /// @author Llama (devsdosomething@llama.xyz) /// @notice This contract lets holders of a specified `ERC20Votes` token create actions on a llama instance if their /// token balance is greater than or equal to the creation threshold. -contract ERC20TokenholderActionCreator is TokenholderActionCreator { +contract ERC20TokenHolderActionCreator is TokenHolderActionCreator { ERC20Votes public token; /// @dev This contract is deployed as a minimal proxy from the factory's `deployTokenVotingModule` function. The @@ -18,7 +18,7 @@ contract ERC20TokenholderActionCreator is TokenholderActionCreator { _disableInitializers(); } - /// @notice Initializes a new `ERC20TokenholderActionCreator` clone. + /// @notice Initializes a new `ERC20TokenHolderActionCreator` clone. /// @dev This function is called by the `deployTokenVotingModule` function in the `LlamaTokenVotingFactory` contract. /// The `initializer` modifier ensures that this function can be invoked at most once. /// @param _token The ERC20 token to be used for voting. @@ -27,7 +27,7 @@ contract ERC20TokenholderActionCreator is TokenholderActionCreator { /// be in the same decimals as the token. For example, if the token has 18 decimals and you want a /// creation threshold of 1000 tokens, pass in 1000e18. function initialize(ERC20Votes _token, ILlamaCore _llamaCore, uint256 _creationThreshold) external initializer { - __initializeTokenholderActionCreatorMinimalProxy(_llamaCore, _creationThreshold); + __initializeTokenHolderActionCreatorMinimalProxy(_llamaCore, _creationThreshold); token = _token; uint256 totalSupply = token.totalSupply(); if (totalSupply == 0) revert InvalidTokenAddress(); diff --git a/src/token-voting/ERC20TokenholderCaster.sol b/src/token-voting/ERC20TokenholderCaster.sol index 1ae50af..6749d34 100644 --- a/src/token-voting/ERC20TokenholderCaster.sol +++ b/src/token-voting/ERC20TokenholderCaster.sol @@ -2,14 +2,14 @@ pragma solidity ^0.8.23; import {ILlamaCore} from "src/interfaces/ILlamaCore.sol"; -import {TokenholderCaster} from "src/token-voting/TokenholderCaster.sol"; +import {TokenHolderCaster} from "src/token-voting/TokenHolderCaster.sol"; import {ERC20Votes} from "@openzeppelin/token/ERC20/extensions/ERC20Votes.sol"; -/// @title ERC20TokenholderCaster +/// @title ERC20TokenHolderCaster /// @author Llama (devsdosomething@llama.xyz) /// @notice This contract lets holders of a given governance ERC20Votes token cast approvals and disapprovals /// on created actions. -contract ERC20TokenholderCaster is TokenholderCaster { +contract ERC20TokenHolderCaster is TokenHolderCaster { ERC20Votes public token; /// @dev This contract is deployed as a minimal proxy from the factory's `deployTokenVotingModule` function. The @@ -18,7 +18,7 @@ contract ERC20TokenholderCaster is TokenholderCaster { _disableInitializers(); } - /// @notice Initializes a new `ERC20TokenholderCaster` clone. + /// @notice Initializes a new `ERC20TokenHolderCaster` clone. /// @dev This function is called by the `deployTokenVotingModule` function in the `LlamaTokenVotingFactory` contract. /// The `initializer` modifier ensures that this function can be invoked at most once. /// @param _token The ERC20 token to be used for voting. @@ -33,7 +33,7 @@ contract ERC20TokenholderCaster is TokenholderCaster { uint256 _minApprovalPct, uint256 _minDisapprovalPct ) external initializer { - __initializeTokenholderCasterMinimalProxy(_llamaCore, _role, _minApprovalPct, _minDisapprovalPct); + __initializeTokenHolderCasterMinimalProxy(_llamaCore, _role, _minApprovalPct, _minDisapprovalPct); token = _token; uint256 totalSupply = token.totalSupply(); if (totalSupply == 0) revert InvalidTokenAddress(); diff --git a/src/token-voting/ERC721TokenholderActionCreator.sol b/src/token-voting/ERC721TokenholderActionCreator.sol index 1687d24..051a9ec 100644 --- a/src/token-voting/ERC721TokenholderActionCreator.sol +++ b/src/token-voting/ERC721TokenholderActionCreator.sol @@ -2,15 +2,15 @@ pragma solidity ^0.8.23; import {ILlamaCore} from "src/interfaces/ILlamaCore.sol"; -import {TokenholderActionCreator} from "src/token-voting/TokenholderActionCreator.sol"; +import {TokenHolderActionCreator} from "src/token-voting/TokenHolderActionCreator.sol"; import {ERC721Votes} from "@openzeppelin/token/ERC721/extensions/ERC721Votes.sol"; import {IERC721} from "@openzeppelin/token/ERC721/IERC721.sol"; -/// @title ERC721TokenholderActionCreator +/// @title ERC721TokenHolderActionCreator /// @author Llama (devsdosomething@llama.xyz) /// @notice This contract lets holders of a given governance ERC721Votes token create actions on the llama instance if /// they hold enough tokens. -contract ERC721TokenholderActionCreator is TokenholderActionCreator { +contract ERC721TokenHolderActionCreator is TokenHolderActionCreator { ERC721Votes public token; /// @dev This contract is deployed as a minimal proxy from the factory's `deployTokenVotingModule` function. The @@ -19,7 +19,7 @@ contract ERC721TokenholderActionCreator is TokenholderActionCreator { _disableInitializers(); } - /// @notice Initializes a new `ERC721TokenholderActionCreator` clone. + /// @notice Initializes a new `ERC721TokenHolderActionCreator` clone. /// @dev This function is called by the `deployTokenVotingModule` function in the `LlamaTokenVotingFactory` contract. /// The `initializer` modifier ensures that this function can be invoked at most once. /// @param _token The ERC721 token to be used for voting. @@ -28,7 +28,7 @@ contract ERC721TokenholderActionCreator is TokenholderActionCreator { /// be in the same decimals as the token. For example, if the token has 18 decimals and you want a /// creation threshold of 1000 tokens, pass in 1000e18. function initialize(ERC721Votes _token, ILlamaCore _llamaCore, uint256 _creationThreshold) external initializer { - __initializeTokenholderActionCreatorMinimalProxy(_llamaCore, _creationThreshold); + __initializeTokenHolderActionCreatorMinimalProxy(_llamaCore, _creationThreshold); token = _token; if (!token.supportsInterface(type(IERC721).interfaceId)) revert InvalidTokenAddress(); uint256 totalSupply = token.getPastTotalSupply(block.timestamp - 1); diff --git a/src/token-voting/ERC721TokenholderCaster.sol b/src/token-voting/ERC721TokenholderCaster.sol index fa9f2c3..b8ae590 100644 --- a/src/token-voting/ERC721TokenholderCaster.sol +++ b/src/token-voting/ERC721TokenholderCaster.sol @@ -2,15 +2,15 @@ pragma solidity ^0.8.23; import {ILlamaCore} from "src/interfaces/ILlamaCore.sol"; -import {TokenholderCaster} from "src/token-voting/TokenholderCaster.sol"; +import {TokenHolderCaster} from "src/token-voting/TokenHolderCaster.sol"; import {ERC721Votes} from "@openzeppelin/token/ERC721/extensions/ERC721Votes.sol"; import {IERC721} from "@openzeppelin/token/ERC721/IERC721.sol"; -/// @title ERC721TokenholderCaster +/// @title ERC721TokenHolderCaster /// @author Llama (devsdosomething@llama.xyz) /// @notice This contract lets holders of a given governance ERC721Votes token cast approvals and disapprovals /// on created actions. -contract ERC721TokenholderCaster is TokenholderCaster { +contract ERC721TokenHolderCaster is TokenHolderCaster { ERC721Votes public token; /// @dev This contract is deployed as a minimal proxy from the factory's `deployTokenVotingModule` function. The @@ -19,7 +19,7 @@ contract ERC721TokenholderCaster is TokenholderCaster { _disableInitializers(); } - /// @notice Initializes a new `ERC721TokenholderCaster` clone. + /// @notice Initializes a new `ERC721TokenHolderCaster` clone. /// @dev This function is called by the `deployTokenVotingModule` function in the `LlamaTokenVotingFactory` contract. /// The `initializer` modifier ensures that this function can be invoked at most once. /// @param _token The ERC721 token to be used for voting. @@ -34,7 +34,7 @@ contract ERC721TokenholderCaster is TokenholderCaster { uint256 _minApprovalPct, uint256 _minDisapprovalPct ) external initializer { - __initializeTokenholderCasterMinimalProxy(_llamaCore, _role, _minApprovalPct, _minDisapprovalPct); + __initializeTokenHolderCasterMinimalProxy(_llamaCore, _role, _minApprovalPct, _minDisapprovalPct); token = _token; if (!token.supportsInterface(type(IERC721).interfaceId)) revert InvalidTokenAddress(); } diff --git a/src/token-voting/LlamaTokenVotingFactory.sol b/src/token-voting/LlamaTokenVotingFactory.sol index f766c23..29d4136 100644 --- a/src/token-voting/LlamaTokenVotingFactory.sol +++ b/src/token-voting/LlamaTokenVotingFactory.sol @@ -4,11 +4,11 @@ pragma solidity ^0.8.23; import {Clones} from "@openzeppelin/proxy/Clones.sol"; import {ILlamaCore} from "src/interfaces/ILlamaCore.sol"; -import {ERC20TokenholderActionCreator} from "src/token-voting/ERC20TokenholderActionCreator.sol"; -import {ERC20TokenholderCaster} from "src/token-voting/ERC20TokenholderCaster.sol"; +import {ERC20TokenHolderActionCreator} from "src/token-voting/ERC20TokenHolderActionCreator.sol"; +import {ERC20TokenHolderCaster} from "src/token-voting/ERC20TokenHolderCaster.sol"; import {ERC20Votes} from "@openzeppelin/token/ERC20/extensions/ERC20Votes.sol"; -import {ERC721TokenholderActionCreator} from "src/token-voting/ERC721TokenholderActionCreator.sol"; -import {ERC721TokenholderCaster} from "src/token-voting/ERC721TokenholderCaster.sol"; +import {ERC721TokenHolderActionCreator} from "src/token-voting/ERC721TokenHolderActionCreator.sol"; +import {ERC721TokenHolderCaster} from "src/token-voting/ERC721TokenHolderCaster.sol"; import {ERC721Votes} from "@openzeppelin/token/ERC721/extensions/ERC721Votes.sol"; /// @title LlamaTokenVotingFactory @@ -17,38 +17,34 @@ import {ERC721Votes} from "@openzeppelin/token/ERC721/extensions/ERC721Votes.sol contract LlamaTokenVotingFactory { error NoModulesDeployed(); - event ERC20TokenholderActionCreatorCreated(address actionCreator, address indexed token); - event ERC721TokenholderActionCreatorCreated(address actionCreator, address indexed token); - event ERC20TokenholderCasterCreated( - address caster, address indexed token, uint256 minApprovalPct, uint256 minDisapprovalPct - ); - event ERC721TokenholderCasterCreated( - address caster, address indexed token, uint256 minApprovalPct, uint256 minDisapprovalPct - ); + event ERC20TokenHolderActionCreatorCreated(address actionCreator, address indexed token); + event ERC721TokenHolderActionCreatorCreated(address actionCreator, address indexed token); + event ERC20TokenHolderCasterCreated(address caster, address indexed token, uint256 voteQuorum, uint256 vetoQuorum); + event ERC721TokenHolderCasterCreated(address caster, address indexed token, uint256 voteQuorum, uint256 vetoQuorum); - /// @notice The ERC20 Tokenholder Action Creator (logic) contract. - ERC20TokenholderActionCreator public immutable ERC20_TOKENHOLDER_ACTION_CREATOR_LOGIC; + /// @notice The ERC20 TokenHolder Action Creator (logic) contract. + ERC20TokenHolderActionCreator public immutable ERC20_TOKENHOLDER_ACTION_CREATOR_LOGIC; - /// @notice The ERC20 Tokenholder Caster (logic) contract. - ERC20TokenholderCaster public immutable ERC20_TOKENHOLDER_CASTER_LOGIC; + /// @notice The ERC20 TokenHolder Caster (logic) contract. + ERC20TokenHolderCaster public immutable ERC20_TOKENHOLDER_CASTER_LOGIC; - /// @notice The ERC721 Tokenholder Action Creator (logic) contract. - ERC721TokenholderActionCreator public immutable ERC721_TOKENHOLDER_ACTION_CREATOR_LOGIC; + /// @notice The ERC721 TokenHolder Action Creator (logic) contract. + ERC721TokenHolderActionCreator public immutable ERC721_TOKENHOLDER_ACTION_CREATOR_LOGIC; - /// @notice The ERC721 Tokenholder Caster (logic) contract. - ERC721TokenholderCaster public immutable ERC721_TOKENHOLDER_CASTER_LOGIC; + /// @notice The ERC721 TokenHolder Caster (logic) contract. + ERC721TokenHolderCaster public immutable ERC721_TOKENHOLDER_CASTER_LOGIC; /// @dev Set the logic contracts used to deploy Token Voting modules. constructor( - ERC20TokenholderActionCreator erc20TokenholderActionCreatorLogic, - ERC20TokenholderCaster erc20TokenholderCasterLogic, - ERC721TokenholderActionCreator erc721TokenholderActionCreatorLogic, - ERC721TokenholderCaster erc721TokenholderCasterLogic + ERC20TokenHolderActionCreator erc20TokenHolderActionCreatorLogic, + ERC20TokenHolderCaster erc20TokenHolderCasterLogic, + ERC721TokenHolderActionCreator erc721TokenHolderActionCreatorLogic, + ERC721TokenHolderCaster erc721TokenHolderCasterLogic ) { - ERC20_TOKENHOLDER_ACTION_CREATOR_LOGIC = erc20TokenholderActionCreatorLogic; - ERC20_TOKENHOLDER_CASTER_LOGIC = erc20TokenholderCasterLogic; - ERC721_TOKENHOLDER_ACTION_CREATOR_LOGIC = erc721TokenholderActionCreatorLogic; - ERC721_TOKENHOLDER_CASTER_LOGIC = erc721TokenholderCasterLogic; + ERC20_TOKENHOLDER_ACTION_CREATOR_LOGIC = erc20TokenHolderActionCreatorLogic; + ERC20_TOKENHOLDER_CASTER_LOGIC = erc20TokenHolderCasterLogic; + ERC721_TOKENHOLDER_ACTION_CREATOR_LOGIC = erc721TokenHolderActionCreatorLogic; + ERC721_TOKENHOLDER_CASTER_LOGIC = erc721TokenHolderCasterLogic; } ///@notice Deploys a token voting module in a single function so it can be deployed in a single llama action. @@ -59,26 +55,24 @@ contract LlamaTokenVotingFactory { ///@param isERC20 Whether the token is an ERC20 or ERC721. ///@param creationThreshold The number of tokens required to create an action (set to 0 if not deploying action /// creator). - ///@param minApprovalPct The minimum percentage of tokens required to approve an action (set to 0 if not deploying + ///@param voteQuorum The minimum percentage of tokens required to approve an action (set to 0 if not deploying /// caster). - ///@param minDisapprovalPct The minimum percentage of tokens required to disapprove an action (set to 0 if not + ///@param vetoQuorum The minimum percentage of tokens required to disapprove an action (set to 0 if not /// deploying caster). function deployTokenVotingModule( ILlamaCore llamaCore, address token, bool isERC20, uint256 creationThreshold, - uint256 minApprovalPct, - uint256 minDisapprovalPct + uint256 voteQuorum, + uint256 vetoQuorum ) external returns (address actionCreator, address caster) { if (isERC20) { - actionCreator = address(_deployERC20TokenholderActionCreator(ERC20Votes(token), llamaCore, creationThreshold)); - caster = - address(_deployERC20TokenholderCaster(ERC20Votes(token), llamaCore, 0, minApprovalPct, minDisapprovalPct)); + actionCreator = address(_deployERC20TokenHolderActionCreator(ERC20Votes(token), llamaCore, creationThreshold)); + caster = address(_deployERC20TokenHolderCaster(ERC20Votes(token), llamaCore, 0, voteQuorum, vetoQuorum)); } else { - actionCreator = address(_deployERC721TokenholderActionCreator(ERC721Votes(token), llamaCore, creationThreshold)); - caster = - address(_deployERC721TokenholderCaster(ERC721Votes(token), llamaCore, 0, minApprovalPct, minDisapprovalPct)); + actionCreator = address(_deployERC721TokenHolderActionCreator(ERC721Votes(token), llamaCore, creationThreshold)); + caster = address(_deployERC721TokenHolderCaster(ERC721Votes(token), llamaCore, 0, voteQuorum, vetoQuorum)); } } @@ -86,61 +80,61 @@ contract LlamaTokenVotingFactory { // ======== Internal Functions ======== // ==================================== - function _deployERC20TokenholderActionCreator(ERC20Votes token, ILlamaCore llamaCore, uint256 creationThreshold) + function _deployERC20TokenHolderActionCreator(ERC20Votes token, ILlamaCore llamaCore, uint256 creationThreshold) internal - returns (ERC20TokenholderActionCreator actionCreator) + returns (ERC20TokenHolderActionCreator actionCreator) { - actionCreator = ERC20TokenholderActionCreator( + actionCreator = ERC20TokenHolderActionCreator( Clones.cloneDeterministic( address(ERC20_TOKENHOLDER_ACTION_CREATOR_LOGIC), keccak256(abi.encodePacked(address(token), msg.sender)) ) ); actionCreator.initialize(token, llamaCore, creationThreshold); - emit ERC20TokenholderActionCreatorCreated(address(actionCreator), address(token)); + emit ERC20TokenHolderActionCreatorCreated(address(actionCreator), address(token)); } - function _deployERC721TokenholderActionCreator(ERC721Votes token, ILlamaCore llamaCore, uint256 creationThreshold) + function _deployERC721TokenHolderActionCreator(ERC721Votes token, ILlamaCore llamaCore, uint256 creationThreshold) internal - returns (ERC721TokenholderActionCreator actionCreator) + returns (ERC721TokenHolderActionCreator actionCreator) { - actionCreator = ERC721TokenholderActionCreator( + actionCreator = ERC721TokenHolderActionCreator( Clones.cloneDeterministic( address(ERC721_TOKENHOLDER_ACTION_CREATOR_LOGIC), keccak256(abi.encodePacked(address(token), msg.sender)) ) ); actionCreator.initialize(token, llamaCore, creationThreshold); - emit ERC721TokenholderActionCreatorCreated(address(actionCreator), address(token)); + emit ERC721TokenHolderActionCreatorCreated(address(actionCreator), address(token)); } - function _deployERC20TokenholderCaster( + function _deployERC20TokenHolderCaster( ERC20Votes token, ILlamaCore llamaCore, uint8 role, - uint256 minApprovalPct, - uint256 minDisapprovalPct - ) internal returns (ERC20TokenholderCaster caster) { - caster = ERC20TokenholderCaster( + uint256 voteQuorum, + uint256 vetoQuorum + ) internal returns (ERC20TokenHolderCaster caster) { + caster = ERC20TokenHolderCaster( Clones.cloneDeterministic( address(ERC20_TOKENHOLDER_CASTER_LOGIC), keccak256(abi.encodePacked(address(token), msg.sender)) ) ); - caster.initialize(token, llamaCore, role, minApprovalPct, minDisapprovalPct); - emit ERC20TokenholderCasterCreated(address(caster), address(token), minApprovalPct, minDisapprovalPct); + caster.initialize(token, llamaCore, role, voteQuorum, vetoQuorum); + emit ERC20TokenHolderCasterCreated(address(caster), address(token), voteQuorum, vetoQuorum); } - function _deployERC721TokenholderCaster( + function _deployERC721TokenHolderCaster( ERC721Votes token, ILlamaCore llamaCore, uint8 role, - uint256 minApprovalPct, - uint256 minDisapprovalPct - ) internal returns (ERC721TokenholderCaster caster) { - caster = ERC721TokenholderCaster( + uint256 voteQuorum, + uint256 vetoQuorum + ) internal returns (ERC721TokenHolderCaster caster) { + caster = ERC721TokenHolderCaster( Clones.cloneDeterministic( address(ERC721_TOKENHOLDER_CASTER_LOGIC), keccak256(abi.encodePacked(address(token), msg.sender)) ) ); - caster.initialize(token, llamaCore, role, minApprovalPct, minDisapprovalPct); - emit ERC721TokenholderCasterCreated(address(caster), address(token), minApprovalPct, minDisapprovalPct); + caster.initialize(token, llamaCore, role, voteQuorum, vetoQuorum); + emit ERC721TokenHolderCasterCreated(address(caster), address(token), voteQuorum, vetoQuorum); } } diff --git a/src/token-voting/TokenholderActionCreator.sol b/src/token-voting/TokenholderActionCreator.sol index 4d273c2..b9d3589 100644 --- a/src/token-voting/TokenholderActionCreator.sol +++ b/src/token-voting/TokenholderActionCreator.sol @@ -8,7 +8,7 @@ import {ILlamaStrategy} from "src/interfaces/ILlamaStrategy.sol"; import {Action, ActionInfo} from "src/lib/Structs.sol"; import {LlamaUtils} from "src/lib/LlamaUtils.sol"; -/// @title TokenholderActionCreator +/// @title TokenHolderActionCreator /// @author Llama (devsdosomething@llama.xyz) /// @notice This contract lets holders of a given governance token create actions if they have /// sufficient token balance. @@ -16,7 +16,7 @@ import {LlamaUtils} from "src/lib/LlamaUtils.sol"; /// it must hold a Policy from the specified `LlamaCore` instance to actually be able to create an action. The /// instance's policy encodes what actions this contract is allowed to create, and attempting to create an action that /// is not allowed by the policy will result in a revert. -abstract contract TokenholderActionCreator is Initializable { +abstract contract TokenHolderActionCreator is Initializable { /// @notice The core contract for this Llama instance. ILlamaCore public llamaCore; @@ -39,12 +39,12 @@ abstract contract TokenholderActionCreator is Initializable { bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); - /// @notice The address of the tokenholder that created the action. + /// @notice The address of the tokenHolder that created the action. mapping(uint256 => address) public actionCreators; /// @notice Mapping of token holder to function selectors to current nonces for EIP-712 signatures. /// @dev This is used to prevent replay attacks by incrementing the nonce for each operation (`createAction`, - /// `cancelAction`, `castApproval` and `castDisapproval`) signed by the token holder. + /// `cancelAction`) signed by the token holder. mapping(address tokenHolder => mapping(bytes4 selector => uint256 currentNonce)) public nonces; /// @notice The default number of tokens required to create an action. @@ -56,7 +56,7 @@ abstract contract TokenholderActionCreator is Initializable { /// @dev Emitted when an action is created. /// @dev This is the same as the `ActionCreated` event from `LlamaCore`. The two events will be /// nearly identical, with the `creator` being the only difference. This version will emit the - /// address of the tokenholder that created the action, while the `LlamaCore` version will emit + /// address of the tokenHolder that created the action, while the `LlamaCore` version will emit /// the address of this contract as the action creator. event ActionCreated( uint256 id, @@ -101,7 +101,7 @@ abstract contract TokenholderActionCreator is Initializable { /// @param _creationThreshold The default number of tokens required to create an action. This must /// be in the same decimals as the token. For example, if the token has 18 decimals and you want a /// creation threshold of 1000 tokens, pass in 1000e18. - function __initializeTokenholderActionCreatorMinimalProxy(ILlamaCore _llamaCore, uint256 _creationThreshold) internal { + function __initializeTokenHolderActionCreatorMinimalProxy(ILlamaCore _llamaCore, uint256 _creationThreshold) internal { if (_llamaCore.actionsCount() < 0) revert InvalidLlamaCoreAddress(); llamaCore = _llamaCore; diff --git a/src/token-voting/TokenholderCaster.sol b/src/token-voting/TokenholderCaster.sol index 07908bb..aec2f21 100644 --- a/src/token-voting/TokenholderCaster.sol +++ b/src/token-voting/TokenholderCaster.sol @@ -10,7 +10,7 @@ import {LlamaUtils} from "src/lib/LlamaUtils.sol"; import {Action, ActionInfo} from "src/lib/Structs.sol"; import {ILlamaRelativeStrategyBase} from "src/interfaces/ILlamaRelativeStrategyBase.sol"; -/// @title TokenholderCaster +/// @title TokenHolderCaster /// @author Llama (devsdosomething@llama.xyz) /// @notice This contract lets holders of a given governance token cast votes and vetos /// on created actions. @@ -18,7 +18,7 @@ import {ILlamaRelativeStrategyBase} from "src/interfaces/ILlamaRelativeStrategyB /// it must hold a Policy from the specified `LlamaCore` instance to actually be able to cast on an action. This /// contract does not verify that it holds the correct policy when voting and relies on `LlamaCore` to /// verify that during submission. -abstract contract TokenholderCaster is Initializable { +abstract contract TokenHolderCaster is Initializable { // ========================= // ======== Structs ======== // ========================= @@ -35,8 +35,8 @@ abstract contract TokenholderCaster is Initializable { uint96 vetosAgainst; // Number of vetos casted against this action. This does not exist in // `LlamaCore`. bool vetoSubmitted; // True if the vetos have been submitted to `LlamaCore`, false otherwise. - mapping(address tokenholder => bool) castVote; // True if tokenholder casted vote, false otherwise. - mapping(address tokenholder => bool) castVeto; // True if tokenholder casted veto, false otherwise. + mapping(address tokenHolder => bool) castVote; // True if tokenHolder casted vote, false otherwise. + mapping(address tokenHolder => bool) castVeto; // True if tokenHolder casted veto, false otherwise. } // ======================== @@ -91,7 +91,7 @@ abstract contract TokenholderCaster is Initializable { /// @dev Thrown when an invalid `llamaCore` address is passed to the constructor. error InvalidLlamaCoreAddress(); - /// @dev The recovered signer does not match the expected tokenholder. + /// @dev The recovered signer does not match the expected tokenHolder. error InvalidSignature(); /// @dev Thrown when an invalid `token` address is passed to the constructor. @@ -112,11 +112,11 @@ abstract contract TokenholderCaster is Initializable { /// @dev Emitted when an vote is cast. /// @dev This is almost the same as the `ApprovalCast` event from `LlamaCore`, with the addition of the support field. - /// The two events will be nearly identical, with the `tokenholder` being the main difference. This version will emit - /// the address of the tokenholder that casted, while the `LlamaCore` version will emit the address of this contract - /// as the action creator. Additionally, there is no `role` emitted here as all tokenholders are eligible to vote. + /// The two events will be nearly identical, with the `tokenHolder` being the main difference. This version will emit + /// the address of the tokenHolder that casted, while the `LlamaCore` version will emit the address of this contract + /// as the action creator. Additionally, there is no `role` emitted here as all tokenHolders are eligible to vote. event VoteCast( - uint256 id, address indexed tokenholder, uint8 indexed role, uint8 indexed support, uint256 quantity, string reason + uint256 id, address indexed tokenHolder, uint8 indexed role, uint8 indexed support, uint256 quantity, string reason ); /// @dev Emitted when cast votes are submitted to the `LlamaCore` contract. @@ -124,11 +124,11 @@ abstract contract TokenholderCaster is Initializable { /// @dev Emitted when a veto is cast. /// @dev This is the same as the `DisapprovalCast` event from `LlamaCore`. The two events will be - /// nearly identical, with the `tokenholder` being the only difference. This version will emit - /// the address of the tokenholder that casted, while the `LlamaCore` version will emit the + /// nearly identical, with the `tokenHolder` being the only difference. This version will emit + /// the address of the tokenHolder that casted, while the `LlamaCore` version will emit the /// address of this contract as the action creator. event VetoCast( - uint256 id, address indexed tokenholder, uint8 indexed role, uint8 indexed support, uint256 quantity, string reason + uint256 id, address indexed tokenHolder, uint8 indexed role, uint8 indexed support, uint256 quantity, string reason ); /// @dev Emitted when cast votes are submitted to the `LlamaCore` contract. @@ -178,17 +178,17 @@ abstract contract TokenholderCaster is Initializable { /// @notice Mapping from action ID to the status of existing casts. mapping(uint256 actionId => CastData) public casts; - /// @notice Mapping of tokenholders to function selectors to current nonces for EIP-712 signatures. - /// @dev This is used to prevent replay attacks by incrementing the nonce for each operation (`createAction`, - /// `cancelAction`, `castVote` and `castVeto`) signed by the tokenholders. - mapping(address tokenholders => mapping(bytes4 selector => uint256 currentNonce)) public nonces; + /// @notice Mapping of tokenHolders to function selectors to current nonces for EIP-712 signatures. + /// @dev This is used to prevent replay attacks by incrementing the nonce for each operation (`castVote` and + /// `castVeto`) signed by the tokenHolders. + mapping(address tokenHolders => mapping(bytes4 selector => uint256 currentNonce)) public nonces; /// @dev This will be called by the `initialize` of the inheriting contract. /// @param _llamaCore The `LlamaCore` contract for this Llama instance. /// @param _role The role used by this contract to cast votes and vetos. /// @param _voteQuorum The minimum % of votes required to submit votes to `LlamaCore`. /// @param _minVetoQuorum The minimum % of vetos required to submit vetos to `LlamaCore`. - function __initializeTokenholderCasterMinimalProxy( + function __initializeTokenHolderCasterMinimalProxy( ILlamaCore _llamaCore, uint8 _role, uint256 _voteQuorum, @@ -205,14 +205,14 @@ abstract contract TokenholderCaster is Initializable { minVetoQuorum = _minVetoQuorum; } - /// @notice How tokenholders add their support of an action with a vote and a reason. + /// @notice How tokenHolders add their support of an action with a vote and a reason. /// @dev Use `""` for `reason` if there is no reason. /// @param actionInfo Data required to create an action. - /// @param support The tokenholder's support of the vote of the action. + /// @param support The tokenHolder's support of the vote of the action. /// 0 = Against /// 1 = For /// 2 = Abstain, but this is not currently supported. - /// @param reason The reason given for the vote by the tokenholder. + /// @param reason The reason given for the vote by the tokenHolder. function castVote(ActionInfo calldata actionInfo, uint8 support, string calldata reason) external { _castVote(msg.sender, actionInfo, support, reason); } @@ -232,14 +232,14 @@ abstract contract TokenholderCaster is Initializable { _castVote(signer, actionInfo, support, reason); } - /// @notice How tokenholders add their support of the veto of an action with a reason. + /// @notice How tokenHolders add their support of the veto of an action with a reason. /// @dev Use `""` for `reason` if there is no reason. /// @param actionInfo Data required to create an action. - /// @param support The tokenholder's support of the veto of the action. + /// @param support The tokenHolder's support of the veto of the action. /// 0 = Against /// 1 = For /// 2 = Abstain, but this is not currently supported. - /// @param reason The reason given for the veto by the tokenholder. + /// @param reason The reason given for the veto by the tokenHolder. function castVeto(ActionInfo calldata actionInfo, uint8 support, string calldata reason) external { _castVeto(msg.sender, actionInfo, support, reason); } @@ -398,11 +398,11 @@ abstract contract TokenholderCaster is Initializable { function _getPastTotalSupply(uint256 timestamp) internal view virtual returns (uint256) {} function _getClockMode() internal view virtual returns (string memory) {} - /// @dev Returns the current nonce for a given tokenholder and selector, and increments it. Used to prevent + /// @dev Returns the current nonce for a given tokenHolder and selector, and increments it. Used to prevent /// replay attacks. - function _useNonce(address tokenholder, bytes4 selector) internal returns (uint256 nonce) { - nonce = nonces[tokenholder][selector]; - nonces[tokenholder][selector] = LlamaUtils.uncheckedIncrement(nonce); + function _useNonce(address tokenHolder, bytes4 selector) internal returns (uint256 nonce) { + nonce = nonces[tokenHolder][selector]; + nonces[tokenHolder][selector] = LlamaUtils.uncheckedIncrement(nonce); } // -------- EIP-712 Getters -------- @@ -419,7 +419,7 @@ abstract contract TokenholderCaster is Initializable { /// @dev Returns the hash of the ABI-encoded EIP-712 message for the `castVote` domain, which can be used to /// recover the signer. function _getCastVoteTypedDataHash( - address tokenholder, + address tokenHolder, uint8 support, ActionInfo calldata actionInfo, string calldata reason @@ -427,11 +427,11 @@ abstract contract TokenholderCaster is Initializable { bytes32 castVoteHash = keccak256( abi.encode( CAST_VOTE_BY_SIG_TYPEHASH, - tokenholder, + tokenHolder, support, _getActionInfoHash(actionInfo), keccak256(bytes(reason)), - _useNonce(tokenholder, msg.sig) + _useNonce(tokenHolder, msg.sig) ) ); @@ -441,7 +441,7 @@ abstract contract TokenholderCaster is Initializable { /// @dev Returns the hash of the ABI-encoded EIP-712 message for the `CastVeto` domain, which can be used to /// recover the signer. function _getCastVetoTypedDataHash( - address tokenholder, + address tokenHolder, uint8 support, ActionInfo calldata actionInfo, string calldata reason @@ -449,11 +449,11 @@ abstract contract TokenholderCaster is Initializable { bytes32 castVetoHash = keccak256( abi.encode( CAST_VETO_BY_SIG_TYPEHASH, - tokenholder, + tokenHolder, support, _getActionInfoHash(actionInfo), keccak256(bytes(reason)), - _useNonce(tokenholder, msg.sig) + _useNonce(tokenHolder, msg.sig) ) );