diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index f181ef21245..853fdb79b80 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -113,6 +113,7 @@ library Cardano.Wallet.Primitive.Types.RewardAccount Cardano.Wallet.Primitive.Types.RewardAccount.Gen Cardano.Wallet.Primitive.Types.SlottingParameters + Cardano.Wallet.Primitive.Types.StakePoolSummary Cardano.Wallet.Primitive.Types.TokenBundle Cardano.Wallet.Primitive.Types.TokenBundle.Gen Cardano.Wallet.Primitive.Types.TokenBundleMaxSize diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolSummary.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolSummary.hs new file mode 100644 index 00000000000..b4221a3e4ae --- /dev/null +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolSummary.hs @@ -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 + ]