-
Notifications
You must be signed in to change notification settings - Fork 14
STX Mining Pool Infrastructure #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Here are two obvious issues which will occur in Mining-Pool:
@danosaur98
|
|
Thanks a lot for the contribution to Mining-Bot. It's awesome! Welcome to discuss more detailed information before the PR merge. @danosaur98 |
|
I think this solution is not flexible enough, and all decisions are in the hands of Operator. According to the current profit distribution formulation, users cannot decide whether I will participate in a certain round of mining. |
This pull request adds the infrastructure for pooled stx mining for the mining bot.
At a high level:
This pooling infrastructure assumes the following:
Formulation
For cycle
:
Let
be the total BTC contributed to the pool during cycle
.
Let
be the total BTC in the pool at the end of cycle
.
Let
, or the amount of BTC left in the pool after mining during cycle
and not including the newest contributions in cycle
.
If you contributed
BTC during cycle
, your reward percentage for cycle
will be
. In other words, your reward percentage is based on how much you contributed in last cycle compared to all the BTC in the pool.
If you contributed
BTC during cycle
where
, your reward percentage for cycle
will be
. In other words, your reward percentage is based on your reward percentage from the last cycle and the amount of btc left in the pool after mining, not including new contributors.
If you contribute during multiple cycles, your total reward percentage is the sum of your reward percentages per contribution.
Example:
Pool begins mining in cycle 10. Any BTC sent to the specified address during cycle 9 is counted as a contribution.
Before Cycle 10
For example:
Cycle 10
Before Cycle 11
Cycle 11
Before Cycle 12
Cycle 12
Before Cycle 13
To test this for yourself, I have added two files:
.
tests/testPoolBalances.jsonandtests/testPoolContributors.json. In these two files, change the first address key to one of the bitcoin addresses you have imported into the mining bot. Then add "poolContributors" as a key to your local storage with the value fromtests/testPoolContributors.json, and add "poolBalances" as a key to your local storage with the value fromtests/testPoolBalances.json. These values would be normally automatically generated through API calls, but you can manually change them for the sake of testing. Your local storage will look something like thisUser flow
On the manage pool page, users can turn on pooling

Users can then specify the BTC address they are mining with and that they intend to pool with. The list of possible addresses is taken from the addresses they added in the wallets page. They can also specify which cycle the pool starts in. In the example above, this was the cycle that the pool began mining in.

Whenever the user queries on the table, we make api calls to Blockcypher to query the bitcoin blockchain for your pooled address. Any inputs are considered a contribution to the pool and we save the incoming address and contribution amount. Any outputs are considered btc spent on mining.
After a cycle ends, you have the reward percentages for each address, so you would compute how many stacks you mined during that cycle, multiply this by the reward percentages for each address to determine how much stacks each address deserves, and then you could send this using the stacks wallet. Automatic payment has not yet been implemented.
We also have not implemented a way to take fees in return for this pooled mining service.
Thank you for reading and please let me know of any changes I should make; I am open to any and all feedback!