Skip to content

Commit

Permalink
Merge pull request #352 from Lumerin-protocol/halving
Browse files Browse the repository at this point in the history
Halving
  • Loading branch information
abs2023 authored Apr 16, 2024
2 parents 965a2ed + dd778b3 commit c149bd1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lumerin-wallet-desktop",
"version": "1.3.3",
"version": "1.3.4",
"engines": {
"node": ">=14"
},
Expand Down Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"@electron/remote": "2.0.9",
"@lumerin/wallet-core": "github:Lumerin-protocol/WalletCore#1.1.0",
"@lumerin/wallet-core": "github:Lumerin-protocol/WalletCore#1.1.1",
"@reach/menu-button": "0.17.0",
"@tabler/icons": "1.119.0",
"axios": "0.27.2",
Expand Down
11 changes: 8 additions & 3 deletions src/components/contracts/SellerHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function SellerHub({
contractsRefresh,
allowSendTransaction,
networkDifficulty,
blockReward,
selectedCurrency,
formUrl,
...props
Expand Down Expand Up @@ -117,7 +118,8 @@ function SellerHub({
props.lmrCoinPrice,
props.btcCoinPrice,
address,
networkDifficulty
networkDifficulty,
blockReward
);
}
}, [contracts]);
Expand All @@ -133,7 +135,10 @@ function SellerHub({
);
const lmrCoinPrice = param[1];
const btcCoinPrice = param[2];
const reward = formatBtcPerTh(param[4]);

const networkDifficulty = param[4];
const blockReward = param[5];
const reward = formatBtcPerTh(networkDifficulty, blockReward);
const deviation = +settings.deviation;
const result = contracts.reduce((acc, contract) => {
const contractProfitTarget =
Expand Down Expand Up @@ -481,7 +486,7 @@ function SellerHub({
count: contractsToShow.length ?? 0,
rented: rentedContracts.reduce(speedReducer, 0),
totalPosted: contractsToShow.reduce(speedReducer, 0),
networkReward: formatBtcPerTh(networkDifficulty)
networkReward: formatBtcPerTh(networkDifficulty, blockReward)
};
const showArchive = deadContracts?.length;
const onArchiveOpen = () => setIsArchiveModalActive(true);
Expand Down
3 changes: 1 addition & 2 deletions src/components/contracts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ export const formatPrice = (price, symbol) => {
return `${Math.round(value * 100) / 100} ${symbol}`;
};

export const formatBtcPerTh = networkDifficulty => {
export const formatBtcPerTh = (networkDifficulty, blockReward) => {
const networkHashrate =
(networkDifficulty * Math.pow(2, 32)) / 600 / Math.pow(10, 12);

const miningHours = 24;
const blockReward = 6.25;
const hashrate = 1; // TH/s
const blocksExpected = 1 / 0.1667; // 1 block every 10 minutes
const profitPerTh =
Expand Down
1 change: 1 addition & 0 deletions src/store/hocs/withContractsState.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const withContractsState = WrappedComponent => {
allowSendTransaction: selectors.isAllowSendTransaction(state),
contractsLastUpdatedAt: selectors.getContractsLastUpdated(state),
networkDifficulty: selectors.getNetworkDifficulty(state),
blockReward: selectors.getBlockReward(state),
lmrCoinPrice: selectors.getRate(state),
ethCoinPrice: selectors.getRateEth(state),
btcCoinPrice: selectors.getRateBtc(state),
Expand Down
3 changes: 2 additions & 1 deletion src/store/reducers/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ const reducer = handleActions(
'network-difficulty-updated': (state, { payload }) => {
return {
...state,
networkDifficulty: payload.difficulty
networkDifficulty: payload.difficulty,
blockReward: payload.reward
};
},

Expand Down
6 changes: 6 additions & 0 deletions src/store/selectors/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ export const getNetworkDifficulty = createSelector(
chainData ? chainMetaData.networkDifficulty : null
);

export const getBlockReward = createSelector(
getChain,
getChainMeta,
(chainData, chainMetaData) => (chainData ? chainMetaData.blockReward : null)
);

export const getRateEth = createSelector(
getChain,
getChainMeta,
Expand Down

0 comments on commit c149bd1

Please sign in to comment.