@myx-trade/sdk 0.1.28 → 0.1.30
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 +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +69 -44
- package/dist/index.mjs +69 -44
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -423,6 +423,7 @@ interface SearchResultContractItem {
|
|
|
423
423
|
priceChange: string;
|
|
424
424
|
tvl: string;
|
|
425
425
|
marketCap: string;
|
|
426
|
+
globalId: number;
|
|
426
427
|
}
|
|
427
428
|
interface SearchResultCookItem {
|
|
428
429
|
chainId: ChainId;
|
|
@@ -437,6 +438,7 @@ interface SearchResultCookItem {
|
|
|
437
438
|
marketCap: string;
|
|
438
439
|
lpPrice: string;
|
|
439
440
|
lpPriceChange: string;
|
|
441
|
+
globalId: number;
|
|
440
442
|
}
|
|
441
443
|
interface SearchResultEarnItem {
|
|
442
444
|
chainId: ChainId;
|
|
@@ -451,6 +453,7 @@ interface SearchResultEarnItem {
|
|
|
451
453
|
tvl: string;
|
|
452
454
|
marketCap: string;
|
|
453
455
|
apr: string;
|
|
456
|
+
globalId: number;
|
|
454
457
|
}
|
|
455
458
|
interface SearchResultResponse {
|
|
456
459
|
earnInfo: {
|
|
@@ -1220,8 +1223,8 @@ declare class SubScription {
|
|
|
1220
1223
|
/**
|
|
1221
1224
|
* tickers subscription methods
|
|
1222
1225
|
*/
|
|
1223
|
-
subscribeTickers(
|
|
1224
|
-
unsubscribeTickers(
|
|
1226
|
+
subscribeTickers(globalIds: number | number[], callback: OnTickersCallback): void;
|
|
1227
|
+
unsubscribeTickers(globalIds: number | number[], callback: OnTickersCallback): void;
|
|
1225
1228
|
/**
|
|
1226
1229
|
* kline subscription methods
|
|
1227
1230
|
*/
|
|
@@ -1576,6 +1579,10 @@ declare class MyxClient {
|
|
|
1576
1579
|
* close the client
|
|
1577
1580
|
*/
|
|
1578
1581
|
close(): void;
|
|
1582
|
+
/**
|
|
1583
|
+
* get access token
|
|
1584
|
+
*/
|
|
1585
|
+
getAccessToken(): Promise<string | null>;
|
|
1579
1586
|
}
|
|
1580
1587
|
|
|
1581
1588
|
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
|
@@ -423,6 +423,7 @@ interface SearchResultContractItem {
|
|
|
423
423
|
priceChange: string;
|
|
424
424
|
tvl: string;
|
|
425
425
|
marketCap: string;
|
|
426
|
+
globalId: number;
|
|
426
427
|
}
|
|
427
428
|
interface SearchResultCookItem {
|
|
428
429
|
chainId: ChainId;
|
|
@@ -437,6 +438,7 @@ interface SearchResultCookItem {
|
|
|
437
438
|
marketCap: string;
|
|
438
439
|
lpPrice: string;
|
|
439
440
|
lpPriceChange: string;
|
|
441
|
+
globalId: number;
|
|
440
442
|
}
|
|
441
443
|
interface SearchResultEarnItem {
|
|
442
444
|
chainId: ChainId;
|
|
@@ -451,6 +453,7 @@ interface SearchResultEarnItem {
|
|
|
451
453
|
tvl: string;
|
|
452
454
|
marketCap: string;
|
|
453
455
|
apr: string;
|
|
456
|
+
globalId: number;
|
|
454
457
|
}
|
|
455
458
|
interface SearchResultResponse {
|
|
456
459
|
earnInfo: {
|
|
@@ -1220,8 +1223,8 @@ declare class SubScription {
|
|
|
1220
1223
|
/**
|
|
1221
1224
|
* tickers subscription methods
|
|
1222
1225
|
*/
|
|
1223
|
-
subscribeTickers(
|
|
1224
|
-
unsubscribeTickers(
|
|
1226
|
+
subscribeTickers(globalIds: number | number[], callback: OnTickersCallback): void;
|
|
1227
|
+
unsubscribeTickers(globalIds: number | number[], callback: OnTickersCallback): void;
|
|
1225
1228
|
/**
|
|
1226
1229
|
* kline subscription methods
|
|
1227
1230
|
*/
|
|
@@ -1576,6 +1579,10 @@ declare class MyxClient {
|
|
|
1576
1579
|
* close the client
|
|
1577
1580
|
*/
|
|
1578
1581
|
close(): void;
|
|
1582
|
+
/**
|
|
1583
|
+
* get access token
|
|
1584
|
+
*/
|
|
1585
|
+
getAccessToken(): Promise<string | null>;
|
|
1579
1586
|
}
|
|
1580
1587
|
|
|
1581
1588
|
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.
|
|
1830
|
+
version: "0.1.30",
|
|
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
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
callbacks
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
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:
|
|
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
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
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(
|
|
11761
|
-
this.logger.debug(`subscribe tickers ${
|
|
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
|
-
|
|
11767
|
-
}
|
|
11768
|
-
},
|
|
11788
|
+
params: { globalId }
|
|
11789
|
+
})),
|
|
11769
11790
|
callback
|
|
11770
11791
|
);
|
|
11771
11792
|
}
|
|
11772
|
-
unsubscribeTickers(
|
|
11773
|
-
this.logger.debug(`unsubscribe tickers ${
|
|
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
|
-
|
|
11779
|
-
}
|
|
11780
|
-
},
|
|
11799
|
+
params: { globalId }
|
|
11800
|
+
})),
|
|
11781
11801
|
callback
|
|
11782
11802
|
);
|
|
11783
11803
|
}
|
|
@@ -12571,7 +12591,6 @@ var Order = class {
|
|
|
12571
12591
|
slPrice: params.slPrice ? params.slPrice : 0,
|
|
12572
12592
|
useAccountBalance: false
|
|
12573
12593
|
});
|
|
12574
|
-
console.log("gaslimit->", gasLimit);
|
|
12575
12594
|
const transaction = await brokerContract.placeOrder(
|
|
12576
12595
|
{
|
|
12577
12596
|
user: params.address,
|
|
@@ -18254,6 +18273,12 @@ var MyxClient = class {
|
|
|
18254
18273
|
this.configManager.clear();
|
|
18255
18274
|
this.subscription.disconnect();
|
|
18256
18275
|
}
|
|
18276
|
+
/**
|
|
18277
|
+
* get access token
|
|
18278
|
+
*/
|
|
18279
|
+
async getAccessToken() {
|
|
18280
|
+
return await this.configManager.getAccessToken();
|
|
18281
|
+
}
|
|
18257
18282
|
};
|
|
18258
18283
|
// Annotate the CommonJS export names for ESM import in node:
|
|
18259
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.
|
|
1745
|
+
version: "0.1.30",
|
|
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
|
|
11379
|
-
|
|
11380
|
-
|
|
11381
|
-
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
callbacks
|
|
11390
|
-
|
|
11391
|
-
|
|
11392
|
-
|
|
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:
|
|
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
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
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(
|
|
11676
|
-
this.logger.debug(`subscribe tickers ${
|
|
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
|
-
|
|
11682
|
-
}
|
|
11683
|
-
},
|
|
11703
|
+
params: { globalId }
|
|
11704
|
+
})),
|
|
11684
11705
|
callback
|
|
11685
11706
|
);
|
|
11686
11707
|
}
|
|
11687
|
-
unsubscribeTickers(
|
|
11688
|
-
this.logger.debug(`unsubscribe tickers ${
|
|
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
|
-
|
|
11694
|
-
}
|
|
11695
|
-
},
|
|
11714
|
+
params: { globalId }
|
|
11715
|
+
})),
|
|
11696
11716
|
callback
|
|
11697
11717
|
);
|
|
11698
11718
|
}
|
|
@@ -12486,7 +12506,6 @@ var Order = class {
|
|
|
12486
12506
|
slPrice: params.slPrice ? params.slPrice : 0,
|
|
12487
12507
|
useAccountBalance: false
|
|
12488
12508
|
});
|
|
12489
|
-
console.log("gaslimit->", gasLimit);
|
|
12490
12509
|
const transaction = await brokerContract.placeOrder(
|
|
12491
12510
|
{
|
|
12492
12511
|
user: params.address,
|
|
@@ -18169,6 +18188,12 @@ var MyxClient = class {
|
|
|
18169
18188
|
this.configManager.clear();
|
|
18170
18189
|
this.subscription.disconnect();
|
|
18171
18190
|
}
|
|
18191
|
+
/**
|
|
18192
|
+
* get access token
|
|
18193
|
+
*/
|
|
18194
|
+
async getAccessToken() {
|
|
18195
|
+
return await this.configManager.getAccessToken();
|
|
18196
|
+
}
|
|
18172
18197
|
};
|
|
18173
18198
|
export {
|
|
18174
18199
|
COMMON_LP_AMOUNT_DECIMALS,
|