cardano-ledger-shelley-1.15.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.15.0.0-inplace" 'True) (C1 ('MetaCons "StakeShare" 'PrefixI 'True) (S1 ('MetaSel ('Just "unStakeShare") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Rational)))

data PoolRewardInfo c Source #

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

Constructors

PoolRewardInfo 

Fields

Instances

Instances details
Generic (PoolRewardInfo c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Associated Types

type Rep (PoolRewardInfo c) ∷ TypeType Source #

Show (PoolRewardInfo c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Crypto c ⇒ DecCBOR (PoolRewardInfo c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Crypto c ⇒ EncCBOR (PoolRewardInfo c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Methods

encCBORPoolRewardInfo c → Encoding Source #

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

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

NFData (PoolRewardInfo c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Methods

rnfPoolRewardInfo c → () Source #

Eq (PoolRewardInfo c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Ord (PoolRewardInfo c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

NoThunks (PoolRewardInfo c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

type Rep (PoolRewardInfo c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

type Rep (PoolRewardInfo c) = D1 ('MetaData "PoolRewardInfo" "Cardano.Ledger.Shelley.Rewards" "cardano-ledger-shelley-1.15.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 c)) :*: (S1 ('MetaSel ('Just "poolBlocks") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Natural) :*: S1 ('MetaSel ('Just "poolLeaderReward") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (LeaderOnlyReward c))))))

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.16.0.0-inplace" 'False) (C1 ('MetaCons "MemberReward" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "LeaderReward" 'PrefixI 'False) (U1TypeType))

data Reward c 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
Crypto c ⇒ ToJSON (Reward c) 
Instance details

Defined in Cardano.Ledger.Rewards

Generic (Reward c) 
Instance details

Defined in Cardano.Ledger.Rewards

Associated Types

type Rep (Reward c) ∷ TypeType Source #

Methods

fromReward c → Rep (Reward c) x Source #

toRep (Reward c) x → Reward c Source #

Show (Reward c) 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

showsPrecIntReward c → ShowS Source #

showReward c → String Source #

showList ∷ [Reward c] → ShowS Source #

Crypto c ⇒ DecCBOR (Reward c) 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

decCBORDecoder s (Reward c) Source #

dropCBORProxy (Reward c) → Decoder s () Source #

labelProxy (Reward c) → Text Source #

Crypto c ⇒ EncCBOR (Reward c) 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

encCBORReward c → Encoding Source #

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

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

NFData (Reward c) 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

rnfReward c → () Source #

Eq (Reward c) 
Instance details

Defined in Cardano.Ledger.Rewards

Methods

(==)Reward c → Reward c → Bool Source #

(/=)Reward c → Reward c → Bool Source #

Ord (Reward c)

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

Methods

compareReward c → Reward c → Ordering Source #

(<)Reward c → Reward c → Bool Source #

(<=)Reward c → Reward c → Bool Source #

(>)Reward c → Reward c → Bool Source #

(>=)Reward c → Reward c → Bool Source #

maxReward c → Reward c → Reward c Source #

minReward c → Reward c → Reward c Source #

NoThunks (Reward c) 
Instance details

Defined in Cardano.Ledger.Rewards

type Rep (Reward c) 
Instance details

Defined in Cardano.Ledger.Rewards

type Rep (Reward c) = D1 ('MetaData "Reward" "Cardano.Ledger.Rewards" "cardano-ledger-core-1.16.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 c)) :*: S1 ('MetaSel ('Just "rewardAmount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Coin))))

data LeaderOnlyReward c Source #

Constructors

LeaderOnlyReward 

Instances

Instances details
Generic (LeaderOnlyReward c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Associated Types

type Rep (LeaderOnlyReward c) ∷ TypeType Source #

Show (LeaderOnlyReward c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Crypto c ⇒ DecCBOR (LeaderOnlyReward c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Crypto c ⇒ EncCBOR (LeaderOnlyReward c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

NFData (LeaderOnlyReward c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Methods

rnfLeaderOnlyReward c → () Source #

Eq (LeaderOnlyReward c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

Ord (LeaderOnlyReward c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

NoThunks (LeaderOnlyReward c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

type Rep (LeaderOnlyReward c) Source # 
Instance details

Defined in Cardano.Ledger.Shelley.Rewards

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

leaderRewCoinPoolParams c → StakeShareStakeShareCoin Source #

Calculate pool leader reward

memberRewCoinPoolParams c → StakeShareStakeShareCoin Source #

Calculate pool member reward

aggregateRewards ∷ ∀ c. ProtVerMap (Credential 'Staking c) (Set (Reward c)) → Map (Credential 'Staking c) 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

filterRewards ∷ ∀ c. ProtVerMap (Credential 'Staking c) (Set (Reward c)) → (Map (Credential 'Staking c) (Set (Reward c)), Map (Credential 'Staking c) (Set (Reward c))) 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

sumRewards ∷ ∀ c. ProtVerMap (Credential 'Staking c) (Set (Reward c)) → Coin Source #

aggregateCompactRewardsProtVerMap (Credential 'Staking c) (Set (Reward c)) → Map (Credential 'Staking c) (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 c)

The set of registered stake credentials

PoolRewardInfo c

Stake pool specific intermediate values needed to compute member rewards.

Credential 'Staking c

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 → CoinBlocksMade (EraCrypto era) → NaturalStake (EraCrypto era) → VMap VB VB (Credential 'Staking (EraCrypto era)) (KeyHash 'StakePool (EraCrypto era)) → Map (KeyHash 'StakePool (EraCrypto era)) CoinCoinCoinPoolParams (EraCrypto era) → Either StakeShare (PoolRewardInfo (EraCrypto era)) 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.