{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}

module Cardano.Ledger.Shelley.RewardProvenance (
  RewardProvenance (..),
  RewardProvenancePool (..),
  Desirability (..),
)
where

import Cardano.Ledger.BaseTypes (BlocksMade (..))
import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..))
import Cardano.Ledger.Binary.Coders
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Crypto
import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..))
import Cardano.Ledger.PoolParams (PoolParams (..))
import Control.DeepSeq (NFData)
import Data.Aeson (FromJSON, ToJSON)
import Data.Default (Default (..))
import Data.Map.Strict (Map)
import Data.Word (Word64)
import GHC.Generics
import NoThunks.Class (NoThunks (..))
import Numeric.Natural (Natural)

-- instances only
-- ==========================================================

-- | Provenance for an individual stake pool's reward calculation.
data RewardProvenancePool c = RewardProvenancePool
  { forall c. RewardProvenancePool c -> Natural
poolBlocksP :: !Natural
  -- ^ The number of blocks the pool produced.
  , forall c. RewardProvenancePool c -> Rational
sigmaP :: !Rational
  -- ^ The stake pool's stake share (portion of the total stake).
  , forall c. RewardProvenancePool c -> Rational
sigmaAP :: !Rational
  -- ^ The stake pool's active stake share (portion of the active stake).
  , forall c. RewardProvenancePool c -> Coin
ownerStakeP :: !Coin
  -- ^ The number of Lovelace owned by the stake pool owners.
  -- If this value is not at least as large as the 'pledgeRatioP',
  -- the stake pool will not earn any rewards for the given epoch.
  , forall c. RewardProvenancePool c -> PoolParams c
poolParamsP :: !(PoolParams c)
  -- ^ The stake pool's registered parameters.
  , forall c. RewardProvenancePool c -> Rational
pledgeRatioP :: !Rational
  -- ^ The stake pool's pledge.
  , forall c. RewardProvenancePool c -> Coin
maxPP :: !Coin
  -- ^ The maximum number of Lovelace this stake pool can earn.
  , forall c. RewardProvenancePool c -> Rational
appPerfP :: !Rational
  -- ^ The stake pool's apparent performance.
  -- See Section 5.5.2 of the
  --  <https://github.com/intersectmbo/cardano-ledger/releases/latest/download/shelley-delegation.pdf>
  , forall c. RewardProvenancePool c -> Coin
poolRP :: !Coin
  -- ^ The total Lovelace earned by the stake pool.
  , forall c. RewardProvenancePool c -> Coin
lRewardP :: !Coin
  -- ^ The total Lovelace earned by the stake pool leader.
  }
  deriving (RewardProvenancePool c -> RewardProvenancePool c -> Bool
forall c. RewardProvenancePool c -> RewardProvenancePool c -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RewardProvenancePool c -> RewardProvenancePool c -> Bool
$c/= :: forall c. RewardProvenancePool c -> RewardProvenancePool c -> Bool
== :: RewardProvenancePool c -> RewardProvenancePool c -> Bool
$c== :: forall c. RewardProvenancePool c -> RewardProvenancePool c -> Bool
Eq, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall c x.
Rep (RewardProvenancePool c) x -> RewardProvenancePool c
forall c x.
RewardProvenancePool c -> Rep (RewardProvenancePool c) x
$cto :: forall c x.
Rep (RewardProvenancePool c) x -> RewardProvenancePool c
$cfrom :: forall c x.
RewardProvenancePool c -> Rep (RewardProvenancePool c) x
Generic)

instance NoThunks (RewardProvenancePool c)

instance NFData (RewardProvenancePool c)

deriving instance Crypto c => FromJSON (RewardProvenancePool c)

deriving instance Crypto c => ToJSON (RewardProvenancePool c)

instance Crypto c => Default (RewardProvenancePool c) where
  def :: RewardProvenancePool c
def = forall c.
Natural
-> Rational
-> Rational
-> Coin
-> PoolParams c
-> Rational
-> Coin
-> Rational
-> Coin
-> Coin
-> RewardProvenancePool c
RewardProvenancePool Natural
0 Rational
0 Rational
0 (Integer -> Coin
Coin Integer
0) forall a. Default a => a
def Rational
0 (Integer -> Coin
Coin Integer
0) Rational
0 (Integer -> Coin
Coin Integer
0) (Integer -> Coin
Coin Integer
0)

