@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
19 lines • 768 B
JavaScript
import { useSelector } from "react-redux";
import { selectInterestRateByCurrency } from "../entities/interestRateSelectors";
const isValidApyType = (type) => type === "NRR" || type === "APY" || type === "APR";
export const useInterestRatesByCurrencies = (currencies) => {
return useSelector((state) => {
const rates = {};
for (const currency of currencies) {
const apiRate = selectInterestRateByCurrency(state, currency.id);
if (apiRate && isValidApyType(apiRate.type)) {
rates[currency.id] = {
value: apiRate.rate,
type: apiRate.type,
};
}
}
return rates;
});
};
//# sourceMappingURL=useInterestRatesByCurrencies.js.map