Funding Proposal

The Vote contract provides the platform with a complete post-investment withdrawal mechanism, allowing community members to decide whether to approve funding proposals through a veto-style vote.

Functionality

The Vote contract is a voting withdrawal system that allows cheque holders to create withdrawal proposals and decide whether to approve these proposals through votes from community members. The contract integrates an external logic contract (Logic) to obtain necessary data and execute specific logic.

The Vote contract inherits from ManagerUpgradeable, providing management functionalities and upgrade capabilities.

The variables:

  • Logic: Address of the external logic contract.

  • totalProposal: Total number of proposals.

  • proposals: Stores detailed information for each proposal.

  • user2proposal: Records the voting status of users for each proposal.

  • proposal2Time: Records the creation time of proposals.

  • proposal2Claimed: Records the amount already claimed for each proposal.

The Functions

  1. Events

    • NewProposal: Triggered when a new proposal is created.

    • NewVote: Triggered when a user votes.

  2. Initialization Function

    • initialize: Initializes the contract, setting the logic contract address.

  3. Management Functions

    • updateLogic: Updates the logic contract address.

  4. Proposal Management

    • createProposal: Creates a withdrawal proposal; only cheque holders can create proposals.

    • withdraw: Withdraws funds based on the voting results.

  5. User Voting

    • userVote: Allows users to vote on proposals; only users who have participated in distributions have voting rights.

  6. Query Functions

    • pendingToken: Retrieves the amount of funds that can be claimed from a proposal.

    • agrUserInfo: Retrieves aggregated user information, including their voting participation status.

Logic

  • Cheque holders can create withdrawal proposals using the createProposal function. This function calls the getPending function of the logic contract to check available funds and temporarily transfers funds to the current contract.

  • Users can vote on proposals using the userVote function. Their voting rights are determined by their participation amount in distributions.

  • Project owners can withdraw funds based on the voting results using the withdraw function.

Interface


// SPDX-License-Identifier: MIT
pragma solidity >=0.8.12;
pragma experimental ABIEncoderV2;

/**
 * @interface IWithdrawMoney
 * Interface for withdrawal contract, handling proposal creation, voting, and withdrawals.
 */
interface IWithdrawMoney {
    struct Withdraw {
        uint256 chequeId;           // Cheque ID associated with the proposal
        uint256 disId;              // Distribution ID associated with the proposal
        uint256 amount;             // Proposed withdrawal amount
        uint256 agree;              // Number of supporters for the proposal
        uint256 oppose;             // Number of opposers for the proposal
        uint256 totalDis;           // Total participants involved in the distribution
        address receivingAddress;   // Address to receive the withdrawal
    }

    /**
     * @notice Get detailed information of a proposal by its ID.
     * @param _proposalId    Proposal ID.
     * @return Withdraw struct containing proposal details.
     */
    function proposals(uint256 _proposalId) external view returns (Withdraw memory);

    /**
     * @notice Get the type of vote (agree/disagree) by a user on a proposal.
     * @param _user         User's address.
     * @param _proposalId   Proposal ID.
     * @return Voting type: 1 for agree, 2 for disagree.
     */
    function user2proposal(address _user, uint256 _proposalId) external view returns (uint8);

    /**
     * @notice Get the creation time of a proposal.
     * @param _proposalId   Proposal ID.
     * @return Timestamp of the proposal creation.
     */
    function proposal2Time(uint256 _proposalId) external view returns (uint256);

    /**
     * @notice Get the claimed amount of a proposal.
     * @param _proposalId    Proposal ID.
     * @return Claimed amount.
     */
    function proposal2Claimed(uint256 _proposalId) external view returns (uint256);

    /**
     * @notice Create a new withdrawal proposal. Only cheque holders can create proposals and must have withdrawable funds.
     * @param _chequeId          Cheque ID.
     * @param _amount            Withdrawal amount.
     * @param _receivingAddress  Address to receive the withdrawal.
     */
    function createProposal(uint256 _chequeId, uint256 _amount, address _receivingAddress) external;

    /**
     * @notice User votes on a proposal. Only users who participated in the distribution can vote. Vote type is 1 for agree, 2 for disagree.
     * @param _proposalId   Proposal ID.
     * @param _state        Vote type, 1 for agree, 2 for disagree.
     */
    function userVote(uint256 _proposalId, uint8 _state) external;

    /**
     * @notice If the proposal is approved, the project team can execute the withdrawal.
     * @param _proposalId   Proposal ID.
     */
    function withdraw(uint256 _proposalId) external;

    /**
     * @notice Get the amount available for withdrawal in a proposal.
     * @param _proposalId   Proposal ID.
     * @return Available withdrawal amount.
     */
    function pendingToken(uint256 _proposalId) external view returns (uint256);

    /**
     * @notice Get aggregated information of a user in a proposal.
     * @param _user         User's address.
     * @param _proposalId   Proposal ID.
     * @return _dis2UserJoin User's participation quota in the corresponding distribution.
     * @return _state User's voting type in the vote.
     * @return _dis2TotalUser Total number of participants in the distribution corresponding to the vote.
     */
    function agrUserInfo(address _user, uint256 _proposalId) external view returns (uint256 _dis2UserJoin, uint8 _state, uint256 _dis2TotalUser);
}


Last updated