---
# System prepended metadata

title: '_Governance, Staking and Treasury_'

---

# _Governance, Staking and Treasury_

## Governance:



```sh
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/IGovernor.sol

interface IFTHMGovernor is IVotes {

    enum ProposalState {
        Pending,
        Active,
        Canceled,
        Defeated,
        Succeeded,
        Queued,
        Expired,
        Executed
    }

    /**
     * @dev Emitted when a proposal is created.
     */
    event ProposalCreated(
        uint256 proposalId,
        address proposer,
        address[] targets,
        uint256[] values,
        string[] signatures,
        bytes[] calldatas,
        uint256 startBlock,
        uint256 endBlock,
        string description
    );

    event ProposalCanceled(uint256 proposalId);

    event ProposalExecuted(uint256 proposalId);

    event VoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason);

    /**
     * @notice module:core
     * @dev Hashing function used to (re)build the proposal id from the proposal details..
     */
    function hashProposal(
        address[] memory targets,
        uint256[] memory values,
        bytes[] memory calldatas,
        bytes32 descriptionHash
    ) public pure virtual returns (uint256);

    /**
     * @notice module:core
     * @dev Current state of a proposal, following Compound's convention
     */
    function state(uint256 proposalId) public view virtual returns (ProposalState);

    /**
     * @notice module:core
     * @dev Block number at which votes close. Votes close at the end of this block, so it is possible to cast a vote
     * during this block.
     */
    function proposalDeadline(uint256 proposalId) public view virtual returns (uint256);

    /**
     * @notice module:user-config
     * @dev Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to
     * leave time for users to buy voting power, of delegate it, before the voting of a proposal starts.
     */
    function votingDelay() public view virtual returns (uint256);

    /**
     * @notice module:user-config
     * @dev Delay, in number of blocks, between the vote start and vote ends.
     */
    function votingPeriod() public view virtual returns (uint256);

    /**
     * @notice module:user-config
     * @dev Minimum number of cast voted required for a proposal to be successful.
     */
    function quorum(uint256 blockNumber) public view virtual returns (uint256);

    /**
     * @notice module:reputation
     * @dev Voting power of an `account` at a specific `blockNumber`.
     */
    function getVotes(address account, uint256 blockNumber) public view virtual returns (uint256);

    /**
     * @dev Create a new proposal. Vote start {IGovernor-votingDelay} blocks after the proposal is created and ends
     * {IGovernor-votingPeriod} blocks after the voting starts.
     *
     * Emits a {ProposalCreated} event.
     */
    function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description) public virtual returns (uint256 proposalId);

    /**
     * @dev Execute a successful proposal. This requires the quorum to be reached, the vote to be successful, and the
     * deadline to be reached.
     *
     * Emits a {ProposalExecuted} event.
     */
    function execute(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash ) public payable virtual returns (uint256 proposalId);

    /**
     * @dev Cast a vote
     *
     * Emits a {VoteCast} event.
     */
    function castVote(uint256 proposalId, uint8 support) public virtual returns (uint256 balance);

}



interface IGovernanceTimeLock {

    // Still need to research

}



interface IVotes {


    /**
     * @dev Returns the current amount of votes that `account` has.
     */
    function getVotes(address account) external view returns (uint256);


    /**
     * @dev Delegates votes from the sender to `delegatee`.
     */
    function delegate(address delegatee) external;


}
```

Extension of OpenZeppelins Governor.

Vote options:
- 0 = Against, 
- 1 = For, 
- 2 = Abstain

A simple vote structure prevents ambiguity and the illusion of choice.  See Alpacas governance for an example of an illusion of choice:
https://snapshot.org/#/alpacafinance.eth/proposal/0x388adc3eecab51a667fc6e972fc28a99cf3f04dbc24945e4369a5ebd9d07a8c6

LifeCycle of a Proposal:

An entity creating a Proposal must have at least _N_ vFTHM tokens.  This is called the Proposal Threshold and prevents spam creation of proposals.

Once a proposal has been submitted a delay starts.

Delay is set to two days.  The delay allows voters to acquire and lock more FTHM if they wish to have more voting power.  Once the delay period is over, voting weights are finalized for the current proposal.

The voting period is set to two weeks, starting immediately after the end of the delay period.

If vFTHM holders vote in favor of the proposal, the execution of the proposal will go into a timelock of two days.  This gives users the time to exit if they disagree with the proposal and gives us time to veto the proposal if we deem it malicious.

Contracts can have IFTHMGovernor as their owner.

Treasury controls release of funds to protocols seeking funding, and Staking controls the calculation of staking rewards and voting power of FTHM users.




## Staking:

