Guest User

Untitled

a guest
Jun 28th, 2021
27
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {-
  2. This file is part of Bancor Flow Governance Test Program.
  3.  
  4. Bancor Flow Governance Test Program is free software: you can
  5. redistribute it and/or modify it under the terms of the GNU General
  6. Public License as published by the Free Software Foundation, either
  7. version 3 of the License, or (at your option) any later version.
  8.  
  9. Bancor Flow Governance Test Program is distributed in the hope that it
  10. will be useful, but WITHOUT ANY WARRANTY; without even the implied
  11. warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  12. the GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with Bancor Flow Governance Test Program.  If not, see:
  16. <https://www.gnu.org/licenses/>
  17.  
  18.  
  19.  
  20. Name: Bancor Flow Governance Test Program
  21. Author: Christopher Conforti
  22. Description: This file contains the core of the system. It implements
  23. the basic logic of the Flow Governance system:
  24. For each proposal voted on, Conviction is created.
  25. For each proposal not voted on, Decay is created.
  26. Sap is Conviction minus Decay.
  27. If Decay is equal to or greater than Conviction, then Rotted.
  28. -}
  29.  
  30. module Flowgov where
  31.  
  32. data Flow a
  33.   = Conviction a
  34.   | Decay a
  35.   | Sap a
  36.   | Rotted
  37.   deriving (Show, Eq)
  38.  
  39. ------------------------------------------------------------------------
  40.  
  41. sap
  42.   :: (Ord a, Num a)
  43.   => Flow a
  44.   -> Flow a
  45.   -> Flow a
  46.  
  47. flow
  48.   :: (Num a, Ord a)
  49.   => a
  50.   -> a
  51.   -> a
  52.   -> Flow a
  53.  
  54. convict
  55.   :: (Num a)
  56.   => a
  57.   -> Flow a
  58.  
  59. decay
  60.   :: (Num a)
  61.   => a
  62.   -> Flow a
  63.  
  64. ------------------------------------------------------------------------
  65.  
  66. sap
  67.   (Conviction a)
  68.   (Decay x)
  69.   = case test of
  70.       True -> Rotted
  71.       False -> Sap result
  72.     where
  73.       result
  74.         = (a - x)
  75.       test
  76.         = (x >= a)
  77.  
  78. flow
  79.   stake
  80.   votes
  81.   proposals
  82.   = sap
  83.       (convict voted)
  84.       (decay unvoted)
  85.     where
  86.       voted
  87.         = stake * votes
  88.       unvoted
  89.         = stake * (proposals - votes)
  90.  
  91. {- The following functions exist for extensibility purposes. They
  92.    each serve as a "return" function. -}
  93. convict
  94.   value
  95.   = Conviction value
  96.  
  97. decay
  98.   value
  99.   = Decay value
RAW Paste Data