Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

refactor: changed language to reflect governors rather than llama #36

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/token-voting/ERC20TokenholderActionCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contract ERC20TokenholderActionCreator is TokenholderActionCreator {
/// The `initializer` modifier ensures that this function can be invoked at most once.
/// @param _token The ERC20 token to be used for voting.
/// @param _llamaCore The `LlamaCore` contract for this Llama instance.
/// @param _role The role used by this contract to cast approvals and disapprovals.
/// @param _role The role used by this contract to cast approvals and vetos.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still approval here. I'm assuming that should be votes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I can see it's still approvals in a bunch of other places. Might want to do a quick search and replace and confirm if the changes look good.

/// @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.
Expand Down
21 changes: 9 additions & 12 deletions src/token-voting/ERC20TokenholderCaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ERC20Votes} from "@openzeppelin/token/ERC20/extensions/ERC20Votes.sol";

/// @title ERC20TokenholderCaster
/// @author Llama ([email protected])
/// @notice This contract lets holders of a given governance ERC20Votes token cast approvals and disapprovals
/// @notice This contract lets holders of a given governance ERC20Votes token cast approvals and vetos
/// on created actions.
contract ERC20TokenholderCaster is TokenholderCaster {
ERC20Votes public token;
Expand All @@ -23,17 +23,14 @@ contract ERC20TokenholderCaster is TokenholderCaster {
/// The `initializer` modifier ensures that this function can be invoked at most once.
/// @param _token The ERC20 token to be used for voting.
/// @param _llamaCore The `LlamaCore` contract for this Llama instance.
/// @param _role The role used by this contract to cast approvals and disapprovals.
/// @param _minApprovalPct The minimum % of approvals required to submit approvals to `LlamaCore`.
/// @param _minDisapprovalPct The minimum % of disapprovals required to submit disapprovals to `LlamaCore`.
function initialize(
ERC20Votes _token,
ILlamaCore _llamaCore,
uint8 _role,
uint256 _minApprovalPct,
uint256 _minDisapprovalPct
) external initializer {
__initializeTokenholderCasterMinimalProxy(_llamaCore, _role, _minApprovalPct, _minDisapprovalPct);
/// @param _role The role used by this contract to cast approvals and vetos.
/// @param _voteQuorum The minimum % of approvals required to submit approvals to `LlamaCore`.
/// @param _vetoQuorum The minimum % of vetos required to submit vetos to `LlamaCore`.
function initialize(ERC20Votes _token, ILlamaCore _llamaCore, uint8 _role, uint256 _voteQuorum, uint256 _vetoQuorum)
external
initializer
{
__initializeTokenholderCasterMinimalProxy(_llamaCore, _role, _voteQuorum, _vetoQuorum);
token = _token;
uint256 totalSupply = token.totalSupply();
if (totalSupply == 0) revert InvalidTokenAddress();
Expand Down
2 changes: 1 addition & 1 deletion src/token-voting/ERC721TokenholderActionCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract ERC721TokenholderActionCreator is TokenholderActionCreator {
/// The `initializer` modifier ensures that this function can be invoked at most once.
/// @param _token The ERC721 token to be used for voting.
/// @param _llamaCore The `LlamaCore` contract for this Llama instance.
/// @param _role The role used by this contract to cast approvals and disapprovals.
/// @param _role The role used by this contract to cast approvals and vetos.
/// @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.
Expand Down
21 changes: 9 additions & 12 deletions src/token-voting/ERC721TokenholderCaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {IERC721} from "@openzeppelin/token/ERC721/IERC721.sol";

/// @title ERC721TokenholderCaster
/// @author Llama ([email protected])
/// @notice This contract lets holders of a given governance ERC721Votes token cast approvals and disapprovals
/// @notice This contract lets holders of a given governance ERC721Votes token cast approvals and vetos
/// on created actions.
contract ERC721TokenholderCaster is TokenholderCaster {
ERC721Votes public token;
Expand All @@ -24,17 +24,14 @@ contract ERC721TokenholderCaster is TokenholderCaster {
/// The `initializer` modifier ensures that this function can be invoked at most once.
/// @param _token The ERC721 token to be used for voting.
/// @param _llamaCore The `LlamaCore` contract for this Llama instance.
/// @param _role The role used by this contract to cast approvals and disapprovals.
/// @param _minApprovalPct The minimum % of approvals required to submit approvals to `LlamaCore`.
/// @param _minDisapprovalPct The minimum % of disapprovals required to submit disapprovals to `LlamaCore`.
function initialize(
ERC721Votes _token,
ILlamaCore _llamaCore,
uint8 _role,
uint256 _minApprovalPct,
uint256 _minDisapprovalPct
) external initializer {
__initializeTokenholderCasterMinimalProxy(_llamaCore, _role, _minApprovalPct, _minDisapprovalPct);
/// @param _role The role used by this contract to cast approvals and vetos.
/// @param _voteQuorum The minimum % of approvals required to submit approvals to `LlamaCore`.
/// @param _vetoQuorum The minimum % of vetos required to submit vetos to `LlamaCore`.
function initialize(ERC721Votes _token, ILlamaCore _llamaCore, uint8 _role, uint256 _voteQuorum, uint256 _vetoQuorum)
external
initializer
{
__initializeTokenholderCasterMinimalProxy(_llamaCore, _role, _voteQuorum, _vetoQuorum);
token = _token;
if (!token.supportsInterface(type(IERC721).interfaceId)) revert InvalidTokenAddress();
}
Expand Down
40 changes: 17 additions & 23 deletions src/token-voting/LlamaTokenVotingFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ contract LlamaTokenVotingFactory {

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 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;
Expand Down Expand Up @@ -59,33 +55,31 @@ contract LlamaTokenVotingFactory {
///@param token The address of the token to be used for voting.
///@param isERC20 Whether the token is an ERC20 or ERC721.
///@param actionCreatorRole The role required by the TokenholderActionCreator to create an action.
///@param casterRole The role required by the TokenholderCaster to cast approvals and disapprovals.
///@param casterRole The role required by the TokenholderCaster to cast approvals and vetos.
///@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(
address token,
bool isERC20,
uint8 actionCreatorRole,
uint8 casterRole,
uint256 creationThreshold,
uint256 minApprovalPct,
uint256 minDisapprovalPct
uint256 voteQuorum,
uint256 vetoQuorum
) external returns (address actionCreator, address caster) {
ILlamaCore core = ILlamaCore(ILlamaExecutor(msg.sender).LLAMA_CORE());
if (isERC20) {
actionCreator =
address(_deployERC20TokenholderActionCreator(ERC20Votes(token), core, actionCreatorRole, creationThreshold));
caster =
address(_deployERC20TokenholderCaster(ERC20Votes(token), core, casterRole, minApprovalPct, minDisapprovalPct));
caster = address(_deployERC20TokenholderCaster(ERC20Votes(token), core, casterRole, voteQuorum, vetoQuorum));
} else {
actionCreator =
address(_deployERC721TokenholderActionCreator(ERC721Votes(token), core, actionCreatorRole, creationThreshold));
caster =
address(_deployERC721TokenholderCaster(ERC721Votes(token), core, casterRole, minApprovalPct, minDisapprovalPct));
caster = address(_deployERC721TokenholderCaster(ERC721Votes(token), core, casterRole, voteQuorum, vetoQuorum));
}
}

Expand Down Expand Up @@ -127,31 +121,31 @@ contract LlamaTokenVotingFactory {
ERC20Votes token,
ILlamaCore llamaCore,
uint8 role,
uint256 minApprovalPct,
uint256 minDisapprovalPct
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(
ERC721Votes token,
ILlamaCore llamaCore,
uint8 role,
uint256 minApprovalPct,
uint256 minDisapprovalPct
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);
}
}
6 changes: 3 additions & 3 deletions src/token-voting/TokenholderActionCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract contract TokenholderActionCreator is Initializable {
/// @notice The default number of tokens required to create an action.
uint256 public creationThreshold;

/// @notice The role used by this contract to cast approvals and disapprovals.
/// @notice The role used by this contract to cast approvals and vetos.
/// @dev This role is expected to have the permissions to create appropriate actions.
uint8 public role;

Expand Down Expand Up @@ -51,7 +51,7 @@ abstract contract TokenholderActionCreator is Initializable {

/// @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`, `castApproval` and `castVeto`) signed by the token holder.
mapping(address tokenHolder => mapping(bytes4 selector => uint256 currentNonce)) public nonces;

/// @dev Emitted when an action is canceled.
Expand Down Expand Up @@ -105,7 +105,7 @@ abstract contract TokenholderActionCreator is Initializable {

/// @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 approvals and disapprovals.
/// @param _role The role used by this contract to cast approvals and vetos.
/// @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.
Expand Down
Loading
Loading