Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e35255a
updated manage pool page
homiebtc May 26, 2021
972fe27
update manage pool switch
homiebtc May 26, 2021
9ac1386
add utility functions for bitcoin
homiebtc May 31, 2021
90e2578
added pool contributer table
homiebtc Jun 10, 2021
7ba7550
working on api call
homiebtc Jun 13, 2021
b829d92
gets contribution but needs to query more automatically
homiebtc Jun 13, 2021
7636af5
gets all transactions, need to work on has_more for input / output
homiebtc Jun 14, 2021
fe17110
added pool start in config
homiebtc Jun 16, 2021
df47bbf
added view contributors for cycle input
homiebtc Jun 22, 2021
cf173c5
added columns to table
homiebtc Jun 22, 2021
cc64789
update locale
homiebtc Jun 22, 2021
63b6712
add transaction cache
homiebtc Jun 23, 2021
a6c3fc5
remove unnecessary query
homiebtc Jun 24, 2021
7893b0e
store outputs too
homiebtc Jun 24, 2021
b0cbb81
show error to user when failed to get newest pool contributors
homiebtc Jun 24, 2021
6447b5f
change initial cycle on form
homiebtc Jun 24, 2021
991e1d6
get balance
homiebtc Jun 25, 2021
b91f044
add stx address
homiebtc Jun 25, 2021
5dc7297
fixed stx address
homiebtc Jun 27, 2021
c1c55e4
added total remaining at end of last cycle
homiebtc Jun 28, 2021
7a67601
updated readme
homiebtc Jun 28, 2021
b6be17b
update readme
homiebtc Jun 29, 2021
1b85a3e
update readme
homiebtc Jun 29, 2021
be82c3b
update readme
homiebtc Jun 29, 2021
9516a47
reward %
homiebtc Jun 30, 2021
6cabdac
fixed reward %
homiebtc Jul 1, 2021
bdc05b5
add send reward button
homiebtc Jul 11, 2021
45d8c22
preparing for send stx button
homiebtc Jul 12, 2021
9cb113b
remove send button for now
homiebtc Jul 12, 2021
e58d54e
update reward %
homiebtc Jul 13, 2021
0a9daa6
update readme
homiebtc Jul 13, 2021
1a775f9
update readme
homiebtc Jul 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ screenshot
.eslintcache

build


# pool
pool/
79 changes: 78 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,84 @@
# Mining-Bot


