"use strict";
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, accountsApy) {
    const { networks } = params;
    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 {
                count,
            };
        }
        return {
            leftElement: accountsCountAndApy({
                label: count > 0 ? label : undefined,
                value: interestRatePercentageRounded,
                type: interestRate?.type,
            }),
            description: count > 0 ? label : undefined,
            apy: accountsApy({
                value: interestRatePercentageRounded,
                type: interestRate?.type,
            }),
            count,
        };
    });
}
exports.useLeftAccountsApyModule = useLeftAccountsApyModule;
//# sourceMappingURL=useLeftAccountsApy.js.map