Porting of function countRewardDay

This commit is contained in:
Nicola Benaglia 2025-06-21 08:09:35 +02:00
parent 3404a70d51
commit 479ebefd63
2 changed files with 116 additions and 76 deletions

View File

@ -54,6 +54,7 @@ import {
currentTier, currentTier,
tierPercent, tierPercent,
countReward, countReward,
countRewardDay,
} from './MintingStats.tsx'; } from './MintingStats.tsx';
export type AddressLevelEntry = { export type AddressLevelEntry = {
@ -769,13 +770,24 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
countReward( countReward(
accountInfo, accountInfo,
addressLevel, addressLevel,
tier4Online, nodeStatus,
nodeStatus tier4Online
).toFixed(8) + ' QORT'
}
/>
<StatCard
label="Estimated Reward Per Day"
value={
countRewardDay(
accountInfo,
addressLevel,
adminInfo,
nodeHeightBlock,
nodeStatus,
tier4Online
).toFixed(8) + ' QORT' ).toFixed(8) + ' QORT'
} }
/> />
<StatCard label="Estimated Reward Per Day" value="pollo" />
{/* <StatCard label="AdminInfo" value={adminInfo} /> */}
</Grid> </Grid>
</Paper> </Paper>
</Container> </Container>

View File

@ -85,7 +85,7 @@ export const blockReward = (nodeStatus): number => {
export const currentTier = (level): string | undefined => { export const currentTier = (level): string | undefined => {
if (level === 0) { if (level === 0) {
return 'Tier 0 (Level 0)'; return 'Tier 0 (Level 0)'; // TODO translate
} else if (level === 1 || level === 2) { } else if (level === 1 || level === 2) {
return 'Tier 1 (Level 1 + 2)'; return 'Tier 1 (Level 1 + 2)';
} else if (level === 3 || level === 4) { } else if (level === 3 || level === 4) {
@ -180,8 +180,8 @@ export const countMintersInLevel = (
export const countReward = ( export const countReward = (
accountInfo, accountInfo,
addressLevel: AddressLevelEntry[], addressLevel: AddressLevelEntry[],
tier4Online: number, nodeStatus,
nodeStatus tier4Online: number
): number => { ): number => {
if (accountInfo != null) { if (accountInfo != null) {
const level = accountInfo.level; const level = accountInfo.level;
@ -265,75 +265,103 @@ export const countReward = (
return 0; // fallback: should never reach this point return 0; // fallback: should never reach this point
}; };
// _countRewardDay() { export const countRewardDay = (
// if (accountInfo.level === 0) { accountInfo,
// return '0' addressLevel: AddressLevelEntry[],
// } else if (accountInfo.level === 1) { adminInfo,
// const countRewardDay10 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[1].count + addressLevel[2].count) * this._timeCalc()).toFixed(8) nodeHeightBlock,
// const countRewardDay11 = (countRewardDay10).toString() nodeStatus,
// return countRewardDay11 tier4Online: number
// } else if (accountInfo.level === 2) { ): number => {
// const countRewardDay20 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[1].count + addressLevel[2].count) * this._timeCalc()).toFixed(8) if (accountInfo != null) {
// const countRewardDay21 = (countRewardDay20).toString() const level = accountInfo.level;
// return countRewardDay21 const timeCalc = averageBlockDay(adminInfo, nodeHeightBlock);
// } else if (accountInfo.level === 3) { if (level === 0) {
// const countRewardDay30 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[3].count + addressLevel[4].count) * this._timeCalc()).toFixed(8) return 0;
// const countRewardDay31 = (countRewardDay30).toString() } else if (level === 1 || level === 2) {
// return countRewardDay31 const countRewardDay12 = parseFloat(
// } else if (accountInfo.level === 4) { (
// const countRewardDay40 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[3].count + addressLevel[4].count) * this._timeCalc()).toFixed(8) (((blockReward(nodeStatus) / 100) *
// const countRewardDay41 = (countRewardDay40).toString() tierPercent(accountInfo, tier4Online)) /
// return countRewardDay41 (addressLevel[1].count + addressLevel[2].count)) *
// } else if (accountInfo.level === 5) { timeCalc
// if (this.tier4Online < 30) { ).toFixed(8)
// const countRewardDay50 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8) );
// const countRewardDay51 = (countRewardDay50).toString() return countRewardDay12;
// return countRewardDay51 } else if (level === 3 || level === 4) {
// } else { const countRewardDay34 = parseFloat(
// const countRewardDay50 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[5].count + addressLevel[6].count) * this._timeCalc()).toFixed(8) (
// const countRewardDay51 = (countRewardDay50).toString() (((blockReward(nodeStatus) / 100) *
// return countRewardDay51 tierPercent(accountInfo, tier4Online)) /
// } (addressLevel[3].count + addressLevel[4].count)) *
// } else if (accountInfo.level === 6) { timeCalc
// if (this.tier4Online < 30) { ).toFixed(8)
// const countRewardDay60 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8) );
// const countRewardDay61 = (countRewardDay60).toString() return countRewardDay34;
// return countRewardDay61 } else if (level === 5 || level === 6) {
// } else { if (this.tier4Online < 30) {
// const countRewardDay60 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[5].count + addressLevel[6].count) * this._timeCalc()).toFixed(8) const countRewardDay56 = parseFloat(
// const countRewardDay61 = (countRewardDay60).toString() (
// return countRewardDay61 (((blockReward(nodeStatus) / 100) *
// } tierPercent(accountInfo, tier4Online)) /
// } else if (accountInfo.level === 7) { (addressLevel[5].count +
// if (this.tier4Online < 30) { addressLevel[6].count +
// const countRewardDay70 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8) addressLevel[7].count +
// const countRewardDay71 = (countRewardDay70).toString() addressLevel[8].count)) *
// return countRewardDay71 timeCalc
// } else { ).toFixed(8)
// const countRewardDay70 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8) );
// const countRewardDay71 = (countRewardDay70).toString() return countRewardDay56;
// return countRewardDay71 } else {
// } const countRewardDay56 = parseFloat(
// } else if (accountInfo.level === 8) { (
// if (this.tier4Online < 30) { (((blockReward(nodeStatus) / 100) *
// const countRewardDay80 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8) tierPercent(accountInfo, tier4Online)) /
// const countRewardDay81 = (countRewardDay80).toString() (addressLevel[5].count + addressLevel[6].count)) *
// return countRewardDay81 timeCalc
// } else { ).toFixed(8)
// const countRewardDay80 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8) );
// const countRewardDay81 = (countRewardDay80).toString() return countRewardDay56;
// return countRewardDay81 }
// } } else if (level === 7 || level === 8) {
// } else if (accountInfo.level === 9) { if (this.tier4Online < 30) {
// const countRewardDay90 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[9].count + addressLevel[10].count) * this._timeCalc()).toFixed(8) const countRewardDay78 = parseFloat(
// const countRewardDay91 = (countRewardDay90).toString() (
// return countRewardDay91 (((blockReward(nodeStatus) / 100) *
// } else if (accountInfo.level === 10) { tierPercent(accountInfo, tier4Online)) /
// const countRewardDay100 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[9].count + addressLevel[10].count) * this._timeCalc()).toFixed(8) (addressLevel[5].count +
// const countRewardDay101 = (countRewardDay100).toString() addressLevel[6].count +
// return countRewardDay101 addressLevel[7].count +
// } addressLevel[8].count)) *
// } timeCalc
).toFixed(8)
);
return countRewardDay78;
} else {
const countRewardDay78 = parseFloat(
(
(((blockReward(nodeStatus) / 100) *
tierPercent(accountInfo, tier4Online)) /
(addressLevel[7].count + addressLevel[8].count)) *
timeCalc
).toFixed(8)
);
return countRewardDay78;
}
} else if (level === 9 || level === 10) {
const countRewardDay910 = parseFloat(
(
(((blockReward(nodeStatus) / 100) *
tierPercent(accountInfo, tier4Online)) /
(addressLevel[9].count + addressLevel[10].count)) *
timeCalc
).toFixed(8)
);
return countRewardDay910;
}
}
return 0; // fallback: should never reach this point
};
export const mintingStatus = (nodeStatus): string => { export const mintingStatus = (nodeStatus): string => {
if ( if (