Porting functions for reward

This commit is contained in:
Nicola Benaglia 2025-06-20 23:08:32 +02:00
parent 32bef6345f
commit 3404a70d51
2 changed files with 146 additions and 131 deletions

View File

@ -52,6 +52,8 @@ import {
mintingStatus, mintingStatus,
countMintersInLevel, countMintersInLevel,
currentTier, currentTier,
tierPercent,
countReward,
} from './MintingStats.tsx'; } from './MintingStats.tsx';
export type AddressLevelEntry = { export type AddressLevelEntry = {
@ -755,12 +757,24 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
)?.toFixed(0) || '' )?.toFixed(0) || ''
} }
/> />
<StatCard label="Tier Share Per Block" value="13%" />
<StatCard <StatCard
label="Est. Reward Per Block" label="Tier Share Per Block"
value="0.00506494 QORT" value={
tierPercent(accountInfo, tier4Online)?.toFixed(0) + ' %'
}
/> />
<StatCard label="Est. Reward Per Day" value="pollo" /> <StatCard
label="Estimated Reward Per Block"
value={
countReward(
accountInfo,
addressLevel,
tier4Online,
nodeStatus
).toFixed(8) + ' QORT'
}
/>
<StatCard label="Estimated Reward Per Day" value="pollo" />
{/* <StatCard label="AdminInfo" value={adminInfo} /> */} {/* <StatCard label="AdminInfo" value={adminInfo} /> */}
</Grid> </Grid>
</Paper> </Paper>

View File