```sh
// Interface

interface IvFTHM is ERC20Votes {
    
}

interface IFTHMStaking {

    
    /// @dev An admin of the staking contract can whitelist (propose) a stream.
    /// Whitelisting of the stream provides the option for the stream
    /// owner (presumably the issuing party of a specific token) to
    /// deposit some ERC-20 tokens on the staking contract and potentially
    /// get in return some FTHM tokens. Deposited ERC-20 tokens will be
    /// distributed to the stakers over some period of time.
    /// @param streamOwner only this account would be able to create a stream
    /// @param rewardToken the address of the ERC-20 tokens to be deposited in the stream
    /// @param scheduleTimes timestamp denoting the start of each scheduled interval. Last element is the end of the stream.
    /// @param scheduleRewards remaining rewards to be delivered at the beginning of each scheduled interval. Last element is always zero.
    /// First value (in scheduleRewards) from array is supposed to be a total amount of rewards for stream.
    /// @param tau the tau is (pending release period) for this stream (e.g one day)
    function proposeStream(
        address streamOwner,
        address rewardToken,
        uint256[] memory scheduleTimes,
        uint256[] memory scheduleRewards,
        uint256 tau
    ) external; // only STREAM_MANAGER_ROLE

    /// cancelStreamProposal cancels a proposal any time before the stream
    /// becomes active (created).
    function cancelStreamProposal(uint256 streamId) external;

    /// create new stream (only stream owner)
    /// stream owner must approve reward tokens to this contract.
    function createStream(uint256 streamId, uint256 rewardTokenAmount) external;

    ///removes a stream (only default admin role)
    function removeStream(uint256 streamId, address streamFundReceiver) external;


    /// @notice Create a new lock.
    /// @dev This will crate a new lock and deposit FTHM to FTHMStaking
    /// calls releaseGovernanceToken(uint256 amount, uint256 _unlockTime)
    function createLock(uint256 _amount, uint256 _unlockTime) external; 

    /// @notice Deposit `_amount` tokens for `_for` and add to `locks[_for]`
    //call _releaseGovernanceToken(uint256 amount, uint256 _unlockTime)
    function depositFor(address _for, uint256 _amount) external;

    //@return nVote = vFTHMPerTokenPoints *  totalStaked/totalAmount * time_locked
    function releaseGovernanceToken(uint256 _amount, uint256 _unlockTime) external returns (uint256);

    // Withdraw the rewards accumulated and FTHM deposited when lock has expired.
    function withdraw() external; 

    /// @notice Early withdraw FTHM with penalty.
    function earlyWithdraw(uint256 _amount) external;

    /// @dev calculates and gets the latest released rewards.
    /// @param streamId stream index
    /// @return rewards released since last update.
    function getRewardsAmount(uint256 streamId, uint256 lastUpdate) external view returns (uint256);

    /// depending upon start and end time, gets index of scheduleTimes and scheduleRewards.
    /// reward = rewardAt[startIndex] - rewardAt[startIndex + 1]
    /// actualTotalRewards = reward * (end - start) / rewardTimeAt[startIndex+1] - rewardTimeAt[startIndex]
    /// @return amount of the released tokens for that period
    function rewardsSchedule( uint256 streamId, uint256 start,uint256 end) external returns (uint256);

    /// @dev gets start index and end index in a stream schedule
    /// @param streamId stream index
    /// @param start start time (in seconds)
    /// @param end end time (in seconds)
    function startEndScheduleIndex(
        uint256 streamId,
        uint256 start,
        uint256 end
    ) external view returns (uint256 startIndex, uint256 endIndex);
    
    /// claim the rewards only, without unstaking FTHM
    /// Rewards depends on the share of FTHM tokens you have.
    /// user.lockedValue/totalLockedValue * totalShares = user.share
    /// claimableReward = user.share * rewardsPerShare
    function claimRewards(uint256 streamId) external;
    function claimAllRewards() external;

}
```

Governance Tokens (vFTHM) are acquired by staking FTHM.  Length of staking period is proportional to how many governance tokens one receives. Staking is essentially voting escrow.

vFTHM token functionality:
- In-transferable
- ERC20Votes
- Delegate (Auto delegate on transfer and mint to yourself)

Staking vault functionality:
- Distribute other protocols tokens to stakers depending on rewards calculation.
- Hold FTHM tokens.
- Distribute vFTHM tokens according to calculation.



## Treasury:


```sh
// Interface

interface ITreasury is GnosisSafe {

}

```

Features:

- Multisig.
- Holds funds to be distributed to other protocols seeking funding, or updates within our protocol that require funding.
- Penalties from early withdrawl and liquidations are deposited here.



## Things to keep in mind:



Calculating of voting power when people create locks.  
Can they have multiple locks or should voting power be aggregated?


## _Subik and Max_