-- | The desirability score of a stake pool, as described
-- in <https://arxiv.org/abs/1807.11218 "Reward Sharing Schemes for Stake Pools">.
-- Additionally, the hit rate estimation described in the
-- <https://github.com/intersectmbo/cardano-ledger/releases/latest/download/pool-ranking.pdf stake pool ranking document> is included.
data Desirability = Desirability
  { Desirability -> Double
desirabilityScore :: !Double
  , Desirability -> Double
hitRateEstimate :: !Double
  }
  deriving (Desirability -> Desirability -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Desirability -> Desirability -> Bool
$c/= :: Desirability -> Desirability -> Bool
== :: Desirability -> Desirability -> Bool
$c== :: Desirability -> Desirability -> Bool
Eq, Int -> Desirability -> ShowS
[Desirability] -> ShowS
Desirability -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Desirability] -> ShowS
$cshowList :: [Desirability] -> ShowS
show :: Desirability -> String
$cshow :: Desirability -> String
showsPrec :: Int -> Desirability -> ShowS
$cshowsPrec :: Int -> Desirability -> ShowS
Show, forall x. Rep Desirability x -> Desirability
forall x. Desirability -> Rep Desirability x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Desirability x -> Desirability
$cfrom :: forall x. Desirability -> Rep Desirability x
Generic)

instance NoThunks Desirability

instance NFData Desirability

