Skip to content

Commit

Permalink
optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
xieqian committed Mar 13, 2024
1 parent 8b38c26 commit 41421c7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions redux/selectors/getAccountRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export const computePoolsDailyAmount = (
shrinkToken(farmData.asset_farm_reward.reward_per_day, rewardAssetDecimals),
);

const dailyAmount = (boostedShares / totalBoostedShares) * totalRewardsPerDay;
const dailyAmount =
totalBoostedShares > 0 ? (boostedShares / totalBoostedShares) * totalRewardsPerDay : 0;

const suppliedShares = Number(
shrinkToken(portfolio.supplied[asset.token_id]?.shares || 0, assetDecimals),
Expand All @@ -102,7 +103,8 @@ export const computePoolsDailyAmount = (
const shares = type === "supplied" ? suppliedShares + collateralShares : borrowedShares;
const newBoostedShares = shares * multiplier;
const newTotalBoostedShares = totalBoostedShares + newBoostedShares - boostedShares;
const newDailyAmount = (newBoostedShares / newTotalBoostedShares) * totalRewardsPerDay;
const newDailyAmount =
newTotalBoostedShares > 0 ? (newBoostedShares / newTotalBoostedShares) * totalRewardsPerDay : 0;

return { dailyAmount, newDailyAmount, multiplier, totalBoostedShares, shares };
};
Expand Down

0 comments on commit 41421c7

Please sign in to comment.