@myx-trade/sdk 0.1.16 → 0.1.18

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
@@ -421,6 +421,8 @@ interface SearchResultContractItem {
421
421
  liquidity: string;
422
422
  basePrice: string;
423
423
  priceChange: string;
424
+ tvl: string;
425
+ marketCap: string;
424
426
  }
425
427
  interface SearchResultCookItem {
426
428
  chainId: ChainId;
@@ -597,7 +599,7 @@ interface HistoryOrderItem {
597
599
  realizedPnl: string;
598
600
  baseSymbol: string;
599
601
  quoteSymbol: string;
600
- leverage: number;
602
+ userLeverage: number;
601
603
  }
602
604
  /**
603
605
  * Get history orders
@@ -606,6 +608,18 @@ declare const getHistoryOrders: ({ accessToken, ...params }: GetHistoryOrdersPar
606
608
  /**
607
609
  * Get position history
608
610
  */
611
+ declare enum CloseTypeEnum {
612
+ Open = 0,
613
+ PartialClose = 1,
614
+ FullClose = 2,
615
+ Liquidation = 3,
616
+ EarlyClose = 4,
617
+ MarketClose = 5,
618
+ ADL = 6,
619
+ TP = 7,
620
+ SL = 8,
621
+ Increase = 9
622
+ }
609
623
  interface PositionHistoryItem {
610
624
  chainId: number;
611
625
  poolId: string;
@@ -622,7 +636,9 @@ interface PositionHistoryItem {
622
636
  realizedPnl: string;
623
637
  baseSymbol: string;
624
638
  quoteSymbol: string;
625
- leverage: number;
639
+ userLeverage: number;
640
+ closeType: CloseTypeEnum;
641
+ avgClosePrice: string;
626
642
  }
627
643
  declare const getPositionHistory: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<PositionHistoryItem[]>>;
628
644
  /**
@@ -643,15 +659,13 @@ interface TradeFlowItem {
643
659
  txTime: number;
644
660
  baseSymbol: string;
645
661
  quoteSymbol: string;
646
- leverage: number;
662
+ userLeverage: number;
663
+ executionFee: string;
664
+ type: OperationEnum;
647
665
  }
648
666
  declare const getTradeFlow: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<TradeFlowItem[]>>;
649
667
 
650
668
  declare const baseUrl = "https://api-test.myx.cash";
651
- /**
652
- * Get pools
653
- */
654
- declare const getPools: () => Promise<MarketPoolResponse>;
655
669
  declare const getOraclePrice: (chainId: ChainId, poolIds?: string[]) => Promise<PriceResponse>;
656
670
  interface LevelConfig {
657
671
  fundingFeeRate1: number;
@@ -1138,7 +1152,7 @@ interface AccessTokenResponse {
1138
1152
  }
1139
1153
  interface MyxClientConfig {
1140
1154
  chainId: number;
1141
- signer: Signer;
1155
+ signer?: Signer;
1142
1156
  walletClient?: WalletClient;
1143
1157
  brokerAddress: string;
1144
1158
  isTestnet?: boolean;
@@ -1155,6 +1169,8 @@ declare class ConfigManager {
1155
1169
  private accessToken?;
1156
1170
  private accessTokenExpiry?;
1157
1171
  constructor(config: MyxClientConfig);
1172
+ clear(): void;
1173
+ auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken">): void;
1158
1174
  private validateConfig;
1159
1175
  /**
1160
1176
  * 获取有效的 accessToken,自动处理获取和刷新
@@ -1280,7 +1296,6 @@ declare class Markets {
1280
1296
  private utils;
1281
1297
  constructor(configManager: ConfigManager, utils: Utils);
1282
1298
  getMarkets(): Promise<never[]>;
1283
- listPools(): Promise<MarketPool[]>;
1284
1299
  getPoolLevelConfig(poolId: string): Promise<PoolLevelConfig>;
1285
1300
  /**
1286
1301
  * kline start
@@ -1353,11 +1368,12 @@ declare class Position {
1353
1368
  * @desc temp skip eip7702
1354
1369
  * @todo adjustCollateral 调整保证金
1355
1370
  */
1356
- adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, }: {
1371
+ adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, poolOracleType, }: {
1357
1372
  poolId: string;
1358
1373
  positionId: string;
1359
1374
  adjustAmount: string;
1360
1375
  quoteToken: string;
1376
+ poolOracleType: OracleType;
1361
1377
  }): Promise<{
1362
1378
  code: number;
1363
1379
  data: {
@@ -1527,6 +1543,14 @@ declare class MyxClient {
1527
1543
  */
1528
1544
  getConfigManager(): ConfigManager;
1529
1545
  constructor(options: MyxClientConfig);
1546
+ /**
1547
+ * auth the client
1548
+ */
1549
+ auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken">): void;
1550
+ /**
1551
+ * close the client
1552
+ */
1553
+ close(): void;
1530
1554
  }
1531
1555
 
1532
- 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, 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, getPools, getPositionHistory, getPositions, getPriceData, getPricesData, getTickerData, getTokenInfo, getTradeFlow, index as market, index$3 as pool, index$1 as quote, removeFavorite, searchMarket, searchMarketAuth };
1556
+ 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
@@ -421,6 +421,8 @@ interface SearchResultContractItem {
421
421
  liquidity: string;
422
422
  basePrice: string;
423
423
  priceChange: string;
424
+ tvl: string;
425
+ marketCap: string;
424
426
  }
425
427
  interface SearchResultCookItem {
426
428
  chainId: ChainId;
@@ -597,7 +599,7 @@ interface HistoryOrderItem {
597
599
  realizedPnl: string;
598
600
  baseSymbol: string;
599
601
  quoteSymbol: string;
600
- leverage: number;
602
+ userLeverage: number;
601
603
  }
602
604
  /**
603
605
  * Get history orders
@@ -606,6 +608,18 @@ declare const getHistoryOrders: ({ accessToken, ...params }: GetHistoryOrdersPar
606
608
  /**
607
609
  * Get position history
608
610
  */
611
+ declare enum CloseTypeEnum {
612
+ Open = 0,
613
+ PartialClose = 1,
614
+ FullClose = 2,
615
+ Liquidation = 3,
616
+ EarlyClose = 4,
617
+ MarketClose = 5,
618
+ ADL = 6,
619
+ TP = 7,
620
+ SL = 8,
621
+ Increase = 9
622
+ }
609
623
  interface PositionHistoryItem {
610
624
  chainId: number;
611
625
  poolId: string;
@@ -622,7 +636,9 @@ interface PositionHistoryItem {
622
636
  realizedPnl: string;
623
637
  baseSymbol: string;
624
638
  quoteSymbol: string;
625
- leverage: number;
639
+ userLeverage: number;
640
+ closeType: CloseTypeEnum;
641
+ avgClosePrice: string;
626
642
  }
627
643
  declare const getPositionHistory: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<PositionHistoryItem[]>>;
628
644
  /**
@@ -643,15 +659,13 @@ interface TradeFlowItem {
643
659
  txTime: number;
644
660
  baseSymbol: string;
645
661
  quoteSymbol: string;
646
- leverage: number;
662
+ userLeverage: number;
663
+ executionFee: string;
664
+ type: OperationEnum;
647
665
  }
648
666
  declare const getTradeFlow: ({ accessToken, ...params }: GetHistoryOrdersParams & AccessTokenRequest) => Promise<ApiResponse<TradeFlowItem[]>>;
649
667
 
650
668
  declare const baseUrl = "https://api-test.myx.cash";
651
- /**
652
- * Get pools
653
- */
654
- declare const getPools: () => Promise<MarketPoolResponse>;
655
669
  declare const getOraclePrice: (chainId: ChainId, poolIds?: string[]) => Promise<PriceResponse>;
656
670
  interface LevelConfig {
657
671
  fundingFeeRate1: number;
@@ -1138,7 +1152,7 @@ interface AccessTokenResponse {
1138
1152
  }
1139
1153
  interface MyxClientConfig {
1140
1154
  chainId: number;
1141
- signer: Signer;
1155
+ signer?: Signer;
1142
1156
  walletClient?: WalletClient;
1143
1157
  brokerAddress: string;
1144
1158
  isTestnet?: boolean;
@@ -1155,6 +1169,8 @@ declare class ConfigManager {
1155
1169
  private accessToken?;
1156
1170
  private accessTokenExpiry?;
1157
1171
  constructor(config: MyxClientConfig);
1172
+ clear(): void;
1173
+ auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken">): void;
1158
1174
  private validateConfig;
1159
1175
  /**
1160
1176
  * 获取有效的 accessToken,自动处理获取和刷新
@@ -1280,7 +1296,6 @@ declare class Markets {
1280
1296
  private utils;
1281
1297
  constructor(configManager: ConfigManager, utils: Utils);
1282
1298
  getMarkets(): Promise<never[]>;
1283
- listPools(): Promise<MarketPool[]>;
1284
1299
  getPoolLevelConfig(poolId: string): Promise<PoolLevelConfig>;
1285
1300
  /**
1286
1301
  * kline start
@@ -1353,11 +1368,12 @@ declare class Position {
1353
1368
  * @desc temp skip eip7702
1354
1369
  * @todo adjustCollateral 调整保证金
1355
1370
  */
1356
- adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, }: {
1371
+ adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, poolOracleType, }: {
1357
1372
  poolId: string;
1358
1373
  positionId: string;
1359
1374
  adjustAmount: string;
1360
1375
  quoteToken: string;
1376
+ poolOracleType: OracleType;
1361
1377
  }): Promise<{
1362
1378
  code: number;
1363
1379
  data: {
@@ -1527,6 +1543,14 @@ declare class MyxClient {
1527
1543
  */
1528
1544
  getConfigManager(): ConfigManager;
1529
1545
  constructor(options: MyxClientConfig);
1546
+ /**
1547
+ * auth the client
1548
+ */
1549
+ auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken">): void;
1550
+ /**
1551
+ * close the client
1552
+ */
1553
+ close(): void;
1530
1554
  }
1531
1555
 
1532
- 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, 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, getPools, getPositionHistory, getPositions, getPriceData, getPricesData, getTickerData, getTokenInfo, getTradeFlow, index as market, index$3 as pool, index$1 as quote, removeFavorite, searchMarket, searchMarketAuth };
1556
+ 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
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  COMMON_LP_AMOUNT_DECIMALS: () => COMMON_LP_AMOUNT_DECIMALS,
34
34
  COMMON_PRICE_DECIMALS: () => COMMON_PRICE_DECIMALS,
35
35
  ChainId: () => ChainId,
36
+ CloseTypeEnum: () => CloseTypeEnum,
36
37
  Direction: () => Direction,
37
38
  DirectionEnum: () => DirectionEnum,
38
39
  ErrorCode: () => ErrorCode2,
@@ -77,7 +78,6 @@ __export(index_exports, {
77
78
  getPoolDetail: () => getPoolDetail,
78
79
  getPoolLevelConfig: () => getPoolLevelConfig,
79
80
  getPoolOpenOrders: () => getPoolOpenOrders,
80
- getPools: () => getPools,
81
81
  getPositionHistory: () => getPositionHistory,
82
82
  getPositions: () => getPositions,
83
83
  getPriceData: () => getPriceData,
@@ -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.16",
1830
+ version: "0.1.18",
1831
1831
  private: false,
1832
1832
  publishConfig: {
1833
1833
  access: "public"
@@ -9695,10 +9695,10 @@ var MarketPoolState = /* @__PURE__ */ ((MarketPoolState3) => {
9695
9695
  MarketPoolState3[MarketPoolState3["Bench"] = 4] = "Bench";
9696
9696
  return MarketPoolState3;
9697
9697
  })(MarketPoolState || {});
9698
- var OracleType = /* @__PURE__ */ ((OracleType6) => {
9699
- OracleType6[OracleType6["Chainlink"] = 1] = "Chainlink";
9700
- OracleType6[OracleType6["Pyth"] = 2] = "Pyth";
9701
- return OracleType6;
9698
+ var OracleType = /* @__PURE__ */ ((OracleType7) => {
9699
+ OracleType7[OracleType7["Chainlink"] = 1] = "Chainlink";
9700
+ OracleType7[OracleType7["Pyth"] = 2] = "Pyth";
9701
+ return OracleType7;
9702
9702
  })(OracleType || {});
9703
9703
  var HttpKlineIntervalEnum = /* @__PURE__ */ ((HttpKlineIntervalEnum2) => {
9704
9704
  HttpKlineIntervalEnum2[HttpKlineIntervalEnum2["Minute1"] = 1] = "Minute1";
@@ -9788,6 +9788,19 @@ var getHistoryOrders = async ({
9788
9788
  }
9789
9789
  );
9790
9790
  };
9791
+ var CloseTypeEnum = /* @__PURE__ */ ((CloseTypeEnum2) => {
9792
+ CloseTypeEnum2[CloseTypeEnum2["Open"] = 0] = "Open";
9793
+ CloseTypeEnum2[CloseTypeEnum2["PartialClose"] = 1] = "PartialClose";
9794
+ CloseTypeEnum2[CloseTypeEnum2["FullClose"] = 2] = "FullClose";
9795
+ CloseTypeEnum2[CloseTypeEnum2["Liquidation"] = 3] = "Liquidation";
9796
+ CloseTypeEnum2[CloseTypeEnum2["EarlyClose"] = 4] = "EarlyClose";
9797
+ CloseTypeEnum2[CloseTypeEnum2["MarketClose"] = 5] = "MarketClose";
9798
+ CloseTypeEnum2[CloseTypeEnum2["ADL"] = 6] = "ADL";
9799
+ CloseTypeEnum2[CloseTypeEnum2["TP"] = 7] = "TP";
9800
+ CloseTypeEnum2[CloseTypeEnum2["SL"] = 8] = "SL";
9801
+ CloseTypeEnum2[CloseTypeEnum2["Increase"] = 9] = "Increase";
9802
+ return CloseTypeEnum2;
9803
+ })(CloseTypeEnum || {});
9791
9804
  var getPositionHistory = async ({
9792
9805
  accessToken,
9793
9806
  ...params
@@ -9819,9 +9832,6 @@ var getTradeFlow = async ({
9819
9832
 
9820
9833
  // src/api/index.ts
9821
9834
  var baseUrl = "https://api-test.myx.cash";
9822
- var getPools = async () => {
9823
- return http.get(`${baseUrl}/v2/mx-scan/market/list`);
9824
- };
9825
9835
  var getOraclePrice = async (chainId2, poolIds = []) => {
9826
9836
  if (!!poolIds.length) {
9827
9837
  return http.get(`${baseUrl}/openapi/gateway/quote/price/oracles`, {
@@ -9844,7 +9854,7 @@ var getPoolLevelConfig = async ({
9844
9854
  };
9845
9855
  var getPoolDetail = async (chainId2, poolId) => {
9846
9856
  return await http.get(
9847
- `${baseUrl}/v2/mx-scan/market/detail?chainId=${chainId2}&poolId=${poolId}`
9857
+ `${baseUrl}/openapi/gateway/scan/market/detail?chainId=${chainId2}&poolId=${poolId}`
9848
9858
  );
9849
9859
  };
9850
9860
  var getPositions = async (accessToken, chainId2) => {
@@ -11970,6 +11980,22 @@ var ConfigManager = class {
11970
11980
  this.validateConfig(mergedConfig);
11971
11981
  this.config = mergedConfig;
11972
11982
  }
11983
+ clear() {
11984
+ this.accessToken = void 0;
11985
+ this.accessTokenExpiry = void 0;
11986
+ this.config = {
11987
+ ...this.config,
11988
+ signer: void 0,
11989
+ getAccessToken: void 0
11990
+ };
11991
+ }
11992
+ auth(params) {
11993
+ this.config = {
11994
+ ...this.config,
11995
+ ...params
11996
+ };
11997
+ this.validateConfig(this.config);
11998
+ }
11973
11999
  validateConfig(config) {
11974
12000
  const { isTestnet, chainId: chainId2 } = config;
11975
12001
  if (isTestnet) {
@@ -12074,9 +12100,6 @@ var Markets = class {
12074
12100
  getMarkets() {
12075
12101
  return Promise.resolve([]);
12076
12102
  }
12077
- async listPools() {
12078
- return (await getPools()).data;
12079
- }
12080
12103
  async getPoolLevelConfig(poolId) {
12081
12104
  const config = this.configManager.getConfig();
12082
12105
  return (await getPoolLevelConfig({
@@ -12389,9 +12412,13 @@ var Position = class {
12389
12412
  poolId,
12390
12413
  positionId,
12391
12414
  adjustAmount,
12392
- quoteToken
12415
+ quoteToken,
12416
+ poolOracleType
12393
12417
  }) {
12394
12418
  const config = this.configManager.getConfig();
12419
+ if (!config.signer) {
12420
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12421
+ }
12395
12422
  this.logger.debug("adjustCollateral-->", {
12396
12423
  poolId,
12397
12424
  positionId,
@@ -12407,7 +12434,8 @@ var Position = class {
12407
12434
  poolId,
12408
12435
  referencePrice: import_ethers24.ethers.parseUnits(priceData?.price ?? "0", 30),
12409
12436
  oracleUpdateData: priceData?.vaa ?? "0",
12410
- publishTime: priceData.publishTime
12437
+ publishTime: priceData.publishTime,
12438
+ oracleType: poolOracleType
12411
12439
  };
12412
12440
  const contractAddress = getContractAddressByChainId(config.chainId);
12413
12441
  if (Number(adjustAmount) > 0) {
@@ -12468,6 +12496,7 @@ var Position = class {
12468
12496
  message: "Adjust collateral transaction submitted"
12469
12497
  };
12470
12498
  } catch (error) {
12499
+ console.log(error, "error");
12471
12500
  const errorMessage = await this.utils.getErrorMessage(error);
12472
12501
  this.logger.error("adjustCollateral error-->", errorMessage);
12473
12502
  return {
@@ -12544,6 +12573,9 @@ var Order = class {
12544
12573
  async createIncreaseOrder(params) {
12545
12574
  try {
12546
12575
  const config = this.configManager.getConfig();
12576
+ if (!config.signer) {
12577
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12578
+ }
12547
12579
  const brokerContract = await getBrokerSingerContract(
12548
12580
  params.chainId,
12549
12581
  config.signer
@@ -12660,6 +12692,9 @@ var Order = class {
12660
12692
  async createDecreaseOrder(params) {
12661
12693
  try {
12662
12694
  const config = this.configManager.getConfig();
12695
+ if (!config.signer) {
12696
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12697
+ }
12663
12698
  const brokerContract = await getBrokerSingerContract(
12664
12699
  params.chainId,
12665
12700
  config.signer
@@ -12772,6 +12807,9 @@ var Order = class {
12772
12807
  async createPositionTpSlOrder(params) {
12773
12808
  try {
12774
12809
  const config = this.configManager.getConfig();
12810
+ if (!config.signer) {
12811
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12812
+ }
12775
12813
  const brokerContract = await getBrokerSingerContract(
12776
12814
  params.chainId,
12777
12815
  config.signer
@@ -12936,6 +12974,9 @@ var Order = class {
12936
12974
  async cancelOrder(orderId) {
12937
12975
  try {
12938
12976
  const config = this.configManager.getConfig();
12977
+ if (!config.signer) {
12978
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12979
+ }
12939
12980
  const brokerContract = await getBrokerSingerContract(
12940
12981
  config.chainId,
12941
12982
  config.signer
@@ -12957,6 +12998,9 @@ var Order = class {
12957
12998
  async cancelOrders(orderIds) {
12958
12999
  try {
12959
13000
  const config = this.configManager.getConfig();
13001
+ if (!config.signer) {
13002
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
13003
+ }
12960
13004
  const brokerContract = await getBrokerSingerContract(
12961
13005
  config.chainId,
12962
13006
  config.signer
@@ -12978,6 +13022,9 @@ var Order = class {
12978
13022
  }
12979
13023
  async updateOrderTpSl(params) {
12980
13024
  const config = this.configManager.getConfig();
13025
+ if (!config.signer) {
13026
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
13027
+ }
12981
13028
  console.log("updateOrderTpSl params", params);
12982
13029
  const brokerContract = await getBrokerSingerContract(
12983
13030
  config.chainId,
@@ -16788,6 +16835,12 @@ var Utils = class {
16788
16835
  "function allowance(address owner, address spender) external view returns (uint256)"
16789
16836
  ];
16790
16837
  const config = this.configManager.getConfig();
16838
+ if (!config.signer) {
16839
+ throw new MyxSDKError(
16840
+ "INVALID_SIGNER" /* InvalidSigner */,
16841
+ "Invalid signer"
16842
+ );
16843
+ }
16791
16844
  const owner = await config.signer.getAddress();
16792
16845
  const spender = spenderAddress ?? getContractAddressByChainId(config.chainId).ORDER_MANAGER;
16793
16846
  const tokenContract = new import_ethers25.ethers.Contract(
@@ -18098,6 +18151,12 @@ var Account = class {
18098
18151
  }
18099
18152
  async getWalletQuoteTokenBalance() {
18100
18153
  const config = this.configManager.getConfig();
18154
+ if (!config.signer) {
18155
+ throw new MyxSDKError(
18156
+ "INVALID_SIGNER" /* InvalidSigner */,
18157
+ "Invalid signer"
18158
+ );
18159
+ }
18101
18160
  const contractAddress = getContractAddressByChainId(config.chainId);
18102
18161
  const erc20Contract = new import_ethers26.ethers.Contract(
18103
18162
  contractAddress.ERC20,
@@ -18115,6 +18174,12 @@ var Account = class {
18115
18174
  */
18116
18175
  async getTradableAmount({ poolId }) {
18117
18176
  const config = this.configManager.getConfig();
18177
+ if (!config.signer) {
18178
+ throw new MyxSDKError(
18179
+ "INVALID_SIGNER" /* InvalidSigner */,
18180
+ "Invalid signer"
18181
+ );
18182
+ }
18118
18183
  const contractAddress = getContractAddressByChainId(config.chainId);
18119
18184
  const accountContract = new import_ethers26.ethers.Contract(
18120
18185
  contractAddress.Account,
@@ -18183,12 +18248,26 @@ var MyxClient = class {
18183
18248
  }
18184
18249
  lp.setConfigManager(this.configManager);
18185
18250
  }
18251
+ /**
18252
+ * auth the client
18253
+ */
18254
+ auth(params) {
18255
+ this.configManager.auth(params);
18256
+ }
18257
+ /**
18258
+ * close the client
18259
+ */
18260
+ close() {
18261
+ this.configManager.clear();
18262
+ this.subscription.disconnect();
18263
+ }
18186
18264
  };
18187
18265
  // Annotate the CommonJS export names for ESM import in node:
18188
18266
  0 && (module.exports = {
18189
18267
  COMMON_LP_AMOUNT_DECIMALS,
18190
18268
  COMMON_PRICE_DECIMALS,
18191
18269
  ChainId,
18270
+ CloseTypeEnum,
18192
18271
  Direction,
18193
18272
  DirectionEnum,
18194
18273
  ErrorCode,
@@ -18233,7 +18312,6 @@ var MyxClient = class {
18233
18312
  getPoolDetail,
18234
18313
  getPoolLevelConfig,
18235
18314
  getPoolOpenOrders,
18236
- getPools,
18237
18315
  getPositionHistory,
18238
18316
  getPositions,
18239
18317
  getPriceData,
package/dist/index.mjs CHANGED
@@ -1741,7 +1741,7 @@ var RotationProvider = class extends BaseProvider {
1741
1741
  // package.json
1742
1742
  var package_default = {
1743
1743
  name: "@myx-trade/sdk",
1744
- version: "0.1.16",
1744
+ version: "0.1.18",
1745
1745
  private: false,
1746
1746
  publishConfig: {
1747
1747
  access: "public"
@@ -9609,10 +9609,10 @@ var MarketPoolState = /* @__PURE__ */ ((MarketPoolState3) => {
9609
9609
  MarketPoolState3[MarketPoolState3["Bench"] = 4] = "Bench";
9610
9610
  return MarketPoolState3;
9611
9611
  })(MarketPoolState || {});
9612
- var OracleType = /* @__PURE__ */ ((OracleType6) => {
9613
- OracleType6[OracleType6["Chainlink"] = 1] = "Chainlink";
9614
- OracleType6[OracleType6["Pyth"] = 2] = "Pyth";
9615
- return OracleType6;
9612
+ var OracleType = /* @__PURE__ */ ((OracleType7) => {
9613
+ OracleType7[OracleType7["Chainlink"] = 1] = "Chainlink";
9614
+ OracleType7[OracleType7["Pyth"] = 2] = "Pyth";
9615
+ return OracleType7;
9616
9616
  })(OracleType || {});
9617
9617
  var HttpKlineIntervalEnum = /* @__PURE__ */ ((HttpKlineIntervalEnum2) => {
9618
9618
  HttpKlineIntervalEnum2[HttpKlineIntervalEnum2["Minute1"] = 1] = "Minute1";
@@ -9702,6 +9702,19 @@ var getHistoryOrders = async ({
9702
9702
  }
9703
9703
  );
9704
9704
  };
9705
+ var CloseTypeEnum = /* @__PURE__ */ ((CloseTypeEnum2) => {
9706
+ CloseTypeEnum2[CloseTypeEnum2["Open"] = 0] = "Open";
9707
+ CloseTypeEnum2[CloseTypeEnum2["PartialClose"] = 1] = "PartialClose";
9708
+ CloseTypeEnum2[CloseTypeEnum2["FullClose"] = 2] = "FullClose";
9709
+ CloseTypeEnum2[CloseTypeEnum2["Liquidation"] = 3] = "Liquidation";
9710
+ CloseTypeEnum2[CloseTypeEnum2["EarlyClose"] = 4] = "EarlyClose";
9711
+ CloseTypeEnum2[CloseTypeEnum2["MarketClose"] = 5] = "MarketClose";
9712
+ CloseTypeEnum2[CloseTypeEnum2["ADL"] = 6] = "ADL";
9713
+ CloseTypeEnum2[CloseTypeEnum2["TP"] = 7] = "TP";
9714
+ CloseTypeEnum2[CloseTypeEnum2["SL"] = 8] = "SL";
9715
+ CloseTypeEnum2[CloseTypeEnum2["Increase"] = 9] = "Increase";
9716
+ return CloseTypeEnum2;
9717
+ })(CloseTypeEnum || {});
9705
9718
  var getPositionHistory = async ({
9706
9719
  accessToken,
9707
9720
  ...params
@@ -9733,9 +9746,6 @@ var getTradeFlow = async ({
9733
9746
 
9734
9747
  // src/api/index.ts
9735
9748
  var baseUrl = "https://api-test.myx.cash";
9736
- var getPools = async () => {
9737
- return http.get(`${baseUrl}/v2/mx-scan/market/list`);
9738
- };
9739
9749
  var getOraclePrice = async (chainId2, poolIds = []) => {
9740
9750
  if (!!poolIds.length) {
9741
9751
  return http.get(`${baseUrl}/openapi/gateway/quote/price/oracles`, {
@@ -9758,7 +9768,7 @@ var getPoolLevelConfig = async ({
9758
9768
  };
9759
9769
  var getPoolDetail = async (chainId2, poolId) => {
9760
9770
  return await http.get(
9761
- `${baseUrl}/v2/mx-scan/market/detail?chainId=${chainId2}&poolId=${poolId}`
9771
+ `${baseUrl}/openapi/gateway/scan/market/detail?chainId=${chainId2}&poolId=${poolId}`
9762
9772
  );
9763
9773
  };
9764
9774
  var getPositions = async (accessToken, chainId2) => {
@@ -11884,6 +11894,22 @@ var ConfigManager = class {
11884
11894
  this.validateConfig(mergedConfig);
11885
11895
  this.config = mergedConfig;
11886
11896
  }
11897
+ clear() {
11898
+ this.accessToken = void 0;
11899
+ this.accessTokenExpiry = void 0;
11900
+ this.config = {
11901
+ ...this.config,
11902
+ signer: void 0,
11903
+ getAccessToken: void 0
11904
+ };
11905
+ }
11906
+ auth(params) {
11907
+ this.config = {
11908
+ ...this.config,
11909
+ ...params
11910
+ };
11911
+ this.validateConfig(this.config);
11912
+ }
11887
11913
  validateConfig(config) {
11888
11914
  const { isTestnet, chainId: chainId2 } = config;
11889
11915
  if (isTestnet) {
@@ -11988,9 +12014,6 @@ var Markets = class {
11988
12014
  getMarkets() {
11989
12015
  return Promise.resolve([]);
11990
12016
  }
11991
- async listPools() {
11992
- return (await getPools()).data;
11993
- }
11994
12017
  async getPoolLevelConfig(poolId) {
11995
12018
  const config = this.configManager.getConfig();
11996
12019
  return (await getPoolLevelConfig({
@@ -12303,9 +12326,13 @@ var Position = class {
12303
12326
  poolId,
12304
12327
  positionId,
12305
12328
  adjustAmount,
12306
- quoteToken
12329
+ quoteToken,
12330
+ poolOracleType
12307
12331
  }) {
12308
12332
  const config = this.configManager.getConfig();
12333
+ if (!config.signer) {
12334
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12335
+ }
12309
12336
  this.logger.debug("adjustCollateral-->", {
12310
12337
  poolId,
12311
12338
  positionId,
@@ -12321,7 +12348,8 @@ var Position = class {
12321
12348
  poolId,
12322
12349
  referencePrice: ethers5.parseUnits(priceData?.price ?? "0", 30),
12323
12350
  oracleUpdateData: priceData?.vaa ?? "0",
12324
- publishTime: priceData.publishTime
12351
+ publishTime: priceData.publishTime,
12352
+ oracleType: poolOracleType
12325
12353
  };
12326
12354
  const contractAddress = getContractAddressByChainId(config.chainId);
12327
12355
  if (Number(adjustAmount) > 0) {
@@ -12382,6 +12410,7 @@ var Position = class {
12382
12410
  message: "Adjust collateral transaction submitted"
12383
12411
  };
12384
12412
  } catch (error) {
12413
+ console.log(error, "error");
12385
12414
  const errorMessage = await this.utils.getErrorMessage(error);
12386
12415
  this.logger.error("adjustCollateral error-->", errorMessage);
12387
12416
  return {
@@ -12458,6 +12487,9 @@ var Order = class {
12458
12487
  async createIncreaseOrder(params) {
12459
12488
  try {
12460
12489
  const config = this.configManager.getConfig();
12490
+ if (!config.signer) {
12491
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12492
+ }
12461
12493
  const brokerContract = await getBrokerSingerContract(
12462
12494
  params.chainId,
12463
12495
  config.signer
@@ -12574,6 +12606,9 @@ var Order = class {
12574
12606
  async createDecreaseOrder(params) {
12575
12607
  try {
12576
12608
  const config = this.configManager.getConfig();
12609
+ if (!config.signer) {
12610
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12611
+ }
12577
12612
  const brokerContract = await getBrokerSingerContract(
12578
12613
  params.chainId,
12579
12614
  config.signer
@@ -12686,6 +12721,9 @@ var Order = class {
12686
12721
  async createPositionTpSlOrder(params) {
12687
12722
  try {
12688
12723
  const config = this.configManager.getConfig();
12724
+ if (!config.signer) {
12725
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12726
+ }
12689
12727
  const brokerContract = await getBrokerSingerContract(
12690
12728
  params.chainId,
12691
12729
  config.signer
@@ -12850,6 +12888,9 @@ var Order = class {
12850
12888
  async cancelOrder(orderId) {
12851
12889
  try {
12852
12890
  const config = this.configManager.getConfig();
12891
+ if (!config.signer) {
12892
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12893
+ }
12853
12894
  const brokerContract = await getBrokerSingerContract(
12854
12895
  config.chainId,
12855
12896
  config.signer
@@ -12871,6 +12912,9 @@ var Order = class {
12871
12912
  async cancelOrders(orderIds) {
12872
12913
  try {
12873
12914
  const config = this.configManager.getConfig();
12915
+ if (!config.signer) {
12916
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12917
+ }
12874
12918
  const brokerContract = await getBrokerSingerContract(
12875
12919
  config.chainId,
12876
12920
  config.signer
@@ -12892,6 +12936,9 @@ var Order = class {
12892
12936
  }
12893
12937
  async updateOrderTpSl(params) {
12894
12938
  const config = this.configManager.getConfig();
12939
+ if (!config.signer) {
12940
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12941
+ }
12895
12942
  console.log("updateOrderTpSl params", params);
12896
12943
  const brokerContract = await getBrokerSingerContract(
12897
12944
  config.chainId,
@@ -16702,6 +16749,12 @@ var Utils = class {
16702
16749
  "function allowance(address owner, address spender) external view returns (uint256)"
16703
16750
  ];
16704
16751
  const config = this.configManager.getConfig();
16752
+ if (!config.signer) {
16753
+ throw new MyxSDKError(
16754
+ "INVALID_SIGNER" /* InvalidSigner */,
16755
+ "Invalid signer"
16756
+ );
16757
+ }
16705
16758
  const owner = await config.signer.getAddress();
16706
16759
  const spender = spenderAddress ?? getContractAddressByChainId(config.chainId).ORDER_MANAGER;
16707
16760
  const tokenContract = new ethers6.Contract(
@@ -18012,6 +18065,12 @@ var Account = class {
18012
18065
  }
18013
18066
  async getWalletQuoteTokenBalance() {
18014
18067
  const config = this.configManager.getConfig();
18068
+ if (!config.signer) {
18069
+ throw new MyxSDKError(
18070
+ "INVALID_SIGNER" /* InvalidSigner */,
18071
+ "Invalid signer"
18072
+ );
18073
+ }
18015
18074
  const contractAddress = getContractAddressByChainId(config.chainId);
18016
18075
  const erc20Contract = new ethers7.Contract(
18017
18076
  contractAddress.ERC20,
@@ -18029,6 +18088,12 @@ var Account = class {
18029
18088
  */
18030
18089
  async getTradableAmount({ poolId }) {
18031
18090
  const config = this.configManager.getConfig();
18091
+ if (!config.signer) {
18092
+ throw new MyxSDKError(
18093
+ "INVALID_SIGNER" /* InvalidSigner */,
18094
+ "Invalid signer"
18095
+ );
18096
+ }
18032
18097
  const contractAddress = getContractAddressByChainId(config.chainId);
18033
18098
  const accountContract = new ethers7.Contract(
18034
18099
  contractAddress.Account,
@@ -18097,11 +18162,25 @@ var MyxClient = class {
18097
18162
  }
18098
18163
  lp.setConfigManager(this.configManager);
18099
18164
  }
18165
+ /**
18166
+ * auth the client
18167
+ */
18168
+ auth(params) {
18169
+ this.configManager.auth(params);
18170
+ }
18171
+ /**
18172
+ * close the client
18173
+ */
18174
+ close() {
18175
+ this.configManager.clear();
18176
+ this.subscription.disconnect();
18177
+ }
18100
18178
  };
18101
18179
  export {
18102
18180
  COMMON_LP_AMOUNT_DECIMALS,
18103
18181
  COMMON_PRICE_DECIMALS,
18104
18182
  ChainId,
18183
+ CloseTypeEnum,
18105
18184
  Direction,
18106
18185
  DirectionEnum,
18107
18186
  ErrorCode2 as ErrorCode,
@@ -18146,7 +18225,6 @@ export {
18146
18225
  getPoolDetail,
18147
18226
  getPoolLevelConfig,
18148
18227
  getPoolOpenOrders,
18149
- getPools,
18150
18228
  getPositionHistory,
18151
18229
  getPositions,
18152
18230
  getPriceData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"