diff --git a/CHANGELOG.md b/CHANGELOG.md index 34eb45c4f..9347b1584 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ Version changes are pinned to SDK releases. ## Unreleased +## [1.10.3] 2023-09-18 + +- New function updateOpenOrdersSync() in CrossClient. ([#272](https://github.com/zetamarkets/sdk/pull/272)) + ## [1.10.2] 2023-09-15 - Bugfix: Unsubscribe from orderbooks on Exchange.close(). ([#271](https://github.com/zetamarkets/sdk/pull/271)) diff --git a/package.json b/package.json index c2222f5a1..63a45634b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@zetamarkets/sdk", "repository": "https://github.com/zetamarkets/sdk/", - "version": "1.10.2", + "version": "1.10.3", "description": "Zeta SDK", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/cross-client.ts b/src/cross-client.ts index ff7a1492c..b2b314f36 100644 --- a/src/cross-client.ts +++ b/src/cross-client.ts @@ -2360,7 +2360,7 @@ export class CrossClient { return this._positions.get(asset); } - public async updateOrders() { + public updateOpenOrdersSync() { if (this._account == null) { console.log("User has no margin account, cannot update orders."); return; @@ -2368,16 +2368,14 @@ export class CrossClient { let orders = []; - await Promise.all( - Exchange.assets.map(async (asset) => { - let market = Exchange.getPerpMarket(asset); - orders.push( - market.getOrdersForAccount( - this._openOrdersAccounts[assetToIndex(asset)] - ) - ); - }) - ); + Exchange.assets.forEach((asset) => { + let market = Exchange.getPerpMarket(asset); + orders.push( + market.getOrdersForAccount( + this._openOrdersAccounts[assetToIndex(asset)] + ) + ); + }); let allOrders = [].concat(...orders); let allOrdersFiltered = allOrders.filter(function (order: types.Order) { @@ -2395,16 +2393,20 @@ export class CrossClient { ); }); let ordersByAsset = new Map(); - await Promise.all( - Exchange.assets.map(async (asset) => { - ordersByAsset.set(asset, []); - }) - ); + + Exchange.assets.forEach((asset) => { + ordersByAsset.set(asset, []); + }); + for (var order of allOrdersFiltered) { ordersByAsset.get(order.asset).push(order); } this._orders = ordersByAsset; + } + + public async updateOrders() { + this.updateOpenOrdersSync(); let triggerOrderBits = [];