@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
19 lines • 802 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInterestRateForAsset = getInterestRateForAsset;
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,
};
}
//# sourceMappingURL=getInterestRateForAsset.js.map