<p>I am also wondering how this actually works since there hasn't been
any official documentation about it. However, given the already available information
on the website, 'cause all miners shares and hashrate are public and some questions
answered on Twitter by @wk057 and @GrassFedBitcoin;
I think I can already have a full picture of it.</p>
<p>The reward system consist of three main concepts:</p>
<ol>
<li>shares earn by each user,</li>
<li>total shares on the pool,</li>
<li>and earnings based on shares.</li>
</ol>
<h1>Earnings</h1>
<p>Earnings are the simplest thing to explain. If a user has <code>s</code> shares and the pool
has a total of <code>total_shares</code> (the sum of all user shares) the moment a block is found, the user earns</p>
<pre><code>s * (block_reward) / total_shares
</code></pre>
<p>where <code>block_reward</code> means subsidy plus fees.</p>
<h1>Share Window</h1>
<p>The share window <code>Z</code> is the maximum number of shares the pool will consider at any time. That is only up to the newest <code>Z</code> shares are considered for the reward distribution.
This number is 8 times the current block difficulty <code>Z = 8 * network_difficulty</code>. I will show below that this factor 8
translates into the number of blocks for which each share
is expected to generate an earning.</p>
<p>Once the pool is running for quite some time the number of accumulated shares is enough to have <code>total_shares = Z</code> hence in the examples below
we will consider that to be the case. Though in general this is not
the case at the beginning of the pool operation.</p>
<h1>User's shares</h1>
<p>One share is equivalent to the work needed to mine a block with difficulty 1.
Ocean, like any other pool, challenges the individual miners with some difficulty <code>d</code>
and each time a hash is accepted <code>d</code> shares are added to this miner's account.</p>
<p>Because there is a maximum number <code>Z</code> of shares considered for the
distribution of rewards,
when a miner starts contributing with a constant hashrate <code>H</code>,
his share number starts growing linearly until a maximum is reached,
this is when the sum of shares in the pool up to <code>Z</code> starting from the
most recent leaves out the oldest shares generated by the user.</p>
<p><a href="https://i.sstatic.net/50P20.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/50P20.jpg" alt="Fig 1. A miner entering the pool sees his shares increasing linearly over time." /></a></p>
<p>In the plot, I call <code>T</code> the <em>relaxation time</em> which is in fact the temporal dimension
of the share window, or simply the time difference between the newest and the oldest share
in the share window.
For as long as the pool has a constant hashrate <code>H_pool</code>,
<code>T</code> can be
understood as the expected time for the pool to produce <code>Z</code> shares:</p>
<pre><code>T = W1 * Z / H_pool
</code></pre>
<p>where <code>W1=0x100010001</code> is (by the definition of difficulty 1), the expected work needed
to solve a difficulty 1 block.</p>
<p>Also in the plot, we see the miner with a constant hashrate <code>H</code>
reaches a share number <code>&lt;S&gt;_T</code> which is the expected
number of shares this miner will receive after <code>T</code> seconds of work:</p>
<pre><code>&lt;S&gt;_T = H * T / W1 
      = Z * H / H_pool
</code></pre>
<p>If a miner with hashrate <code>H</code> reaches the expected maximum number of shares and then leaves the pool
forever, his shares will linearly decrease as the oldest shares are thrown away from the share window.</p>
<p><a href="https://i.sstatic.net/H3NLB.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/H3NLB.jpg" alt="Fig 2. A miner leaving the pool sees his shares decay linearly over time." /></a></p>
<p>We can understand the distribution of rewards from the point of view
of individual shares.
For instance, assuming a constant hashrate of the pool,
a share earned at any time will stay valid for a
time frame of about <code>T</code>. Now consider the expected number of blocks found by the pool
in this time frame <code>&lt;N&gt;_T</code>:</p>
<pre><code>&lt;N&gt;_T = H_pool * T / W1 / network_difficulty 
      = Z / network_difficulty 
      = 8
