<p>It is not a per-block constant. Reward calculation certainly is based on the number of blocks a pool makes, but along with a set of parameters and complex algorithm.</p>
<p>The reward calculation is done based on the below params,</p>
<ol>
<li>the monetary expansion ratio</li>
<li>fees collected during an epoch</li>
<li>TAU - the percentage of rewards to go into the treasury</li>
<li>slot-co-eff and number of slots per epoch</li>
<li>total number of blocks minted by all pools in an epoch</li>
<li>total stake in the epoch by all pools</li>
<li>total stake controlled by a pool</li>
<li>pledge of the stake pool</li>
</ol>
<p>Plus, the calculation also includes all these parameters based on epoch snapshots. The full calculation is quite big. But I hope I could give you a path to start with. You can find the documentation regarding the same at the below link,</p>
<p><a href="https://docs.cardano.org/en/latest/explore-cardano/understanding-pledging-and-rewards.html" rel="nofollow noreferrer">https://docs.cardano.org/en/latest/explore-cardano/understanding-pledging-and-rewards.html</a></p>
<p>Also, these parameters and snapshots are not available in graphQL, you can use ledger state dump for rewards calculation.</p>

CC BY-SA 4.0
2021-06-05T10:07:06.040Z
Would you say that all those params can be extracted from the blockchain using Graphql to make the perfect calculation. Or am I losing my time?
Enzo
CC BY-SA 4.0
2021-06-06T05:47:38.300Z
You can get all the details you need from the ledger state dump. Graphql does not provide enough information for rewards calculation.
Ashish Prajapati
CC BY-SA 4.0
2021-06-06T17:58:10.860Z
Do you have any idea on how to make a good estimation instead of the perfect calculation?
Enzo
CC BY-SA 4.0
2021-06-07T06:16:21.923Z
you can look at the previous epoch rewards data for a pool at cardanoscan.io, and consider the per block reward by dividing total rewards by the number of blocks it minted. NOTE that this is a very very high-level estimation.
Ashish Prajapati
CC BY-SA 4.0
2022-09-21T08:47:33.007Z
The link in the answer is currently broken, does anyone knows where it has been moved to?
Pedro Martins Timóteo da Costa
CC BY-SA 4.0
2021-06-05T07:28:52.093Z
2021-06-06T05:48:58.353Z
2021-06-06T05:48:58.353Z
Ashish Prajapati
<p>Having this Graphql query I know how many blocks this pool has produced on this epoch.</p>
<pre><code>query stakePoolById($poolId: StakePoolID!) #$epochId: Int
{
  stakePools(where: { id: { _eq: $poolId } }) {
    url
    margin
    fixedCost
    blocks {
      epoch {
        number
        fees
      }
    }
  }
}
</code></pre>
<p>The problem is that I don't know how much a pool get for each block produced. I guess that knowing that constant I can sum all the blocks produced and subtract the margin and the fixedCost.</p>
<p>Is this the right approach?</p>

CC BY-SA 4.0
2021-06-04T18:34:33.920Z
Where can one find the schema you're querying? To me, this comes out of nowhere.
Matthias Sieber
CC BY-SA 4.0
2021-06-05T10:05:32.557Z
I'm using https://graphql-api.mainnet.dandelion.link/ and https://input-output-hk.github.io/cardano-graphql/
Enzo
<graphql-engine>
How to calculate the current reward of a pool at current Epoch using graphql
# How to calculate the current reward of a pool at current Epoch using graphql

(Asked by: username_0 on 2021-06-04)

Having this Graphql query I know how many blocks this pool has produced on this epoch.
query stakePoolById($poolId: StakePoolID!) #$epochId: Int
{
  stakePools(where: { id: { _eq: $poolId } }) {
    url
    margin
    fixedCost
    blocks {
      epoch {
        number
        fees
      }
    }
  }
}

The problem is that I don't know how much a pool get for each block produced. I guess that knowing that constant I can sum all the blocks produced and subtract the margin and the fixedCost.
Is this the right approach?

**Tags:** graphql-engine
> **Comments:**
> **username_1**: Where can one find the schema you're querying? To me, this comes out of nowhere.  
> **username_0**: I'm using https://graphql-api.mainnet.dandelion.link/ and https://input-output-hk.github.io/cardano-graphql/  

---

## 1 answers

### Answer by username_2 on 2021-06-05. Score: 3 | Accepted answer

It is not a per-block constant. Reward calculation certainly is based on the number of blocks a pool makes, but along with a set of parameters and complex algorithm.

The reward calculation is done based on the below params,

1. the monetary expansion ratio
2. fees collected during an epoch
3. TAU - the percentage of rewards to go into the treasury
4. slot-co-eff and number of slots per epoch
5. total number of blocks minted by all pools in an epoch
6. total stake in the epoch by all pools
7. total stake controlled by a pool
8. pledge of the stake pool

Plus, the calculation also includes all these parameters based on epoch snapshots. The full calculation is quite big. But I hope I could give you a path to start with. You can find the documentation regarding the same at the below link,

<https://docs.cardano.org/en/latest/explore-cardano/understanding-pledging-and-rewards.html>

Also, these parameters and snapshots are not available in graphQL, you can use ledger state dump for rewards calculation.

> **Comments:**
> **username_0**: Would you say that all those params can be extracted from the blockchain using Graphql to make the perfect calculation. Or am I losing my time?  
> **username_2**: You can get all the details you need from the ledger state dump. Graphql does not provide enough information for rewards calculation.  
> **username_0**: Do you have any idea on how to make a good estimation instead of the perfect calculation?  
> **username_2**: you can look at the previous epoch rewards data for a pool at cardanoscan.io, and consider the per block reward by dividing total rewards by the number of blocks it minted. NOTE that this is a very very high-level estimation.  
> **username_3**: The link in the answer is currently broken, does anyone knows where it has been moved to?  

---

