Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-
- This file is part of Bancor Flow Governance Test Program.
- Bancor Flow Governance Test Program is free software: you can
- redistribute it and/or modify it under the terms of the GNU General
- Public License as published by the Free Software Foundation, either
- version 3 of the License, or (at your option) any later version.
- Bancor Flow Governance Test Program is distributed in the hope that it
- will be useful, but WITHOUT ANY WARRANTY; without even the implied
- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
- the GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with Bancor Flow Governance Test Program. If not, see:
- <https://www.gnu.org/licenses/>
- Name: Bancor Flow Governance Test Program
- Author: Christopher Conforti
- Description: This file contains the core of the system. It implements
- the basic logic of the Flow Governance system:
- For each proposal voted on, Conviction is created.
- For each proposal not voted on, Decay is created.
- Sap is Conviction minus Decay.
- If Decay is equal to or greater than Conviction, then Rotted.
- -}
- module Flowgov where
- data Flow a
- = Conviction a
- | Decay a
- | Sap a
- | Rotted
- deriving (Show, Eq)
- ------------------------------------------------------------------------
- sap
- :: (Ord a, Num a)
- => Flow a
- -> Flow a
- -> Flow a
- flow
- :: (Num a, Ord a)
- => a
- -> a
- -> a
- -> Flow a
- convict
- :: (Num a)
- => a
- -> Flow a
- decay
- :: (Num a)
- => a
- -> Flow a
- ------------------------------------------------------------------------
- sap
- (Conviction a)
- (Decay x)
- = case test of
- True -> Rotted
- False -> Sap result
- where
- result
- = (a - x)
- test
- = (x >= a)
- flow
- stake
- votes
- proposals
- = sap
- (convict voted)
- (decay unvoted)
- where
- voted
- = stake * votes
- unvoted
- = stake * (proposals - votes)
- {- The following functions exist for extensibility purposes. They
- each serve as a "return" function. -}
- convict
- value
- = Conviction value
- decay
- value
- = Decay value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement