Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cardano.Ledger.Shelley.Rewards
Synopsis
- newtype StakeShare = StakeShare { }
-
data
PoolRewardInfo
crypto =
PoolRewardInfo
{
- poolRelativeStake :: ! StakeShare
- poolPot :: ! Coin
- poolPs :: !( PoolParams crypto)
- poolBlocks :: ! Natural
- poolLeaderReward :: !( LeaderOnlyReward crypto)
- mkApparentPerformance :: UnitInterval -> Rational -> Natural -> Natural -> Rational
- data RewardType
-
data
LeaderOnlyReward
crypto =
LeaderOnlyReward
{
- lRewardPool :: !( KeyHash ' StakePool crypto)
- lRewardAmount :: ! Coin
- leaderRewardToGeneral :: LeaderOnlyReward c -> Reward c
-
data
Reward
crypto =
Reward
{
- rewardType :: RewardType
- rewardPool :: KeyHash ' StakePool crypto
- rewardAmount :: Coin
- leaderRew :: Coin -> PoolParams crypto -> StakeShare -> StakeShare -> Coin
- memberRew :: Coin -> PoolParams crypto -> StakeShare -> StakeShare -> Coin
- aggregateRewards :: forall crypto pp. HasField "_protocolVersion" pp ProtVer => pp -> Map ( Credential ' Staking crypto) ( Set ( Reward crypto)) -> Map ( Credential ' Staking crypto) Coin
- filterRewards :: forall crypto pp. HasField "_protocolVersion" pp ProtVer => pp -> Map ( Credential ' Staking crypto) ( Set ( Reward crypto)) -> ( Map ( Credential ' Staking crypto) ( Set ( Reward crypto)), Map ( Credential ' Staking crypto) ( Set ( Reward crypto)))
- sumRewards :: forall crypto pp. HasField "_protocolVersion" pp ProtVer => pp -> Map ( Credential ' Staking crypto) ( Set ( Reward crypto)) -> Coin
- rewardOnePoolMember :: HasField "_protocolVersion" pp ProtVer => pp -> Coin -> Set ( Credential ' Staking c) -> PoolRewardInfo c -> Credential ' Staking c -> Coin -> Maybe Coin
- mkPoolRewardInfo :: ( HasField "_d" ( PParams era) UnitInterval , HasField "_a0" ( PParams era) NonNegativeInterval , HasField "_nOpt" ( PParams era) Natural ) => PParams era -> Coin -> BlocksMade ( Crypto era) -> Natural -> Stake ( Crypto era) -> VMap VB VB ( Credential ' Staking ( Crypto era)) ( KeyHash ' StakePool ( Crypto era)) -> Map ( KeyHash ' StakePool ( Crypto era)) Coin -> Coin -> Coin -> PoolParams ( Crypto era) -> Either StakeShare ( PoolRewardInfo ( Crypto era))
Documentation
data PoolRewardInfo crypto Source #
Stake Pool specific information needed to compute the rewards for its members.
Constructors
PoolRewardInfo | |
Fields
|
Instances
mkApparentPerformance :: UnitInterval -> Rational -> Natural -> Natural -> Rational Source #
Calculate pool reward
data RewardType Source #
Constructors
MemberReward | |
LeaderReward |
Instances
data LeaderOnlyReward crypto Source #
Constructors
LeaderOnlyReward | |
Fields
|
Instances
leaderRewardToGeneral :: LeaderOnlyReward c -> Reward c Source #
Constructors
Reward | |
Fields
|
Instances
Eq ( Reward crypto) Source # | |
Ord ( Reward crypto) Source # |
Note that this Ord instance is chosen to align precisely
with the Allegra reward aggregation, as given by the
function
|
Defined in Cardano.Ledger.Shelley.Rewards Methods compare :: Reward crypto -> Reward crypto -> Ordering Source # (<) :: Reward crypto -> Reward crypto -> Bool Source # (<=) :: Reward crypto -> Reward crypto -> Bool Source # (>) :: Reward crypto -> Reward crypto -> Bool Source # (>=) :: Reward crypto -> Reward crypto -> Bool Source # max :: Reward crypto -> Reward crypto -> Reward crypto Source # min :: Reward crypto -> Reward crypto -> Reward crypto Source # |
|
Show ( Reward crypto) Source # | |
Generic ( Reward crypto) Source # | |
NFData ( Reward crypto) Source # | |
Defined in Cardano.Ledger.Shelley.Rewards |
|
Crypto crypto => ToCBOR ( Reward crypto) Source # | |
Defined in Cardano.Ledger.Shelley.Rewards |
|
Crypto crypto => FromCBOR ( Reward crypto) Source # | |
NoThunks ( Reward crypto) Source # | |
type Rep ( Reward crypto) Source # | |
Defined in Cardano.Ledger.Shelley.Rewards
type
Rep
(
Reward
crypto) =
D1
('
MetaData
"Reward" "Cardano.Ledger.Shelley.Rewards" "cardano-ledger-shelley-0.1.0.0-4LNBTpyKcsy6EW18a3tTt2" '
False
) (
C1
('
MetaCons
"Reward" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"rewardType") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
RewardType
)
:*:
(
S1
('
MetaSel
('
Just
"rewardPool") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
(
KeyHash
'
StakePool
crypto))
:*:
S1
('
MetaSel
('
Just
"rewardAmount") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
Coin
))))
|
leaderRew :: Coin -> PoolParams crypto -> StakeShare -> StakeShare -> Coin Source #
Calculate pool leader reward
memberRew :: Coin -> PoolParams crypto -> StakeShare -> StakeShare -> Coin Source #
Calculate pool member reward
aggregateRewards :: forall crypto pp. HasField "_protocolVersion" pp ProtVer => pp -> Map ( Credential ' Staking crypto) ( Set ( Reward crypto)) -> Map ( Credential ' Staking crypto) Coin Source #
filterRewards :: forall crypto pp. HasField "_protocolVersion" pp ProtVer => pp -> Map ( Credential ' Staking crypto) ( Set ( Reward crypto)) -> ( Map ( Credential ' Staking crypto) ( Set ( Reward crypto)), Map ( Credential ' Staking crypto) ( Set ( Reward crypto))) 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.
sumRewards :: forall crypto pp. HasField "_protocolVersion" pp ProtVer => pp -> Map ( Credential ' Staking crypto) ( Set ( Reward crypto)) -> Coin Source #
Arguments
:: HasField "_protocolVersion" pp ProtVer | |
=> pp |
The protocol parameters |
-> 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 :: ( HasField "_d" ( PParams era) UnitInterval , HasField "_a0" ( PParams era) NonNegativeInterval , HasField "_nOpt" ( PParams era) Natural ) => PParams era -> Coin -> BlocksMade ( Crypto era) -> Natural -> Stake ( Crypto era) -> VMap VB VB ( Credential ' Staking ( Crypto era)) ( KeyHash ' StakePool ( Crypto era)) -> Map ( KeyHash ' StakePool ( Crypto era)) Coin -> Coin -> Coin -> PoolParams ( Crypto era) -> Either StakeShare ( PoolRewardInfo ( Crypto 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.