Skip to content

Commit

Permalink
[ADP-3229] Move stake pool summary to primitive lib (#4249)
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
paolino authored Nov 20, 2023
2 parents a318e1a + e5bab28 commit 29a688a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/primitive/cardano-wallet-primitive.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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
]

0 comments on commit 29a688a

Please sign in to comment.