Please Visit [Mining-Bot Documentation](https://daemon-technologies.github.io/docs/)

- [WSL Tutorial Video](https://www.youtube.com/watch?v=FXifFx0Akzc)
- [MacOS](https://www.youtube.com/watch?v=TCtCTttsSeI)

## Pooling

This pooling infrastructure assumes the following:

- All inputs to your specified pooling address will be new contributors.
- All outputs to your specified pooling address will be btc spent on mining.

### Formulation

For cycle ![](https://latex.codecogs.com/png.latex?n):

- Let ![](https://latex.codecogs.com/png.latex?X_{n-1}) be the total BTC contributed to the pool during cycle ![](https://latex.codecogs.com/png.latex?n-1).

- Let ![](https://latex.codecogs.com/png.latex?Y_{n-1}) be the total BTC in the pool at the end of cycle ![](https://latex.codecogs.com/png.latex?n-1).

- Let ![](https://latex.codecogs.com/png.latex?Z_{n-1}=Y_{n-1}-X_{n-1}), or the amount of BTC left in the pool after mining during cycle ![](https://latex.codecogs.com/png.latex?n-1) and not including the newest contributions in cycle ![](https://latex.codecogs.com/png.latex?n-1).

- If you contributed ![](https://latex.codecogs.com/png.latex?c_{n-1}) BTC during cycle ![](https://latex.codecogs.com/png.latex?n-1), your reward percentage for cycle ![](https://latex.codecogs.com/png.latex?n) will be ![](https://latex.codecogs.com/png.latex?P_n=\frac{c_{n-1}}{X_{n-1}}*\frac{X_{n-1}}{Y_{n-1}}=\frac{c_{n-1}}{Y_{n-1}}). 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 ![](https://latex.codecogs.com/png.latex?c_{k}) BTC during cycle ![](https://latex.codecogs.com/png.latex?k) where ![](https://latex.codecogs.com/png.latex?k<n-1), your reward percentage for cycle ![](https://latex.codecogs.com/png.latex?n) will be ![](https://latex.codecogs.com/png.latex?P_n=P_{n-1}\frac{Z_{n-1}}{Y_{n-1}}). 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:

- ![](https://latex.codecogs.com/png.latex?n=10)
- You contribute 0.1 BTC (![](https://latex.codecogs.com/png.latex?c_{9}=0.1))
- Other people contribute 0.9 BTC total.
- Pool has a total of 1 BTC right before cycle #10 begins (![](https://latex.codecogs.com/png.latex?X_{9}=Y_{9}=1))
- You will earn ![](https://latex.codecogs.com/png.latex?P_{10}=\frac{c_{9}}{Y_{9}}=\frac{0.1}{1}=0.1) of all mining rewards in cycle #10.

### Cycle #10

- ![](https://latex.codecogs.com/png.latex?n=10)
- You earn 10% of all mining rewards this cycle.
- This address begins to mine STX.

### Before Cycle #11

- ![](https://latex.codecogs.com/png.latex?n=11)
- For example, let's say by the end of cycle #10, 0.1 BTC has been spent on mining, and another 0.9 BTC was contributed, so pool now has 1.8 BTC before cycle #11. (![](https://latex.codecogs.com/png.latex?X_{10}=0.9,Y_{10}=1.8,Z_{10}=1.8-0.9=0.9))
- Your last contribution was during cycle 9 (![](https://latex.codecogs.com/png.latex?k=9)), so your reward percentage for cycle 11 will be ![](https://latex.codecogs.com/png.latex?P_{11}=P_{10}\frac{Z_{10}}{Y_{10}}=0.1*\frac{0.9}{1.8}=0.05), so you will receive 5% of all rewards in cycle #11

### Cycle #11

- ![](https://latex.codecogs.com/png.latex?n=11)
- You receive 5% of all mining rewards this cycle.
- This address continues mining STX.
- BTC sent to this address during this cycle will count as contributions for cycle #12

### Before Cycle #12

- ![](https://latex.codecogs.com/png.latex?n=12)
- For example, let's say by the end of cycle #11, another 0.1 BTC has been spent on mining, and no other BTC was contributed, so pool now has 1.7 BTC before cycle #12 (![](https://latex.codecogs.com/png.latex?X_{11}=0,Y_{11}=1.7,Z_{11}=1.7-0=1.7)).
- Since no other BTC was contributed, and your last contribution was during cycle 9 (![](https://latex.codecogs.com/png.latex?k=9)) you still get a total of 5% of all mining rewards in cycle #12 (![](https://latex.codecogs.com/png.latex?P_{12}=P_{11}\frac{Z_{11}}{Y_{11}}=0.05*\frac{1.7}{1.7}=0.05)).

### Cycle #12

- ![](https://latex.codecogs.com/png.latex?n=12)
- You receive 5% of all mining rewards this cycle.
- This address continues mining STX.
- BTC sent to this address during this cycle will count as contributions for cycle #13

### Before Cycle #13

- ![](https://latex.codecogs.com/png.latex?n=13)
- You contribute another 0.4 BTC to the pool
- For example, let's say by the end of cycle #12, another 0.1 BTC has been spent on mining, so there is now 2 BTC before cycle #13 (![](https://latex.codecogs.com/png.latex?X_{12}=0.4,Y_{12}=2,Z_{12}=2.0-0.4=1.6)).
- Your contribution during cycle 12 gives you a cycle 13 reward percentage of ![](https://latex.codecogs.com/png.latex?P_{13}=P_{12}\frac{Z_{12}}{Y_{12}}=0.05*\frac{1.6}{2.0}=0.04)
- Your contribution during cycle 9 gives you a cycle 13 reward percentage of ![](https://latex.codecogs.com/png.latex?P_{13}=\frac{c_{12}}{Y_{12}}=\frac{0.4}{2.0}=0.2)
- Your total reward percentage will be 0.04 + 0.2 = 0.24 of all mining rewards in cycle 13.
14 changes: 13 additions & 1 deletion config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default defineConfig({
{
path: '/wallet',
name: 'wallet',
icon: 'TeamOutlined',
icon: 'WalletOutlined',
component: './wallet',
},
{
Expand All @@ -68,6 +68,18 @@ export default defineConfig({
icon: 'UnorderedListOutlined',
component: './sysConf',
},
{
path: '/managePool',
name: 'managePool',
icon: 'TeamOutlined',
component: './managePool'
},
// {
// path: '/joinPool',
// name: 'joinPool',
// icon: 'UserAddOutlined',
// component: './joinPool'
// },
{
path: '/',
redirect: `/publicData`,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"jsdom-global": "^3.0.2",
"lint-staged": "^10.0.0",
"mockjs": "^1.0.1-beta3",
"prettier": "^2.0.1",
"prettier": "2.3.0",
"pro-download": "1.0.1",
"puppeteer-core": "^5.0.0",
"stylelint": "^13.0.0"
Expand Down
2 changes: 2 additions & 0 deletions src/components/RightContent/SwitchNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ const SwitchNetwork: React.FC<PageProps> = () => {
setNetworkName("Xenon");
message.info(`Switch to Xenon network`);
changeNetworkDAO("Xenon");
localStorage.removeItem("pooledBtcAddress")
window.location.reload();
// switchPage('Xenon');
break;
}
case "Mainnet": {
setNetworkName("Mainnet");
message.info(`Switch to Mainnet network`);
localStorage.removeItem("pooledBtcAddress")
changeNetworkDAO("Mainnet");
window.location.reload();
// switchPage('Xenon');
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en-US/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export default {
'menu.wallet': 'Wallet',
'menu.client': 'Mining Client',
'menu.sysConf': 'System Configuration',
'menu.managePool': 'Manage Pool',
'menu.joinPool': 'Join Pool',

'menu.welcome': 'Welcome',
'menu.more-blocks': 'More Blocks',
Expand Down
44 changes: 44 additions & 0 deletions src/pages/joinPool/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { useEffect, useState } from "react";
import { PageContainer } from "@ant-design/pro-layout";
import { ConfigProvider } from "antd";

import { switchConfigProviderLocale } from "@/services/locale";
import {
getCurrentCycle,
getCycleBlocks,
getPoolContributors,
} from "@/services/managePool/managePool";

const TableList: React.FC<{}> = () => {
const [currentCycle, setCurrentCycle] = useState<number>(-1);
useEffect(() => {
getCurrentCycle().then(({ cycle }) => {
if (cycle) {
setCurrentCycle(cycle!);
}
});
}, []);

useEffect(() => {
const { startBlock, endBlock } = getCycleBlocks(currentCycle);
getPoolContributors(startBlock, endBlock).then((transactions) => {
if (transactions) {
console.log(transactions);
}
});
}, [currentCycle]);
return (
<PageContainer>
<ConfigProvider locale={switchConfigProviderLocale()}>
<div>joinPool</div>
<div>Cycle #{currentCycle}</div>
<div>
From block {getCycleBlocks(currentCycle).startBlock} to
{getCycleBlocks(currentCycle).endBlock}
</div>
</ConfigProvider>
</PageContainer>
);
};

export default TableList;
Loading