Please give a detailed calculation with all values and parameters of how you computed R in the example above, I’m thinking you maybe didn’t adjust for total minted blocks.
For clarification: in epoch 305 there were 21025 blocks. So you have to multiply the rewards coming from the reserve by 21025/21600. If 21600 or more blocks are minted in an epoch, there’s no adjustment!
I think I was wrong about the total supply needing to be the one from two epochs ago, because what’s out of the reserve is already out of the reserve…
Hi,
I ran the the pool TOSHZ through my calculator with these total supply and total active stake and get 680 ada for the epochs where only 1 block is minted.
You can see the breakdown if the tool you check the option “Show Detail of Last simulation” which will show you an example run of rewards for a full year
I suspect there might be something off with your sigma calculation. Anyhow here is an extract from my code that does the maths - hope this helps:
const reserveAda = this.state.maxAdaSupply - this.state.currentAdaSupply;
const blocksPerEpoch = this.state.slotsInEpoch * Number(this.state.chainDensity);
const distributionFromReserve = reserveAda * Number(this.state.rho);
const grossReward = this.state.feesInEpoch + distributionFromReserve;
const z0 = 1 / this.state.k;
const distributionToTreasury = grossReward * Number(this.state.tau);
const rewardToPoolOperators = grossReward - distributionToTreasury;
const poolPledge = this.state.poolPledge;
const delegatorsStake = this.state.totalStake - poolPledge;
const sigma = this.state.totalStake / this.state.currentAdaSupply;
const s = this.state.poolPledge / this.state.currentAdaSupply;
const sigmadash = Math.min(sigma, z0);
const sdash = Math.min(s, z0);
const blockAssigmentProbability = this.state.totalStake / this.state.totalAdaStaked;
const expectedNBlocksInEpoch = blockAssigmentProbability * blocksPerEpoch;
const expectedNBlocksPerYear = expectedNBlocksInEpoch * this.state.epochsInYear;
const a0 = Number(this.state.a0);
const expectedPoolRewardInEpoch = rewardToPoolOperators / (1 + a0) * (sigmadash + sdash * a0 * ((sigmadash - sdash * ((z0-sigmadash)/z0))/z0));
const expectedPoolRewardPerYear = expectedPoolRewardInEpoch * this.state.epochsInYear;
const annualizedPoolReward = expectedPoolRewardPerYear / this.state.totalStake;
This calculation also don’t adjust distributionFromReserve for minted blocks in the given epoch.
Thanks @dstratio and @brouwerQ for your continued feedback on this. I couldn’t find anything at https://docs.cardano.org/core-concepts/pledging-rewards that described applying the block fraction to the rewards coming from the reserve (the section about fees and monetary expansion). Here’s how I arrive at R (network params coming from blockfrost.io)
epoch = 305;
network_info = api.network()
epoch_info = api.epoch(epoch)
fees = int(epoch_info.fees)/1000000
total_active_stake = int(epoch_info.active_stake) / 1000000
total_block_count = int(epoch_info.block_count)
#reserves = int(network_info.supply.reserves) / 1000000
reserves = 11217568742 #epoch 303 11259657628, epoch 305 11217568742
#total_supply = int(network_info.supply.total)/ 1000000
total_supply = 45000000000 - reserves
pool_info = get_pool_info_by_hx(pool_id,epoch)
pool_data = api.pool(pool_id = pool_id)
param_info = api.epoch_latest_parameters(epoch)
pot = fees + (reserves * float(param_info.rho))
R = pot * (1 - float(param_info.tau))
I do apply a block fraction factor at the end when calculating the net rewards for the pool
adjusted_reward = reward * (block_fraction / sigma_a)
where block_fraction = blocks minted by the pool that epoch / total actual blocks minted by the network that epoch , i.e. 1 / 21025)
and sigma_a = stake_delegated to the pool / total_active_stake in the network. Both of these values I get from block frost, but may reflect current amounts at the time of the calculation, versus beginning of the epoch.
I’ll play around with pool and network stake values manually pulled from adapools for the epoch and see what the results are
EDIT: so instead of calculating sigma_a using real-time values pulled from blockfrost, I calculated sigma_a using epoch 305 active stake values pulled manually from adapools, for TOSHZ and the overal network
sigma_a = 322535 / 23854751264
Net rewards still come out to 698 ada (698.9954977562475)
Don’t base your calculator on that page, because it’s an incomplete simplification. It didn’t even had had the difference between sigma and sigma_a before until I changed it myself by a PR on GitHub that was later adopted (with a different PR though). Before it was just sigma 
Look at the Shelley Design document for a complete description of how it works (GitHub - input-output-hk/cardano-ledger: The ledger implementation and specifications of the Cardano blockchain., direct link to PDF: https://hydra.iohk.io/build/7740466/download/1/delegation_design_spec.pdf). In section 5.4.3 Monetary Expansion the ratio total minted epoch blocks to 21600, or η, is explained. Because it’s capped by 1 in the min function it only counts if the number of total blocks is less than 21600. Be aware that this factor only is applied to the part coming from the reserve, thus before fees are added and the part for the treasury is set aside.
Thanks for the links. Read through it and tried to adjust the python script. Now I’m coming up with over 800 ada in rewards for toshz, epoch 305, so I’m still doing something wrong. I don’t know if I’m confusing total supply and total in circulation
For epoch 305, I calculated total supply as 45B - reserves reported by adapools, then estimated total circulating as a percentage of total supply based on this latest report from blockfrost
{
“supply”: {
“max”: “45000000000000000”,
“total”: “33824240746574389”,
“circulating”: “33414573946080877”,
“locked”: “26817134836032”,
“treasury”: “724010388331415”,
“reserves”: “11175759253425611”
},
“stake”: {
“live”: “23771868389500974”,
“active”: “23854464200396318”
}
}
param_info = api.epoch_latest_parameters(epoch)
fees = int(epoch_info.fees)/1000000
deposits = 3565710
reserves = 11217568742 #epoch 303 11259657628, epoch 305 11217568742
#total_supply = int(network_info.supply.total)/ 1000000
total_supply = 45000000000 - reserves
total_circulating = total_supply * .988 #estimated for epoch 305, .988 * total_supply
#pot = fees + (reserves * float(param_info.rho))
network_block_pct = total_block_count / 21600
monetary_expansion = min(network_block_pct,1) * float(param_info.rho) * (45000000000 - total_circulating)
R = fees + monetary_expansion
Output
R = 34195565.58168414
Reward adjusted by beta divided by sigma_a: 883.7353548494995
I had included deposits in the calculation of R initially, but then the ada total was over 900
I don’t know what you’re doing with that percentage thing…
Max supply = total supply = 45B
Circulating supply = total stake = 45B - reserve
(Total) active stake = ADA delegated to non retired pools
Some sites might use some definitions wrong, e.g. using total stake where they mean active stake. Some also use a wrong value for active stake (e.g. not excluding ADA delegated to retired pools).
Just be sure to use the values from the right epoch. The formal specification file on the GitHub link should clarify (not easy though).