UNPKG

@ledgerhq/live-common

Version:
19 lines 802 B
"use strict"; 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