From e3f68f0a88ded17d1c06e03d8bd6d8ee4982a332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8r=E2=88=82=C2=A1?= Date: Wed, 11 Dec 2024 12:38:26 +0100 Subject: [PATCH] Initial version of the interfaces --- src/LockToVotePlugin.sol | 4 +- src/interfaces/ILockManager.sol | 24 ++++++++- src/interfaces/ILockToVote.sol | 80 ++++++++++++++++++++++++++++ src/interfaces/ILockToVotePlugin.sol | 12 ----- 4 files changed, 104 insertions(+), 16 deletions(-) create mode 100644 src/interfaces/ILockToVote.sol delete mode 100644 src/interfaces/ILockToVotePlugin.sol diff --git a/src/LockToVotePlugin.sol b/src/LockToVotePlugin.sol index 5ad080c..e6ed951 100644 --- a/src/LockToVotePlugin.sol +++ b/src/LockToVotePlugin.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; -import {ILockToVotePlugin} from "./interfaces/ILockToVotePlugin.sol"; +import {ILockToVote} from "./interfaces/ILockToVote.sol"; -contract LockToVotePlugin is ILockToVotePlugin { +contract LockToVotePlugin is ILockToVote { struct PluginSettings { uint64 proposlDuration; } diff --git a/src/interfaces/ILockManager.sol b/src/interfaces/ILockManager.sol index 60fb2ab..5035c32 100644 --- a/src/interfaces/ILockManager.sol +++ b/src/interfaces/ILockManager.sol @@ -2,9 +2,29 @@ pragma solidity ^0.8.17; +import {ILockToVote} from "./ILockToVote.sol"; + /// @title ILockManager -/// @author Aragon Association - 2024 -/// @notice +/// @author Aragon X +/// @notice Helper contract acting as the vault for locked tokens used to vote on multiple plugins and proposals. interface ILockManager { + /// @notice Locks the balance currently allowed by msg.sender on this contract + function lock() external; + + /// @notice Locks the balance currently allowed by msg.sender on this contract and registers a vote on the target plugin + /// @param plugin The address of the lock to vote plugin where the lock will be used + /// @param proposalId The ID of the proposal where the vote will be registered + function lockAndVote(ILockToVote plugin, uint256 proposalId) external; + + /// @notice Uses the locked balance to place a vote on the given proposal for the given plugin + /// @param plugin The address of the lock to vote plugin where the locked balance will be used + /// @param proposalId The ID of the proposal where the vote will be registered + function vote(ILockToVote plugin, uint256 proposalId) external; + + /// @notice If the mode 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. + function unlock() external; + /// @notice Called by a lock to vote plugin whenever a proposal is executed. It instructs the manager to remove the proposal from the list of active proposal locks. + /// @param proposalId The ID of the proposal that msg.sender is reporting as done. + function releaseLock(uint256 proposalId) external; } diff --git a/src/interfaces/ILockToVote.sol b/src/interfaces/ILockToVote.sol new file mode 100644 index 0000000..12fc6a0 --- /dev/null +++ b/src/interfaces/ILockToVote.sol @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +pragma solidity ^0.8.17; + +import {IDAO} from "@aragon/osx/core/dao/IDAO.sol"; +import {IVotesUpgradeable} from "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol"; + +/// @title ILockToVote +/// @author Aragon X +/// @notice +interface ILockToVote { + /// @notice getter function for the voting token. + /// @dev public function also useful for registering interfaceId and for distinguishing from majority voting interface. + /// @return The token used for voting. + function votingToken() external view returns (IVotesUpgradeable); + + /// @notice Returns the approvalRatio parameter stored in the plugin settings. + /// @return The approval ratio parameter, as a fraction of 1_000_000. + function minApprovalRatio() external view returns (uint32); + + /// @notice Creates a new proposal. + /// @param metadata The metadata of the proposal. + /// @param actions The actions that will be executed after the proposal passes. + /// @param duration The amount of seconds to allow for token holders to vote. NOTE: If the supplied value is zero, the proposal will be treated as an emergency one. + /// @return proposalId The ID of the proposal. + function createProposal( + bytes calldata metadata, + IDAO.Action[] calldata actions, + uint64 duration + ) external returns (uint256 proposalId); + + /// @notice 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. + /// @param proposalId The proposal Id. + /// @param account The account address to be checked. + /// @return Returns true if the account is allowed to vote. + /// @dev The function assumes that the queried proposal exists. + function canVeto( + uint256 proposalId, + address account + ) external view returns (bool); + + /// @notice Registers an approval vote for the given proposal. + /// @param proposalId The ID of the proposal to vote on. + function vote(uint256 proposalId) external; + + function clearVote(uint256 proposalId) external; + + /// @notice Returns whether the account has voted for the proposal. + /// @param proposalId The ID of the proposal. + /// @param account The account address to be checked. + /// @return The whether the given account has voted for the given proposal to pass. + function hasVoted( + uint256 proposalId, + address account + ) external view returns (bool); + + /// @notice Checks if the amount of locked votes for the given proposal is greater than the approval threshold. + /// @param proposalId The ID of the proposal. + /// @return Returns `true` if the total approval power against the proposal is greater or equal than the threshold and `false` otherwise. + function isMinApprovalReached( + uint256 proposalId + ) external view returns (bool); + + /// @notice Checks if a proposal can be executed. + /// @param proposalId The ID of the proposal to be checked. + /// @return True if the proposal can be executed, false otherwise. + function canExecute(uint256 proposalId) external view returns (bool); + + /// @notice Executes the given proposal. + /// @param proposalId The ID of the proposal to execute. + function execute(uint256 proposalId) external; + + /// @notice If the given proposal is no longer active, it notifies the manager so that the active locks no longer track it. + /// @param proposalId The ID of the proposal to clean up for. + function releaseLock(uint256 proposalId) external; +} diff --git a/src/interfaces/ILockToVotePlugin.sol b/src/interfaces/ILockToVotePlugin.sol deleted file mode 100644 index ff3df9a..0000000 --- a/src/interfaces/ILockToVotePlugin.sol +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-or-later - -pragma solidity ^0.8.17; - -import {IDAO} from "@aragon/osx/core/dao/IDAO.sol"; - -/// @title ILockToVotePlugin -/// @author Aragon Association - 2024 -/// @notice -interface ILockToVotePlugin { - -}