UNPKG

@ledgerhq/live-common

Version:
46 lines 2.07 kB
export const stakeProgramsToEarnParam = (stakePrograms) => { const list = stakePrograms?.params?.list ?? []; const redirects = stakePrograms?.params?.redirects ?? {}; const result = {}; const keys = Object.keys(redirects); if (keys.length === 0) { return { stakeProgramsParam: undefined, stakeCurrenciesParam: [] }; } keys.forEach(key => { result[key] = redirects[key].platform; }); return { stakeProgramsParam: result, stakeCurrenciesParam: list }; }; export const getStablecoinYieldSetting = (stakePrograms) => { /** Tether USDT provider is proxy for stablecoin flow rollout. */ const usdtProvider = !stakePrograms?.enabled || !stakePrograms?.params?.redirects ? undefined : stakePrograms?.params?.redirects["ethereum/erc20/usd_tether__erc20_"]?.platform; return !usdtProvider ? "inactive" : usdtProvider === "earn" ? "api" : "dapp"; }; export const getBitcoinYieldSetting = (stakePrograms) => { /** Check if Bitcoin has "earn" provider configured in redirects. */ const bitcoinProvider = !stakePrograms?.enabled || !stakePrograms?.params?.redirects ? undefined : stakePrograms?.params?.redirects["bitcoin"]?.platform; return !bitcoinProvider ? "inactive" : bitcoinProvider === "earn" ? "deposit_screen" : bitcoinProvider; }; export const getEthDepositScreenSetting = (stakePrograms) => { /** Check if Ethereum has "earn" provider configured in redirects with ethDepositCohort. */ const ethereumRedirect = stakePrograms?.enabled ? stakePrograms?.params?.redirects?.["ethereum"] : undefined; // If no ethereum redirect exists, return "standard" // If platform is not "earn", return "standard" if (ethereumRedirect?.platform !== "earn") { return "standard"; } // Extract ethDepositCohort from queryParams const ethDepositCohort = ethereumRedirect.queryParams?.ethDepositCohort; return ethDepositCohort ?? "missing_cohort_value"; }; //# sourceMappingURL=index.js.map