-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
More types migration - [x] Move StakePoolSummary type to primitive lib ADP-3229
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolSummary.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
|
||
module Cardano.Wallet.Primitive.Types.StakePoolSummary | ||
( StakePoolsSummary (..) | ||
) where | ||
|
||
import Prelude | ||
|
||
import Cardano.Wallet.Primitive.Types.Coin | ||
( Coin (..) | ||
) | ||
import Cardano.Wallet.Primitive.Types.PoolId | ||
( PoolId (..) | ||
) | ||
import Data.Map | ||
( Map | ||
) | ||
import Data.Quantity | ||
( Percentage | ||
) | ||
import Fmt | ||
( Buildable (..) | ||
, listF' | ||
, mapF | ||
, pretty | ||
) | ||
|
||
import qualified Data.Map as Map | ||
|
||
data StakePoolsSummary = StakePoolsSummary | ||
{ nOpt :: Int | ||
, rewards :: Map PoolId Coin | ||
, stake :: Map PoolId Percentage | ||
} | ||
deriving (Show, Eq) | ||
|
||
instance Buildable StakePoolsSummary where | ||
build StakePoolsSummary{nOpt, rewards, stake} = | ||
listF' | ||
id | ||
[ "Stake: " <> mapF (Map.toList stake) | ||
, "Non-myopic member rewards: " <> mapF (Map.toList rewards) | ||
, "Optimum number of pools: " <> pretty nOpt | ||
] |