import { groupAccountsByAsset } from "./groupAccountsByAsset";
import BigNumber from "bignumber.js";
export const getBalanceAndFiatValueByAssets = (accounts, assets, counterValuesState, targetCurrency) => {
    const groupedAccountsByAsset = groupAccountsByAsset(accounts, counterValuesState, targetCurrency);
    return assets.map(asset => {
        const assetGroup = groupedAccountsByAsset[asset.id];
        if (assetGroup) {
            return yieldAssetDetails(assetGroup, asset);
        }
        return {
            id: asset.id,
            name: asset.name,
            ticker: asset.ticker,
            currency: asset,
            balance: new BigNumber(0),
            fiatValue: 0,
        };
    });
};
const yieldAssetDetails = (assetGroup, asset) => {
    // Use the reference currency for consistent magnitude
    const assetDetails = assetGroup.referenceCurrency;
    return {
        id: asset.id,
        name: asset.name,
        ticker: asset.ticker,
        currency: assetDetails,
        balance: assetGroup.totalBalance,
        fiatValue: assetGroup.totalFiatValue.toNumber(),
    };
};
//# sourceMappingURL=getBalanceAndFiatValueByAssets.js.map