diff --git a/components/Header/stats/apy.tsx b/components/Header/stats/apy.tsx index d0e2b61f..1a6ac862 100644 --- a/components/Header/stats/apy.tsx +++ b/components/Header/stats/apy.tsx @@ -20,7 +20,6 @@ export const APY = () => { const { weightedNetLiquidity, hasNegativeNetLiquidity, assets } = useNonFarmedAssets(); const totalApy = netAPY + netLiquidityAPY; const amount = `${totalApy.toLocaleString(undefined, APY_FORMAT)}%`; - const [showTooltip, setShowTooltip] = useState(false); const showLabels = netAPY > 0 || netLiquidityAPY > 0; const { averageSupplyApy, averageBorrowedApy } = useAverageAPY(); const apyLabels = [ @@ -56,7 +55,7 @@ export const APY = () => { titleTooltip="Net APY = Daily Total Profit / Your Net Liquidity * 365 days" amount={amount} tooltip={tooltip} - labels={apyLabels} + labels={showLabels ? apyLabels : []} /> diff --git a/components/Header/stats/rewards.tsx b/components/Header/stats/rewards.tsx index fba2be21..35181bbd 100644 --- a/components/Header/stats/rewards.tsx +++ b/components/Header/stats/rewards.tsx @@ -58,7 +58,11 @@ export const UserDailyRewards = () => { ], [ { - value: `-${toInternationalCurrencySystem_usd(baseBorrowedUsdDaily)}`, + value: `${ + baseBorrowedUsdDaily > 0 + ? `-${toInternationalCurrencySystem_usd(baseBorrowedUsdDaily)}` + : "$0" + }`, text: "Borrow Interest", }, ], @@ -74,7 +78,7 @@ export const UserDailyRewards = () => { } - labels={rewardsLabels} + labels={totalUsdDaily !== 0 ? rewardsLabels : []} /> ); @@ -139,7 +143,7 @@ const IncentiveMore = ({ farmSuppliedUsdDaily, farmBorrowedUsdDaily, farmNetTvlU setShowTooltip(!showTooltip); }} > -
+
0 ? (boostedShares / totalBoostedShares) * totalRewardsPerDay : 0; - result[rewardTokenId] = new Decimal(result[rewardTokenId] || 0) // TODO + result[rewardTokenId] = new Decimal(result[rewardTokenId] || 0) .plus(dailyAmount) .toNumber(); }); diff --git a/redux/selectors/getAverageAPY.ts b/redux/selectors/getAverageAPY.ts index b3f66479..5a0817e4 100644 --- a/redux/selectors/getAverageAPY.ts +++ b/redux/selectors/getAverageAPY.ts @@ -11,8 +11,8 @@ export const getAverageAPY = createSelector( const [gainBorrowed, totalBorrowed] = getGains(account.portfolio, assets, "borrowed"); const suplyGains = gainCollateral + gainSupplied; const supplyTotals = totalCollateral + totalSupplied; - const averageSupplyApy = (suplyGains / supplyTotals) * 100; - const averageBorrowedApy = (gainBorrowed / totalBorrowed) * 100; + const averageSupplyApy = supplyTotals > 0 ? (suplyGains / supplyTotals) * 100 : 0; + const averageBorrowedApy = totalBorrowed > 0 ? (gainBorrowed / totalBorrowed) * 100 : 0; return { averageSupplyApy, averageBorrowedApy }; }, ); diff --git a/redux/selectors/getAverageBorrowedRewardApy.ts b/redux/selectors/getAverageBorrowedRewardApy.ts index 1c472a49..82f1704f 100644 --- a/redux/selectors/getAverageBorrowedRewardApy.ts +++ b/redux/selectors/getAverageBorrowedRewardApy.ts @@ -88,6 +88,6 @@ export const getAverageBorrowedRewardApy = () => }, [0, 0], ); - return dailyTotalBorrowProfit > 0 ? (dailyTotalBorrowProfit / totalBorrow) * 365 * 100 : 0; + return totalBorrow > 0 ? (dailyTotalBorrowProfit / totalBorrow) * 365 * 100 : 0; }, ); diff --git a/redux/selectors/getAverageNetRewardApy.ts b/redux/selectors/getAverageNetRewardApy.ts index 5676e11b..2bb4c64f 100644 --- a/redux/selectors/getAverageNetRewardApy.ts +++ b/redux/selectors/getAverageNetRewardApy.ts @@ -91,4 +91,7 @@ export const getNetGains = ( return [balanceUSD * (netTvlMultiplier ? 1 : 0), apr]; }) - .reduce(([gain, sum], [balance, apr]) => [gain + balance * apr, sum + balance], [0, 0]); + .reduce( + ([gain, sum], [balanceUSD, apr]) => [gain + balanceUSD * apr, sum + balanceUSD], + [0, 0], + );