Skip to content

Commit

Permalink
feat: ✨ add new APR api (osmosis-labs#2688)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideSegullo authored Jan 14, 2024
1 parent 7f765a7 commit 9f87c02
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions packages/web/components/your-balance/your-balance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CoinPretty, Dec, IntPretty } from "@keplr-wallet/unit";
import { CoinPretty, Dec } from "@keplr-wallet/unit";
import {
ObservableConcentratedPoolDetail,
ObservableQueryPool,
Expand All @@ -24,6 +24,7 @@ import {
useDisclosure,
useFakeFeeConfig,
useFeatureFlags,
useGetApr,
useHideDustUserSetting,
useStakedAmountConfig,
useTransferConfig,
Expand Down Expand Up @@ -66,6 +67,7 @@ const YourBalance = observer(
} = useStore();
const featureFlags = useFeatureFlags();
const { t } = useTranslation();
const { stakingAPR } = useGetApr();
const language = useCurrentLanguage();
const osmosisChainId = chainStore.osmosis.chainId;
const account = accountStore.getWallet(osmosisChainId);
Expand All @@ -89,20 +91,6 @@ const YourBalance = observer(
userOsmoAddress: account?.address,
});

const chain = useMemo(
() =>
ChainList.find((chain) =>
chain.keplrChain.currencies.find(
(currency) => currency.coinDenom === denom.toUpperCase()
)
),
[denom]
);

const inflationApr = chain
? queriesStore.get(chain.chain_id).cosmos.queryInflation.inflation
: new IntPretty(0);

const details = useMemo(() => {
return tokenDetailsByLanguage
? tokenDetailsByLanguage[language]
Expand Down Expand Up @@ -281,11 +269,11 @@ const YourBalance = observer(
sub={
hasStakingBalance
? formatPretty(balance)
: inflationApr.toDec().isZero()
: !isOsmo
? t("tokenInfos.stakeYourDenomToEarnNoAPR", { denom })
: t("tokenInfos.stakeYourDenomToEarn", {
denom,
apr: inflationApr.maxDecimals(1).toString(),
apr: stakingAPR.truncate().toString(),
})
}
image={
Expand Down

0 comments on commit 9f87c02

Please sign in to comment.