Skip to content

Commit

Permalink
Renaming some function arguments
Browse files Browse the repository at this point in the history
to more clearly separate supply, total stake, active stake.
  • Loading branch information
kantp committed Sep 14, 2020
1 parent 6930bab commit f226924
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Expand Up @@ -919,7 +919,7 @@ createRUpd ::
EpochState era ->
Coin ->
ShelleyBase (RewardUpdate era)
createRUpd slotsPerEpoch b@(BlocksMade b') es@(EpochState acnt ss ls pr _ nm) total = do
createRUpd slotsPerEpoch b@(BlocksMade b') es@(EpochState acnt ss ls pr _ nm) maxSupply = do
asc <- asks activeSlotCoeff
let SnapShot stake' delegs' poolParams = _pstakeGo ss
Coin reserves = _reserves acnt
Expand All @@ -938,7 +938,7 @@ createRUpd slotsPerEpoch b@(BlocksMade b') es@(EpochState acnt ss ls pr _ nm) to
Coin rPot = _feeSS ss <> deltaR1
deltaT1 = floor $ intervalValue (_tau pr) * fromIntegral rPot
_R = Coin $ rPot - deltaT1
totalStake = circulation es total
totalStake = circulation es maxSupply
(rs_, newLikelihoods) =
reward pr b _R (Map.keysSet $ _rewards ds) poolParams stake' delegs' totalStake asc slotsPerEpoch
deltaR2 = _R Val.~~ (Map.foldr (<>) mempty rs_)
Expand Down
Expand Up @@ -248,7 +248,7 @@ desirability ::
PerformanceEstimate ->
Coin ->
Double
desirability pp r pool (PerformanceEstimate p) (Coin total) =
desirability pp r pool (PerformanceEstimate p) (Coin totalStake) =
if fTilde <= cost
then 0
else (fTilde - cost) * (1 - margin)
Expand All @@ -258,7 +258,7 @@ desirability pp r pool (PerformanceEstimate p) (Coin total) =
fTildeDenom = fromRational $ 1 + a0
cost = (fromRational . coinToRational . _poolCost) pool
margin = (fromRational . unitIntervalToRational . _poolMargin) pool
tot = max 1 (fromIntegral total)
tot = max 1 (fromIntegral totalStake)
Coin pledge = _poolPledge pool
s = fromIntegral pledge % tot
a0 = _a0 pp
Expand All @@ -274,15 +274,15 @@ getTopRankedPools ::
Map (KeyHash 'StakePool era) (PoolParams era) ->
Map (KeyHash 'StakePool era) PerformanceEstimate ->
Set (KeyHash 'StakePool era)
getTopRankedPools rPot total pp poolParams aps =
Set.fromList $
fmap fst $
take (fromIntegral $ _nOpt pp) (sortBy (flip compare `on` snd) rankings)
getTopRankedPools rPot totalStake pp poolParams aps =
where
pdata = Map.toList $ Map.intersectionWith (,) poolParams aps
rankings =
[ ( hk,
desirability pp rPot pool ap total
desirability pp rPot pool ap totalStake
)
| (hk, (pool, ap)) <- pdata
]
Expand Down Expand Up @@ -350,7 +350,7 @@ rewardOnePool ::
Coin ->
Set (Credential 'Staking era) ->
Map (Credential 'Staking era) Coin
rewardOnePool pp r blocksN blocksTotal pool (Stake stake) sigma sigmaA (Coin total) addrsRew =
rewardOnePool pp r blocksN blocksTotal pool (Stake stake) sigma sigmaA (Coin totalStake) addrsRew =
rewards'
where
Coin ostake =
Expand All @@ -359,14 +359,14 @@ rewardOnePool pp r blocksN blocksTotal pool (Stake stake) sigma sigmaA (Coin tot
mempty
(_poolOwners pool)
Coin pledge = _poolPledge pool
pr = fromIntegral pledge % fromIntegral total
pr = fromIntegral pledge % fromIntegral totalStake
(Coin maxP) =
if pledge <= ostake
then maxPool pp r sigma pr
else mempty
appPerf = mkApparentPerformance (_d pp) sigmaA blocksN blocksTotal
poolR = rationalToCoinViaFloor (appPerf * fromIntegral maxP)
tot = fromIntegral total
tot = fromIntegral totalStake
mRewards =
Map.fromList
[ ( hk,
Expand Down Expand Up @@ -401,16 +401,16 @@ reward
poolParams
stake
delegs
(Coin total)
(Coin totalStake)
asc
slotsPerEpoch = (rewards', hs)
where
totalBlocks = sum b
Coin totalActive = fold . unStake $ stake
Coin activeStake = fold . unStake $ stake
results = do
(hk, pparams) <- Map.toList poolParams
let sigma = fromIntegral pstake % fromIntegral total
sigmaA = fromIntegral pstake % fromIntegral totalActive
let sigma = fromIntegral pstake % fromIntegral totalStake
sigmaA = fromIntegral pstake % fromIntegral activeStake
blocksProduced = Map.lookup hk b
actgr@(Stake s) = poolStake hk delegs stake
Coin pstake = fold s
Expand All @@ -427,7 +427,7 @@ reward
actgr
sigma
sigmaA
(Coin total)
(Coin totalStake)
addrsRew
ls =
likelihood
Expand Down

0 comments on commit f226924

Please sign in to comment.