"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInterestRateForAsset = void 0;
const roundPercentage = (value, decimals = 2) => {
    const factor = 10 ** decimals;
    return Math.round(value * 100 * factor) / factor;
};
function getInterestRateForAsset(asset, interestRates, networks = []) {
    const currencyId = asset.type === "TokenCurrency"
        ? asset.id
        : networks.find(n => n.type === "TokenCurrency" && n.parentCurrency?.id === asset.id)?.id ??
            asset.id;
    const interestRate = interestRates[currencyId] ?? undefined;
    return {
        interestRate,
        interestRatePercentageRounded: interestRate ? roundPercentage(interestRate.value) : 0,
    };
}
exports.getInterestRateForAsset = getInterestRateForAsset;
//# sourceMappingURL=getInterestRateForAsset.js.map