Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype StakeShare = StakeShare {}
- data PoolRewardInfo = PoolRewardInfo {}
- mkApparentPerformance ∷ UnitInterval → Rational → Natural → Natural → Rational
- data RewardType
- data Reward = Reward {
- rewardType ∷ !RewardType
- rewardPool ∷ !(KeyHash 'StakePool)
- rewardAmount ∷ !Coin
- data LeaderOnlyReward = LeaderOnlyReward {
- lRewardPool ∷ !(KeyHash 'StakePool)
- lRewardAmount ∷ !Coin
- leaderRewardToGeneral ∷ LeaderOnlyReward → Reward
- leaderRew ∷ Coin → PoolParams → StakeShare → StakeShare → Coin
- memberRew ∷ Coin → PoolParams → StakeShare → StakeShare → Coin
- aggregateRewards ∷ ProtVer → Map (Credential 'Staking) (Set Reward) → Map (Credential 'Staking) Coin
- filterRewards ∷ ProtVer → Map (Credential 'Staking) (Set Reward) → (Map (Credential 'Staking) (Set Reward), Map (Credential 'Staking) (Set Reward))
- sumRewards ∷ ProtVer → Map (Credential 'Staking) (Set Reward) → Coin
- aggregateCompactRewards ∷ ProtVer → Map (Credential 'Staking) (Set Reward) → Map (Credential 'Staking) (CompactForm Coin)
- sumCompactRewards ∷ ProtVer → Map (Credential 'Staking) (Set Reward) → CompactForm Coin
- rewardOnePoolMember ∷ ProtVer → Coin → Set (Credential 'Staking) → PoolRewardInfo → Credential 'Staking → Coin → Maybe Coin
- mkPoolRewardInfo ∷ EraPParams era ⇒ PParams era → Coin → BlocksMade → Natural → Stake → VMap VB VB (Credential 'Staking) (KeyHash 'StakePool) → Map (KeyHash 'StakePool) Coin → Coin → Coin → PoolParams → Either StakeShare PoolRewardInfo
Documentation
data PoolRewardInfo Source #
Stake Pool specific information needed to compute the rewards for its members.
PoolRewardInfo | |
|
Instances
mkApparentPerformance ∷ UnitInterval → Rational → Natural → Natural → Rational 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.
Instances
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
Reward | |
|
Instances
ToJSON Reward | |
Generic Reward | |
Show Reward | |
DecCBOR Reward | |
EncCBOR Reward | |
NFData Reward | |
Defined in Cardano.Ledger.Rewards | |
Eq Reward | |
Ord Reward | Note that this Ord instance is chosen to align precisely
with the Allegra reward aggregation, as given by the
function |
Defined in Cardano.Ledger.Rewards | |
NoThunks Reward | |
type Rep Reward | |
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 #
Instances
leaderRew ∷ Coin → PoolParams → StakeShare → StakeShare → Coin Source #
Calculate pool leader reward
memberRew ∷ Coin → PoolParams → StakeShare → StakeShare → Coin Source #
Calculate pool member reward
aggregateRewards ∷ ProtVer → Map (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
filterRewards ∷ ProtVer → Map (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
sumRewards ∷ ProtVer → Map (Credential 'Staking) (Set Reward) → Coin Source #
aggregateCompactRewards ∷ ProtVer → Map (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.
sumCompactRewards ∷ ProtVer → Map (Credential 'Staking) (Set Reward) → CompactForm Coin Source #
∷ 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
mkPoolRewardInfo ∷ EraPParams era ⇒ PParams era → Coin → BlocksMade → Natural → Stake → VMap VB VB (Credential 'Staking) (KeyHash 'StakePool) → Map (KeyHash 'StakePool) Coin → Coin → Coin → PoolParams → Either 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.