diff --git a/hooks/usePoolLiquidity.tsx b/hooks/usePoolLiquidity.tsx index db6f167b..b121df8d 100644 --- a/hooks/usePoolLiquidity.tsx +++ b/hooks/usePoolLiquidity.tsx @@ -200,17 +200,17 @@ export const useMultiplePoolsLiquidity = ({ tokenAmountInMicroDenom: rewardsInfo.totalStakedInMicroDenom, }) || 1 + const totalRewardRatePerYearInDollarValue = + rewardsContracts.contracts.reduce((value, rewardsContract) => { + return ( + value + rewardsContract.rewardRate.ratePerYear.dollarValue + ) + }, 0) + rewardsInfo.yieldPercentageReturn = - rewardsContracts.contracts.reduce( - (yieldReturnValue, rewardsContract) => { - return ( - yieldReturnValue + - rewardsContract.rewardRate.ratePerYear.dollarValue / - rewardsInfo.totalStakedDollarValue - ) - }, - 0 - ) + (totalRewardRatePerYearInDollarValue / + rewardsInfo.totalStakedDollarValue) * + 100 } return { diff --git a/queries/tokenToTokenPriceQuery.ts b/queries/tokenToTokenPriceQuery.ts index 6cef8b75..9064d15d 100644 --- a/queries/tokenToTokenPriceQuery.ts +++ b/queries/tokenToTokenPriceQuery.ts @@ -27,18 +27,21 @@ export async function tokenToTokenPriceQuery({ return 1 } - if (fromTokenInfo.symbol === baseToken.symbol && toTokenInfo.swap_address) { - return formatPrice( - await getToken1ForToken2Price({ - nativeAmount: convertedTokenAmount, - swapAddress: toTokenInfo.swap_address, - rpcEndpoint: chainInfo.rpc, - }) - ) - } else if ( - toTokenInfo.symbol === baseToken.symbol && - fromTokenInfo.swap_address - ) { + const shouldQueryBaseTokenForTokenB = + fromTokenInfo.symbol === baseToken.symbol && toTokenInfo.swap_address + + const shouldQueryTokenBForBaseToken = + toTokenInfo.symbol === baseToken.symbol && fromTokenInfo.swap_address + + if (shouldQueryBaseTokenForTokenB) { + const resp = await getToken1ForToken2Price({ + nativeAmount: convertedTokenAmount, + swapAddress: toTokenInfo.swap_address, + rpcEndpoint: chainInfo.rpc, + }) + + return formatPrice(resp) + } else if (shouldQueryTokenBForBaseToken) { return formatPrice( await getToken2ForToken1Price({ tokenAmount: convertedTokenAmount,