Skip to content

Commit

Permalink
Merge pull request #1477 from multiversx/MEX-514-compute-user-boosted…
Browse files Browse the repository at this point in the history
…-apr

[MEX-514] fix compute user APR if no total staked amount
  • Loading branch information
claudiulataretu authored Sep 16, 2024
2 parents 450aa76 + 0a6500d commit 3bc63f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/modules/farm/v2/services/farm.v2.compute.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ export class FarmComputeServiceV2
.plus(additionalUserFarmAmount)
.toFixed();

if (userTotalFarmPosition === '0') {
return 0;
}

const userRewardsPerWeek = await this.computeUserRewardsForWeek(
scAddress,
userAddress,
Expand Down Expand Up @@ -385,6 +389,10 @@ export class FarmComputeServiceV2
.plus(additionalUserFarmAmount)
.toFixed();

if (userTotalFarmPosition === '0') {
return 0;
}

const userMaxRewardsPerWeek = new BigNumber(
boostedRewardsPerWeek[0].amount,
)
Expand Down
8 changes: 8 additions & 0 deletions src/modules/staking/services/staking.compute.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,10 @@ export class StakingComputeService {
.plus(additionalUserStakeAmount)
.toFixed();

if (userTotalStakePosition === '0') {
return 0;
}

const userRewardsPerWeek = await this.computeUserRewardsForWeek(
scAddress,
userAddress,
Expand Down Expand Up @@ -726,6 +730,10 @@ export class StakingComputeService {
.plus(additionalUserStakeAmount)
.toFixed();

if (userTotalStakePosition === '0') {
return 0;
}

const userMaxRewardsPerWeek = new BigNumber(
boostedRewardsPerWeek[0].amount,
)
Expand Down

0 comments on commit 3bc63f2

Please sign in to comment.