Skip to content

Commit

Permalink
Update calculate Node Annualized Yield, Replace 0 totalPos with 1
Browse files Browse the repository at this point in the history
  • Loading branch information
leej1012 committed Jan 17, 2024
1 parent 13c13f8 commit 6866327
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,15 @@ public void updateNodeAnnualizedYield() throws Exception {
foundationInspire = first.multiply(currentStake).multiply(new BigDecimal(1).add(second));
}

BigDecimal initPercent = nodeStake.divide(currentStake, 12, BigDecimal.ROUND_HALF_UP);
BigDecimal stakePercent = totalPos.divide(currentStake, 12, BigDecimal.ROUND_HALF_UP);
if (totalPos.compareTo(BigDecimal.ZERO) == 0) {
totalPos = new BigDecimal(paramsConfig.insteadZeroPos);
}
if (userStake.compareTo(BigDecimal.ZERO) == 0) {
userStake = new BigDecimal(paramsConfig.insteadZeroPos);
}

BigDecimal initPercent = nodeStake.divide(currentStake, 12, RoundingMode.HALF_UP);
BigDecimal stakePercent = totalPos.divide(currentStake, 12, RoundingMode.HALF_UP);

BigDecimal initPartFinalReleaseOng = finalReleaseOng.multiply(initPercent);
BigDecimal stakePartFinalReleaseOng = finalReleaseOng.multiply(stakePercent);
Expand All @@ -611,13 +618,6 @@ public void updateNodeAnnualizedYield() throws Exception {
BigDecimal finalUserCommission = (initPartFinalCommission.multiply(initUserProportion)).add((stakePartFinalCommission.multiply(stakeUserProportion)));
BigDecimal finalNodeCommission = (initPartFinalCommission.multiply(initNodeProportion)).add((stakePartFinalCommission.multiply(stakeNodeProportion)));

if (totalPos.compareTo(BigDecimal.ZERO) == 0) {
totalPos = new BigDecimal(paramsConfig.insteadZeroPos);
}
if (userStake.compareTo(BigDecimal.ZERO) == 0) {
userStake = new BigDecimal(paramsConfig.insteadZeroPos);
}

BigDecimal nodeStakeUsd = nodeStake.multiply(ont);
BigDecimal totalPosUsd = totalPos.multiply(ont);
BigDecimal userStakeUsd = userStake.multiply(ont);
Expand Down

0 comments on commit 6866327

Please sign in to comment.