</code></pre>
<p>hence each share won by a miner is expected to reward him 8 earnings
before it is thrown away from the share window.</p>
<h1>Fairness</h1>
<p>A pool has a fair earning distribution if the expected <code>earning(W)</code>
for a certain amount of work <code>W</code>
diluted over time is:</p>
<pre><code>earning(W) = block_reward * W / (W1 * network_difficulty)
</code></pre>
<p>assuming a constant <code>block_reward</code> and
<code>network_difficulty</code>.
We stress that the denominator <code>W1 * network_difficulty</code>
is the expected work needed to mine a block, approximately the
number of hashes tried by the entire network in 10 minutes.</p>
<p>We had seen that each individual share earned by a miner in the Ocean pool is obtained after <code>W1</code> of work on average
and it earns the miner a <code>1/Z</code> fraction of the reward
in an expected number of 8 blocks found by the pool
from the moment the share is added until it is dropped from the
share window. Therefore we have earnings per share computed as:</p>
<pre><code>earning_per_share = 1/Z * 8 * block_reward 
                  = block_reward / network_difficulty 
                  = earning(W1)
</code></pre>
<p>thus the earning distribution is fair according to our definition,
independently of the miner's online time, hashrate,
the pool's hashrate or the network global parameters.</p>
<p>Eventually, if we know a miner's share function in time we can compute the total expected
reward for his shares.
For instance in a time interval <code>[0, t]</code> the share function is <code>s(t)</code>,
we split the interval into <code>M</code> small pieces of length <code>dt = t / M</code>.
Then the probability of finding a block in each of these time intervals is
<code>p = H_pool * dt/ (W1 * network_difficulty)</code>.
The reward for the miner in the entire time period is a random variable <code>R</code> which is the sum
of the reward for the miner in each of the tiny time intervals:</p>
<pre><code>R = sum_i r_i
</code></pre>
<p>where <code>r_i = b_i * block_reward * s(t_i) / Z</code>, in which <code>b_i</code> denotes a Bernoulli variable that takes values
1 with probability <code>p</code> and 0 with probability <code>1-p</code>.
So the expected value of the reward for the single miner becomes:</p>
<pre><code>&lt;R&gt; = sum_i &lt;r_i&gt; 
    = block_reward * H_pool / (Z * W1 * network_difficulty) sum_i s(t_i) dt
</code></pre>
<p>that converges to a Riemann integral in the limit
of <code>M -&gt; infinity</code>, the integral is the area under
the curve of shares vs time.
We can use this relation to compute the total earnings of a miner in different example
situations.</p>
<h1>Example 1. Alice mining always</h1>
<p>Let the hashrate of the pool be <code>H_pool = 1.25 EH/s</code>, consider Alice a miner with a hashrate
of <code>H_alice = 250 PH/s</code>, which corresponds to a 20% of the pool's hashrate.
And let <code>network_difficulty = 80T</code>.</p>
<p>The share window of the pool is <code>Z = 8*network_difficulty = 640T</code> and the time window
would correspond to <code>T = Z * W1/H_pool = 330 Ms</code> or about 25 days.</p>
<p>Alice has been mining non-stop since the beginning, so she has already reached the maximum
number of shares in the window: <code>S_alice = H_alice * T / W1 = 128T</code>.
If a block is found, Alice will get <code>S_alice / Z = 20%</code> of the block reward.</p>
<p>That means on average in a time frame <code>t</code>
Alice does a total work <code>W_total = H_alice * t</code>
and the pool finds <code>&lt;N&gt;_t = H_pool * t/ (W1 * network_difficulty)</code>
blocks so Alice earns</p>
<pre><code>&lt;R&gt;_t = &lt;N&gt;_t * block_reward * S_alice / Z 
      = block_reward * W_total / (network_difficulty * W1)
      = earning(W_total)
</code></pre>
<p>which is fair for Alice.</p>
<p>To put some numbers into it, it means that for blocks with
<code>block_reward = 7 BTC</code>, Alice is earning on average <code>0.003 BTC</code>
every 10 minutes or <code>0.44 BTC/day</code>, and this number only depends on Alice hashrate
and the network parameters (<code>block_reward</code> and <code>network_difficulty</code>).</p>
<h1>Example 2. Charlie the small miner</h1>
<p>Now consider a small miner that arrives to the pool,
it is small so the total hashrate of the pool doesn't change.
Let's say Charlie has <code>H_charlie = 1 TH/s</code>.
At a constant hashrate and difficulty, Charlie would have to wait
for at least <code>T</code> seconds or 25 days until it can reach the maximum number of shares,
see fig 3. If after some time <code>dt</code> Charlie leaves the pool, his shares will
start to fall linearly to zero in a time period of 25 days (relax time <code>T</code>).</p>
<p><a href="https://i.sstatic.net/YqEe6.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/YqEe6.jpg" alt="Fig 3." /></a></p>
<p>During all the time Charlie was hashing for the pool, he contributed to
a total of <code>W_total = H_charlie * (T + dt)</code>.
The expected earnings of Charlie in the three regions in fig. 3 are
(using the integral under the curve):</p>
<pre><code>&lt;R1&gt; = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*T/2)

