{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE UndecidableInstances #-}

-- | The stake distribution, aggregated by stake pool (as opposed to stake credential),
-- plays a primary role in Cardano's proof of stake network.
-- Together with the VRF checks, the stake distribution determines leader election.
-- The leader election is the precisely the part of the ledger that is
-- determined by Ouroboros (Praos and Genesis), our consensus mechanism.
-- See Section 16, "Leader Value Calculation", of the
-- <https://github.com/intersectmbo/cardano-ledger/releases/latest/download/shelley-ledger.pdf formal specification>.
module Cardano.Ledger.State.PoolDistr (
  IndividualPoolStake (..),
  PoolDistr (..),
  poolDistrDistrL,
  poolDistrTotalL,
  individualTotalPoolStakeL,
) where

import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..), decodeRecordNamed, encodeListLen)
import Cardano.Ledger.Binary.Coders (Decode (..), Encode (..), decode, encode, (!>), (<!))
import Cardano.Ledger.Coin
import Cardano.Ledger.Keys (KeyHash, KeyRole (..), KeyRoleVRF (StakePoolVRF), VRFVerKeyHash)
import Control.DeepSeq (NFData)
import Data.Aeson (KeyValue, ToJSON (..), object, pairs, (.=))
import Data.Map.Strict (Map)
import GHC.Generics (Generic)
import Lens.Micro
import NoThunks.Class (NoThunks (..))

