@myx-trade/sdk 0.1.17 → 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;
@@ -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;
@@ -623,6 +637,8 @@ interface PositionHistoryItem {
623
637
  baseSymbol: string;
624
638
  quoteSymbol: string;
625
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
  /**
@@ -644,6 +660,8 @@ interface TradeFlowItem {
644
660
  baseSymbol: string;
645
661
  quoteSymbol: string;
646
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
 
@@ -1134,7 +1152,7 @@ interface AccessTokenResponse {
1134
1152
  }
1135
1153
  interface MyxClientConfig {
1136
1154
  chainId: number;
1137
- signer: Signer;
1155
+ signer?: Signer;
1138
1156
  walletClient?: WalletClient;
1139
1157
  brokerAddress: string;
1140
1158
  isTestnet?: boolean;
@@ -1151,6 +1169,8 @@ declare class ConfigManager {
1151
1169
  private accessToken?;
1152
1170
  private accessTokenExpiry?;
1153
1171
  constructor(config: MyxClientConfig);
1172
+ clear(): void;
1173
+ auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken">): void;
1154
1174
  private validateConfig;
1155
1175
  /**
1156
1176
  * 获取有效的 accessToken,自动处理获取和刷新
@@ -1348,11 +1368,12 @@ declare class Position {
1348
1368
  * @desc temp skip eip7702
1349
1369
  * @todo adjustCollateral 调整保证金
1350
1370
  */
1351
- adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, }: {
1371
+ adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, poolOracleType, }: {
1352
1372
  poolId: string;
1353
1373
  positionId: string;
1354
1374
  adjustAmount: string;
1355
1375
  quoteToken: string;
1376
+ poolOracleType: OracleType;
1356
1377
  }): Promise<{
1357
1378
  code: number;
1358
1379
  data: {
@@ -1522,6 +1543,14 @@ declare class MyxClient {
1522
1543
  */
1523
1544
  getConfigManager(): ConfigManager;
1524
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;
1525
1554
  }
1526
1555
 
1527
- 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, 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;
@@ -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;
@@ -623,6 +637,8 @@ interface PositionHistoryItem {
623
637
  baseSymbol: string;
624
638
  quoteSymbol: string;
625
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
  /**
@@ -644,6 +660,8 @@ interface TradeFlowItem {
644
660
  baseSymbol: string;
645
661
  quoteSymbol: string;
646
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
 
@@ -1134,7 +1152,7 @@ interface AccessTokenResponse {
1134
1152
  }
1135
1153
  interface MyxClientConfig {
1136
1154
  chainId: number;
1137
- signer: Signer;
1155
+ signer?: Signer;
1138
1156
  walletClient?: WalletClient;
1139
1157
  brokerAddress: string;
1140
1158
  isTestnet?: boolean;
@@ -1151,6 +1169,8 @@ declare class ConfigManager {
1151
1169
  private accessToken?;
1152
1170
  private accessTokenExpiry?;
1153
1171
  constructor(config: MyxClientConfig);
1172
+ clear(): void;
1173
+ auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken">): void;
1154
1174
  private validateConfig;
1155
1175
  /**
1156
1176
  * 获取有效的 accessToken,自动处理获取和刷新
@@ -1348,11 +1368,12 @@ declare class Position {
1348
1368
  * @desc temp skip eip7702
1349
1369
  * @todo adjustCollateral 调整保证金
1350
1370
  */
1351
- adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, }: {
1371
+ adjustCollateral({ poolId, positionId, adjustAmount, quoteToken, poolOracleType, }: {
1352
1372
  poolId: string;
1353
1373
  positionId: string;
1354
1374
  adjustAmount: string;
1355
1375
  quoteToken: string;
1376
+ poolOracleType: OracleType;
1356
1377
  }): Promise<{
1357
1378
  code: number;
1358
1379
  data: {
@@ -1522,6 +1543,14 @@ declare class MyxClient {
1522
1543
  */
1523
1544
  getConfigManager(): ConfigManager;
1524
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;
1525
1554
  }
1526
1555
 
1527
- 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, 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,
@@ -1826,7 +1827,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
1826
1827
  // package.json
1827
1828
  var package_default = {
1828
1829
  name: "@myx-trade/sdk",
1829
- version: "0.1.17",
1830
+ version: "0.1.18",
1830
1831
  private: false,
1831
1832
  publishConfig: {
1832
1833
  access: "public"
@@ -9694,10 +9695,10 @@ var MarketPoolState = /* @__PURE__ */ ((MarketPoolState3) => {
9694
9695
  MarketPoolState3[MarketPoolState3["Bench"] = 4] = "Bench";
9695
9696
  return MarketPoolState3;
9696
9697
  })(MarketPoolState || {});
9697
- var OracleType = /* @__PURE__ */ ((OracleType6) => {
9698
- OracleType6[OracleType6["Chainlink"] = 1] = "Chainlink";
9699
- OracleType6[OracleType6["Pyth"] = 2] = "Pyth";
9700
- return OracleType6;
9698
+ var OracleType = /* @__PURE__ */ ((OracleType7) => {
9699
+ OracleType7[OracleType7["Chainlink"] = 1] = "Chainlink";
9700
+ OracleType7[OracleType7["Pyth"] = 2] = "Pyth";
9701
+ return OracleType7;
9701
9702
  })(OracleType || {});
9702
9703
  var HttpKlineIntervalEnum = /* @__PURE__ */ ((HttpKlineIntervalEnum2) => {
9703
9704
  HttpKlineIntervalEnum2[HttpKlineIntervalEnum2["Minute1"] = 1] = "Minute1";
@@ -9787,6 +9788,19 @@ var getHistoryOrders = async ({
9787
9788
  }
9788
9789
  );
9789
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 || {});
9790
9804
  var getPositionHistory = async ({
9791
9805
  accessToken,
9792
9806
  ...params
@@ -11966,6 +11980,22 @@ var ConfigManager = class {
11966
11980
  this.validateConfig(mergedConfig);
11967
11981
  this.config = mergedConfig;
11968
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
+ }
11969
11999
  validateConfig(config) {
11970
12000
  const { isTestnet, chainId: chainId2 } = config;
11971
12001
  if (isTestnet) {
@@ -12382,9 +12412,13 @@ var Position = class {
12382
12412
  poolId,
12383
12413
  positionId,
12384
12414
  adjustAmount,
12385
- quoteToken
12415
+ quoteToken,
12416
+ poolOracleType
12386
12417
  }) {
12387
12418
  const config = this.configManager.getConfig();
12419
+ if (!config.signer) {
12420
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12421
+ }
12388
12422
  this.logger.debug("adjustCollateral-->", {
12389
12423
  poolId,
12390
12424
  positionId,
@@ -12400,7 +12434,8 @@ var Position = class {
12400
12434
  poolId,
12401
12435
  referencePrice: import_ethers24.ethers.parseUnits(priceData?.price ?? "0", 30),
12402
12436
  oracleUpdateData: priceData?.vaa ?? "0",
12403
- publishTime: priceData.publishTime
12437
+ publishTime: priceData.publishTime,
12438
+ oracleType: poolOracleType
12404
12439
  };
12405
12440
  const contractAddress = getContractAddressByChainId(config.chainId);
12406
12441
  if (Number(adjustAmount) > 0) {
@@ -12461,6 +12496,7 @@ var Position = class {
12461
12496
  message: "Adjust collateral transaction submitted"
12462
12497
  };
12463
12498
  } catch (error) {
12499
+ console.log(error, "error");
12464
12500
  const errorMessage = await this.utils.getErrorMessage(error);
12465
12501
  this.logger.error("adjustCollateral error-->", errorMessage);
12466
12502
  return {
@@ -12537,6 +12573,9 @@ var Order = class {
12537
12573
  async createIncreaseOrder(params) {
12538
12574
  try {
12539
12575
  const config = this.configManager.getConfig();
12576
+ if (!config.signer) {
12577
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12578
+ }
12540
12579
  const brokerContract = await getBrokerSingerContract(
12541
12580
  params.chainId,
12542
12581
  config.signer
@@ -12653,6 +12692,9 @@ var Order = class {
12653
12692
  async createDecreaseOrder(params) {
12654
12693
  try {
12655
12694
  const config = this.configManager.getConfig();
12695
+ if (!config.signer) {
12696
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12697
+ }
12656
12698
  const brokerContract = await getBrokerSingerContract(
12657
12699
  params.chainId,
12658
12700
  config.signer
@@ -12765,6 +12807,9 @@ var Order = class {
12765
12807
  async createPositionTpSlOrder(params) {
12766
12808
  try {
12767
12809
  const config = this.configManager.getConfig();
12810
+ if (!config.signer) {
12811
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12812
+ }
12768
12813
  const brokerContract = await getBrokerSingerContract(
12769
12814
  params.chainId,
12770
12815
  config.signer
@@ -12929,6 +12974,9 @@ var Order = class {
12929
12974
  async cancelOrder(orderId) {
12930
12975
  try {
12931
12976
  const config = this.configManager.getConfig();
12977
+ if (!config.signer) {
12978
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12979
+ }
12932
12980
  const brokerContract = await getBrokerSingerContract(
12933
12981
  config.chainId,
12934
12982
  config.signer
@@ -12950,6 +12998,9 @@ var Order = class {
12950
12998
  async cancelOrders(orderIds) {
12951
12999
  try {
12952
13000
  const config = this.configManager.getConfig();
13001
+ if (!config.signer) {
13002
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
13003
+ }
12953
13004
  const brokerContract = await getBrokerSingerContract(
12954
13005
  config.chainId,
12955
13006
  config.signer
@@ -12971,6 +13022,9 @@ var Order = class {
12971
13022
  }
12972
13023
  async updateOrderTpSl(params) {
12973
13024
  const config = this.configManager.getConfig();
13025
+ if (!config.signer) {
13026
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
13027
+ }
12974
13028
  console.log("updateOrderTpSl params", params);
12975
13029
  const brokerContract = await getBrokerSingerContract(
12976
13030
  config.chainId,
@@ -16781,6 +16835,12 @@ var Utils = class {
16781
16835
  "function allowance(address owner, address spender) external view returns (uint256)"
16782
16836
  ];
16783
16837
  const config = this.configManager.getConfig();
16838
+ if (!config.signer) {
16839
+ throw new MyxSDKError(
16840
+ "INVALID_SIGNER" /* InvalidSigner */,
16841
+ "Invalid signer"
16842
+ );
16843
+ }
16784
16844
  const owner = await config.signer.getAddress();
16785
16845
  const spender = spenderAddress ?? getContractAddressByChainId(config.chainId).ORDER_MANAGER;
16786
16846
  const tokenContract = new import_ethers25.ethers.Contract(
@@ -18091,6 +18151,12 @@ var Account = class {
18091
18151
  }
18092
18152
  async getWalletQuoteTokenBalance() {
18093
18153
  const config = this.configManager.getConfig();
18154
+ if (!config.signer) {
18155
+ throw new MyxSDKError(
18156
+ "INVALID_SIGNER" /* InvalidSigner */,
18157
+ "Invalid signer"
18158
+ );
18159
+ }
18094
18160
  const contractAddress = getContractAddressByChainId(config.chainId);
18095
18161
  const erc20Contract = new import_ethers26.ethers.Contract(
18096
18162
  contractAddress.ERC20,
@@ -18108,6 +18174,12 @@ var Account = class {
18108
18174
  */
18109
18175
  async getTradableAmount({ poolId }) {
18110
18176
  const config = this.configManager.getConfig();
18177
+ if (!config.signer) {
18178
+ throw new MyxSDKError(
18179
+ "INVALID_SIGNER" /* InvalidSigner */,
18180
+ "Invalid signer"
18181
+ );
18182
+ }
18111
18183
  const contractAddress = getContractAddressByChainId(config.chainId);
18112
18184
  const accountContract = new import_ethers26.ethers.Contract(
18113
18185
  contractAddress.Account,
@@ -18176,12 +18248,26 @@ var MyxClient = class {
18176
18248
  }
18177
18249
  lp.setConfigManager(this.configManager);
18178
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
+ }
18179
18264
  };
18180
18265
  // Annotate the CommonJS export names for ESM import in node:
18181
18266
  0 && (module.exports = {
18182
18267
  COMMON_LP_AMOUNT_DECIMALS,
18183
18268
  COMMON_PRICE_DECIMALS,
18184
18269
  ChainId,
18270
+ CloseTypeEnum,
18185
18271
  Direction,
18186
18272
  DirectionEnum,
18187
18273
  ErrorCode,
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.17",
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
@@ -11881,6 +11894,22 @@ var ConfigManager = class {
11881
11894
  this.validateConfig(mergedConfig);
11882
11895
  this.config = mergedConfig;
11883
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
+ }
11884
11913
  validateConfig(config) {
11885
11914
  const { isTestnet, chainId: chainId2 } = config;
11886
11915
  if (isTestnet) {
@@ -12297,9 +12326,13 @@ var Position = class {
12297
12326
  poolId,
12298
12327
  positionId,
12299
12328
  adjustAmount,
12300
- quoteToken
12329
+ quoteToken,
12330
+ poolOracleType
12301
12331
  }) {
12302
12332
  const config = this.configManager.getConfig();
12333
+ if (!config.signer) {
12334
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12335
+ }
12303
12336
  this.logger.debug("adjustCollateral-->", {
12304
12337
  poolId,
12305
12338
  positionId,
@@ -12315,7 +12348,8 @@ var Position = class {
12315
12348
  poolId,
12316
12349
  referencePrice: ethers5.parseUnits(priceData?.price ?? "0", 30),
12317
12350
  oracleUpdateData: priceData?.vaa ?? "0",
12318
- publishTime: priceData.publishTime
12351
+ publishTime: priceData.publishTime,
12352
+ oracleType: poolOracleType
12319
12353
  };
12320
12354
  const contractAddress = getContractAddressByChainId(config.chainId);
12321
12355
  if (Number(adjustAmount) > 0) {
@@ -12376,6 +12410,7 @@ var Position = class {
12376
12410
  message: "Adjust collateral transaction submitted"
12377
12411
  };
12378
12412
  } catch (error) {
12413
+ console.log(error, "error");
12379
12414
  const errorMessage = await this.utils.getErrorMessage(error);
12380
12415
  this.logger.error("adjustCollateral error-->", errorMessage);
12381
12416
  return {
@@ -12452,6 +12487,9 @@ var Order = class {
12452
12487
  async createIncreaseOrder(params) {
12453
12488
  try {
12454
12489
  const config = this.configManager.getConfig();
12490
+ if (!config.signer) {
12491
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12492
+ }
12455
12493
  const brokerContract = await getBrokerSingerContract(
12456
12494
  params.chainId,
12457
12495
  config.signer
@@ -12568,6 +12606,9 @@ var Order = class {
12568
12606
  async createDecreaseOrder(params) {
12569
12607
  try {
12570
12608
  const config = this.configManager.getConfig();
12609
+ if (!config.signer) {
12610
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12611
+ }
12571
12612
  const brokerContract = await getBrokerSingerContract(
12572
12613
  params.chainId,
12573
12614
  config.signer
@@ -12680,6 +12721,9 @@ var Order = class {
12680
12721
  async createPositionTpSlOrder(params) {
12681
12722
  try {
12682
12723
  const config = this.configManager.getConfig();
12724
+ if (!config.signer) {
12725
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12726
+ }
12683
12727
  const brokerContract = await getBrokerSingerContract(
12684
12728
  params.chainId,
12685
12729
  config.signer
@@ -12844,6 +12888,9 @@ var Order = class {
12844
12888
  async cancelOrder(orderId) {
12845
12889
  try {
12846
12890
  const config = this.configManager.getConfig();
12891
+ if (!config.signer) {
12892
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12893
+ }
12847
12894
  const brokerContract = await getBrokerSingerContract(
12848
12895
  config.chainId,
12849
12896
  config.signer
@@ -12865,6 +12912,9 @@ var Order = class {
12865
12912
  async cancelOrders(orderIds) {
12866
12913
  try {
12867
12914
  const config = this.configManager.getConfig();
12915
+ if (!config.signer) {
12916
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12917
+ }
12868
12918
  const brokerContract = await getBrokerSingerContract(
12869
12919
  config.chainId,
12870
12920
  config.signer
@@ -12886,6 +12936,9 @@ var Order = class {
12886
12936
  }
12887
12937
  async updateOrderTpSl(params) {
12888
12938
  const config = this.configManager.getConfig();
12939
+ if (!config.signer) {
12940
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
12941
+ }
12889
12942
  console.log("updateOrderTpSl params", params);
12890
12943
  const brokerContract = await getBrokerSingerContract(
12891
12944
  config.chainId,
@@ -16696,6 +16749,12 @@ var Utils = class {
16696
16749
  "function allowance(address owner, address spender) external view returns (uint256)"
16697
16750
  ];
16698
16751
  const config = this.configManager.getConfig();
16752
+ if (!config.signer) {
16753
+ throw new MyxSDKError(
16754
+ "INVALID_SIGNER" /* InvalidSigner */,
16755
+ "Invalid signer"
16756
+ );
16757
+ }
16699
16758
  const owner = await config.signer.getAddress();
16700
16759
  const spender = spenderAddress ?? getContractAddressByChainId(config.chainId).ORDER_MANAGER;
16701
16760
  const tokenContract = new ethers6.Contract(
@@ -18006,6 +18065,12 @@ var Account = class {
18006
18065
  }
18007
18066
  async getWalletQuoteTokenBalance() {
18008
18067
  const config = this.configManager.getConfig();
18068
+ if (!config.signer) {
18069
+ throw new MyxSDKError(
18070
+ "INVALID_SIGNER" /* InvalidSigner */,
18071
+ "Invalid signer"
18072
+ );
18073
+ }
18009
18074
  const contractAddress = getContractAddressByChainId(config.chainId);
18010
18075
  const erc20Contract = new ethers7.Contract(
18011
18076
  contractAddress.ERC20,
@@ -18023,6 +18088,12 @@ var Account = class {
18023
18088
  */
18024
18089
  async getTradableAmount({ poolId }) {
18025
18090
  const config = this.configManager.getConfig();
18091
+ if (!config.signer) {
18092
+ throw new MyxSDKError(
18093
+ "INVALID_SIGNER" /* InvalidSigner */,
18094
+ "Invalid signer"
18095
+ );
18096
+ }
18026
18097
  const contractAddress = getContractAddressByChainId(config.chainId);
18027
18098
  const accountContract = new ethers7.Contract(
18028
18099
  contractAddress.Account,
@@ -18091,11 +18162,25 @@ var MyxClient = class {
18091
18162
  }
18092
18163
  lp.setConfigManager(this.configManager);
18093
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
+ }
18094
18178
  };
18095
18179
  export {
18096
18180
  COMMON_LP_AMOUNT_DECIMALS,
18097
18181
  COMMON_PRICE_DECIMALS,
18098
18182
  ChainId,
18183
+ CloseTypeEnum,
18099
18184
  Direction,
18100
18185
  DirectionEnum,
18101
18186
  ErrorCode2 as ErrorCode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"