Skip to content

Commit

Permalink
Merge pull request #1 from aragon/f/interfaces
Browse files Browse the repository at this point in the history
Initial version of the interfaces
  • Loading branch information
brickpop authored Dec 11, 2024
2 parents 16f212e + e3f68f0 commit 1bf6aa2
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/LockToVotePlugin.sol
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
24 changes: 22 additions & 2 deletions src/interfaces/ILockManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
80 changes: 80 additions & 0 deletions src/interfaces/ILockToVote.sol
Original file line number Diff line number Diff line change
@@ -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;
}
12 changes: 0 additions & 12 deletions src/interfaces/ILockToVotePlugin.sol

This file was deleted.

0 comments on commit 1bf6aa2

Please sign in to comment.