cardano-ledger-shelley-1.16.0.0: Shelley Ledger Executable Model
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Ledger.Shelley.Rewards

Synopsis

Documentation

newtype StakeShare Source #

StakeShare type

Constructors

StakeShare 

Instances

Instances details
Generic StakeShare Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Associated Types

type Rep StakeShareTypeType Source #

Show StakeShare Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

NFData StakeShare Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Methods

rnfStakeShare → () Source #

Eq StakeShare Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Ord StakeShare Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

NoThunks StakeShare Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

type Rep StakeShare Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

type Rep StakeShare = D1 ('MetaData "StakeShare" "Cardano.Ledger.Shelley.Rewards" "cardano-ledger-shelley-1.16.0.0-inplace" 'True) (C1 ('MetaCons "StakeShare" 'PrefixI 'True) (S1 ('MetaSel ('Just "unStakeShare") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Rational)))

data PoolRewardInfo Source #

Stake Pool specific information needed to compute the rewards for its members.

Constructors

PoolRewardInfo 

Fields

Instances

Instances details
Generic PoolRewardInfo Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Associated Types

type Rep PoolRewardInfoTypeType Source #

Show PoolRewardInfo Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

DecCBOR PoolRewardInfo Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

EncCBOR PoolRewardInfo Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

NFData PoolRewardInfo Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Methods

rnfPoolRewardInfo → () Source #

Eq PoolRewardInfo Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Ord PoolRewardInfo Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

NoThunks PoolRewardInfo Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

type Rep PoolRewardInfo Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

type Rep PoolRewardInfo = D1 ('MetaData "PoolRewardInfo" "Cardano.Ledger.Shelley.Rewards" "cardano-ledger-shelley-1.16.0.0-inplace" 'False) (C1 ('MetaCons "PoolRewardInfo" 'PrefixI 'True) ((S1 ('MetaSel ('Just "poolRelativeStake") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StakeShare) :*: S1 ('MetaSel ('Just "poolPot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Coin)) :*: (S1 ('MetaSel ('Just "poolPs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PoolParams) :*: (S1 ('MetaSel ('Just "poolBlocks") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Natural) :*: S1 ('MetaSel ('Just "poolLeaderReward") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LeaderOnlyReward)))))

mkApparentPerformanceUnitIntervalRationalNaturalNaturalRational Source #

Calculate pool reward

data RewardType Source #

The staking rewards in Cardano are all either:

  • member rewards - rewards given to a registered stake credential which has delegated to a stake pool, or
  • leader rewards - rewards given to a registered stake pool (in particular, given to the stake credential in the stake pool registration certificate).

See Figure 47, "Functions used in the Reward Splitting", of the formal specification for more details.

Constructors

MemberReward 
LeaderReward 

Instances

Instances details
ToJSON RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

Bounded RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

Enum RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

Generic RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

Associated Types

type Rep RewardTypeTypeType Source #

Show RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

DecCBOR RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

EncCBOR RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

encCBORRewardTypeEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy RewardTypeSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [RewardType] → Size Source #

NFData RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

rnfRewardType → () Source #

Eq RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

Ord RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

NoThunks RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

type Rep RewardType 
Instance details

Defined in Cardano.Ledger.Rewards

type Rep RewardType = D1 ('MetaData "RewardType" "Cardano.Ledger.Rewards" "cardano-ledger-core-1.17.0.0-inplace" 'False) (C1 ('MetaCons "MemberReward" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "LeaderReward" 'PrefixI 'False) (U1TypeType))

data Reward Source #

The Reward type captures:

  • if the reward is a member or leader reward
  • the stake pool ID associated with the reward
  • the number of Lovelace in the reward

Constructors

Reward 

Instances

Instances details
ToJSON Reward 
Instance details

Defined in Cardano.Ledger.Rewards

Generic Reward 
Instance details

Defined in Cardano.Ledger.Rewards

Associated Types

type Rep RewardTypeType Source #

Methods

fromRewardRep Reward x Source #

toRep Reward x → Reward Source #

Show Reward 
Instance details

Defined in Cardano.Ledger.Rewards

DecCBOR Reward 
Instance details

Defined in Cardano.Ledger.Rewards

EncCBOR Reward 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

encCBORRewardEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy RewardSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Reward] → Size Source #

NFData Reward 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

rnfReward → () Source #

Eq Reward 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

(==)RewardRewardBool Source #

(/=)RewardRewardBool Source #

Ord Reward

Note that this Ord instance is chosen to align precisely with the Allegra reward aggregation, as given by the function aggregateRewards so that findMax returns the expected value.

Instance details

Defined in Cardano.Ledger.Rewards

NoThunks Reward 
Instance details

Defined in Cardano.Ledger.Rewards

type Rep Reward 
Instance details

Defined in Cardano.Ledger.Rewards

type Rep Reward = D1 ('MetaData "Reward" "Cardano.Ledger.Rewards" "cardano-ledger-core-1.17.0.0-inplace" 'False) (C1 ('MetaCons "Reward" 'PrefixI 'True) (S1 ('MetaSel ('Just "rewardType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RewardType) :*: (S1 ('MetaSel ('Just "rewardPool") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool)) :*: S1 ('MetaSel ('Just "rewardAmount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Coin))))

data LeaderOnlyReward Source #

Constructors

LeaderOnlyReward 

Instances

Instances details
Generic LeaderOnlyReward Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Associated Types

type Rep LeaderOnlyRewardTypeType Source #

Show LeaderOnlyReward Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

DecCBOR LeaderOnlyReward Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

EncCBOR LeaderOnlyReward Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

NFData LeaderOnlyReward Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Methods

rnfLeaderOnlyReward → () Source #

Eq LeaderOnlyReward Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Ord LeaderOnlyReward Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

NoThunks LeaderOnlyReward Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

type Rep LeaderOnlyReward Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

type Rep LeaderOnlyReward = D1 ('MetaData "LeaderOnlyReward" "Cardano.Ledger.Shelley.Rewards" "cardano-ledger-shelley-1.16.0.0-inplace" 'False) (C1 ('MetaCons "LeaderOnlyReward" 'PrefixI 'True) (S1 ('MetaSel ('Just "lRewardPool") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool)) :*: S1 ('MetaSel ('Just "lRewardAmount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Coin)))

leaderRewCoinPoolParamsStakeShareStakeShareCoin Source #

Calculate pool leader reward

memberRewCoinPoolParamsStakeShareStakeShareCoin Source #

Calculate pool member reward

aggregateRewardsProtVerMap (Credential 'Staking) (Set Reward) → Map (Credential 'Staking) Coin Source #

for each (Set (Reward c)) entry in the map, sum up the coin. In the ShelleyEra some of the coins are ignored (because of backward compatibility) see filterRewards Note that domain of the returned map is a subset of the input map rewards

filterRewardsProtVerMap (Credential 'Staking) (Set Reward) → (Map (Credential 'Staking) (Set Reward), Map (Credential 'Staking) (Set Reward)) Source #

Filter the reward payments to those that will actually be delivered. This function exists since in Shelley, a stake credential earning rewards from multiple sources would only receive one reward. So some of the coins are ignored, because of this backward compatibility issue in early protocolVersions. Note that both of the domains of the returned maps are a subset of the the domain of the input map rewards

aggregateCompactRewardsProtVerMap (Credential 'Staking) (Set Reward) → Map (Credential 'Staking) (CompactForm Coin) Source #

for each (Set (Reward c)) entry in the map, sum up the coin. In the ShelleyEra some of the coins are ignored (because of backward compatibility) see filterRewards Note that the domain of the output map is a subset of the domain of the input rewards.

rewardOnePoolMember Source #

Arguments

ProtVer

The protocol version

Coin

The total amount of stake in the system

Set (Credential 'Staking)

The set of registered stake credentials

PoolRewardInfo

Stake pool specific intermediate values needed to compute member rewards.

Credential 'Staking

The stake credential whose reward is being calculated.

Coin

The stake controlled by the stake credential in the previous parameter above.

Maybe Coin

The reward for the given stake credential. This could be Nothing if the credential is no longer registered, if it is an owner, or if the reward is zero.

The stake pool member reward calculation

mkPoolRewardInfoEraPParams era ⇒ PParams era → CoinBlocksMadeNaturalStakeVMap VB VB (Credential 'Staking) (KeyHash 'StakePool) → Map (KeyHash 'StakePool) CoinCoinCoinPoolParamsEither StakeShare PoolRewardInfo Source #

Calculate single stake pool specific values for the reward computation.

Note that if a stake pool has made no blocks in the given epoch, it will get no rewards, and so we do not need to return PoolRewardInfo. We do, however, need to return the relative stake of the pool in order to compute data for the stake pool ranking. Eventually we will remove the ranking information out of the ledger code and into a separate service, and at that point we can simplify this function to not care about ranking.