-- | The 'IndividualPoolStake' contains all the stake controlled
-- by a single stake pool (the combination of owners and delegates)
-- for a given epoch, and also the hash of the stake pool's
-- registered VRF key.
--
-- When a stake pool produces a block, the header contains the
-- full VRF verification key and VRF value for leader election.
-- We check the VRF key against the value in 'IndividualPoolStake'
-- and we check the VRF value using the epoch nonce and
-- the relative stake of the pool as given in 'IndividualPoolStake'.
-- The stake is relative to the total amount of active stake
-- in the network. Stake is active if it is both registered and
-- delegated to a registered stake pool.
data IndividualPoolStake = IndividualPoolStake
  { IndividualPoolStake -> Rational
individualPoolStake :: !Rational
  -- ^ Pool stake distribution. This is a ratio of `individualTotalPoolStake`/`pdTotalActiveStake`
  , IndividualPoolStake -> CompactForm Coin
individualTotalPoolStake :: !(CompactForm Coin)
  -- ^ Total stake delegated to this pool. In addition to all the stake  that
  -- is part of `individualPoolStake` we also add proposal-deposits to this
  -- field.
  , IndividualPoolStake -> VRFVerKeyHash 'StakePoolVRF
individualPoolStakeVrf :: !(VRFVerKeyHash 'StakePoolVRF)
  }
  deriving stock (Int -> IndividualPoolStake -> ShowS
[IndividualPoolStake] -> ShowS
IndividualPoolStake -> String
(Int -> IndividualPoolStake -> ShowS)
-> (IndividualPoolStake -> String)
-> ([IndividualPoolStake] -> ShowS)
-> Show IndividualPoolStake
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IndividualPoolStake -> ShowS
showsPrec :: Int -> IndividualPoolStake -> ShowS
$cshow :: IndividualPoolStake -> String
show :: IndividualPoolStake -> String
$cshowList :: [IndividualPoolStake] -> ShowS
showList :: [IndividualPoolStake] -> ShowS
Show, IndividualPoolStake -> IndividualPoolStake -> Bool
(IndividualPoolStake -> IndividualPoolStake -> Bool)
-> (IndividualPoolStake -> IndividualPoolStake -> Bool)
-> Eq IndividualPoolStake
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IndividualPoolStake -> IndividualPoolStake -> Bool
== :: IndividualPoolStake -> IndividualPoolStake -> Bool
$c/= :: IndividualPoolStake -> IndividualPoolStake -> Bool
/= :: IndividualPoolStake -> IndividualPoolStake -> Bool
Eq, (forall x. IndividualPoolStake -> Rep IndividualPoolStake x)
-> (forall x. Rep IndividualPoolStake x -> IndividualPoolStake)
-> Generic IndividualPoolStake
forall x. Rep IndividualPoolStake x -> IndividualPoolStake
forall x. IndividualPoolStake -> Rep IndividualPoolStake x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. IndividualPoolStake -> Rep IndividualPoolStake x
from :: forall x. IndividualPoolStake -> Rep IndividualPoolStake x
$cto :: forall x. Rep IndividualPoolStake x -> IndividualPoolStake
to :: forall x. Rep IndividualPoolStake x -> IndividualPoolStake
Generic)
  deriving anyclass (IndividualPoolStake -> ()
(IndividualPoolStake -> ()) -> NFData IndividualPoolStake
forall a. (a -> ()) -> NFData a
$crnf :: IndividualPoolStake -> ()
rnf :: IndividualPoolStake -> ()
NFData, Context -> IndividualPoolStake -> IO (Maybe ThunkInfo)
Proxy IndividualPoolStake -> String
(Context -> IndividualPoolStake -> IO (Maybe ThunkInfo))
-> (Context -> IndividualPoolStake -> IO (Maybe ThunkInfo))
-> (Proxy IndividualPoolStake -> String)
-> NoThunks IndividualPoolStake
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> IndividualPoolStake -> IO (Maybe ThunkInfo)
noThunks :: Context -> IndividualPoolStake -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> IndividualPoolStake -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> IndividualPoolStake -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy IndividualPoolStake -> String
showTypeOf :: Proxy IndividualPoolStake -> String
NoThunks)

individualTotalPoolStakeL :: Lens' IndividualPoolStake (CompactForm Coin)
individualTotalPoolStakeL :: Lens' IndividualPoolStake (CompactForm Coin)
individualTotalPoolStakeL = (IndividualPoolStake -> CompactForm Coin)
-> (IndividualPoolStake -> CompactForm Coin -> IndividualPoolStake)
-> Lens' IndividualPoolStake (CompactForm Coin)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens IndividualPoolStake -> CompactForm Coin
individualTotalPoolStake ((IndividualPoolStake -> CompactForm Coin -> IndividualPoolStake)
 -> Lens' IndividualPoolStake (CompactForm Coin))
-> (IndividualPoolStake -> CompactForm Coin -> IndividualPoolStake)
-> Lens' IndividualPoolStake (CompactForm Coin)
forall a b. (a -> b) -> a -> b
$ \IndividualPoolStake
x CompactForm Coin
y -> IndividualPoolStake
x {individualTotalPoolStake = y}

instance EncCBOR IndividualPoolStake where
  encCBOR :: IndividualPoolStake -> Encoding
encCBOR (IndividualPoolStake Rational
stake CompactForm Coin
stakeCoin VRFVerKeyHash 'StakePoolVRF
vrf) =
    [Encoding] -> Encoding
forall a. Monoid a => [a] -> a
mconcat
      [ Word -> Encoding
encodeListLen Word
3
      , Rational -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR Rational
stake
      , CompactForm Coin -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR CompactForm Coin
stakeCoin
      , VRFVerKeyHash 'StakePoolVRF -> Encoding
forall a. EncCBOR a => a -> Encoding
encCBOR VRFVerKeyHash 'StakePoolVRF
vrf
      ]

instance DecCBOR IndividualPoolStake where
  decCBOR :: forall s. Decoder s IndividualPoolStake
decCBOR =
    Text
-> (IndividualPoolStake -> Int)
-> Decoder s IndividualPoolStake
-> Decoder s IndividualPoolStake
forall a s. Text -> (a -> Int) -> Decoder s a -> Decoder s a
decodeRecordNamed Text
"IndividualPoolStake" (Int -> IndividualPoolStake -> Int
forall a b. a -> b -> a
const Int
3) (Decoder s IndividualPoolStake -> Decoder s IndividualPoolStake)
-> Decoder s IndividualPoolStake -> Decoder s IndividualPoolStake
forall a b. (a -> b) -> a -> b
$
      Rational
-> CompactForm Coin
-> VRFVerKeyHash 'StakePoolVRF
-> IndividualPoolStake
IndividualPoolStake
        (Rational
 -> CompactForm Coin
 -> VRFVerKeyHash 'StakePoolVRF
 -> IndividualPoolStake)
-> Decoder s Rational
-> Decoder
     s
     (CompactForm Coin
      -> VRFVerKeyHash 'StakePoolVRF -> IndividualPoolStake)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s Rational
forall s. Decoder s Rational
forall a s. DecCBOR a => Decoder s a
decCBOR
        Decoder
  s
  (CompactForm Coin
   -> VRFVerKeyHash 'StakePoolVRF -> IndividualPoolStake)
-> Decoder s (CompactForm Coin)
-> Decoder s (VRFVerKeyHash 'StakePoolVRF -> IndividualPoolStake)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (CompactForm Coin)
forall s. Decoder s (CompactForm Coin)
forall a s. DecCBOR a => Decoder s a
decCBOR
        Decoder s (VRFVerKeyHash 'StakePoolVRF -> IndividualPoolStake)
-> Decoder s (VRFVerKeyHash 'StakePoolVRF)
-> Decoder s IndividualPoolStake
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (VRFVerKeyHash 'StakePoolVRF)
forall s. Decoder s (VRFVerKeyHash 'StakePoolVRF)
forall a s. DecCBOR a => Decoder s a
decCBOR

instance ToJSON IndividualPoolStake where
  toJSON :: IndividualPoolStake -> Value
toJSON = [Pair] -> Value
object ([Pair] -> Value)
-> (IndividualPoolStake -> [Pair]) -> IndividualPoolStake -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IndividualPoolStake -> [Pair]
forall e a. KeyValue e a => IndividualPoolStake -> [a]
toIndividualPoolStakePair
  toEncoding :: IndividualPoolStake -> Encoding
toEncoding = Series -> Encoding
pairs (Series -> Encoding)
-> (IndividualPoolStake -> Series)
-> IndividualPoolStake
-> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Series] -> Series
forall a. Monoid a => [a] -> a
mconcat ([Series] -> Series)
-> (IndividualPoolStake -> [Series])
-> IndividualPoolStake
-> Series
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IndividualPoolStake -> [Series]
forall e a. KeyValue e a => IndividualPoolStake -> [a]
toIndividualPoolStakePair

toIndividualPoolStakePair :: KeyValue e a => IndividualPoolStake -> [a]
toIndividualPoolStakePair :: forall e a. KeyValue e a => IndividualPoolStake -> [a]
toIndividualPoolStakePair indivPoolStake :: IndividualPoolStake
indivPoolStake@(IndividualPoolStake Rational
_ CompactForm Coin
_ VRFVerKeyHash 'StakePoolVRF
_) =
  let IndividualPoolStake {Rational
CompactForm Coin
VRFVerKeyHash 'StakePoolVRF
individualPoolStake :: IndividualPoolStake -> Rational
individualTotalPoolStake :: IndividualPoolStake -> CompactForm Coin
individualPoolStakeVrf :: IndividualPoolStake -> VRFVerKeyHash 'StakePoolVRF
individualPoolStake :: Rational
individualTotalPoolStake :: CompactForm Coin
individualPoolStakeVrf :: VRFVerKeyHash 'StakePoolVRF
..} = IndividualPoolStake
indivPoolStake
   in [ Key
"individualPoolStake" Key -> Rational -> a
forall v. ToJSON v => Key -> v -> a
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Rational
individualPoolStake
      , Key
"individualTotalPoolStake" Key -> CompactForm Coin -> a
forall v. ToJSON v => Key -> v -> a
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= CompactForm Coin
individualTotalPoolStake
      , Key
"individualPoolStakeVrf" Key -> VRFVerKeyHash 'StakePoolVRF -> a
forall v. ToJSON v => Key -> v -> a
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= VRFVerKeyHash 'StakePoolVRF
individualPoolStakeVrf
      ]

-- | A map of stake pool IDs (the hash of the stake pool operator's
-- verification key) to 'IndividualPoolStake'. Also holds absolute values
-- necessary for the calculations in the `computeDRepDistr`.
data PoolDistr = PoolDistr
  { PoolDistr -> Map (KeyHash 'StakePool) IndividualPoolStake
unPoolDistr :: !(Map (KeyHash 'StakePool) IndividualPoolStake)
  , PoolDistr -> CompactForm Coin
pdTotalActiveStake :: !(CompactForm Coin)
  -- ^ Total stake delegated to registered stake pools. In addition to
  -- the stake considered for the `individualPoolStake` Rational, we add
  -- proposal-deposits to this field.
  }
  deriving stock (Int -> PoolDistr -> ShowS
[PoolDistr] -> ShowS
PoolDistr -> String
(Int -> PoolDistr -> ShowS)
-> (PoolDistr -> String)
-> ([PoolDistr] -> ShowS)
-> Show PoolDistr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PoolDistr -> ShowS
showsPrec :: Int -> PoolDistr -> ShowS
$cshow :: PoolDistr -> String
show :: PoolDistr -> String
$cshowList :: [PoolDistr] -> ShowS
showList :: [PoolDistr] -> ShowS
Show, PoolDistr -> PoolDistr -> Bool
(PoolDistr -> PoolDistr -> Bool)
-> (PoolDistr -> PoolDistr -> Bool) -> Eq PoolDistr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PoolDistr -> PoolDistr -> Bool
== :: PoolDistr -> PoolDistr -> Bool
$c/= :: PoolDistr -> PoolDistr -> Bool
/= :: PoolDistr -> PoolDistr -> Bool
Eq, (forall x. PoolDistr -> Rep PoolDistr x)
-> (forall x. Rep PoolDistr x -> PoolDistr) -> Generic PoolDistr
forall x. Rep PoolDistr x -> PoolDistr
forall x. PoolDistr -> Rep PoolDistr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PoolDistr -> Rep PoolDistr x
from :: forall x. PoolDistr -> Rep PoolDistr x
$cto :: forall x. Rep PoolDistr x -> PoolDistr
to :: forall x. Rep PoolDistr x -> PoolDistr
Generic)
  deriving (PoolDistr -> ()
(PoolDistr -> ()) -> NFData PoolDistr
forall a. (a -> ()) -> NFData a
$crnf :: PoolDistr -> ()
rnf :: PoolDistr -> ()
NFData, Context -> PoolDistr -> IO (Maybe ThunkInfo)
Proxy PoolDistr -> String
(Context -> PoolDistr -> IO (Maybe ThunkInfo))
-> (Context -> PoolDistr -> IO (Maybe ThunkInfo))
-> (Proxy PoolDistr -> String)
-> NoThunks PoolDistr
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PoolDistr -> IO (Maybe ThunkInfo)
noThunks :: Context -> PoolDistr -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PoolDistr -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PoolDistr -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PoolDistr -> String
showTypeOf :: Proxy PoolDistr -> String
NoThunks, [PoolDistr] -> Value
[PoolDistr] -> Encoding
PoolDistr -> Bool
PoolDistr -> Value
PoolDistr -> Encoding
(PoolDistr -> Value)
-> (PoolDistr -> Encoding)
-> ([PoolDistr] -> Value)
-> ([PoolDistr] -> Encoding)
-> (PoolDistr -> Bool)
-> ToJSON PoolDistr
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: PoolDistr -> Value
toJSON :: PoolDistr -> Value
$ctoEncoding :: PoolDistr -> Encoding
toEncoding :: PoolDistr -> Encoding
$ctoJSONList :: [PoolDistr] -> Value
toJSONList :: [PoolDistr] -> Value
$ctoEncodingList :: [PoolDistr] -> Encoding
toEncodingList :: [PoolDistr] -> Encoding
$comitField :: PoolDistr -> Bool
omitField :: PoolDistr -> Bool
ToJSON)

poolDistrDistrL :: Lens' PoolDistr (Map (KeyHash 'StakePool) IndividualPoolStake)
poolDistrDistrL :: Lens' PoolDistr (Map (KeyHash 'StakePool) IndividualPoolStake)
poolDistrDistrL = (PoolDistr -> Map (KeyHash 'StakePool) IndividualPoolStake)
-> (PoolDistr
    -> Map (KeyHash 'StakePool) IndividualPoolStake -> PoolDistr)
-> Lens' PoolDistr (Map (KeyHash 'StakePool) IndividualPoolStake)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens PoolDistr -> Map (KeyHash 'StakePool) IndividualPoolStake
unPoolDistr ((PoolDistr
  -> Map (KeyHash 'StakePool) IndividualPoolStake -> PoolDistr)
 -> Lens' PoolDistr (Map (KeyHash 'StakePool) IndividualPoolStake))
-> (PoolDistr
    -> Map (KeyHash 'StakePool) IndividualPoolStake -> PoolDistr)
-> Lens' PoolDistr (Map (KeyHash 'StakePool) IndividualPoolStake)
forall a b. (a -> b) -> a -> b
$ \PoolDistr
x Map (KeyHash 'StakePool) IndividualPoolStake
y -> PoolDistr
x {unPoolDistr = y}

poolDistrTotalL :: Lens' PoolDistr (CompactForm Coin)
poolDistrTotalL :: Lens' PoolDistr (CompactForm Coin)
poolDistrTotalL = (PoolDistr -> CompactForm Coin)
-> (PoolDistr -> CompactForm Coin -> PoolDistr)
-> Lens' PoolDistr (CompactForm Coin)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens PoolDistr -> CompactForm Coin
pdTotalActiveStake ((PoolDistr -> CompactForm Coin -> PoolDistr)
 -> Lens' PoolDistr (CompactForm Coin))
-> (PoolDistr -> CompactForm Coin -> PoolDistr)
-> Lens' PoolDistr (CompactForm Coin)
forall a b. (a -> b) -> a -> b
$ \PoolDistr
x CompactForm Coin
y -> PoolDistr
x {pdTotalActiveStake = y}

instance EncCBOR PoolDistr where
  encCBOR :: PoolDistr -> Encoding
encCBOR (PoolDistr Map (KeyHash 'StakePool) IndividualPoolStake
distr CompactForm Coin
total) =
    Encode ('Closed 'Dense) PoolDistr -> Encoding
forall (w :: Wrapped) t. Encode w t -> Encoding
encode (Encode ('Closed 'Dense) PoolDistr -> Encoding)
-> Encode ('Closed 'Dense) PoolDistr -> Encoding
forall a b. (a -> b) -> a -> b
$
      (Map (KeyHash 'StakePool) IndividualPoolStake
 -> CompactForm Coin -> PoolDistr)
-> Encode
     ('Closed 'Dense)
     (Map (KeyHash 'StakePool) IndividualPoolStake
      -> CompactForm Coin -> PoolDistr)
forall t. t -> Encode ('Closed 'Dense) t
Rec Map (KeyHash 'StakePool) IndividualPoolStake
-> CompactForm Coin -> PoolDistr
PoolDistr
        Encode
  ('Closed 'Dense)
  (Map (KeyHash 'StakePool) IndividualPoolStake
   -> CompactForm Coin -> PoolDistr)
-> Encode
     ('Closed 'Dense) (Map (KeyHash 'StakePool) IndividualPoolStake)
-> Encode ('Closed 'Dense) (CompactForm Coin -> PoolDistr)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> Map (KeyHash 'StakePool) IndividualPoolStake
-> Encode
     ('Closed 'Dense) (Map (KeyHash 'StakePool) IndividualPoolStake)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Map (KeyHash 'StakePool) IndividualPoolStake
distr
        Encode ('Closed 'Dense) (CompactForm Coin -> PoolDistr)
-> Encode ('Closed 'Dense) (CompactForm Coin)
-> Encode ('Closed 'Dense) PoolDistr
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> CompactForm Coin -> Encode ('Closed 'Dense) (CompactForm Coin)
forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To CompactForm Coin
total

instance DecCBOR PoolDistr where
  decCBOR :: forall s. Decoder s PoolDistr
decCBOR =
    Decode ('Closed 'Dense) PoolDistr -> Decoder s PoolDistr
forall t (w :: Wrapped) s. Typeable t => Decode w t -> Decoder s t
decode (Decode ('Closed 'Dense) PoolDistr -> Decoder s PoolDistr)
-> Decode ('Closed 'Dense) PoolDistr -> Decoder s PoolDistr
forall a b. (a -> b) -> a -> b
$
      (Map (KeyHash 'StakePool) IndividualPoolStake
 -> CompactForm Coin -> PoolDistr)
-> Decode
     ('Closed 'Dense)
     (Map (KeyHash 'StakePool) IndividualPoolStake
      -> CompactForm Coin -> PoolDistr)
forall t. t -> Decode ('Closed 'Dense) t
RecD Map (KeyHash 'StakePool) IndividualPoolStake
-> CompactForm Coin -> PoolDistr
PoolDistr
        Decode
  ('Closed 'Dense)
  (Map (KeyHash 'StakePool) IndividualPoolStake
   -> CompactForm Coin -> PoolDistr)
-> Decode
     ('Closed Any) (Map (KeyHash 'StakePool) IndividualPoolStake)
-> Decode ('Closed 'Dense) (CompactForm Coin -> PoolDistr)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (Map (KeyHash 'StakePool) IndividualPoolStake)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        Decode ('Closed 'Dense) (CompactForm Coin -> PoolDistr)
-> Decode ('Closed Any) (CompactForm Coin)
-> Decode ('Closed 'Dense) PoolDistr
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (CompactForm Coin)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From