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,
countMintersInLevel,
currentTier,
tierPercent,
countReward,
} from './MintingStats.tsx';
export type AddressLevelEntry = {
@ -755,12 +757,24 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
)?.toFixed(0) || ''
}
/>
<StatCard label="Tier Share Per Block" value="13%" />
<StatCard
label="Est. Reward Per Block"
value="0.00506494 QORT"
label="Tier Share Per Block"
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} /> */}
</Grid>
</Paper>

View File

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