@myx-trade/sdk 0.1.27 → 0.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1220,8 +1220,8 @@ declare class SubScription {
1220
1220
  /**
1221
1221
  * tickers subscription methods
1222
1222
  */
1223
- subscribeTickers(globalId: number, callback: OnTickersCallback): void;
1224
- unsubscribeTickers(globalId: number, callback: OnTickersCallback): void;
1223
+ subscribeTickers(globalIds: number | number[], callback: OnTickersCallback): void;
1224
+ unsubscribeTickers(globalIds: number | number[], callback: OnTickersCallback): void;
1225
1225
  /**
1226
1226
  * kline subscription methods
1227
1227
  */
@@ -1576,6 +1576,10 @@ declare class MyxClient {
1576
1576
  * close the client
1577
1577
  */
1578
1578
  close(): void;
1579
+ /**
1580
+ * get access token
1581
+ */
1582
+ getAccessToken(): Promise<string | null>;
1579
1583
  }
1580
1584
 
1581
1585
  export { type AccessTokenRequest, type AccessTokenResponse$1 as AccessTokenResponse, type AccessTokenType, type AddFavoriteParams, type Address$1 as Address, type ApiResponse, type BaseDetailResponse, type BaseResponse, COMMON_LP_AMOUNT_DECIMALS, COMMON_PRICE_DECIMALS, ChainId, type ChainIdRequest, CloseTypeEnum, type DashboardType, Direction, DirectionEnum, ErrorCode, ExecTypeEnum, type FavoritesListItem, type FavoritesListParams, type FavoritesTimeInterval, type FavoritesType, type GetBaseDetailParams, type GetHistoryOrdersParams, type GetKlineDataParams, type GetMarketDetailParams, type GetPoolLevelConfigParams, type GetTickerDataParams, type HistoryOrderItem, HttpKlineIntervalEnum, type KlineDataItemType, type KlineDataResponse, type KlineResolution, type LevelConfig, Market, MarketCapType, type MarketDetailResponse, type MarketInfo, type MarketInfoMap, type MarketPool, type MarketPoolResponse, MarketPoolState, MarketType, MyxClient, type MyxClientConfig, type MyxSubscriptionOptions, type NetWorkFee, type ObjectType, type OnKlineCallback, type OnOrderCallback, type OnPositionCallback, type OnTickersAllCallback, type OnTickersCallback, OperationEnum, OperationType, OracleType, type Order$1 as Order, OrderStatus, OrderStatusEnum, OrderType, OrderTypeEnum, type PlaceOrderParams, type PoolLevelConfig, type PoolOpenOrder, type PoolOpenOrdersResponse, type PoolResponse, type Position$1 as Position, type PositionHistoryItem, type PositionResponse, type PositionTpSlOrderParams, type PositionType, type PriceResponse, type PriceType, type RemoveFavoriteParams, type SearchMarketParams, type SearchResultContractItem, type SearchResultCookItem, type SearchResultEarnItem, type SearchResultResponse, SearchSecondTypeEnum, SearchTypeEnum, type StatDashBoardResponse, type TickerDataItem, type TickersDataResponse, TimeInForce, type TradeFlowItem, type TradingResult, TriggerType, TriggerTypeEnum, type UpdateOrderTpSlParams, addFavorite, approve, index$2 as base, baseUrl, bigintAmountSlipperCalculator, bigintTradingGasPriceWithRatio, bigintTradingGasToRatioCalculator, getAllTickers, getAllowanceApproved, getBalanceOf, getBaseDetail, getFavoritesList, getHistoryOrders, getKlineData, getKlineLatestBar, getMarketDetail, getOraclePrice, getOrders, getPoolDetail, getPoolLevelConfig, getPoolOpenOrders, getPositionHistory, getPositions, getPriceData, getPricesData, getTickerData, getTokenInfo, getTradeFlow, index as market, index$3 as pool, index$1 as quote, removeFavorite, searchMarket, searchMarketAuth };
package/dist/index.d.ts CHANGED
@@ -1220,8 +1220,8 @@ declare class SubScription {
1220
1220
  /**
1221
1221
  * tickers subscription methods
1222
1222
  */
1223
- subscribeTickers(globalId: number, callback: OnTickersCallback): void;
1224
- unsubscribeTickers(globalId: number, callback: OnTickersCallback): void;
1223
+ subscribeTickers(globalIds: number | number[], callback: OnTickersCallback): void;
1224
+ unsubscribeTickers(globalIds: number | number[], callback: OnTickersCallback): void;
1225
1225
  /**
1226
1226
  * kline subscription methods
1227
1227
  */
@@ -1576,6 +1576,10 @@ declare class MyxClient {
1576
1576
  * close the client
1577
1577
  */
1578
1578
  close(): void;
1579
+ /**
1580
+ * get access token
1581
+ */
1582
+ getAccessToken(): Promise<string | null>;
1579
1583
  }
1580
1584
 
1581
1585
  export { type AccessTokenRequest, type AccessTokenResponse$1 as AccessTokenResponse, type AccessTokenType, type AddFavoriteParams, type Address$1 as Address, type ApiResponse, type BaseDetailResponse, type BaseResponse, COMMON_LP_AMOUNT_DECIMALS, COMMON_PRICE_DECIMALS, ChainId, type ChainIdRequest, CloseTypeEnum, type DashboardType, Direction, DirectionEnum, ErrorCode, ExecTypeEnum, type FavoritesListItem, type FavoritesListParams, type FavoritesTimeInterval, type FavoritesType, type GetBaseDetailParams, type GetHistoryOrdersParams, type GetKlineDataParams, type GetMarketDetailParams, type GetPoolLevelConfigParams, type GetTickerDataParams, type HistoryOrderItem, HttpKlineIntervalEnum, type KlineDataItemType, type KlineDataResponse, type KlineResolution, type LevelConfig, Market, MarketCapType, type MarketDetailResponse, type MarketInfo, type MarketInfoMap, type MarketPool, type MarketPoolResponse, MarketPoolState, MarketType, MyxClient, type MyxClientConfig, type MyxSubscriptionOptions, type NetWorkFee, type ObjectType, type OnKlineCallback, type OnOrderCallback, type OnPositionCallback, type OnTickersAllCallback, type OnTickersCallback, OperationEnum, OperationType, OracleType, type Order$1 as Order, OrderStatus, OrderStatusEnum, OrderType, OrderTypeEnum, type PlaceOrderParams, type PoolLevelConfig, type PoolOpenOrder, type PoolOpenOrdersResponse, type PoolResponse, type Position$1 as Position, type PositionHistoryItem, type PositionResponse, type PositionTpSlOrderParams, type PositionType, type PriceResponse, type PriceType, type RemoveFavoriteParams, type SearchMarketParams, type SearchResultContractItem, type SearchResultCookItem, type SearchResultEarnItem, type SearchResultResponse, SearchSecondTypeEnum, SearchTypeEnum, type StatDashBoardResponse, type TickerDataItem, type TickersDataResponse, TimeInForce, type TradeFlowItem, type TradingResult, TriggerType, TriggerTypeEnum, type UpdateOrderTpSlParams, addFavorite, approve, index$2 as base, baseUrl, bigintAmountSlipperCalculator, bigintTradingGasPriceWithRatio, bigintTradingGasToRatioCalculator, getAllTickers, getAllowanceApproved, getBalanceOf, getBaseDetail, getFavoritesList, getHistoryOrders, getKlineData, getKlineLatestBar, getMarketDetail, getOraclePrice, getOrders, getPoolDetail, getPoolLevelConfig, getPoolOpenOrders, getPositionHistory, getPositions, getPriceData, getPricesData, getTickerData, getTokenInfo, getTradeFlow, index as market, index$3 as pool, index$1 as quote, removeFavorite, searchMarket, searchMarketAuth };
package/dist/index.js CHANGED
@@ -1827,7 +1827,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
1827
1827
  // package.json
1828
1828
  var package_default = {
1829
1829
  name: "@myx-trade/sdk",
1830
- version: "0.1.27",
1830
+ version: "0.1.29",
1831
1831
  private: false,
1832
1832
  publishConfig: {
1833
1833
  access: "public"
@@ -11458,49 +11458,71 @@ var MyxWebSocketClient = class {
11458
11458
  /**
11459
11459
  * subscribe
11460
11460
  * support multiple consumers subscribing to the same listenerId, only send one subscription message
11461
+ * support batch subscription: pass an array of subscriptions to subscribe multiple topics at once
11461
11462
  */
11462
11463
  subscribe(subscription, callback) {
11463
- const subscriptionId = generateListenerId(subscription);
11464
- if (this.subscriptions.has(subscriptionId)) {
11465
- const existingSubscription = this.subscriptions.get(subscriptionId);
11466
- existingSubscription.callbacks.add(callback);
11467
- this.logger.debug(
11468
- `add callback to existing subscription: ${subscriptionId}`
11469
- );
11470
- } else {
11471
- const subscriptionObj = {
11472
- id: subscriptionId,
11473
- topic: subscription.topic,
11474
- callbacks: /* @__PURE__ */ new Set([callback])
11475
- };
11476
- this.subscriptions.set(subscriptionId, subscriptionObj);
11477
- this.logger.debug(`create new subscription: ${subscriptionId}`);
11464
+ const subscriptionList = Array.isArray(subscription) ? subscription : [subscription];
11465
+ const newSubscriptionIds = [];
11466
+ const processedIds = /* @__PURE__ */ new Set();
11467
+ subscriptionList.forEach((subscriptionItem) => {
11468
+ const subscriptionId = generateListenerId(subscriptionItem);
11469
+ if (processedIds.has(subscriptionId)) {
11470
+ return;
11471
+ }
11472
+ processedIds.add(subscriptionId);
11473
+ if (this.subscriptions.has(subscriptionId)) {
11474
+ const existingSubscription = this.subscriptions.get(subscriptionId);
11475
+ existingSubscription.callbacks.add(callback);
11476
+ this.logger.debug(
11477
+ `add callback to existing subscription: ${subscriptionId}`
11478
+ );
11479
+ } else {
11480
+ const subscriptionObj = {
11481
+ id: subscriptionId,
11482
+ topic: subscriptionItem.topic,
11483
+ callbacks: /* @__PURE__ */ new Set([callback])
11484
+ };
11485
+ this.subscriptions.set(subscriptionId, subscriptionObj);
11486
+ newSubscriptionIds.push(subscriptionId);
11487
+ this.logger.debug(`create new subscription: ${subscriptionId}`);
11488
+ }
11489
+ });
11490
+ if (newSubscriptionIds.length > 0) {
11478
11491
  this.send({
11479
11492
  request: "subv2" /* SubscribeV2 */,
11480
- args: [subscriptionId]
11493
+ args: newSubscriptionIds
11481
11494
  });
11482
11495
  }
11483
11496
  }
11484
11497
  /**
11485
11498
  * unsubscribe
11486
11499
  * unsubscribe by callback, only send unsubscribe message when all callbacks are removed
11500
+ * support batch unsubscribe: pass an array of subscriptions to unsubscribe multiple topics at once
11487
11501
  */
11488
11502
  unsubscribe(subscriptions, callback) {
11489
11503
  if (!subscriptions) return;
11504
+ const subscriptionList = Array.isArray(subscriptions) ? subscriptions : [subscriptions];
11490
11505
  const subscriptionsToUnsubscribe = [];
11491
- const subscriptionId = generateListenerId(subscriptions);
11492
- const subscriptionObj = this.subscriptions.get(subscriptionId);
11493
- if (subscriptionObj) {
11494
- subscriptionObj.callbacks.delete(callback);
11495
- this.logger.debug(`remove callback from subscription: ${subscriptionId}`);
11496
- if (subscriptionObj.callbacks.size === 0) {
11497
- this.subscriptions.delete(subscriptionId);
11498
- subscriptionsToUnsubscribe.push(subscriptionId);
11499
- this.logger.debug(
11500
- `subscription ${subscriptionId} has no callbacks, will unsubscribe`
11501
- );
11506
+ const processedIds = /* @__PURE__ */ new Set();
11507
+ subscriptionList.forEach((subscriptionItem) => {
11508
+ const subscriptionId = generateListenerId(subscriptionItem);
11509
+ if (processedIds.has(subscriptionId)) {
11510
+ return;
11502
11511
  }
11503
- }
11512
+ processedIds.add(subscriptionId);
11513
+ const subscriptionObj = this.subscriptions.get(subscriptionId);
11514
+ if (subscriptionObj) {
11515
+ subscriptionObj.callbacks.delete(callback);
11516
+ this.logger.debug(`remove callback from subscription: ${subscriptionId}`);
11517
+ if (subscriptionObj.callbacks.size === 0) {
11518
+ this.subscriptions.delete(subscriptionId);
11519
+ subscriptionsToUnsubscribe.push(subscriptionId);
11520
+ this.logger.debug(
11521
+ `subscription ${subscriptionId} has no callbacks, will unsubscribe`
11522
+ );
11523
+ }
11524
+ }
11525
+ });
11504
11526
  if (subscriptionsToUnsubscribe.length > 0) {
11505
11527
  this.send({
11506
11528
  request: "unsubv2" /* UnsubscribeV2 */,
@@ -11757,27 +11779,25 @@ var SubScription = class {
11757
11779
  /**
11758
11780
  * tickers subscription methods
11759
11781
  */
11760
- subscribeTickers(globalId, callback) {
11761
- this.logger.debug(`subscribe tickers ${globalId}`);
11782
+ subscribeTickers(globalIds, callback) {
11783
+ this.logger.debug(`subscribe tickers ${globalIds}`);
11784
+ const globalIdsList = Array.isArray(globalIds) ? globalIds : [globalIds];
11762
11785
  this.wsClient.subscribe(
11763
- {
11786
+ globalIdsList.map((globalId) => ({
11764
11787
  topic: "ticker" /* Ticker */,
11765
- params: {
11766
- globalId
11767
- }
11768
- },
11788
+ params: { globalId }
11789
+ })),
11769
11790
  callback
11770
11791
  );
11771
11792
  }
11772
- unsubscribeTickers(globalId, callback) {
11773
- this.logger.debug(`unsubscribe tickers ${globalId}`);
11793
+ unsubscribeTickers(globalIds, callback) {
11794
+ this.logger.debug(`unsubscribe tickers ${globalIds}`);
11795
+ const globalIdsList = Array.isArray(globalIds) ? globalIds : [globalIds];
11774
11796
  this.wsClient.unsubscribe(
11775
- {
11797
+ globalIdsList.map((globalId) => ({
11776
11798
  topic: "ticker" /* Ticker */,
11777
- params: {
11778
- globalId
11779
- }
11780
- },
11799
+ params: { globalId }
11800
+ })),
11781
11801
  callback
11782
11802
  );
11783
11803
  }
@@ -18253,6 +18273,12 @@ var MyxClient = class {
18253
18273
  this.configManager.clear();
18254
18274
  this.subscription.disconnect();
18255
18275
  }
18276
+ /**
18277
+ * get access token
18278
+ */
18279
+ async getAccessToken() {
18280
+ return await this.configManager.getAccessToken();
18281
+ }
18256
18282
  };
18257
18283
  // Annotate the CommonJS export names for ESM import in node:
18258
18284
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -1742,7 +1742,7 @@ var RotationProvider = class extends BaseProvider {
1742
1742
  // package.json
1743
1743
  var package_default = {
1744
1744
  name: "@myx-trade/sdk",
1745
- version: "0.1.27",
1745
+ version: "0.1.29",
1746
1746
  private: false,
1747
1747
  publishConfig: {
1748
1748
  access: "public"
@@ -11373,49 +11373,71 @@ var MyxWebSocketClient = class {
11373
11373
  /**
11374
11374
  * subscribe
11375
11375
  * support multiple consumers subscribing to the same listenerId, only send one subscription message
11376
+ * support batch subscription: pass an array of subscriptions to subscribe multiple topics at once
11376
11377
  */
11377
11378
  subscribe(subscription, callback) {
11378
- const subscriptionId = generateListenerId(subscription);
11379
- if (this.subscriptions.has(subscriptionId)) {
11380
- const existingSubscription = this.subscriptions.get(subscriptionId);
11381
- existingSubscription.callbacks.add(callback);
11382
- this.logger.debug(
11383
- `add callback to existing subscription: ${subscriptionId}`
11384
- );
11385
- } else {
11386
- const subscriptionObj = {
11387
- id: subscriptionId,
11388
- topic: subscription.topic,
11389
- callbacks: /* @__PURE__ */ new Set([callback])
11390
- };
11391
- this.subscriptions.set(subscriptionId, subscriptionObj);
11392
- this.logger.debug(`create new subscription: ${subscriptionId}`);
11379
+ const subscriptionList = Array.isArray(subscription) ? subscription : [subscription];
11380
+ const newSubscriptionIds = [];
11381
+ const processedIds = /* @__PURE__ */ new Set();
11382
+ subscriptionList.forEach((subscriptionItem) => {
11383
+ const subscriptionId = generateListenerId(subscriptionItem);
11384
+ if (processedIds.has(subscriptionId)) {
11385
+ return;
11386
+ }
11387
+ processedIds.add(subscriptionId);
11388
+ if (this.subscriptions.has(subscriptionId)) {
11389
+ const existingSubscription = this.subscriptions.get(subscriptionId);
11390
+ existingSubscription.callbacks.add(callback);
11391
+ this.logger.debug(
11392
+ `add callback to existing subscription: ${subscriptionId}`
11393
+ );
11394
+ } else {
11395
+ const subscriptionObj = {
11396
+ id: subscriptionId,
11397
+ topic: subscriptionItem.topic,
11398
+ callbacks: /* @__PURE__ */ new Set([callback])
11399
+ };
11400
+ this.subscriptions.set(subscriptionId, subscriptionObj);
11401
+ newSubscriptionIds.push(subscriptionId);
11402
+ this.logger.debug(`create new subscription: ${subscriptionId}`);
11403
+ }
11404
+ });
11405
+ if (newSubscriptionIds.length > 0) {
11393
11406
  this.send({
11394
11407
  request: "subv2" /* SubscribeV2 */,
11395
- args: [subscriptionId]
11408
+ args: newSubscriptionIds
11396
11409
  });
11397
11410
  }
11398
11411
  }
11399
11412
  /**
11400
11413
  * unsubscribe
11401
11414
  * unsubscribe by callback, only send unsubscribe message when all callbacks are removed
11415
+ * support batch unsubscribe: pass an array of subscriptions to unsubscribe multiple topics at once
11402
11416
  */
11403
11417
  unsubscribe(subscriptions, callback) {
11404
11418
  if (!subscriptions) return;
11419
+ const subscriptionList = Array.isArray(subscriptions) ? subscriptions : [subscriptions];
11405
11420
  const subscriptionsToUnsubscribe = [];
11406
- const subscriptionId = generateListenerId(subscriptions);
11407
- const subscriptionObj = this.subscriptions.get(subscriptionId);
11408
- if (subscriptionObj) {
11409
- subscriptionObj.callbacks.delete(callback);
11410
- this.logger.debug(`remove callback from subscription: ${subscriptionId}`);
11411
- if (subscriptionObj.callbacks.size === 0) {
11412
- this.subscriptions.delete(subscriptionId);
11413
- subscriptionsToUnsubscribe.push(subscriptionId);
11414
- this.logger.debug(
11415
- `subscription ${subscriptionId} has no callbacks, will unsubscribe`
11416
- );
11421
+ const processedIds = /* @__PURE__ */ new Set();
11422
+ subscriptionList.forEach((subscriptionItem) => {
11423
+ const subscriptionId = generateListenerId(subscriptionItem);
11424
+ if (processedIds.has(subscriptionId)) {
11425
+ return;
11417
11426
  }
11418
- }
11427
+ processedIds.add(subscriptionId);
11428
+ const subscriptionObj = this.subscriptions.get(subscriptionId);
11429
+ if (subscriptionObj) {
11430
+ subscriptionObj.callbacks.delete(callback);
11431
+ this.logger.debug(`remove callback from subscription: ${subscriptionId}`);
11432
+ if (subscriptionObj.callbacks.size === 0) {
11433
+ this.subscriptions.delete(subscriptionId);
11434
+ subscriptionsToUnsubscribe.push(subscriptionId);
11435
+ this.logger.debug(
11436
+ `subscription ${subscriptionId} has no callbacks, will unsubscribe`
11437
+ );
11438
+ }
11439
+ }
11440
+ });
11419
11441
  if (subscriptionsToUnsubscribe.length > 0) {
11420
11442
  this.send({
11421
11443
  request: "unsubv2" /* UnsubscribeV2 */,
@@ -11672,27 +11694,25 @@ var SubScription = class {
11672
11694
  /**
11673
11695
  * tickers subscription methods
11674
11696
  */
11675
- subscribeTickers(globalId, callback) {
11676
- this.logger.debug(`subscribe tickers ${globalId}`);
11697
+ subscribeTickers(globalIds, callback) {
11698
+ this.logger.debug(`subscribe tickers ${globalIds}`);
11699
+ const globalIdsList = Array.isArray(globalIds) ? globalIds : [globalIds];
11677
11700
  this.wsClient.subscribe(
11678
- {
11701
+ globalIdsList.map((globalId) => ({
11679
11702
  topic: "ticker" /* Ticker */,
11680
- params: {
11681
- globalId
11682
- }
11683
- },
11703
+ params: { globalId }
11704
+ })),
11684
11705
  callback
11685
11706
  );
11686
11707
  }
11687
- unsubscribeTickers(globalId, callback) {
11688
- this.logger.debug(`unsubscribe tickers ${globalId}`);
11708
+ unsubscribeTickers(globalIds, callback) {
11709
+ this.logger.debug(`unsubscribe tickers ${globalIds}`);
11710
+ const globalIdsList = Array.isArray(globalIds) ? globalIds : [globalIds];
11689
11711
  this.wsClient.unsubscribe(
11690
- {
11712
+ globalIdsList.map((globalId) => ({
11691
11713
  topic: "ticker" /* Ticker */,
11692
- params: {
11693
- globalId
11694
- }
11695
- },
11714
+ params: { globalId }
11715
+ })),
11696
11716
  callback
11697
11717
  );
11698
11718
  }
@@ -18168,6 +18188,12 @@ var MyxClient = class {
18168
18188
  this.configManager.clear();
18169
18189
  this.subscription.disconnect();
18170
18190
  }
18191
+ /**
18192
+ * get access token
18193
+ */
18194
+ async getAccessToken() {
18195
+ return await this.configManager.getAccessToken();
18196
+ }
18171
18197
  };
18172
18198
  export {
18173
18199
  COMMON_LP_AMOUNT_DECIMALS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"