-- | 'RewardProvenenace' captures some of the intermediate calculations when computing
--     the staking reward distribution. Most of these fields are simple scalar
--     values, computed from the current State, and are fixed before we start to compute
--     the distribution. Two of them are aggregates computed when we compute the distribution
--     ('pools' and 'desirabilities').
--
--  For more background, see "Figure 48: The Reward Calculation" and
--  "Figure 51: Reward Update Creation" of the
--  <https://github.com/intersectmbo/cardano-ledger/releases/latest/download/shelley-ledger.pdf the formal specification>.
--  The variable names here align with those in the specification.
--  See also Section 5 of the
--  <https://github.com/intersectmbo/cardano-ledger/releases/latest/download/shelley-delegation.pdf>
data RewardProvenance c = RewardProvenance
  { forall c. RewardProvenance c -> Word64
spe :: !Word64
  -- ^ The number of slots per epoch.
  , forall c. RewardProvenance c -> BlocksMade c
blocks :: !(BlocksMade c)
  -- ^ A map from pool ID (the key hash of the stake pool operator's
  -- verification key) to the number of blocks made in the given epoch.
  , forall c. RewardProvenance c -> Coin
maxLL :: !Coin
  -- ^ The maximum Lovelace supply. On mainnet, this value is equal to
  -- 45 * 10^15 (45 billion ADA).
  , forall c. RewardProvenance c -> Coin
deltaR1 :: !Coin
  -- ^ The maximum amount of Lovelace which can be removed from the reserves
  -- to be given out as rewards for the given epoch.
  , forall c. RewardProvenance c -> Coin
deltaR2 :: !Coin
  -- ^ The difference between the total Lovelace that could have been
  -- distributed as rewards this epoch (which is 'r') and what was actually distributed.
  , forall c. RewardProvenance c -> Coin
r :: !Coin
  -- ^ The total Lovelace available for rewards for the given epoch,
  -- equal to 'rPot' less 'deltaT1'.
  , forall c. RewardProvenance c -> Coin
totalStake :: !Coin
  -- ^ The maximum Lovelace supply ('maxLL') less the current value of the reserves.
  , forall c. RewardProvenance c -> Integer
blocksCount :: !Integer
  -- ^ The total number of blocks produced during the given epoch.
  , forall c. RewardProvenance c -> Rational
d :: !Rational
  -- ^ The decentralization parameter.
  , forall c. RewardProvenance c -> Integer
expBlocks :: !Integer
  -- ^ The number of blocks expected to be produced during the given epoch.
  , forall c. RewardProvenance c -> Rational
eta :: !Rational
  -- ^ The ratio of the number of blocks actually made versus the number
  -- of blocks that were expected.
  , forall c. RewardProvenance c -> Coin
rPot :: !Coin
  -- ^ The reward pot for the given epoch, equal to 'deltaR1' plus the fee pot.
  , forall c. RewardProvenance c -> Coin
deltaT1 :: !Coin
  -- ^ The amount of Lovelace taken from the treasury for the given epoch.
  , forall c. RewardProvenance c -> Coin
activeStake :: !Coin
  -- ^ The amount of Lovelace that is delegated during the given epoch.
  , forall c.
RewardProvenance c
-> Map (KeyHash 'StakePool c) (RewardProvenancePool c)
pools ::
      !( Map
          (KeyHash 'StakePool c)
          (RewardProvenancePool c)
       )
  -- ^ Individual stake pool provenance.
  , forall c.
RewardProvenance c -> Map (KeyHash 'StakePool c) Desirability
desirabilities ::
      !(Map (KeyHash 'StakePool c) Desirability)
  -- ^ A map from pool ID to the desirability score.
  -- See the <https://github.com/intersectmbo/cardano-ledger/releases/latest/download/pool-ranking.pdf stake pool ranking document>.
  }
  deriving (RewardProvenance c -> RewardProvenance c -> Bool
forall c. RewardProvenance c -> RewardProvenance c -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RewardProvenance c -> RewardProvenance c -> Bool
$c/= :: forall c. RewardProvenance c -> RewardProvenance c -> Bool
== :: RewardProvenance c -> RewardProvenance c -> Bool
$c== :: forall c. RewardProvenance c -> RewardProvenance c -> Bool
Eq, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall c x. Rep (RewardProvenance c) x -> RewardProvenance c
forall c x. RewardProvenance c -> Rep (RewardProvenance c) x
$cto :: forall c x. Rep (RewardProvenance c) x -> RewardProvenance c
$cfrom :: forall c x. RewardProvenance c -> Rep (RewardProvenance c) x
Generic)

deriving instance FromJSON Desirability

deriving instance ToJSON Desirability

deriving instance Crypto c => FromJSON (RewardProvenance c)

deriving instance Crypto c => ToJSON (RewardProvenance c)

instance NoThunks (RewardProvenance c)

instance NFData (RewardProvenance c)

instance Default (RewardProvenance c) where
  def :: RewardProvenance c
def =
    forall c.
Word64
-> BlocksMade c
-> Coin
-> Coin
-> Coin
-> Coin
-> Coin
-> Integer
-> Rational
-> Integer
-> Rational
-> Coin
-> Coin
-> Coin
-> Map (KeyHash 'StakePool c) (RewardProvenancePool c)
-> Map (KeyHash 'StakePool c) Desirability
-> RewardProvenance c
RewardProvenance
      Word64
0
      (forall c. Map (KeyHash 'StakePool c) Natural -> BlocksMade c
BlocksMade forall a. Default a => a
def)
      (Integer -> Coin
Coin Integer
0)
      (Integer -> Coin
Coin Integer
0)
      (Integer -> Coin
Coin Integer
0)
      (Integer -> Coin
Coin Integer
0)
      (Integer -> Coin
Coin Integer
0)
      Integer
0
      Rational
0
      Integer
0
      Rational
0
      (Integer -> Coin
Coin Integer
0)
      (Integer -> Coin
Coin Integer
0)
      (Integer -> Coin
Coin Integer
0)
      forall a. Default a => a
def
      forall a. Default a => a
def

-- =======================================================
-- Show instances

mylines :: Int -> [String] -> String
mylines :: Int -> Context -> String
mylines Int
n Context
xs = Context -> String
unlines (forall a b. (a -> b) -> [a] -> [b]
map (forall a. Int -> a -> [a]
replicate Int
n Char
' ' forall a. [a] -> [a] -> [a]
++) Context
xs)

instance Show (RewardProvenancePool c) where
  show :: RewardProvenancePool c -> String
show RewardProvenancePool c
t =
    String
"RewardProvenancePool\n"
      forall a. [a] -> [a] -> [a]
++ Int -> Context -> String
mylines
        Int
3
        [ String
"poolBlocks = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenancePool c -> Natural
poolBlocksP RewardProvenancePool c
t)
        , String
"sigma = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenancePool c -> Rational
sigmaP RewardProvenancePool c
t)
        , String
"sigmaA = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenancePool c -> Rational
sigmaAP RewardProvenancePool c
t)
        , String
"ownerStake = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenancePool c -> Coin
ownerStakeP RewardProvenancePool c
t)
        , String
"poolParams = " forall a. [a] -> [a] -> [a]
++ forall c. PoolParams c -> String
showPoolParams (forall c. RewardProvenancePool c -> PoolParams c
poolParamsP RewardProvenancePool c
t)
        , String
"pledgeRatio = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenancePool c -> Rational
pledgeRatioP RewardProvenancePool c
t)
        , String
"maxP = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenancePool c -> Coin
maxPP RewardProvenancePool c
t)
        , String
"appPerf = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenancePool c -> Rational
appPerfP RewardProvenancePool c
t)
        , String
"poolR = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenancePool c -> Coin
poolRP RewardProvenancePool c
t)
        , String
"lReward = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenancePool c -> Coin
lRewardP RewardProvenancePool c
t)
        ]