&lt;R2&gt; = H_pool * block_reward / (Z * W1 * network_difficulty) * S* dt

&lt;R3&gt; = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*T/2)
</code></pre>
<p>where <code>S = H_charlie * T / W1</code> is the maximum number of shares of Charlie.
When these three are summed up we find</p>
<pre><code>&lt;R1 + R2 + R3&gt; = block_reward * S / network_difficulty * (1 + dt/T) 
               = block_reward * W_total  / (W1 * network_difficulty)
               = earning(W_total)
</code></pre>
<p>Which means that a fair earning is expected for Charlie if
he comes and mines for a long time (until it reaches constant shares)
and then leaves the pool.</p>
<p>For example, if Charlie mines for <code>T = 25 days</code> reaching constant shares
and then after mining for 10 more days he turns off his
miner. Then <code>&lt;R1&gt; = &lt;R3&gt; = 2240 sat</code> and <code>&lt;R2&gt; = 1760 sat</code>,
and a total expected earning of <code>&lt;R1 + R2 + R3&gt; = 6240 sat</code>
before his share count in the window is 0, or <code>176 sat/day</code> for
the ratio of total earnings divided by the work time.</p>
<h1>Example 3. Charlie leaves early</h1>
<p>Consider again the small miner Charlie, but this time he mines for some time <code>t1 &lt; T</code>, so his shares start to accumulate linearly
until, at time <code>t1</code>, he turns off his miner;
then for some time his shares remain constant,
until at time <code>T</code> his oldest share
falls out of the share window and his share count starts to decrease linearly until it
reaches zero at time <code>T + t1</code>, see fig. 4.</p>
<p><a href="https://i.sstatic.net/RpwLW.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/RpwLW.jpg" alt="Fig. 4." /></a></p>
<p>The total work is <code>W_total = H_charlie * t1</code> and the expected earnings are:</p>
<pre><code>&lt;R1&gt; = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*t1/2)

&lt;R2&gt; = H_pool * block_reward / (Z * W1 * network_difficulty) * S*(T-t1)

&lt;R3&gt; = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*t1/2)
</code></pre>
<p>where <code>S = H_charlie * t1 / W1</code>. When we add them up we find:</p>
<pre><code>&lt;R1 + R2 + R3&gt; = block_reward * S / network_difficulty 
               = block_reward * W_total / (W1 * network_difficulty)
               = earning(W_total)