@ -101,48 +101,32 @@ export const currentTier = (level): string | undefined => {
} }
}; };
export const tierPercent = (accountInfo, tier4Online): number | undefined => { export const tierPercent = (accountInfo, tier4Online): number => {
if (accountInfo.level === 0) { if (accountInfo !== null) {
const level = accountInfo.level;
if (level === 0) {
return 0; return 0;
} else if (accountInfo.level === 1) { } else if (level === 1 || level === 2) {
return 6; return 6;
} else if (accountInfo.level === 2) { } else if (level === 3 || level === 4) {
return 6;
} else if (accountInfo.level === 3) {
return 13; return 13;
} else if (accountInfo.level === 4) { } else if (level === 5 || level === 6) {
return 1;
} else if (accountInfo.level === 5) {
if (tier4Online < 30) { if (tier4Online < 30) {
return 45; return 45;
} else { } else {
return 19; return 19;
} }
} else if (accountInfo.level === 6) { } else if (level === 7 || level === 8) {
if (tier4Online < 30) {
return 45;
} else {
return 19;
}
} else if (accountInfo.level === 7) {
if (tier4Online < 30) { if (tier4Online < 30) {
return 45; return 45;
} else { } else {
return 26; return 26;
} }
} else if (accountInfo.level === 8) { } else if (level === 9 || level === 10) {
if (tier4Online < 30) {
return 45;
} else {
return 26;
}
} else if (accountInfo.level === 9) {
return 32; return 32;
} else if (accountInfo.level === 10) {
return 32;
} else {
return undefined; // fallback: should never reach this point
} }
}
return 0; // fallback: should never reach this point
}; };
export const countMintersInLevel = ( export const countMintersInLevel = (
@ -193,141 +177,159 @@ export const countMintersInLevel = (
return undefined; // fallback: should never reach this point return undefined; // fallback: should never reach this point
}; };
// _countReward() { export const countReward = (
// if (accountInfo.level === 0) { accountInfo,
// return '0' addressLevel: AddressLevelEntry[],
// } else if (accountInfo.level === 1) { tier4Online: number,
// const countReward10 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[1].count + addressLevel[2].count)).toFixed(8) nodeStatus
// const countReward11 = (countReward10).toString() ): number => {
// return countReward11 if (accountInfo != null) {
// } else if (accountInfo.level === 2) { const level = accountInfo.level;
// const countReward20 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[1].count + addressLevel[2].count)).toFixed(8) if (level === 0) {
// const countReward21 = (countReward20).toString() return 0;
// return countReward21 } else if (level === 1 || level === 2) {
// } else if (accountInfo.level === 3) { const countReward12: number = parseFloat(
// const countReward30 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[3].count + addressLevel[4].count)).toFixed(8) (
// const countReward31 = (countReward30).toString() ((blockReward(nodeStatus) / 100) *
// return countReward31 tierPercent(accountInfo, tier4Online)) /
// } else if (accountInfo.level === 4) { (addressLevel[1].count + addressLevel[2].count)
// const countReward40 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[3].count + addressLevel[4].count)).toFixed(8) ).toFixed(8)
// const countReward41 = (countReward40).toString() );
// return countReward41 return countReward12;
// } else if (accountInfo.level === 5) { } else if (level === 3 || level === 4) {
// if (this.tier4Online < 30) { const countReward34 = parseFloat(
// const countReward50 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count)).toFixed(8) (
// const countReward51 = (countReward50).toString() ((blockReward(nodeStatus) / 100) *
// return countReward51 tierPercent(accountInfo, tier4Online)) /
// } else { (addressLevel[3].count + addressLevel[4].count)
// const countReward50 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count)).toFixed(8) ).toFixed(8)
// const countReward51 = (countReward50).toString() );
// return countReward51 return countReward34;
// } } else if (level === 5 || level === 6) {
// } else if (accountInfo.level === 6) { if (tier4Online < 30) {
// if (this.tier4Online < 30) { const countReward56 = parseFloat(
// const countReward60 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count)).toFixed(8) (
// const countReward61 = (countReward60).toString() ((blockReward(nodeStatus) / 100) *
// return countReward61 tierPercent(accountInfo, tier4Online)) /
// } else { (addressLevel[5].count +
// const countReward60 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count)).toFixed(8) addressLevel[6].count +
// const countReward61 = (countReward60).toString() addressLevel[7].count +
// return countReward61 addressLevel[8].count)
// } ).toFixed(8)
// } else if (accountInfo.level === 7) { );
// if (this.tier4Online < 30) { return countReward56;
// const countReward70 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count)).toFixed(8) } else {
// const countReward71 = (countReward70).toString() const countReward56 = parseFloat(
// return countReward71 (
// } else { ((blockReward(nodeStatus) / 100) *
// const countReward70 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[7].count + addressLevel[8].count)).toFixed(8) tierPercent(accountInfo, tier4Online)) /
// const countReward71 = (countReward70).toString() (addressLevel[5].count + addressLevel[6].count)
// return countReward71 ).toFixed(8)
// } );
// } else if (accountInfo.level === 8) { return countReward56;
// if (this.tier4Online < 30) { }
// const countReward80 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count)).toFixed(8) } else if (level === 7 || level === 8) {
// const countReward81 = (countReward80).toString() if (tier4Online < 30) {
// return countReward81 const countReward78 = parseFloat(
// } else { (
// const countReward80 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[7].count + addressLevel[8].count)).toFixed(8) ((blockReward(nodeStatus) / 100) *
// const countReward81 = (countReward80).toString() tierPercent(accountInfo, tier4Online)) /
// return countReward81 (addressLevel[5].count +
// } addressLevel[6].count +
// } else if (accountInfo.level === 9) { addressLevel[7].count +
// const countReward90 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[9].count + addressLevel[10].count)).toFixed(8) addressLevel[8].count)
// const countReward91 = (countReward90).toString() ).toFixed(8)
// return countReward91 );
// } else if (accountInfo.level === 10) { return countReward78;
// const countReward100 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[9].count + addressLevel[10].count)).toFixed(8) } else {
// const countReward101 = (countReward100).toString() const countReward78 = parseFloat(
// return countReward101 (
// } ((blockReward(nodeStatus) / 100) *
// } tierPercent(accountInfo, tier4Online)) /
(addressLevel[7].count + addressLevel[8].count)
).toFixed(8)
);
return countReward78;
}
} else if (level === 9 || level === 10) {
const countReward910 = parseFloat(
(
((blockReward(nodeStatus) / 100) *
tierPercent(accountInfo, tier4Online)) /
(addressLevel[9].count + addressLevel[10].count)
).toFixed(8)
);
return countReward910;
}
}
return 0; // fallback: should never reach this point
};
// _countRewardDay() { // _countRewardDay() {
// if (accountInfo.level === 0) { // if (accountInfo.level === 0) {
// return '0' // return '0'
// } else if (accountInfo.level === 1) { // } else if (accountInfo.level === 1) {
// const countRewardDay10 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[1].count + addressLevel[2].count) * this._timeCalc()).toFixed(8) // const countRewardDay10 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[1].count + addressLevel[2].count) * this._timeCalc()).toFixed(8)
// const countRewardDay11 = (countRewardDay10).toString() // const countRewardDay11 = (countRewardDay10).toString()
// return countRewardDay11 // return countRewardDay11
// } else if (accountInfo.level === 2) { // } else if (accountInfo.level === 2) {
// const countRewardDay20 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[1].count + addressLevel[2].count) * this._timeCalc()).toFixed(8) // const countRewardDay20 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[1].count + addressLevel[2].count) * this._timeCalc()).toFixed(8)
// const countRewardDay21 = (countRewardDay20).toString() // const countRewardDay21 = (countRewardDay20).toString()
// return countRewardDay21 // return countRewardDay21
// } else if (accountInfo.level === 3) { // } else if (accountInfo.level === 3) {
// const countRewardDay30 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[3].count + addressLevel[4].count) * this._timeCalc()).toFixed(8) // const countRewardDay30 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[3].count + addressLevel[4].count) * this._timeCalc()).toFixed(8)
// const countRewardDay31 = (countRewardDay30).toString() // const countRewardDay31 = (countRewardDay30).toString()
// return countRewardDay31 // return countRewardDay31
// } else if (accountInfo.level === 4) { // } else if (accountInfo.level === 4) {
// const countRewardDay40 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[3].count + addressLevel[4].count) * this._timeCalc()).toFixed(8) // const countRewardDay40 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[3].count + addressLevel[4].count) * this._timeCalc()).toFixed(8)
// const countRewardDay41 = (countRewardDay40).toString() // const countRewardDay41 = (countRewardDay40).toString()
// return countRewardDay41 // return countRewardDay41
// } else if (accountInfo.level === 5) { // } else if (accountInfo.level === 5) {
// if (this.tier4Online < 30) { // if (this.tier4Online < 30) {
// const countRewardDay50 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).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() // const countRewardDay51 = (countRewardDay50).toString()
// return countRewardDay51 // return countRewardDay51
// } else { // } else {
// const countRewardDay50 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count) * this._timeCalc()).toFixed(8) // const countRewardDay50 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[5].count + addressLevel[6].count) * this._timeCalc()).toFixed(8)
// const countRewardDay51 = (countRewardDay50).toString() // const countRewardDay51 = (countRewardDay50).toString()
// return countRewardDay51 // return countRewardDay51
// } // }
// } else if (accountInfo.level === 6) { // } else if (accountInfo.level === 6) {
// if (this.tier4Online < 30) { // if (this.tier4Online < 30) {
// const countRewardDay60 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).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() // const countRewardDay61 = (countRewardDay60).toString()
// return countRewardDay61 // return countRewardDay61
// } else { // } else {
// const countRewardDay60 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count) * this._timeCalc()).toFixed(8) // const countRewardDay60 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[5].count + addressLevel[6].count) * this._timeCalc()).toFixed(8)
// const countRewardDay61 = (countRewardDay60).toString() // const countRewardDay61 = (countRewardDay60).toString()
// return countRewardDay61 // return countRewardDay61
// } // }
// } else if (accountInfo.level === 7) { // } else if (accountInfo.level === 7) {
// if (this.tier4Online < 30) { // if (this.tier4Online < 30) {
// const countRewardDay70 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8) // const countRewardDay70 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8)
// const countRewardDay71 = (countRewardDay70).toString() // const countRewardDay71 = (countRewardDay70).toString()
// return countRewardDay71 // return countRewardDay71
// } else { // } else {
// const countRewardDay70 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8) // const countRewardDay70 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8)
// const countRewardDay71 = (countRewardDay70).toString() // const countRewardDay71 = (countRewardDay70).toString()
// return countRewardDay71 // return countRewardDay71
// } // }
// } else if (accountInfo.level === 8) { // } else if (accountInfo.level === 8) {
// if (this.tier4Online < 30) { // if (this.tier4Online < 30) {
// const countRewardDay80 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8) // const countRewardDay80 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[5].count + addressLevel[6].count + addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8)
// const countRewardDay81 = (countRewardDay80).toString() // const countRewardDay81 = (countRewardDay80).toString()
// return countRewardDay81 // return countRewardDay81
// } else { // } else {
// const countRewardDay80 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8) // const countRewardDay80 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[7].count + addressLevel[8].count) * this._timeCalc()).toFixed(8)
// const countRewardDay81 = (countRewardDay80).toString() // const countRewardDay81 = (countRewardDay80).toString()
// return countRewardDay81 // return countRewardDay81
// } // }
// } else if (accountInfo.level === 9) { // } else if (accountInfo.level === 9) {
// const countRewardDay90 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[9].count + addressLevel[10].count) * this._timeCalc()).toFixed(8) // const countRewardDay90 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[9].count + addressLevel[10].count) * this._timeCalc()).toFixed(8)
// const countRewardDay91 = (countRewardDay90).toString() // const countRewardDay91 = (countRewardDay90).toString()
// return countRewardDay91 // return countRewardDay91
// } else if (accountInfo.level === 10) { // } else if (accountInfo.level === 10) {
// const countRewardDay100 = ((this._blockReward() / 100 * this._tierPercent()) / (addressLevel[9].count + addressLevel[10].count) * this._timeCalc()).toFixed(8) // const countRewardDay100 = ((blockReward(nodeStatus) / 100 * tierPercent(accountInfo, tier4Online)) / (addressLevel[9].count + addressLevel[10].count) * this._timeCalc()).toFixed(8)
// const countRewardDay101 = (countRewardDay100).toString() // const countRewardDay101 = (countRewardDay100).toString()
// return countRewardDay101 // return countRewardDay101
// } // }
@ -388,20 +390,19 @@ export const averageBlockDay = (adminInfo, nodeHeightBlock) => {
return averageBlockDay; return averageBlockDay;
}; };
export const levelUpBlocks = (accountInfo, nodeStatus) => { export const levelUpBlocks = (accountInfo, nodeStatus): number => {
if ( if (
accountInfo?.blocksMinted === undefined || accountInfo?.blocksMinted === undefined ||
nodeStatus?.height === undefined || nodeStatus?.height === undefined ||
accountTargetBlocks(accountInfo?.level) == undefined accountTargetBlocks(accountInfo?.level) == undefined
) )
return null; return 0;
const countBlocks = const countBlocks =
accountTargetBlocks(accountInfo?.level)! - accountTargetBlocks(accountInfo?.level)! -
(accountInfo?.blocksMinted + accountInfo?.blocksMintedAdjustment); (accountInfo?.blocksMinted + accountInfo?.blocksMintedAdjustment);
const countBlocksString = countBlocks.toString(); return countBlocks;
return countBlocksString;
}; };
export const levelUpDays = ( export const levelUpDays = (