showPoolParams :: PoolParams c -> String
showPoolParams :: forall c. PoolParams c -> String
showPoolParams PoolParams c
x =
  String
"PoolParams\n"
    forall a. [a] -> [a] -> [a]
++ Int -> Context -> String
mylines
      Int
6
      [ String
"poolId = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. PoolParams c -> KeyHash 'StakePool c
ppId PoolParams c
x)
      , String
"poolVrf = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. PoolParams c -> VRFVerKeyHash 'StakePoolVRF c
ppVrf PoolParams c
x)
      , String
"poolPledge = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. PoolParams c -> Coin
ppPledge PoolParams c
x)
      , String
"poolCost = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. PoolParams c -> Coin
ppCost PoolParams c
x)
      , String
"poolMargin = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. PoolParams c -> UnitInterval
ppMargin PoolParams c
x)
      , String
"poolRAcnt = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. PoolParams c -> RewardAccount c
ppRewardAccount PoolParams c
x)
      , String
"poolOwners = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. PoolParams c -> Set (KeyHash 'Staking c)
ppOwners PoolParams c
x)
      , String
"poolRelays = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. PoolParams c -> StrictSeq StakePoolRelay
ppRelays PoolParams c
x)
      , String
"poolMD = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. PoolParams c -> StrictMaybe PoolMetadata
ppMetadata PoolParams c
x)
      ]

instance Show (RewardProvenance c) where
  show :: RewardProvenance c -> String
show RewardProvenance c
t =
    String
"RewardProvenance\n"
      forall a. [a] -> [a] -> [a]
++ Int -> Context -> String
mylines
        Int
3
        [ String
"spe = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Word64
spe RewardProvenance c
t)
        , String
"blocks = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> BlocksMade c
blocks RewardProvenance c
t)
        , String
"maxLL = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Coin
maxLL RewardProvenance c
t)
        , String
"deltaR1 = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Coin
deltaR1 RewardProvenance c
t)
        , String
"deltaR2 = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Coin
deltaR2 RewardProvenance c
t)
        , String
"r = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Coin
r RewardProvenance c
t)
        , String
"totalStake = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Coin
totalStake RewardProvenance c
t)
        , String
"blocksCount = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Integer
blocksCount RewardProvenance c
t)
        , String
"d = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Rational
d RewardProvenance c
t)
        , String
"expBlocks = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Integer
expBlocks RewardProvenance c
t)
        , String
"eta = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Rational
eta RewardProvenance c
t)
        , String
"rPot = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Coin
rPot RewardProvenance c
t)
        , String
"deltaT1 = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Coin
deltaT1 RewardProvenance c
t)
        , String
"activeStake = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c. RewardProvenance c -> Coin
activeStake RewardProvenance c
t)
        , String
"pools = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c.
RewardProvenance c
-> Map (KeyHash 'StakePool c) (RewardProvenancePool c)
pools RewardProvenance c
t)
        , String
"desirabilities = " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall c.
RewardProvenance c -> Map (KeyHash 'StakePool c) Desirability
desirabilities RewardProvenance c
t)
        ]

-- =======================================================
-- CBOR instances

instance EncCBOR Desirability where
  encCBOR :: Desirability -> Encoding
