UNPKG

@ledgerhq/live-common

Version:
33 lines 1.72 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.useLeftAccountsApyModule = useLeftAccountsApyModule; const react_1 = __importDefault(require("react")); const useInterestRatesByCurrencies_1 = require("../../dada-client/hooks/useInterestRatesByCurrencies"); const getInterestRateForAsset_1 = require("../utils/getInterestRateForAsset"); function useLeftAccountsApyModule(params, { useAccountData, accountsCountAndApy, ApyIndicator, }) { const { networks } = params; const accountData = useAccountData(params); const interestRates = (0, useInterestRatesByCurrencies_1.useInterestRatesByCurrencies)(networks); return accountData.map(({ asset, label, count }) => { const { interestRate, interestRatePercentageRounded } = (0, getInterestRateForAsset_1.getInterestRateForAsset)(asset, interestRates, networks); if ((!interestRate || interestRatePercentageRounded <= 0) && count <= 0) { return { count, }; } return { leftElement: accountsCountAndApy({ label: count > 0 ? label : undefined, value: interestRatePercentageRounded, type: interestRate?.type, }), description: count > 0 ? label : undefined, apy: interestRate && interestRatePercentageRounded > 0 ? (react_1.default.createElement(ApyIndicator, { value: interestRatePercentageRounded, type: interestRate.type })) : undefined, count, }; }); } //# sourceMappingURL=useLeftAccountsApy.js.map