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