</code></pre>
<p>Which means a fair earning is expected for Charlie even if he participates for
a short period of time.</p>
<p>For example, let <code>t1 = 1 day</code>, it follows that <code>&lt;R1&gt; = &lt;R3&gt; = 3.5 sat</code>
and <code>&lt;R2&gt; = 169 sat</code>, in total <code>&lt;R1 + R2 + R3&gt; = 176 sat</code>
or <code>176 sat/day</code> (earnings per time of work).</p>
<h1>Example 4. Bob the big miner</h1>
<p>Now assume, a big miner Bob enters the pool with <code>H_bob = 1.25 EH/s</code>, doubling the pool's
hashrate.
Bob quickly starts adding shares and the pool would need to discard old shares
as twice as fast than previously to keep the window size at constant <code>Z</code>. In other words
the relaxation time changes from <code>T = 25.5 days</code> to <code>T' = Z * W1 / (H_pool + H_bob) = 12.7 days</code>.
It will take Bob 12 days, until he reaches the maximum number of shares: <code>S = Z/2 = 320T</code>.
After this moment, every time a block is found Bob will earn half of the block reward.</p>
<p>If Bob decides to leave after some time <code>dt</code> of having a constant share count,
then his shares will start decreasing linearly with time, see fig. 5.</p>
<p><a href="https://i.sstatic.net/o1lCG.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/o1lCG.jpg" alt="Fig. 5." /></a></p>
<p>But since the pool has now less hashrate than when Bob was mining, it will take 25 days before
all of Bob's shares are gone. But still the expected number of blocks is 8.
Due to the fairness argument described above, each one of Bob
shares is as good as any other miner shares.</p>
<p>The total work done by Bob is <code>W_total = H_bob * (T' + dt)</code> while the expected earnings on each
region are</p>
<pre><code>&lt;R1&gt; = (H_pool+H_bob) * block_reward / (Z * W1 * network_difficulty) * (S*T'/2)

&lt;R2&gt; = (H_pool+H_bob) * block_reward / (Z * W1 * network_difficulty) * S*dt

&lt;R3&gt; = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*T)/2
</code></pre>
<p>again adding them up we find that</p>
<pre><code>&lt;R1 + R2 + R3&gt; = block_reward / network_difficulty * (S + S*dt/T')
               = block_reward * W_total / (W1*network_difficulty)
               = earning(W_total)
</code></pre>
<p>Also for the big miner we verify that earnings are fair.</p>
<p>For instance if <code>dt = 7 days</code> we find that <code>&lt;R1&gt; = &lt;R3&gt; = 14 BTC</code>
and <code>&lt;R2&gt; = 15.4 BTC</code>, for a total expected earning of
<code>&lt;R1+R2+R3&gt; = 43.3 BTC</code> or <code>2.2 BTC/day</code> (total earnings per day of work),
notice this is always <code>176 sat/day</code> for each <code>TH/s</code> of hashrate.</p>
<h1>Example 5. Bob the big miner leaves early</h1>
<p>Now assume, Bob enters the pool but mines only for a short
period of time <code>t1 &lt; T'</code>.
While Bob is mining his shares grow linearly up to
<code>S = t1 * H_bob</code>, then after he stops
the number of shares remain constant for some time <code>dt</code> until
the oldest shares by Bob start to leave the share window:</p>
<pre><code>t1 * (H_pool + H_bob) + dt * H_pool = Z * W1
</code></pre>
<p>Afterwards, his shares starts decreasing linearly
until zero at time <code>t1 + T</code>; see fig. 6.</p>
<p><a href="https://i.sstatic.net/6XtQD.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6XtQD.jpg" alt="Fig. 6." /></a></p>
<p>The total work done by Bob is <code>W_total = H_bob * t1</code> while the expected earnings on each
region are:</p>
<pre><code>&lt;R1&gt; = (H_pool+H_bob) * block_reward / (Z * W1 * network_difficulty) * (S*t1/2)

&lt;R2&gt; = H_pool * block_reward / (Z * W1 * network_difficulty) * S*dt

&lt;R3&gt; = H_pool * block_reward / (Z * W1 * network_difficulty) * S * (T-dt)/2
</code></pre>
<p>again adding them up we find that:</p>
<pre><code>&lt;R1 + R2 + R3&gt; = block_reward / network_difficulty * S * (t1/T' + dt/T + 1 )/2
               = block_reward * W_total / (W1 * network_difficulty)
               = earning(W_total)
</code></pre>
<p>Earnings are always fair.</p>
<p>Now let's say <code>t1 = 1 day</code>, during that period of time
the miner will earn <code>&lt;R1&gt; = 0.086 BTC</code>. Then, the miner turns off
and during the following <code>dt = (1-t1/T') * T = 23.5 days</code>
in which the shares remain constant the miner will earn
<code>&lt;R2&gt; = 2.027 BTC</code>.
Then finally the shares will start to decrease linearly for the next
<code>T-dt = 2 days</code> and the miner will earn <code>&lt;R3&gt; = 0.086 BTC</code>,
for a total expected earnings of <code>&lt;R1 + R2 + R3&gt; = 2.2 BTC</code>
or <code>2.2 BTC/day</code>
(total earnings for time of work) or <code>176 sat/day</code> for each <code>TH/s</code>.</p>

CC BY-SA 4.0
2024-02-19T10:57:41.320Z
2024-02-20T00:11:52.557Z
2024-02-20T00:11:52.557Z
Lagrang3
<p>This week a new mining pool &quot;Ocean&quot; was announced. The mining pool uses a payout scheme called <em>Transparent Index of Distinct Extended Shares (TIDES)</em>. The Ocean website describes the scheme as follows.</p>
<blockquote>
<p>Our reward scheme is called Transparent Index of Distinct Extended
Shares (TIDES). As blocks are being mined, they generate the reward by
a weighted percentage of effort to the most recently found proofs. The
proof period funds are distributed across has been chosen such that
each proof should be paid on average 8 times. Instead of a set amount
of bitcoins per proof, the block reward is divided by percent, so
transaction fees are included. Because of this design, each payout to
you is fully auditable. Previous implementations of similar systems
such as PPLNS would distort the payouts owed to miners by using
“shifts” and much smaller proof windows, resulting in miners getting
significantly less accurate payments for their contributed hashrate.</p>
<p>TIDES is the most accurate payout scheme available in Bitcoin today
and unlike other schemes like FPPS it does not require the pool to
serve as a custodial intermediary for payment processing.</p>
</blockquote>
<p>Can someone explain in more details how much a miner gets paid in each blocks? Let’s say Alice is contributing 20% of the shares continuously to the mining pool. Bob hops mining pools and contributes 30% to the first block but then doesn’t return to mine with Ocean. How much would they get paid and when?</p>

CC BY-SA 4.0
2024-02-29T14:34:26.530Z
I see that yesterday this related blog post was published: https://ocean.xyz/docs/tides
Murch
<mining-pools><pool-payout-methods>
How does Ocean’s TIDES payout scheme work?
Murch
# How does Ocean’s TIDES payout scheme work?

(Asked by: username_0 on 2023-11-30)

This week a new mining pool "Ocean" was announced. The mining pool uses a payout scheme called *Transparent Index of Distinct Extended Shares (TIDES)*. The Ocean website describes the scheme as follows.

> Our reward scheme is called Transparent Index of Distinct Extended
> Shares (TIDES). As blocks are being mined, they generate the reward by
> a weighted percentage of effort to the most recently found proofs. The
> proof period funds are distributed across has been chosen such that
> each proof should be paid on average 8 times. Instead of a set amount
> of bitcoins per proof, the block reward is divided by percent, so
> transaction fees are included. Because of this design, each payout to
> you is fully auditable. Previous implementations of similar systems
> such as PPLNS would distort the payouts owed to miners by using
> “shifts” and much smaller proof windows, resulting in miners getting
> significantly less accurate payments for their contributed hashrate.
>
> TIDES is the most accurate payout scheme available in Bitcoin today
> and unlike other schemes like FPPS it does not require the pool to
> serve as a custodial intermediary for payment processing.

Can someone explain in more details how much a miner gets paid in each blocks? Let’s say Alice is contributing 20% of the shares continuously to the mining pool. Bob hops mining pools and contributes 30% to the first block but then doesn’t return to mine with Ocean. How much would they get paid and when?

**Tags:** mining-pools, pool-payout-methods

> **Comments:**
> **username_0**: I see that yesterday this related blog post was published: https://ocean.xyz/docs/tides  

---

## 1 answers

### Answer by username_1 on 2024-02-19. Score: 3 | Accepted answer

I am also wondering how this actually works since there hasn't been
any official documentation about it. However, given the already available information
on the website, 'cause all miners shares and hashrate are public and some questions
answered on Twitter by @wk057 and @GrassFedBitcoin;
I think I can already have a full picture of it.

The reward system consist of three main concepts:

1. shares earn by each user,
2. total shares on the pool,
3. and earnings based on shares.

# Earnings

Earnings are the simplest thing to explain. If a user has `s` shares and the pool
has a total of `total_shares` (the sum of all user shares) the moment a block is found, the user earns

```
s * (block_reward) / total_shares

```

where `block_reward` means subsidy plus fees.

# Share Window

The share window `Z` is the maximum number of shares the pool will consider at any time. That is only up to the newest `Z` shares are considered for the reward distribution.
This number is 8 times the current block difficulty `Z = 8 * network_difficulty`. I will show below that this factor 8
translates into the number of blocks for which each share
is expected to generate an earning.

Once the pool is running for quite some time the number of accumulated shares is enough to have `total_shares = Z` hence in the examples below
we will consider that to be the case. Though in general this is not
the case at the beginning of the pool operation.

# User's shares

One share is equivalent to the work needed to mine a block with difficulty 1.
Ocean, like any other pool, challenges the individual miners with some difficulty `d`
and each time a hash is accepted `d` shares are added to this miner's account.

Because there is a maximum number `Z` of shares considered for the
distribution of rewards,
when a miner starts contributing with a constant hashrate `H`,
his share number starts growing linearly until a maximum is reached,
this is when the sum of shares in the pool up to `Z` starting from the
most recent leaves out the oldest shares generated by the user.

[![Fig 1. A miner entering the pool sees his shares increasing linearly over time.](https://i.sstatic.net/50P20.jpg)](https://i.sstatic.net/50P20.jpg)

In the plot, I call `T` the *relaxation time* which is in fact the temporal dimension
of the share window, or simply the time difference between the newest and the oldest share
in the share window.
For as long as the pool has a constant hashrate `H_pool`,
`T` can be
understood as the expected time for the pool to produce `Z` shares:

```
T = W1 * Z / H_pool

```

where `W1=0x100010001` is (by the definition of difficulty 1), the expected work needed
to solve a difficulty 1 block.

Also in the plot, we see the miner with a constant hashrate `H`
reaches a share number `<S>_T` which is the expected
number of shares this miner will receive after `T` seconds of work:

```
<S>_T = H * T / W1 
      = Z * H / H_pool

```

If a miner with hashrate `H` reaches the expected maximum number of shares and then leaves the pool
forever, his shares will linearly decrease as the oldest shares are thrown away from the share window.

[![Fig 2. A miner leaving the pool sees his shares decay linearly over time.](https://i.sstatic.net/H3NLB.jpg)](https://i.sstatic.net/H3NLB.jpg)

We can understand the distribution of rewards from the point of view
of individual shares.
For instance, assuming a constant hashrate of the pool,
a share earned at any time will stay valid for a
time frame of about `T`. Now consider the expected number of blocks found by the pool
in this time frame `<N>_T`:

```
<N>_T = H_pool * T / W1 / network_difficulty 
      = Z / network_difficulty 
      = 8

```

hence each share won by a miner is expected to reward him 8 earnings
before it is thrown away from the share window.

# Fairness

A pool has a fair earning distribution if the expected `earning(W)`
for a certain amount of work `W`
diluted over time is:

```
earning(W) = block_reward * W / (W1 * network_difficulty)

```

assuming a constant `block_reward` and
`network_difficulty`.
We stress that the denominator `W1 * network_difficulty`
is the expected work needed to mine a block, approximately the
number of hashes tried by the entire network in 10 minutes.

We had seen that each individual share earned by a miner in the Ocean pool is obtained after `W1` of work on average
and it earns the miner a `1/Z` fraction of the reward
in an expected number of 8 blocks found by the pool
from the moment the share is added until it is dropped from the
share window. Therefore we have earnings per share computed as:

```
earning_per_share = 1/Z * 8 * block_reward 
                  = block_reward / network_difficulty 
                  = earning(W1)

```

thus the earning distribution is fair according to our definition,
independently of the miner's online time, hashrate,
the pool's hashrate or the network global parameters.

Eventually, if we know a miner's share function in time we can compute the total expected
reward for his shares.
For instance in a time interval `[0, t]` the share function is `s(t)`,
we split the interval into `M` small pieces of length `dt = t / M`.
Then the probability of finding a block in each of these time intervals is
`p = H_pool * dt/ (W1 * network_difficulty)`.
The reward for the miner in the entire time period is a random variable `R` which is the sum
of the reward for the miner in each of the tiny time intervals:

```
R = sum_i r_i

```

where `r_i = b_i * block_reward * s(t_i) / Z`, in which `b_i` denotes a Bernoulli variable that takes values
1 with probability `p` and 0 with probability `1-p`.
So the expected value of the reward for the single miner becomes:

```
<R> = sum_i <r_i> 
    = block_reward * H_pool / (Z * W1 * network_difficulty) sum_i s(t_i) dt

```

that converges to a Riemann integral in the limit
of `M -> infinity`, the integral is the area under
the curve of shares vs time.
We can use this relation to compute the total earnings of a miner in different example
situations.

# Example 1. Alice mining always

Let the hashrate of the pool be `H_pool = 1.25 EH/s`, consider Alice a miner with a hashrate
of `H_alice = 250 PH/s`, which corresponds to a 20% of the pool's hashrate.
And let `network_difficulty = 80T`.

The share window of the pool is `Z = 8*network_difficulty = 640T` and the time window
would correspond to `T = Z * W1/H_pool = 330 Ms` or about 25 days.

Alice has been mining non-stop since the beginning, so she has already reached the maximum
number of shares in the window: `S_alice = H_alice * T / W1 = 128T`.
If a block is found, Alice will get `S_alice / Z = 20%` of the block reward.

That means on average in a time frame `t`
Alice does a total work `W_total = H_alice * t`
and the pool finds `<N>_t = H_pool * t/ (W1 * network_difficulty)`
blocks so Alice earns

```
<R>_t = <N>_t * block_reward * S_alice / Z 
      = block_reward * W_total / (network_difficulty * W1)
      = earning(W_total)

```

which is fair for Alice.

To put some numbers into it, it means that for blocks with
`block_reward = 7 BTC`, Alice is earning on average `0.003 BTC`
every 10 minutes or `0.44 BTC/day`, and this number only depends on Alice hashrate
and the network parameters (`block_reward` and `network_difficulty`).

# Example 2. Charlie the small miner

Now consider a small miner that arrives to the pool,
it is small so the total hashrate of the pool doesn't change.
Let's say Charlie has `H_charlie = 1 TH/s`.
At a constant hashrate and difficulty, Charlie would have to wait
for at least `T` seconds or 25 days until it can reach the maximum number of shares,
see fig 3. If after some time `dt` Charlie leaves the pool, his shares will
start to fall linearly to zero in a time period of 25 days (relax time `T`).

[![Fig 3.](https://i.sstatic.net/YqEe6.jpg)](https://i.sstatic.net/YqEe6.jpg)

During all the time Charlie was hashing for the pool, he contributed to
a total of `W_total = H_charlie * (T + dt)`.
The expected earnings of Charlie in the three regions in fig. 3 are
(using the integral under the curve):

```
<R1> = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*T/2)

<R2> = H_pool * block_reward / (Z * W1 * network_difficulty) * S* dt

<R3> = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*T/2)

```

where `S = H_charlie * T / W1` is the maximum number of shares of Charlie.
When these three are summed up we find

```
<R1 + R2 + R3> = block_reward * S / network_difficulty * (1 + dt/T) 
               = block_reward * W_total  / (W1 * network_difficulty)
               = earning(W_total)

```

Which means that a fair earning is expected for Charlie if
he comes and mines for a long time (until it reaches constant shares)
and then leaves the pool.

For example, if Charlie mines for `T = 25 days` reaching constant shares
and then after mining for 10 more days he turns off his
miner. Then `<R1> = <R3> = 2240 sat` and `<R2> = 1760 sat`,
and a total expected earning of `<R1 + R2 + R3> = 6240 sat`
before his share count in the window is 0, or `176 sat/day` for
the ratio of total earnings divided by the work time.

# Example 3. Charlie leaves early

Consider again the small miner Charlie, but this time he mines for some time `t1 < T`, so his shares start to accumulate linearly
until, at time `t1`, he turns off his miner;
then for some time his shares remain constant,
until at time `T` his oldest share
falls out of the share window and his share count starts to decrease linearly until it
reaches zero at time `T + t1`, see fig. 4.

[![Fig. 4.](https://i.sstatic.net/RpwLW.jpg)](https://i.sstatic.net/RpwLW.jpg)

The total work is `W_total = H_charlie * t1` and the expected earnings are:

```
<R1> = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*t1/2)

<R2> = H_pool * block_reward / (Z * W1 * network_difficulty) * S*(T-t1)

<R3> = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*t1/2)

```

where `S = H_charlie * t1 / W1`. When we add them up we find:

```
<R1 + R2 + R3> = block_reward * S / network_difficulty 
               = block_reward * W_total / (W1 * network_difficulty)
               = earning(W_total)

```

Which means a fair earning is expected for Charlie even if he participates for
a short period of time.

For example, let `t1 = 1 day`, it follows that `<R1> = <R3> = 3.5 sat`
and `<R2> = 169 sat`, in total `<R1 + R2 + R3> = 176 sat`
or `176 sat/day` (earnings per time of work).

# Example 4. Bob the big miner

Now assume, a big miner Bob enters the pool with `H_bob = 1.25 EH/s`, doubling the pool's
hashrate.
Bob quickly starts adding shares and the pool would need to discard old shares
as twice as fast than previously to keep the window size at constant `Z`. In other words
the relaxation time changes from `T = 25.5 days` to `T' = Z * W1 / (H_pool + H_bob) = 12.7 days`.
It will take Bob 12 days, until he reaches the maximum number of shares: `S = Z/2 = 320T`.
After this moment, every time a block is found Bob will earn half of the block reward.

If Bob decides to leave after some time `dt` of having a constant share count,
then his shares will start decreasing linearly with time, see fig. 5.

[![Fig. 5.](https://i.sstatic.net/o1lCG.jpg)](https://i.sstatic.net/o1lCG.jpg)

But since the pool has now less hashrate than when Bob was mining, it will take 25 days before
all of Bob's shares are gone. But still the expected number of blocks is 8.
Due to the fairness argument described above, each one of Bob
shares is as good as any other miner shares.

The total work done by Bob is `W_total = H_bob * (T' + dt)` while the expected earnings on each
region are

```
<R1> = (H_pool+H_bob) * block_reward / (Z * W1 * network_difficulty) * (S*T'/2)

<R2> = (H_pool+H_bob) * block_reward / (Z * W1 * network_difficulty) * S*dt

<R3> = H_pool * block_reward / (Z * W1 * network_difficulty) * (S*T)/2

```

again adding them up we find that

```
<R1 + R2 + R3> = block_reward / network_difficulty * (S + S*dt/T')
               = block_reward * W_total / (W1*network_difficulty)
               = earning(W_total)

```

Also for the big miner we verify that earnings are fair.

For instance if `dt = 7 days` we find that `<R1> = <R3> = 14 BTC`
and `<R2> = 15.4 BTC`, for a total expected earning of
`<R1+R2+R3> = 43.3 BTC` or `2.2 BTC/day` (total earnings per day of work),
notice this is always `176 sat/day` for each `TH/s` of hashrate.

# Example 5. Bob the big miner leaves early

Now assume, Bob enters the pool but mines only for a short
period of time `t1 < T'`.
While Bob is mining his shares grow linearly up to
`S = t1 * H_bob`, then after he stops
the number of shares remain constant for some time `dt` until
the oldest shares by Bob start to leave the share window:

```
t1 * (H_pool + H_bob) + dt * H_pool = Z * W1

```

Afterwards, his shares starts decreasing linearly
until zero at time `t1 + T`; see fig. 6.

[![Fig. 6.](https://i.sstatic.net/6XtQD.jpg)](https://i.sstatic.net/6XtQD.jpg)

The total work done by Bob is `W_total = H_bob * t1` while the expected earnings on each
region are:

```
<R1> = (H_pool+H_bob) * block_reward / (Z * W1 * network_difficulty) * (S*t1/2)

<R2> = H_pool * block_reward / (Z * W1 * network_difficulty) * S*dt

<R3> = H_pool * block_reward / (Z * W1 * network_difficulty) * S * (T-dt)/2

```

again adding them up we find that:

```
<R1 + R2 + R3> = block_reward / network_difficulty * S * (t1/T' + dt/T + 1 )/2
               = block_reward * W_total / (W1 * network_difficulty)
               = earning(W_total)

```

Earnings are always fair.

Now let's say `t1 = 1 day`, during that period of time
the miner will earn `<R1> = 0.086 BTC`. Then, the miner turns off
and during the following `dt = (1-t1/T') * T = 23.5 days`
in which the shares remain constant the miner will earn
`<R2> = 2.027 BTC`.
Then finally the shares will start to decrease linearly for the next
`T-dt = 2 days` and the miner will earn `<R3> = 0.086 BTC`,
for a total expected earnings of `<R1 + R2 + R3> = 2.2 BTC`
or `2.2 BTC/day`
(total earnings for time of work) or `176 sat/day` for each `TH/s`.


---