encCBOR (Desirability Double
p1 Double
p2) =
    forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall a b. (a -> b) -> a -> b
$ forall t. t -> Encode ('Closed 'Dense) t
Rec Double -> Double -> Desirability
Desirability forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Double
p1 forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Double
p2

instance DecCBOR Desirability where
  decCBOR :: forall s. Decoder s Desirability
decCBOR = forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode forall a b. (a -> b) -> a -> b
$ forall t. t -> Decode ('Closed 'Dense) t
RecD Double -> Double -> Desirability
Desirability forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From

instance Crypto c => EncCBOR (RewardProvenancePool c) where
  encCBOR :: RewardProvenancePool c -> Encoding
encCBOR (RewardProvenancePool Natural
p1 Rational
p2 Rational
p3 Coin
p4 PoolParams c
p5 Rational
p6 Coin
p7 Rational
p8 Coin
p9 Coin
p10) =
    forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall a b. (a -> b) -> a -> b
$
      forall t. t -> Encode ('Closed 'Dense) t
Rec forall c.
Natural
-> Rational
-> Rational
-> Coin
-> PoolParams c
-> Rational
-> Coin
-> Rational
-> Coin
-> Coin
-> RewardProvenancePool c
RewardProvenancePool
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Natural
p1
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Rational
p2
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Rational
p3
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p4
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To PoolParams c
p5
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Rational
p6
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p7
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Rational
p8
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p9
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p10

instance Crypto c => DecCBOR (RewardProvenancePool c) where
  decCBOR :: forall s. Decoder s (RewardProvenancePool c)
decCBOR =
    forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode forall a b. (a -> b) -> a -> b
$
      forall t. t -> Decode ('Closed 'Dense) t
RecD forall c.
Natural
-> Rational
-> Rational
-> Coin
-> PoolParams c
-> Rational
-> Coin
-> Rational
-> Coin
-> Coin
-> RewardProvenancePool c
RewardProvenancePool
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From

instance Crypto c => EncCBOR (RewardProvenance c) where
  encCBOR :: RewardProvenance c -> Encoding
encCBOR (RewardProvenance Word64
p1 BlocksMade c
p2 Coin
p3 Coin
p4 Coin
p5 Coin
p6 Coin
p7 Integer
p8 Rational
p9 Integer
p10 Rational
p11 Coin
p12 Coin
p13 Coin
p14 Map (KeyHash 'StakePool c) (RewardProvenancePool c)
p15 Map (KeyHash 'StakePool c) Desirability
p16) =
    forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall a b. (a -> b) -> a -> b
$
      forall t. t -> Encode ('Closed 'Dense) t
Rec forall c.
Word64
-> BlocksMade c
-> Coin
-> Coin
-> Coin
-> Coin
-> Coin
-> Integer
-> Rational
-> Integer
-> Rational
-> Coin
-> Coin
-> Coin
-> Map (KeyHash 'StakePool c) (RewardProvenancePool c)
-> Map (KeyHash 'StakePool c) Desirability
-> RewardProvenance c
RewardProvenance
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Word64
p1
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To BlocksMade c
p2
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p3
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p4
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p5
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p6
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p7
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Integer
p8
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Rational
p9
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Integer
p10
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Rational
p11
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p12
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p13
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Coin
p14
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Map (KeyHash 'StakePool c) (RewardProvenancePool c)
p15
        forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Map (KeyHash 'StakePool c) Desirability
p16

instance Crypto c => DecCBOR (RewardProvenance c) where
  decCBOR :: forall s. Decoder s (RewardProvenance c)
decCBOR =
    forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode forall a b. (a -> b) -> a -> b
$
      forall t. t -> Decode ('Closed 'Dense) t
RecD forall c.
Word64
-> BlocksMade c
-> Coin
-> Coin
-> Coin
-> Coin
-> Coin
-> Integer
-> Rational
-> Integer
-> Rational
-> Coin
-> Coin
-> Coin
-> Map (KeyHash 'StakePool c) (RewardProvenancePool c)
-> Map (KeyHash 'StakePool c) Desirability
-> RewardProvenance c
RewardProvenance
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From
        forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! forall t (w :: Wrapped). DecCBOR t => Decode w t
From