@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
30 lines • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLeftAccountsApyModule = void 0;
const useInterestRatesByCurrencies_1 = require("../../dada-client/hooks/useInterestRatesByCurrencies");
const getInterestRateForAsset_1 = require("../utils/getInterestRateForAsset");
function useLeftAccountsApyModule(params, useAccountData, accountsCountAndApy, networks) {
const accountData = useAccountData(params);
const interestRates = (0, useInterestRatesByCurrencies_1.useInterestRatesByCurrencies)(networks);
// Map each account to its APY info using the shared utility
return accountData.map(({ asset, label, count }) => {
const { interestRate, interestRatePercentageRounded } = (0, getInterestRateForAsset_1.getInterestRateForAsset)(asset, interestRates, networks);
if ((!interestRate || interestRatePercentageRounded <= 0) && count <= 0) {
return {
...asset,
count,
};
}
return {
...asset,
leftElement: accountsCountAndApy({
label: count > 0 ? label : undefined,
value: interestRatePercentageRounded,
type: interestRate?.type,
}),
count,
};
});
}
exports.useLeftAccountsApyModule = useLeftAccountsApyModule;
//# sourceMappingURL=useLeftAccountsApy.js.map