From a6654362f3a122926ddcb85b6019e887c27cf7b4 Mon Sep 17 00:00:00 2001 From: Alec WM <2741569+alecdwm@users.noreply.github.com> Date: Fri, 7 Feb 2025 01:05:30 +1100 Subject: [PATCH] feat: link to analog timechain APR docs (#1798) --- .../src/ui/domains/Staking/Bond/BondForm.tsx | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/apps/extension/src/ui/domains/Staking/Bond/BondForm.tsx b/apps/extension/src/ui/domains/Staking/Bond/BondForm.tsx index 2a710b568..6eb5c667f 100644 --- a/apps/extension/src/ui/domains/Staking/Bond/BondForm.tsx +++ b/apps/extension/src/ui/domains/Staking/Bond/BondForm.tsx @@ -6,6 +6,7 @@ import { ChangeEventHandler, FC, PropsWithChildren, + ReactNode, Suspense, useCallback, useEffect, @@ -310,6 +311,7 @@ export const AmountEdit = () => { } const StakeApr = () => { + const { t } = useTranslation() const { token, poolId } = useBondWizard() let data, isLoading = false, @@ -339,17 +341,60 @@ const StakeApr = () => { return
15.00%
if (isError) { - if (error?.message === STAKING_APR_UNAVAILABLE) return "APR Unavailable" - return
Unable to fetch APR data
+ if (error?.message === STAKING_APR_UNAVAILABLE) { + // fallback to 55% when the yield is unavailable for Analog, + // as we have a link to their docs explaining the APR for their chain + if (token?.chain?.id === "analog-timechain") { + return ( + +
55%
+
+ ) + } + + return t("APR Unavailable") + } + return
{t("Unable to fetch APR data")}
} return ( - {display} + {display} ) } +/** + * For chains with a novel staking rewards mechanism, this component adds an info tooltip to the + * calculated APR which links to the rewards docs for the chain. + */ +const WithAprDocsLink = ({ children }: { children: ReactNode }) => { + const { t } = useTranslation() + const { token } = useBondWizard() + + // return the APR + if (token?.chain?.id !== "analog-timechain") return children + + // return the APR wrapped with a tooltip + return ( +
+ {children} + + + + + + + {t("Learn more about Analog Timechain staking rewards")} + +
+ ) +} + const FeeEstimate = () => { const { feeEstimate, feeToken, isLoadingFeeEstimate, errorFeeEstimate } = useBondWizard()