maxnax
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # _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_

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully