Skip to content

Commit

Permalink
fix(exchanges, accountAssets): fix normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
bludnic committed Aug 23, 2024
1 parent 3b5c85c commit 2f6b166
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/exchanges/src/exchanges/ccxt/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import { normalizeOrderStatus } from "../../utils/normalizeOrderStatus.js";

const accountAssets: Normalize["accountAssets"] = {
response: (data) =>
Object.entries(data).map(([currency, balance]) => {
return {
currency,
balance: Number(balance.total),
availableBalance: Number(balance.free),
};
Object.entries(data).flatMap(([currency, balance]) => {
// exclude non-coin keys like "timestamp", "info", etc.
const isCoin = balance?.total && balance?.free;
if (!isCoin) return [];

return [
{
currency,
balance: Number(balance.total),
availableBalance: Number(balance.free),
},
];
}),
};

Expand Down

0 comments on commit 2f6b166

Please sign in to comment.