LockManagerERC20
Contract · src/LockManagerERC20.sol
Explained in: The LockManager
Author: Aragon X 2025
Inherits: ILockManager, LockManagerBase
Helper contract acting as the vault for locked tokens used to vote on LockToGovern plugins.
Constructor
constructor
constructor(IERC20 _token)| Parameter | Type | Description |
|---|---|---|
_token | IERC20 | The address of the token contract that users can lock |
Functions
activeProposalsCreatedBy
function activeProposalsCreatedBy(address _creator) external view returns (uint256 _result)Selector: 0x2383ff1e
Returns how many of the known proposalID's were created by the given address
| Parameter | Type | Description |
|---|---|---|
_creator | address | The address to use for filtering |
canVote
function canVote(
uint256 _proposalId,
address _voter,
IMajorityVoting.VoteOption _voteOption
) external view returns (bool)Selector: 0x17d1b404
Checks if an account can participate on a proposal. This can be because the proposal - has not started, - has ended, - was executed, or - the voter doesn't have any tokens locked.
Dev: The function assumes that the queried proposal exists.
| Returns | Type | Description |
|---|---|---|
[0] | bool | Returns true if the account is allowed to vote. |
getLockedBalance
function getLockedBalance(address _account) external view returns (uint256)Selector: 0xc4086893
Returns the currently locked balance that the given account has on the contract.
knownProposalIdAt
function knownProposalIdAt(uint256 _index) external view returns (uint256)Selector: 0xc110d7b4
Returns the known proposalID at the given index
| Parameter | Type | Description |
|---|---|---|
_index | uint256 | The position at which to read the proposalId |
knownProposalIdCreators
function knownProposalIdCreators(uint256) external view returns (address)Selector: 0x81ebbcb0
Keeps track of who created each known proposalId
knownProposalIdsLength
function knownProposalIdsLength() external view returns (uint256)Selector: 0x4a5b3860
Returns the number of known proposalID's
lock()
function lock() externalSelector: 0xf83d08ba
Locks the balance currently allowed by msg.sender on this contract NOTE: Tokens locked and not allocated into a proposal are treated in the same way as the rest. They can only be unlocked when all active proposals with votes have ended.
lock(uint256)
function lock(uint256 _amount) externalSelector: 0xdd467064
Locks the given amount from msg.sender on this contract NOTE: Tokens locked and not allocated into a proposal are treated in the same way as the rest. They can only be unlocked when all active proposals with votes have ended.
lockAndVote(uint256,uint8,uint256)
function lockAndVote(
uint256 _proposalId,
IMajorityVoting.VoteOption _voteOption,
uint256 _amount
) externalSelector: 0x1adb4f63
Locks the given amount from msg.sender on this contract and registers the given vote on the target plugin
lockAndVote(uint256,uint8)
function lockAndVote(uint256 _proposalId, IMajorityVoting.VoteOption _voteOption) externalSelector: 0x98f7aab1
Locks the balance currently allowed by msg.sender on this contract and registers the given vote on the target plugin
plugin
function plugin() external view returns (ILockToGovernBase)Selector: 0xef01df4f
The address of the lock to vote plugin to use
| Returns | Type | Description |
|---|---|---|
[0] | ILockToGovernBase |
proposalCreated
function proposalCreated(uint256 _proposalId, address _creator) externalSelector: 0x6c393965
Called by the lock to vote plugin whenever a proposal is created. It instructs the manager to start tracking the given proposal.
proposalSettled
function proposalSettled(uint256 _proposalId) externalSelector: 0x6689ef0f
Called by the lock to vote plugin whenever a proposal is executed (or settled). It instructs the manager to remove the proposal from the list of active proposal locks. There's no guarantee that proposalSettled() will be reliably called for a proposal ID. Manually checking a proposal's state may be necessary in order to verify that it has ended.
pruneProposals
function pruneProposals(uint256 _count) externalSelector: 0xbfadf8f7
Triggers a manual cleanup of the known proposal ID's that have already ended. Settled proposals are garbage collected when they are executed or when a user unlocks his tokens. Use this method if a long list of unsettled yet ended proposals ever creates a gas bottleneck that discourages users from unlocking.
setPluginAddress
function setPluginAddress(ILockToGovernBase _newPluginAddress) externalSelector: 0x587a6b40
Defines the given plugin address as the target for voting.
| Parameter | Type | Description |
|---|---|---|
_newPluginAddress | ILockToGovernBase |
settings
function settings() external view returns (PluginMode pluginMode)Selector: 0xe06174e4
The current LockManager settings
| Returns | Type | Description |
|---|---|---|
pluginMode | PluginMode |
token
function token() external view returns (address _token)Selector: 0xfc0c546a
Returns the address of the token contract used to determine the voting power.
Dev: Not having
tokenas a public variable because the return types would differ (address vs IERC20)
| Returns | Type | Description |
|---|---|---|
_token | address | The token used for voting. |
unlock
function unlock() externalSelector: 0xa69df4b5
If the governance plugin allows it, releases all active locks placed on active proposals and transfers msg.sender's locked balance back. Depending on the current mode, it withdraws only if no locks are being used in active proposals.
vote
function vote(uint256 _proposalId, IMajorityVoting.VoteOption _voteOption) externalSelector: 0x943e8216
Uses the locked balance to vote on the given proposal for the registered plugin
Events
BalanceLocked
event BalanceLocked(address indexed voter, uint256 amount)Emitted when a token holder locks funds into the LockManager contract.
| Parameter | Type | Description |
|---|---|---|
voter | address | The address of the account locking tokens. |
amount | uint256 | The amount of tokens being added to the existing balance. |
BalanceUnlocked
event BalanceUnlocked(address indexed voter, uint256 amount)Emitted when a token holder unlocks funds from the manager contract
| Parameter | Type | Description |
|---|---|---|
voter | address | The address of the account unlocking tokens. |
amount | uint256 | The amount of tokens being unlocked. |
ProposalSettled
event ProposalSettled(uint256 indexed proposalId)Emitted when the plugin reports a proposal as settled
Dev: The event could be emitted with a delay, compared to the effective proposal endDate
| Parameter | Type | Description |
|---|---|---|
proposalId | uint256 | The ID the proposal where votes can no longer be submitted or cleared |
Errors
InvalidPlugin
error InvalidPlugin()Thrown when trying to set an invalid contract as the plugin
InvalidPluginAddress
error InvalidPluginAddress()Thrown when the address calling proposalSettled() is not the plugin's
LocksStillActive
error LocksStillActive()Raised when attempting to unlock while active votes are cast in strict mode
NoBalance
error NoBalance()Raised when the caller holds no tokens or didn't lock any tokens
ProposalCreatedStillActive
error ProposalCreatedStillActive(uint256 proposalId)Thrown when attempting to unlock with a created proposal that is still active
| Parameter | Type | Description |
|---|---|---|
proposalId | uint256 | The ID the active proposal |
SetPluginAddressForbidden
error SetPluginAddressForbidden()Thrown when trying to define the address of the plugin after it already was