@nightlylabs/dex-sdk 0.3.38 → 0.3.39

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.cjs CHANGED
@@ -23578,6 +23578,7 @@ var EndpointsV1 = /* @__PURE__ */ ((EndpointsV12) => {
23578
23578
  EndpointsV12["GetIndexPrices"] = "/v1/get_index_prices";
23579
23579
  EndpointsV12["GetAccountValueRanking"] = "/v1/get_account_value_ranking";
23580
23580
  EndpointsV12["GetUserAccountValueRanking"] = "/v1/get_user_account_value_ranking";
23581
+ EndpointsV12["GetExchangeStatsHistory"] = "/v1/get_exchange_stats_history";
23581
23582
  return EndpointsV12;
23582
23583
  })(EndpointsV1 || {});
23583
23584
  var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
@@ -23933,13 +23934,15 @@ var AccountSequenceNumber = class {
23933
23934
  // src/client.ts
23934
23935
  var getRandomId = () => (0, import_uuid.v7)();
23935
23936
  var Client = class _Client {
23936
- constructor(connection, enableWs, url, apiKey, chainId, params, networkMode = "testnet") {
23937
+ constructor(connection, config = {}) {
23937
23938
  this._apiKeySequenceNumber = 0;
23938
23939
  this._subscriptions = /* @__PURE__ */ new Map();
23939
23940
  this._gasUnitPrice = 100;
23940
23941
  this._expirationTimestampDelay = 20;
23941
23942
  // 20 seconds
23942
23943
  this.timeout = 5e3;
23944
+ // Same as below in init
23945
+ this.wsDebug = false;
23943
23946
  /////////////////////////////////// Sponsored transactions
23944
23947
  this.submitSponsoredTransaction = async (tx, signature) => {
23945
23948
  const payload = {
@@ -24377,27 +24380,27 @@ var Client = class _Client {
24377
24380
  const response = await this.sendGetJson("/time" /* Time */);
24378
24381
  return response.time;
24379
24382
  };
24383
+ const networkMode = config.networkMode || "testnet";
24380
24384
  const networkConfig = getNetworkConfig(networkMode);
24381
24385
  this._aptos = connection;
24382
- this._chainId = chainId || networkConfig.chainId;
24383
- this._apiKey = apiKey || generateApiKey();
24386
+ this._chainId = config.chainId || networkConfig.chainId;
24387
+ this._apiKey = config.apiKey || generateApiKey();
24384
24388
  this._subscriptions = /* @__PURE__ */ new Map();
24385
- this._serverUrl = url || networkConfig.apiUrl;
24389
+ this._serverUrl = config.url || networkConfig.apiUrl;
24386
24390
  this._sequenceNumberManager = new AccountSequenceNumber(this._aptos, this._apiKey);
24387
24391
  this._abis = getABIsForNetwork(networkMode);
24388
24392
  this._contractAddress = Object.values(this._abis)[0].address;
24389
- this._maxGas = params?.maxGas || 2e4;
24390
- this._gasUnitPrice = params?.gasUnitPrice || 100;
24391
- this._expirationTimestampDelay = params?.expirationTimestampSecs || 20;
24392
- if (enableWs) {
24393
- this.connectWebSocket();
24394
- }
24393
+ this._maxGas = config.params?.maxGas || 2e4;
24394
+ this._gasUnitPrice = config.params?.gasUnitPrice || 100;
24395
+ this._expirationTimestampDelay = config.params?.expirationTimestampSecs || 20;
24396
+ this.wsDebug = config.wsDebug || false;
24397
+ this.timeout = config.timeout || 5e3;
24395
24398
  }
24396
- static async init(connection, enableWs = true, url, apiKey, chainId, params, networkMode = "testnet") {
24397
- const id = chainId || await connection.getChainId();
24398
- const client = new _Client(connection, enableWs, url, apiKey, id, params, networkMode);
24399
- if (enableWs) {
24400
- client.connectWebSocket();
24399
+ static async init(connection, config = {}) {
24400
+ const id = config.chainId || await connection.getChainId();
24401
+ const client = new _Client(connection, { ...config, chainId: id });
24402
+ if (config.enableWs !== false) {
24403
+ await client.connectWebSocket();
24401
24404
  }
24402
24405
  return client;
24403
24406
  }
@@ -24405,10 +24408,7 @@ var Client = class _Client {
24405
24408
  * Create a new Client instance
24406
24409
  *
24407
24410
  * @param connection - Aptos connection instance
24408
- * @param networkMode - Network mode ('testnet' or 'mainnet'). Defaults to 'testnet'
24409
- * @param enableWs - Enable WebSocket connection. Defaults to true
24410
- * @param url - Custom API URL. If not provided, uses default URL based on network mode
24411
- * @param apiKey - API key account. If not provided, generates a new one
24411
+ * @param config - Client configuration options
24412
24412
  * @returns Promise<Client>
24413
24413
  *
24414
24414
  * @example
@@ -24417,23 +24417,24 @@ var Client = class _Client {
24417
24417
  *
24418
24418
  * @example
24419
24419
  * // Create a mainnet client
24420
- * const client = await Client.create(aptos, 'mainnet')
24420
+ * const client = await Client.create(aptos, { networkMode: 'mainnet' })
24421
+ *
24422
+ * @example
24423
+ * // Create an HTTP-only client (no WebSocket)
24424
+ * const client = await Client.create(aptos, { enableWs: false })
24421
24425
  *
24422
24426
  * @example
24423
24427
  * // Create a client with custom settings
24424
- * const client = await Client.create(
24425
- * aptos,
24426
- * 'mainnet',
24427
- * true, // enable WebSocket
24428
- * 'https://custom-api.example.com', // custom API URL
24429
- * myApiKeyAccount // custom API key
24430
- * )
24428
+ * const client = await Client.create(aptos, {
24429
+ * networkMode: 'mainnet',
24430
+ * url: 'https://custom-api.example.com',
24431
+ * apiKey: myApiKeyAccount,
24432
+ * wsDebug: true,
24433
+ * timeout: 10000,
24434
+ * })
24431
24435
  */
24432
- static async create(connection, networkMode = "testnet", enableWs = true, url, apiKey) {
24433
- const networkConfig = getNetworkConfig(networkMode);
24434
- const apiUrl = url || networkConfig.apiUrl;
24435
- const chainId = networkConfig.chainId;
24436
- return _Client.init(connection, enableWs, apiUrl, apiKey, chainId, void 0, networkMode);
24436
+ static async create(connection, config = {}) {
24437
+ return _Client.init(connection, config);
24437
24438
  }
24438
24439
  async setApiKey(apiKey) {
24439
24440
  this._apiKey = apiKey;
@@ -24459,19 +24460,48 @@ var Client = class _Client {
24459
24460
  this._expirationTimestampDelay = params.expirationTimestampSecs;
24460
24461
  }
24461
24462
  //////////////////////////////////////// Websocket functions
24463
+ _wsLog(...args) {
24464
+ if (this.wsDebug) console.log("[WS]", ...args);
24465
+ }
24466
+ setWsDebugActive(active) {
24467
+ this.wsDebug = active;
24468
+ }
24462
24469
  async connectWebSocket() {
24463
24470
  if (this._ws) {
24464
24471
  console.warn("WebSocket is already connected");
24465
24472
  return;
24466
24473
  }
24467
24474
  try {
24468
- this._ws = await _Client.initWebSocket(this._serverUrl, this.timeout);
24475
+ this._wsLog("Connecting to", this._serverUrl);
24476
+ this._ws = await this._initWebSocket(this._serverUrl, this.timeout);
24469
24477
  this._setupWebSocketHandlers();
24470
- return;
24478
+ this._wsLog("Connected");
24471
24479
  } catch (error) {
24480
+ this._wsLog("Connection failed:", error);
24472
24481
  throw new Error(`Failed to connect WebSocket: ${error}`);
24473
24482
  }
24474
24483
  }
24484
+ _initWebSocket(url, timeout) {
24485
+ return new Promise((resolve, reject) => {
24486
+ const wsUrl = `${url.replace("http", "ws").replace("https", "wss")}` + "/v1/ws" /* Ws */;
24487
+ this._wsLog("initWebSocket url:", wsUrl, "timeout:", timeout);
24488
+ const ws = new WebSocket(wsUrl);
24489
+ const timer = setTimeout(() => {
24490
+ this._wsLog("initWebSocket timeout after", timeout, "ms");
24491
+ reject(new Error("WebSocket connection timeout"));
24492
+ }, timeout);
24493
+ ws.onopen = () => {
24494
+ clearTimeout(timer);
24495
+ this._wsLog("initWebSocket opened");
24496
+ resolve(ws);
24497
+ };
24498
+ ws.onerror = (error) => {
24499
+ clearTimeout(timer);
24500
+ this._wsLog("initWebSocket error:", error);
24501
+ reject(error);
24502
+ };
24503
+ });
24504
+ }
24475
24505
  _setupWebSocketHandlers() {
24476
24506
  if (!this._ws) return;
24477
24507
  this._ws.onmessage = async (msg) => {
@@ -24482,49 +24512,52 @@ var Client = class _Client {
24482
24512
  data = msg.data;
24483
24513
  }
24484
24514
  const decodedMsg = JSON.parse(data);
24515
+ this._wsLog("Received:", decodedMsg.type, decodedMsg.content);
24485
24516
  const topic = getTopicFromMessage(decodedMsg);
24486
24517
  const callback = this._subscriptions.get(topic);
24487
24518
  if (callback) {
24488
24519
  callback(decodedMsg);
24520
+ } else {
24521
+ this._wsLog("No handler for topic:", topic);
24489
24522
  }
24490
24523
  };
24491
- }
24492
- static async initWebSocket(url, timeout = 5e3) {
24493
- return new Promise((resolve, reject) => {
24494
- const ws = new WebSocket(
24495
- `${url.replace("http", "ws").replace("https", "wss")}` + "/v1/ws" /* Ws */
24524
+ this._ws.onclose = (event) => {
24525
+ this._wsLog(
24526
+ "Closed: code=" + event.code,
24527
+ "reason=" + event.reason,
24528
+ "clean=" + event.wasClean
24496
24529
  );
24497
- const timer = setTimeout(() => {
24498
- reject(new Error("WebSocket connection timeout"));
24499
- }, timeout);
24500
- ws.onopen = () => {
24501
- clearTimeout(timer);
24502
- resolve(ws);
24503
- };
24504
- ws.onerror = (error) => {
24505
- clearTimeout(timer);
24506
- reject(error);
24507
- };
24508
- });
24530
+ this._ws = void 0;
24531
+ this._subscriptions.clear();
24532
+ this.onWsClose?.(event);
24533
+ };
24534
+ this._ws.onerror = (error) => {
24535
+ this._wsLog("Error:", error);
24536
+ };
24509
24537
  }
24510
24538
  async disconnectWebSocket() {
24511
24539
  if (!this._ws) {
24512
24540
  console.warn("WebSocket is not connected");
24513
24541
  return;
24514
24542
  }
24543
+ this._wsLog("Disconnecting, clearing", this._subscriptions.size, "subscriptions");
24515
24544
  this._subscriptions.clear();
24516
24545
  this._ws.close();
24517
24546
  this._ws = void 0;
24518
24547
  }
24519
24548
  // Method to check if WebSocket is connected
24520
24549
  isWebSocketConnected() {
24521
- return this._ws !== void 0 && this._ws.readyState === WebSocket.OPEN;
24550
+ const connected = this._ws !== void 0 && this._ws.readyState === WebSocket.OPEN;
24551
+ this._wsLog("isWebSocketConnected:", connected);
24552
+ return connected;
24522
24553
  }
24523
24554
  sendWsMessage(message) {
24524
24555
  if (!this._ws) throw new Error("WebSocket is not connected");
24525
24556
  return new Promise((resolve, reject) => {
24526
24557
  const topic = message.content.id;
24558
+ this._wsLog("Sending:", message.type, "id=" + topic);
24527
24559
  const timer = setTimeout(() => {
24560
+ this._wsLog("Timeout waiting for response:", message.type, "id=" + topic);
24528
24561
  reject(new Error(`Connection timed out after ${this.timeout} ms`));
24529
24562
  }, this.timeout);
24530
24563
  let handler = (response) => {
@@ -24532,11 +24565,13 @@ var Client = class _Client {
24532
24565
  this._subscriptions.delete(topic);
24533
24566
  if (response.type === "Error") {
24534
24567
  const errorMessage = response.content.message || "Unknown websocket error without message";
24568
+ this._wsLog("Error response:", errorMessage, "id=" + topic);
24535
24569
  reject(
24536
24570
  new Error(`WebSocket error (id: ${response.content.id}): ${errorMessage}`)
24537
24571
  );
24538
24572
  return;
24539
24573
  }
24574
+ this._wsLog("Ack received for:", message.type, "id=" + topic);
24540
24575
  resolve(response);
24541
24576
  };
24542
24577
  this._subscriptions.set(topic, handler);
@@ -25453,11 +25488,11 @@ function parseEntryFunctionAbi(args) {
25453
25488
  // src/testFaucet.ts
25454
25489
  var import_ts_sdk4 = require("@aptos-labs/ts-sdk");
25455
25490
  var TestFaucet = class _TestFaucet extends client_default {
25456
- constructor(connection, enableWs, url, apiKey, networkMode = "testnet") {
25457
- super(connection, enableWs, url, apiKey, void 0, void 0, networkMode);
25491
+ constructor(connection, config = {}) {
25492
+ super(connection, config);
25458
25493
  }
25459
- static async create(connection, networkMode = "testnet", enableWs = false, url = "https://api.dev.neony.exchange", apiKey) {
25460
- return new _TestFaucet(connection, enableWs, url, apiKey, networkMode);
25494
+ static async create(connection, config = {}) {
25495
+ return new _TestFaucet(connection, { enableWs: false, ...config });
25461
25496
  }
25462
25497
  async initFaucetPayload() {
25463
25498
  const abi = this._abis.FaucetEntrypointsABI;
package/dist/index.d.cts CHANGED
@@ -3682,6 +3682,7 @@ interface TokenConfigEntry {
3682
3682
  contractAddress: string;
3683
3683
  tokenDecimals: number;
3684
3684
  vaultId?: string;
3685
+ createdAt?: string;
3685
3686
  }
3686
3687
  interface MarginStep {
3687
3688
  initialMarginRatio: string;
@@ -3709,6 +3710,7 @@ interface PerpMarketConfigEntry {
3709
3710
  fundingRate: FundingRate;
3710
3711
  basicMakerFee: string;
3711
3712
  basicTakerFee: string;
3713
+ createdAt?: string;
3712
3714
  }
3713
3715
  interface SpotMarketConfigEntry {
3714
3716
  marketName: string;
@@ -3718,6 +3720,7 @@ interface SpotMarketConfigEntry {
3718
3720
  tickSize: string;
3719
3721
  basicMakerFee: string;
3720
3722
  basicTakerFee: string;
3723
+ createdAt?: string;
3721
3724
  }
3722
3725
  interface FeeData {
3723
3726
  feeToVaultAccount: string;
@@ -3731,6 +3734,19 @@ interface ExchangeConfig {
3731
3734
  feeData: FeeData;
3732
3735
  systemHaircut: string;
3733
3736
  }
3737
+ interface TvlTokenEntry {
3738
+ tokenAddress: string;
3739
+ amount: string;
3740
+ valueUsd: string;
3741
+ }
3742
+ interface ExchangeStatsEntry {
3743
+ timestampOpen: string;
3744
+ timestampClose: string;
3745
+ tvlBreakdown: TvlTokenEntry[];
3746
+ perpVolumeUsd: string;
3747
+ spotVolumeUsd: string;
3748
+ openInterestUsd: string;
3749
+ }
3734
3750
  interface FeeTier {
3735
3751
  volume: string;
3736
3752
  cashback: string;
@@ -3762,13 +3778,6 @@ interface GetAccountValueRankingResponse {
3762
3778
  usersRanking: AccountValueRankingEntry[];
3763
3779
  paginationCursor?: PaginationCursor;
3764
3780
  }
3765
- interface GetUserAccountValueRankingRequest {
3766
- userId?: string;
3767
- userAddress?: string;
3768
- }
3769
- interface GetUserAccountValueRankingResponse {
3770
- usersRanking: AccountValueRankingEntry[];
3771
- }
3772
3781
  interface GetAllVaultsIdsResponse {
3773
3782
  vaultsIds: string[];
3774
3783
  }
@@ -3811,6 +3820,15 @@ interface GetChartCandlesInRangeResponse {
3811
3820
  chartCandles: ChartCandle[];
3812
3821
  paginationCursor?: PaginationCursor;
3813
3822
  }
3823
+ interface GetExchangeStatsHistoryRequest {
3824
+ olderTimestampMs?: string;
3825
+ newerTimestampMs?: string;
3826
+ paginationCursor?: PaginationCursor;
3827
+ }
3828
+ interface GetExchangeStatsHistoryResponse {
3829
+ data: ExchangeStatsEntry[];
3830
+ paginationCursor?: PaginationCursor;
3831
+ }
3814
3832
  interface GetIndexPriceHistoryRequest {
3815
3833
  priceIndex: string;
3816
3834
  olderTimestampMs?: string;
@@ -4154,6 +4172,13 @@ interface PointsRankingEntry {
4154
4172
  interface GetTopPointsRankingResponse {
4155
4173
  usersRanking: PointsRankingEntry[];
4156
4174
  }
4175
+ interface GetUserAccountValueRankingRequest {
4176
+ userId?: string;
4177
+ userAddress?: string;
4178
+ }
4179
+ interface GetUserAccountValueRankingResponse {
4180
+ usersRanking: AccountValueRankingEntry[];
4181
+ }
4157
4182
  interface GetUserAggregatedBoxRewardsStatsRequest {
4158
4183
  userId: string;
4159
4184
  }
@@ -5159,7 +5184,8 @@ declare enum EndpointsV1 {
5159
5184
  GetUserPersonalPointsRanking = "/v1/get_user_personal_points_ranking",
5160
5185
  GetIndexPrices = "/v1/get_index_prices",
5161
5186
  GetAccountValueRanking = "/v1/get_account_value_ranking",
5162
- GetUserAccountValueRanking = "/v1/get_user_account_value_ranking"
5187
+ GetUserAccountValueRanking = "/v1/get_user_account_value_ranking",
5188
+ GetExchangeStatsHistory = "/v1/get_exchange_stats_history"
5163
5189
  }
5164
5190
  type Topic = {
5165
5191
  type: "PerpMarket";
@@ -5432,6 +5458,16 @@ interface TxParams {
5432
5458
  gasUnitPrice: number;
5433
5459
  expirationTimestampSecs: number;
5434
5460
  }
5461
+ interface ClientConfig {
5462
+ enableWs?: boolean;
5463
+ url?: string;
5464
+ apiKey?: Account;
5465
+ chainId?: number;
5466
+ params?: TxParams;
5467
+ networkMode?: NetworkMode;
5468
+ wsDebug?: boolean;
5469
+ timeout?: number;
5470
+ }
5435
5471
  interface ChangePerpOrderParams {
5436
5472
  userId: string;
5437
5473
  market: string;
@@ -5748,18 +5784,17 @@ declare class Client {
5748
5784
  _gasUnitPrice: number;
5749
5785
  _expirationTimestampDelay: number;
5750
5786
  timeout: number;
5787
+ wsDebug: boolean;
5788
+ onWsClose: ((event: CloseEvent) => void) | undefined;
5751
5789
  _abis: ReturnType<typeof getABIsForNetwork>;
5752
5790
  _contractAddress: string;
5753
- static init(connection: Aptos, enableWs?: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams, networkMode?: NetworkMode): Promise<Client>;
5754
- constructor(connection: Aptos, enableWs: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams, networkMode?: NetworkMode);
5791
+ static init(connection: Aptos, config?: ClientConfig): Promise<Client>;
5792
+ constructor(connection: Aptos, config?: ClientConfig);
5755
5793
  /**
5756
5794
  * Create a new Client instance
5757
5795
  *
5758
5796
  * @param connection - Aptos connection instance
5759
- * @param networkMode - Network mode ('testnet' or 'mainnet'). Defaults to 'testnet'
5760
- * @param enableWs - Enable WebSocket connection. Defaults to true
5761
- * @param url - Custom API URL. If not provided, uses default URL based on network mode
5762
- * @param apiKey - API key account. If not provided, generates a new one
5797
+ * @param config - Client configuration options
5763
5798
  * @returns Promise<Client>
5764
5799
  *
5765
5800
  * @example
@@ -5768,27 +5803,33 @@ declare class Client {
5768
5803
  *
5769
5804
  * @example
5770
5805
  * // Create a mainnet client
5771
- * const client = await Client.create(aptos, 'mainnet')
5806
+ * const client = await Client.create(aptos, { networkMode: 'mainnet' })
5807
+ *
5808
+ * @example
5809
+ * // Create an HTTP-only client (no WebSocket)
5810
+ * const client = await Client.create(aptos, { enableWs: false })
5772
5811
  *
5773
5812
  * @example
5774
5813
  * // Create a client with custom settings
5775
- * const client = await Client.create(
5776
- * aptos,
5777
- * 'mainnet',
5778
- * true, // enable WebSocket
5779
- * 'https://custom-api.example.com', // custom API URL
5780
- * myApiKeyAccount // custom API key
5781
- * )
5814
+ * const client = await Client.create(aptos, {
5815
+ * networkMode: 'mainnet',
5816
+ * url: 'https://custom-api.example.com',
5817
+ * apiKey: myApiKeyAccount,
5818
+ * wsDebug: true,
5819
+ * timeout: 10000,
5820
+ * })
5782
5821
  */
5783
- static create(connection: Aptos, networkMode?: NetworkMode, enableWs?: boolean, url?: string, apiKey?: Account): Promise<Client>;
5822
+ static create(connection: Aptos, config?: ClientConfig): Promise<Client>;
5784
5823
  setApiKey(apiKey: Account): Promise<void>;
5785
5824
  getContractAddress(): string;
5786
5825
  getApiKeySequenceNumber(): Promise<bigint | null>;
5787
5826
  fetchApiKeySequenceNumber(): Promise<number>;
5788
5827
  setTxParams(params: TxParams): void;
5828
+ private _wsLog;
5829
+ setWsDebugActive(active: boolean): void;
5789
5830
  connectWebSocket(): Promise<void>;
5831
+ private _initWebSocket;
5790
5832
  private _setupWebSocketHandlers;
5791
- static initWebSocket(url: string, timeout?: number): Promise<WebSocket>;
5792
5833
  disconnectWebSocket(): Promise<void>;
5793
5834
  isWebSocketConnected(): boolean;
5794
5835
  sendWsMessage(message: WsCommand): Promise<WsMessage>;
@@ -5932,8 +5973,8 @@ declare const ExchangeProxies: {
5932
5973
  declare const GLOBAL_DENOMINATOR = 100000000;
5933
5974
 
5934
5975
  declare class TestFaucet extends Client {
5935
- constructor(connection: Aptos, enableWs: boolean, url?: string, apiKey?: Account, networkMode?: NetworkMode);
5936
- static create(connection: Aptos, networkMode?: NetworkMode, enableWs?: boolean, url?: string, apiKey?: Account): Promise<TestFaucet>;
5976
+ constructor(connection: Aptos, config?: ClientConfig);
5977
+ static create(connection: Aptos, config?: ClientConfig): Promise<TestFaucet>;
5937
5978
  initFaucetPayload(): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
5938
5979
  initFaucet(): Promise<SubmitSponsoredTransactionResponse>;
5939
5980
  mintTokenPayload(receiver: Address, token: string, amount: number): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
@@ -5947,4 +5988,4 @@ declare const generateApiKey: () => _aptos_labs_ts_sdk.Ed25519Account;
5947
5988
  declare const getTopicFromCommand: (data: WsCommand) => string;
5948
5989
  declare const getTopicFromMessage: (data: WsMessage) => string;
5949
5990
 
5950
- export { ABIs, type AccountValueRankingEntry, type AddApiCreditsParams, type AddApiKey, type AddApiKeyParams, type Address, AdminEndpoints, type ApiCreditsChange, type ApiStatus, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLendUpdate, type BorrowLending, type BorrowLendingAggregatedData, type BorrowLendingHistoricalData, type BoxOpeningEvent, type BoxReward, BoxRewardTier, type CancelAllPerpOrdersParams, type CancelAllSpotOrdersParams, type CancelPerpOrdersParams, type CancelSpotOrdersParams, type CanceledPerpOrderData, type CanceledPerpOrders, type CanceledPerpTriggerOrderData, type CanceledPerpTriggerOrders, type CanceledSpotOrderData, type CanceledSpotOrders, type ChangePerpOrderParams, type ChangeSpotOrderParams, type ChartCandle, ChartInterval, type CheckReferralCodeRequest, type CheckReferralCodeResponse, type ClaimDepositParams, type ClaimKickbackFeeParams, type ClaimReferralFee, type ClaimReferralFeesParams, type ClaimUserKickbackFee, type ClaimedKickback, type ClaimedReferralKickback, Client, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, type DepositTokenParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type FeeData, type FeeTier, type Fees, type FundingCheckpoint, type FundingPayment, type FundingRate, GLOBAL_DENOMINATOR, type GetAccountValueRankingRequest, type GetAccountValueRankingResponse, type GetAllVaultsIdsResponse, type GetBorrowLendingAggregatedStatsRequest, type GetBorrowLendingAggregatedStatsResponse, type GetBorrowLendingDataResponse, type GetBorrowLendingHistoricalDataRequest, type GetBorrowLendingHistoricalDataResponse, type GetChartCandlesInRangeRequest, type GetChartCandlesInRangeResponse, type GetIndexPriceHistoryRequest, type GetIndexPriceHistoryResponse, type GetIndexPricesResponse, type GetIndexerStatusResponse, type GetOrderBookDataRequest, type GetOrderBookDataResponse, type GetPerpMarketsConfigResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpRecentTradesRequest, type GetPerpRecentTradesResponse, type GetPerpUserFillsRequest, type GetPerpUserFillsResponse, type GetPerpUserOrdersRequest, type GetPerpUserOrdersResponse, type GetPerpUserTriggerOrdersRequest, type GetPerpUserTriggerOrdersResponse, type GetPriceIndexesResponse, type GetServicesStatusResponse, type GetSpotMarketsConfigResponse, type GetSpotMarketsDataRequest, type GetSpotMarketsDataResponse, type GetSpotRecentTradesRequest, type GetSpotRecentTradesResponse, type GetSpotUserFillsRequest, type GetSpotUserFillsResponse, type GetSpotUserOrdersRequest, type GetSpotUserOrdersResponse, type GetTokenAggregatedStatsRequest, type GetTokenAggregatedStatsResponse, type GetTokenStatsHistoryRequest, type GetTokenStatsHistoryResponse, type GetTokensConfigResponse, type GetTopPointsRankingResponse, type GetUserAccountValueRankingRequest, type GetUserAccountValueRankingResponse, type GetUserAggregatedBoxRewardsStatsRequest, type GetUserAggregatedBoxRewardsStatsResponse, type GetUserAggregatedReferralStatsRequest, type GetUserAggregatedReferralStatsResponse, type GetUserAggregatedStatsRequest, type GetUserAggregatedStatsResponse, type GetUserAggregatedVaultStatsRequest, type GetUserAggregatedVaultStatsResponse, type GetUserBoxRewardsStatsHistoryRequest, type GetUserBoxRewardsStatsHistoryResponse, type GetUserBoxesHistoryRequest, type GetUserBoxesHistoryResponse, type GetUserClaimedKickbackHistoryRequest, type GetUserClaimedKickbackHistoryResponse, type GetUserClaimedReferralKickbackHistoryRequest, type GetUserClaimedReferralKickbackHistoryResponse, type GetUserDataRequest, type GetUserDataResponse, type GetUserDepositsRequest, type GetUserDepositsResponse, type GetUserFullLiquidationsHistoryRequest, type GetUserFundingHistoryRequest, type GetUserFundingHistoryResponse, type GetUserLiquidationsCancelHistoryResponse, type GetUserLiquidationsCancelOrdersHistoryRequest, type GetUserLiquidationsHistoryResponse, type GetUserPartialLiquidationsHistoryRequest, type GetUserPartialLiquidationsHistoryResponse, type GetUserPersonalPointsRankingRequest, type GetUserPersonalPointsRankingResponse, type GetUserPointsHistoryRequest, type GetUserPointsHistoryResponse, type GetUserPortfolioValueRequest, type GetUserPortfolioValueResponse, type GetUserReferralStatsHistoryRequest, type GetUserReferralStatsHistoryResponse, type GetUserRewardsValueRequest, type GetUserRewardsValueResponse, type GetUserTradeStatsHistoryRequest, type GetUserTradeStatsHistoryResponse, type GetUserTransferHistoryRequest, type GetUserTransferHistoryResponse, type GetUserVaultDepositsRequest, type GetUserVaultDepositsResponse, type GetUserVaultWithdrawsRequest, type GetUserVaultWithdrawsResponse, type GetUserVolumeForReferralRequest, type GetUserVolumeForReferralResponse, type GetUserWithdrawalsRequest, type GetUserWithdrawalsResponse, type GetUsersByAddressRequest, type GetUsersByAddressResponse, type GetVaultDepositsRequest, type GetVaultDepositsResponse, type GetVaultHistoricalDataRequest, type GetVaultHistoricalDataResponse, type GetVaultWithdrawalsRequest, type GetVaultWithdrawalsResponse, type GlobalLiquidation, type GlobalPartialLiquidation, type HistoricBoxReward, type HistoricalBoxRewardsStats, type HistoricalDeposit, type HistoricalFullLiquidation, type HistoricalFunding, type HistoricalLiquidatedBorrow, type HistoricalLiquidatedCollateral, type HistoricalLiquidatedLend, type HistoricalLiquidatedPosition, type HistoricalLiquidationCancelOrders, type HistoricalPartialLiquidatedPosition, type HistoricalPartialLiquidation, type HistoricalPerpOrder, type HistoricalPoints, type HistoricalReferralStats, type HistoricalSpotOrder, type HistoricalTokenStats, type HistoricalTradeStats, type HistoricalUserTransfer, type HistoricalVaultDeposit, type HistoricalVaultWithdraw, type HistoricalWithdraw, type IndexPriceHistory, type IndexPriceLive, type Lend, type LendTokenParams, type Liquidation, type LiquidationCancelledOrderData, type LiquidationCancelledTriggerOrderData, MAINNET_CONFIG, type MarginStep, Network, type NetworkConfig, type NetworkMode, type NodeStatus, type OpenBoxesRequest, type OpenBoxesResponse, type OpenBoxesSignRequest, type OracleUpdate, type OracleUpdates, type OrderBookData, OrderSide, OrderStatus, OrderType, type PaginationCursor, type PartialLiquidation, type PerpFill, type PerpMarketConfigEntry, type PerpMarketData, type PerpOrder, type PerpOrderData, type PerpOrderDataForMarket, type PerpOrderFills, type PerpOrderbookState, type PerpOrderbookUpdate, type PerpPosition, type PerpTrade, type PerpTradesUpdate, type PerpTriggerOrder, type PerpTriggerOrderTriggered, type PlaceMultiplePerpOrdersParams, type PlaceMultipleSpotOrdersParams, type PlacePerpLimitOrder, type PlacePerpMarketOrder, type PlacePerpOrderParams, type PlacePerpTriggerOrder, type PlacePerpTriggerOrderParams, type PlaceSpotLimitOrder, type PlaceSpotMarketOrder, type PlaceSpotOrderParams, type PointsRankingEntry, type PriceIndex, type RedeemTokenParams, type Referral, type ReferralUpdate, type RemoveApiKey, type RemoveApiKeyParams, type RemoveApiKeySignerParams, type RepayBorrow, type ReplaceMultipleOrdersParams, type ReplaceMultipleSpotOrdersParams, type SetAlias, type SetAliasNameParams, type SetAutoLend, type SetAutolendParams, type SetReferralCodeParams, type SetReferralParamsRequest, type SetReferralParamsResponse, type SpotFill, type SpotMarketConfigEntry, type SpotMarketData, type SpotOrder, type SpotOrderData, type SpotOrderDataForMarket, type SpotOrderFills, type SpotOrderbookState, type SpotOrderbookUpdate, type SpotTrade, type SpotTradesUpdate, Status, type StatusResponse, type SubServiceStatus, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TESTNET_CONFIG, TestFaucet, type TimeResponse, type TokenAggregatedStats, type TokenConfigEntry, type TokenizeUserVaultInvestmentParams, type Topic, type Trade, TradeRole, TransferAction, type TransferToUserParams, type TriggerOrder, type TxParams, type UpdateUserFeeTier, type User, type UserAggregatedBoxRewardsStats, type UserAggregatedReferralStats, type UserAggregatedStats, type UserAggregatedVaultStats, type UserBoxOpeningEvent, type UserPointsBreakdown, type UserPortfolioValue, type UserRewardsValue, UserStatus, type UserTransfer, type UtilizationCurve, type Vault, type VaultDeposit, type VaultHistoricalData, type VaultInvestment, type VaultWithdraw, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WithdrawTokenParams, type WsBorrowLendUpdate, type WsBoxOpeningUpdate, type WsCommand, type WsFill, type WsLiquidatedBorrow, type WsLiquidatedCollateral, type WsLiquidatedLend, type WsLiquidatedPosition, type WsLiquidationUpdate, type WsMessage, type WsOracleUpdates, type WsPartialLiquidatedPosition, type WsPerpMarketUpdates, type WsSpotMarketUpdates, type WsUserUpdates, createAptosClient, createAptosClientFromEnv, generateApiKey, getABIsForNetwork, getNetworkConfig, getNetworkModeFromEnv, getRandomId, getTopicFromCommand, getTopicFromMessage, nowInMiliseconds, parseEntryFunctionAbi, sleep, toSystemValue };
5991
+ export { ABIs, type AccountValueRankingEntry, type AddApiCreditsParams, type AddApiKey, type AddApiKeyParams, type Address, AdminEndpoints, type ApiCreditsChange, type ApiStatus, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLendUpdate, type BorrowLending, type BorrowLendingAggregatedData, type BorrowLendingHistoricalData, type BoxOpeningEvent, type BoxReward, BoxRewardTier, type CancelAllPerpOrdersParams, type CancelAllSpotOrdersParams, type CancelPerpOrdersParams, type CancelSpotOrdersParams, type CanceledPerpOrderData, type CanceledPerpOrders, type CanceledPerpTriggerOrderData, type CanceledPerpTriggerOrders, type CanceledSpotOrderData, type CanceledSpotOrders, type ChangePerpOrderParams, type ChangeSpotOrderParams, type ChartCandle, ChartInterval, type CheckReferralCodeRequest, type CheckReferralCodeResponse, type ClaimDepositParams, type ClaimKickbackFeeParams, type ClaimReferralFee, type ClaimReferralFeesParams, type ClaimUserKickbackFee, type ClaimedKickback, type ClaimedReferralKickback, Client, type ClientConfig, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, type DepositTokenParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type ExchangeStatsEntry, type FeeData, type FeeTier, type Fees, type FundingCheckpoint, type FundingPayment, type FundingRate, GLOBAL_DENOMINATOR, type GetAccountValueRankingRequest, type GetAccountValueRankingResponse, type GetAllVaultsIdsResponse, type GetBorrowLendingAggregatedStatsRequest, type GetBorrowLendingAggregatedStatsResponse, type GetBorrowLendingDataResponse, type GetBorrowLendingHistoricalDataRequest, type GetBorrowLendingHistoricalDataResponse, type GetChartCandlesInRangeRequest, type GetChartCandlesInRangeResponse, type GetExchangeStatsHistoryRequest, type GetExchangeStatsHistoryResponse, type GetIndexPriceHistoryRequest, type GetIndexPriceHistoryResponse, type GetIndexPricesResponse, type GetIndexerStatusResponse, type GetOrderBookDataRequest, type GetOrderBookDataResponse, type GetPerpMarketsConfigResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpRecentTradesRequest, type GetPerpRecentTradesResponse, type GetPerpUserFillsRequest, type GetPerpUserFillsResponse, type GetPerpUserOrdersRequest, type GetPerpUserOrdersResponse, type GetPerpUserTriggerOrdersRequest, type GetPerpUserTriggerOrdersResponse, type GetPriceIndexesResponse, type GetServicesStatusResponse, type GetSpotMarketsConfigResponse, type GetSpotMarketsDataRequest, type GetSpotMarketsDataResponse, type GetSpotRecentTradesRequest, type GetSpotRecentTradesResponse, type GetSpotUserFillsRequest, type GetSpotUserFillsResponse, type GetSpotUserOrdersRequest, type GetSpotUserOrdersResponse, type GetTokenAggregatedStatsRequest, type GetTokenAggregatedStatsResponse, type GetTokenStatsHistoryRequest, type GetTokenStatsHistoryResponse, type GetTokensConfigResponse, type GetTopPointsRankingResponse, type GetUserAccountValueRankingRequest, type GetUserAccountValueRankingResponse, type GetUserAggregatedBoxRewardsStatsRequest, type GetUserAggregatedBoxRewardsStatsResponse, type GetUserAggregatedReferralStatsRequest, type GetUserAggregatedReferralStatsResponse, type GetUserAggregatedStatsRequest, type GetUserAggregatedStatsResponse, type GetUserAggregatedVaultStatsRequest, type GetUserAggregatedVaultStatsResponse, type GetUserBoxRewardsStatsHistoryRequest, type GetUserBoxRewardsStatsHistoryResponse, type GetUserBoxesHistoryRequest, type GetUserBoxesHistoryResponse, type GetUserClaimedKickbackHistoryRequest, type GetUserClaimedKickbackHistoryResponse, type GetUserClaimedReferralKickbackHistoryRequest, type GetUserClaimedReferralKickbackHistoryResponse, type GetUserDataRequest, type GetUserDataResponse, type GetUserDepositsRequest, type GetUserDepositsResponse, type GetUserFullLiquidationsHistoryRequest, type GetUserFundingHistoryRequest, type GetUserFundingHistoryResponse, type GetUserLiquidationsCancelHistoryResponse, type GetUserLiquidationsCancelOrdersHistoryRequest, type GetUserLiquidationsHistoryResponse, type GetUserPartialLiquidationsHistoryRequest, type GetUserPartialLiquidationsHistoryResponse, type GetUserPersonalPointsRankingRequest, type GetUserPersonalPointsRankingResponse, type GetUserPointsHistoryRequest, type GetUserPointsHistoryResponse, type GetUserPortfolioValueRequest, type GetUserPortfolioValueResponse, type GetUserReferralStatsHistoryRequest, type GetUserReferralStatsHistoryResponse, type GetUserRewardsValueRequest, type GetUserRewardsValueResponse, type GetUserTradeStatsHistoryRequest, type GetUserTradeStatsHistoryResponse, type GetUserTransferHistoryRequest, type GetUserTransferHistoryResponse, type GetUserVaultDepositsRequest, type GetUserVaultDepositsResponse, type GetUserVaultWithdrawsRequest, type GetUserVaultWithdrawsResponse, type GetUserVolumeForReferralRequest, type GetUserVolumeForReferralResponse, type GetUserWithdrawalsRequest, type GetUserWithdrawalsResponse, type GetUsersByAddressRequest, type GetUsersByAddressResponse, type GetVaultDepositsRequest, type GetVaultDepositsResponse, type GetVaultHistoricalDataRequest, type GetVaultHistoricalDataResponse, type GetVaultWithdrawalsRequest, type GetVaultWithdrawalsResponse, type GlobalLiquidation, type GlobalPartialLiquidation, type HistoricBoxReward, type HistoricalBoxRewardsStats, type HistoricalDeposit, type HistoricalFullLiquidation, type HistoricalFunding, type HistoricalLiquidatedBorrow, type HistoricalLiquidatedCollateral, type HistoricalLiquidatedLend, type HistoricalLiquidatedPosition, type HistoricalLiquidationCancelOrders, type HistoricalPartialLiquidatedPosition, type HistoricalPartialLiquidation, type HistoricalPerpOrder, type HistoricalPoints, type HistoricalReferralStats, type HistoricalSpotOrder, type HistoricalTokenStats, type HistoricalTradeStats, type HistoricalUserTransfer, type HistoricalVaultDeposit, type HistoricalVaultWithdraw, type HistoricalWithdraw, type IndexPriceHistory, type IndexPriceLive, type Lend, type LendTokenParams, type Liquidation, type LiquidationCancelledOrderData, type LiquidationCancelledTriggerOrderData, MAINNET_CONFIG, type MarginStep, Network, type NetworkConfig, type NetworkMode, type NodeStatus, type OpenBoxesRequest, type OpenBoxesResponse, type OpenBoxesSignRequest, type OracleUpdate, type OracleUpdates, type OrderBookData, OrderSide, OrderStatus, OrderType, type PaginationCursor, type PartialLiquidation, type PerpFill, type PerpMarketConfigEntry, type PerpMarketData, type PerpOrder, type PerpOrderData, type PerpOrderDataForMarket, type PerpOrderFills, type PerpOrderbookState, type PerpOrderbookUpdate, type PerpPosition, type PerpTrade, type PerpTradesUpdate, type PerpTriggerOrder, type PerpTriggerOrderTriggered, type PlaceMultiplePerpOrdersParams, type PlaceMultipleSpotOrdersParams, type PlacePerpLimitOrder, type PlacePerpMarketOrder, type PlacePerpOrderParams, type PlacePerpTriggerOrder, type PlacePerpTriggerOrderParams, type PlaceSpotLimitOrder, type PlaceSpotMarketOrder, type PlaceSpotOrderParams, type PointsRankingEntry, type PriceIndex, type RedeemTokenParams, type Referral, type ReferralUpdate, type RemoveApiKey, type RemoveApiKeyParams, type RemoveApiKeySignerParams, type RepayBorrow, type ReplaceMultipleOrdersParams, type ReplaceMultipleSpotOrdersParams, type SetAlias, type SetAliasNameParams, type SetAutoLend, type SetAutolendParams, type SetReferralCodeParams, type SetReferralParamsRequest, type SetReferralParamsResponse, type SpotFill, type SpotMarketConfigEntry, type SpotMarketData, type SpotOrder, type SpotOrderData, type SpotOrderDataForMarket, type SpotOrderFills, type SpotOrderbookState, type SpotOrderbookUpdate, type SpotTrade, type SpotTradesUpdate, Status, type StatusResponse, type SubServiceStatus, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TESTNET_CONFIG, TestFaucet, type TimeResponse, type TokenAggregatedStats, type TokenConfigEntry, type TokenizeUserVaultInvestmentParams, type Topic, type Trade, TradeRole, TransferAction, type TransferToUserParams, type TriggerOrder, type TvlTokenEntry, type TxParams, type UpdateUserFeeTier, type User, type UserAggregatedBoxRewardsStats, type UserAggregatedReferralStats, type UserAggregatedStats, type UserAggregatedVaultStats, type UserBoxOpeningEvent, type UserPointsBreakdown, type UserPortfolioValue, type UserRewardsValue, UserStatus, type UserTransfer, type UtilizationCurve, type Vault, type VaultDeposit, type VaultHistoricalData, type VaultInvestment, type VaultWithdraw, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WithdrawTokenParams, type WsBorrowLendUpdate, type WsBoxOpeningUpdate, type WsCommand, type WsFill, type WsLiquidatedBorrow, type WsLiquidatedCollateral, type WsLiquidatedLend, type WsLiquidatedPosition, type WsLiquidationUpdate, type WsMessage, type WsOracleUpdates, type WsPartialLiquidatedPosition, type WsPerpMarketUpdates, type WsSpotMarketUpdates, type WsUserUpdates, createAptosClient, createAptosClientFromEnv, generateApiKey, getABIsForNetwork, getNetworkConfig, getNetworkModeFromEnv, getRandomId, getTopicFromCommand, getTopicFromMessage, nowInMiliseconds, parseEntryFunctionAbi, sleep, toSystemValue };
package/dist/index.d.ts CHANGED
@@ -3682,6 +3682,7 @@ interface TokenConfigEntry {
3682
3682
  contractAddress: string;
3683
3683
  tokenDecimals: number;
3684
3684
  vaultId?: string;
3685
+ createdAt?: string;
3685
3686
  }
3686
3687
  interface MarginStep {
3687
3688
  initialMarginRatio: string;
@@ -3709,6 +3710,7 @@ interface PerpMarketConfigEntry {
3709
3710
  fundingRate: FundingRate;
3710
3711
  basicMakerFee: string;
3711
3712
  basicTakerFee: string;
3713
+ createdAt?: string;
3712
3714
  }
3713
3715
  interface SpotMarketConfigEntry {
3714
3716
  marketName: string;
@@ -3718,6 +3720,7 @@ interface SpotMarketConfigEntry {
3718
3720
  tickSize: string;
3719
3721
  basicMakerFee: string;
3720
3722
  basicTakerFee: string;
3723
+ createdAt?: string;
3721
3724
  }
3722
3725
  interface FeeData {
3723
3726
  feeToVaultAccount: string;
@@ -3731,6 +3734,19 @@ interface ExchangeConfig {
3731
3734
  feeData: FeeData;
3732
3735
  systemHaircut: string;
3733
3736
  }
3737
+ interface TvlTokenEntry {
3738
+ tokenAddress: string;
3739
+ amount: string;
3740
+ valueUsd: string;
3741
+ }
3742
+ interface ExchangeStatsEntry {
3743
+ timestampOpen: string;
3744
+ timestampClose: string;
3745
+ tvlBreakdown: TvlTokenEntry[];
3746
+ perpVolumeUsd: string;
3747
+ spotVolumeUsd: string;
3748
+ openInterestUsd: string;
3749
+ }
3734
3750
  interface FeeTier {
3735
3751
  volume: string;
3736
3752
  cashback: string;
@@ -3762,13 +3778,6 @@ interface GetAccountValueRankingResponse {
3762
3778
  usersRanking: AccountValueRankingEntry[];
3763
3779
  paginationCursor?: PaginationCursor;
3764
3780
  }
3765
- interface GetUserAccountValueRankingRequest {
3766
- userId?: string;
3767
- userAddress?: string;
3768
- }
3769
- interface GetUserAccountValueRankingResponse {
3770
- usersRanking: AccountValueRankingEntry[];
3771
- }
3772
3781
  interface GetAllVaultsIdsResponse {
3773
3782
  vaultsIds: string[];
3774
3783
  }
@@ -3811,6 +3820,15 @@ interface GetChartCandlesInRangeResponse {
3811
3820
  chartCandles: ChartCandle[];
3812
3821
  paginationCursor?: PaginationCursor;
3813
3822
  }
3823
+ interface GetExchangeStatsHistoryRequest {
3824
+ olderTimestampMs?: string;
3825
+ newerTimestampMs?: string;
3826
+ paginationCursor?: PaginationCursor;
3827
+ }
3828
+ interface GetExchangeStatsHistoryResponse {
3829
+ data: ExchangeStatsEntry[];
3830
+ paginationCursor?: PaginationCursor;
3831
+ }
3814
3832
  interface GetIndexPriceHistoryRequest {
3815
3833
  priceIndex: string;
3816
3834
  olderTimestampMs?: string;
@@ -4154,6 +4172,13 @@ interface PointsRankingEntry {
4154
4172
  interface GetTopPointsRankingResponse {
4155
4173
  usersRanking: PointsRankingEntry[];
4156
4174
  }
4175
+ interface GetUserAccountValueRankingRequest {
4176
+ userId?: string;
4177
+ userAddress?: string;
4178
+ }
4179
+ interface GetUserAccountValueRankingResponse {
4180
+ usersRanking: AccountValueRankingEntry[];
4181
+ }
4157
4182
  interface GetUserAggregatedBoxRewardsStatsRequest {
4158
4183
  userId: string;
4159
4184
  }
@@ -5159,7 +5184,8 @@ declare enum EndpointsV1 {
5159
5184
  GetUserPersonalPointsRanking = "/v1/get_user_personal_points_ranking",
5160
5185
  GetIndexPrices = "/v1/get_index_prices",
5161
5186
  GetAccountValueRanking = "/v1/get_account_value_ranking",
5162
- GetUserAccountValueRanking = "/v1/get_user_account_value_ranking"
5187
+ GetUserAccountValueRanking = "/v1/get_user_account_value_ranking",
5188
+ GetExchangeStatsHistory = "/v1/get_exchange_stats_history"
5163
5189
  }
5164
5190
  type Topic = {
5165
5191
  type: "PerpMarket";
@@ -5432,6 +5458,16 @@ interface TxParams {
5432
5458
  gasUnitPrice: number;
5433
5459
  expirationTimestampSecs: number;
5434
5460
  }
5461
+ interface ClientConfig {
5462
+ enableWs?: boolean;
5463
+ url?: string;
5464
+ apiKey?: Account;
5465
+ chainId?: number;
5466
+ params?: TxParams;
5467
+ networkMode?: NetworkMode;
5468
+ wsDebug?: boolean;
5469
+ timeout?: number;
5470
+ }
5435
5471
  interface ChangePerpOrderParams {
5436
5472
  userId: string;
5437
5473
  market: string;
@@ -5748,18 +5784,17 @@ declare class Client {
5748
5784
  _gasUnitPrice: number;
5749
5785
  _expirationTimestampDelay: number;
5750
5786
  timeout: number;
5787
+ wsDebug: boolean;
5788
+ onWsClose: ((event: CloseEvent) => void) | undefined;
5751
5789
  _abis: ReturnType<typeof getABIsForNetwork>;
5752
5790
  _contractAddress: string;
5753
- static init(connection: Aptos, enableWs?: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams, networkMode?: NetworkMode): Promise<Client>;
5754
- constructor(connection: Aptos, enableWs: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams, networkMode?: NetworkMode);
5791
+ static init(connection: Aptos, config?: ClientConfig): Promise<Client>;
5792
+ constructor(connection: Aptos, config?: ClientConfig);
5755
5793
  /**
5756
5794
  * Create a new Client instance
5757
5795
  *
5758
5796
  * @param connection - Aptos connection instance
5759
- * @param networkMode - Network mode ('testnet' or 'mainnet'). Defaults to 'testnet'
5760
- * @param enableWs - Enable WebSocket connection. Defaults to true
5761
- * @param url - Custom API URL. If not provided, uses default URL based on network mode
5762
- * @param apiKey - API key account. If not provided, generates a new one
5797
+ * @param config - Client configuration options
5763
5798
  * @returns Promise<Client>
5764
5799
  *
5765
5800
  * @example
@@ -5768,27 +5803,33 @@ declare class Client {
5768
5803
  *
5769
5804
  * @example
5770
5805
  * // Create a mainnet client
5771
- * const client = await Client.create(aptos, 'mainnet')
5806
+ * const client = await Client.create(aptos, { networkMode: 'mainnet' })
5807
+ *
5808
+ * @example
5809
+ * // Create an HTTP-only client (no WebSocket)
5810
+ * const client = await Client.create(aptos, { enableWs: false })
5772
5811
  *
5773
5812
  * @example
5774
5813
  * // Create a client with custom settings
5775
- * const client = await Client.create(
5776
- * aptos,
5777
- * 'mainnet',
5778
- * true, // enable WebSocket
5779
- * 'https://custom-api.example.com', // custom API URL
5780
- * myApiKeyAccount // custom API key
5781
- * )
5814
+ * const client = await Client.create(aptos, {
5815
+ * networkMode: 'mainnet',
5816
+ * url: 'https://custom-api.example.com',
5817
+ * apiKey: myApiKeyAccount,
5818
+ * wsDebug: true,
5819
+ * timeout: 10000,
5820
+ * })
5782
5821
  */
5783
- static create(connection: Aptos, networkMode?: NetworkMode, enableWs?: boolean, url?: string, apiKey?: Account): Promise<Client>;
5822
+ static create(connection: Aptos, config?: ClientConfig): Promise<Client>;
5784
5823
  setApiKey(apiKey: Account): Promise<void>;
5785
5824
  getContractAddress(): string;
5786
5825
  getApiKeySequenceNumber(): Promise<bigint | null>;
5787
5826
  fetchApiKeySequenceNumber(): Promise<number>;
5788
5827
  setTxParams(params: TxParams): void;
5828
+ private _wsLog;
5829
+ setWsDebugActive(active: boolean): void;
5789
5830
  connectWebSocket(): Promise<void>;
5831
+ private _initWebSocket;
5790
5832
  private _setupWebSocketHandlers;
5791
- static initWebSocket(url: string, timeout?: number): Promise<WebSocket>;
5792
5833
  disconnectWebSocket(): Promise<void>;
5793
5834
  isWebSocketConnected(): boolean;
5794
5835
  sendWsMessage(message: WsCommand): Promise<WsMessage>;
@@ -5932,8 +5973,8 @@ declare const ExchangeProxies: {
5932
5973
  declare const GLOBAL_DENOMINATOR = 100000000;
5933
5974
 
5934
5975
  declare class TestFaucet extends Client {
5935
- constructor(connection: Aptos, enableWs: boolean, url?: string, apiKey?: Account, networkMode?: NetworkMode);
5936
- static create(connection: Aptos, networkMode?: NetworkMode, enableWs?: boolean, url?: string, apiKey?: Account): Promise<TestFaucet>;
5976
+ constructor(connection: Aptos, config?: ClientConfig);
5977
+ static create(connection: Aptos, config?: ClientConfig): Promise<TestFaucet>;
5937
5978
  initFaucetPayload(): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
5938
5979
  initFaucet(): Promise<SubmitSponsoredTransactionResponse>;
5939
5980
  mintTokenPayload(receiver: Address, token: string, amount: number): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
@@ -5947,4 +5988,4 @@ declare const generateApiKey: () => _aptos_labs_ts_sdk.Ed25519Account;
5947
5988
  declare const getTopicFromCommand: (data: WsCommand) => string;
5948
5989
  declare const getTopicFromMessage: (data: WsMessage) => string;
5949
5990
 
5950
- export { ABIs, type AccountValueRankingEntry, type AddApiCreditsParams, type AddApiKey, type AddApiKeyParams, type Address, AdminEndpoints, type ApiCreditsChange, type ApiStatus, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLendUpdate, type BorrowLending, type BorrowLendingAggregatedData, type BorrowLendingHistoricalData, type BoxOpeningEvent, type BoxReward, BoxRewardTier, type CancelAllPerpOrdersParams, type CancelAllSpotOrdersParams, type CancelPerpOrdersParams, type CancelSpotOrdersParams, type CanceledPerpOrderData, type CanceledPerpOrders, type CanceledPerpTriggerOrderData, type CanceledPerpTriggerOrders, type CanceledSpotOrderData, type CanceledSpotOrders, type ChangePerpOrderParams, type ChangeSpotOrderParams, type ChartCandle, ChartInterval, type CheckReferralCodeRequest, type CheckReferralCodeResponse, type ClaimDepositParams, type ClaimKickbackFeeParams, type ClaimReferralFee, type ClaimReferralFeesParams, type ClaimUserKickbackFee, type ClaimedKickback, type ClaimedReferralKickback, Client, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, type DepositTokenParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type FeeData, type FeeTier, type Fees, type FundingCheckpoint, type FundingPayment, type FundingRate, GLOBAL_DENOMINATOR, type GetAccountValueRankingRequest, type GetAccountValueRankingResponse, type GetAllVaultsIdsResponse, type GetBorrowLendingAggregatedStatsRequest, type GetBorrowLendingAggregatedStatsResponse, type GetBorrowLendingDataResponse, type GetBorrowLendingHistoricalDataRequest, type GetBorrowLendingHistoricalDataResponse, type GetChartCandlesInRangeRequest, type GetChartCandlesInRangeResponse, type GetIndexPriceHistoryRequest, type GetIndexPriceHistoryResponse, type GetIndexPricesResponse, type GetIndexerStatusResponse, type GetOrderBookDataRequest, type GetOrderBookDataResponse, type GetPerpMarketsConfigResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpRecentTradesRequest, type GetPerpRecentTradesResponse, type GetPerpUserFillsRequest, type GetPerpUserFillsResponse, type GetPerpUserOrdersRequest, type GetPerpUserOrdersResponse, type GetPerpUserTriggerOrdersRequest, type GetPerpUserTriggerOrdersResponse, type GetPriceIndexesResponse, type GetServicesStatusResponse, type GetSpotMarketsConfigResponse, type GetSpotMarketsDataRequest, type GetSpotMarketsDataResponse, type GetSpotRecentTradesRequest, type GetSpotRecentTradesResponse, type GetSpotUserFillsRequest, type GetSpotUserFillsResponse, type GetSpotUserOrdersRequest, type GetSpotUserOrdersResponse, type GetTokenAggregatedStatsRequest, type GetTokenAggregatedStatsResponse, type GetTokenStatsHistoryRequest, type GetTokenStatsHistoryResponse, type GetTokensConfigResponse, type GetTopPointsRankingResponse, type GetUserAccountValueRankingRequest, type GetUserAccountValueRankingResponse, type GetUserAggregatedBoxRewardsStatsRequest, type GetUserAggregatedBoxRewardsStatsResponse, type GetUserAggregatedReferralStatsRequest, type GetUserAggregatedReferralStatsResponse, type GetUserAggregatedStatsRequest, type GetUserAggregatedStatsResponse, type GetUserAggregatedVaultStatsRequest, type GetUserAggregatedVaultStatsResponse, type GetUserBoxRewardsStatsHistoryRequest, type GetUserBoxRewardsStatsHistoryResponse, type GetUserBoxesHistoryRequest, type GetUserBoxesHistoryResponse, type GetUserClaimedKickbackHistoryRequest, type GetUserClaimedKickbackHistoryResponse, type GetUserClaimedReferralKickbackHistoryRequest, type GetUserClaimedReferralKickbackHistoryResponse, type GetUserDataRequest, type GetUserDataResponse, type GetUserDepositsRequest, type GetUserDepositsResponse, type GetUserFullLiquidationsHistoryRequest, type GetUserFundingHistoryRequest, type GetUserFundingHistoryResponse, type GetUserLiquidationsCancelHistoryResponse, type GetUserLiquidationsCancelOrdersHistoryRequest, type GetUserLiquidationsHistoryResponse, type GetUserPartialLiquidationsHistoryRequest, type GetUserPartialLiquidationsHistoryResponse, type GetUserPersonalPointsRankingRequest, type GetUserPersonalPointsRankingResponse, type GetUserPointsHistoryRequest, type GetUserPointsHistoryResponse, type GetUserPortfolioValueRequest, type GetUserPortfolioValueResponse, type GetUserReferralStatsHistoryRequest, type GetUserReferralStatsHistoryResponse, type GetUserRewardsValueRequest, type GetUserRewardsValueResponse, type GetUserTradeStatsHistoryRequest, type GetUserTradeStatsHistoryResponse, type GetUserTransferHistoryRequest, type GetUserTransferHistoryResponse, type GetUserVaultDepositsRequest, type GetUserVaultDepositsResponse, type GetUserVaultWithdrawsRequest, type GetUserVaultWithdrawsResponse, type GetUserVolumeForReferralRequest, type GetUserVolumeForReferralResponse, type GetUserWithdrawalsRequest, type GetUserWithdrawalsResponse, type GetUsersByAddressRequest, type GetUsersByAddressResponse, type GetVaultDepositsRequest, type GetVaultDepositsResponse, type GetVaultHistoricalDataRequest, type GetVaultHistoricalDataResponse, type GetVaultWithdrawalsRequest, type GetVaultWithdrawalsResponse, type GlobalLiquidation, type GlobalPartialLiquidation, type HistoricBoxReward, type HistoricalBoxRewardsStats, type HistoricalDeposit, type HistoricalFullLiquidation, type HistoricalFunding, type HistoricalLiquidatedBorrow, type HistoricalLiquidatedCollateral, type HistoricalLiquidatedLend, type HistoricalLiquidatedPosition, type HistoricalLiquidationCancelOrders, type HistoricalPartialLiquidatedPosition, type HistoricalPartialLiquidation, type HistoricalPerpOrder, type HistoricalPoints, type HistoricalReferralStats, type HistoricalSpotOrder, type HistoricalTokenStats, type HistoricalTradeStats, type HistoricalUserTransfer, type HistoricalVaultDeposit, type HistoricalVaultWithdraw, type HistoricalWithdraw, type IndexPriceHistory, type IndexPriceLive, type Lend, type LendTokenParams, type Liquidation, type LiquidationCancelledOrderData, type LiquidationCancelledTriggerOrderData, MAINNET_CONFIG, type MarginStep, Network, type NetworkConfig, type NetworkMode, type NodeStatus, type OpenBoxesRequest, type OpenBoxesResponse, type OpenBoxesSignRequest, type OracleUpdate, type OracleUpdates, type OrderBookData, OrderSide, OrderStatus, OrderType, type PaginationCursor, type PartialLiquidation, type PerpFill, type PerpMarketConfigEntry, type PerpMarketData, type PerpOrder, type PerpOrderData, type PerpOrderDataForMarket, type PerpOrderFills, type PerpOrderbookState, type PerpOrderbookUpdate, type PerpPosition, type PerpTrade, type PerpTradesUpdate, type PerpTriggerOrder, type PerpTriggerOrderTriggered, type PlaceMultiplePerpOrdersParams, type PlaceMultipleSpotOrdersParams, type PlacePerpLimitOrder, type PlacePerpMarketOrder, type PlacePerpOrderParams, type PlacePerpTriggerOrder, type PlacePerpTriggerOrderParams, type PlaceSpotLimitOrder, type PlaceSpotMarketOrder, type PlaceSpotOrderParams, type PointsRankingEntry, type PriceIndex, type RedeemTokenParams, type Referral, type ReferralUpdate, type RemoveApiKey, type RemoveApiKeyParams, type RemoveApiKeySignerParams, type RepayBorrow, type ReplaceMultipleOrdersParams, type ReplaceMultipleSpotOrdersParams, type SetAlias, type SetAliasNameParams, type SetAutoLend, type SetAutolendParams, type SetReferralCodeParams, type SetReferralParamsRequest, type SetReferralParamsResponse, type SpotFill, type SpotMarketConfigEntry, type SpotMarketData, type SpotOrder, type SpotOrderData, type SpotOrderDataForMarket, type SpotOrderFills, type SpotOrderbookState, type SpotOrderbookUpdate, type SpotTrade, type SpotTradesUpdate, Status, type StatusResponse, type SubServiceStatus, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TESTNET_CONFIG, TestFaucet, type TimeResponse, type TokenAggregatedStats, type TokenConfigEntry, type TokenizeUserVaultInvestmentParams, type Topic, type Trade, TradeRole, TransferAction, type TransferToUserParams, type TriggerOrder, type TxParams, type UpdateUserFeeTier, type User, type UserAggregatedBoxRewardsStats, type UserAggregatedReferralStats, type UserAggregatedStats, type UserAggregatedVaultStats, type UserBoxOpeningEvent, type UserPointsBreakdown, type UserPortfolioValue, type UserRewardsValue, UserStatus, type UserTransfer, type UtilizationCurve, type Vault, type VaultDeposit, type VaultHistoricalData, type VaultInvestment, type VaultWithdraw, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WithdrawTokenParams, type WsBorrowLendUpdate, type WsBoxOpeningUpdate, type WsCommand, type WsFill, type WsLiquidatedBorrow, type WsLiquidatedCollateral, type WsLiquidatedLend, type WsLiquidatedPosition, type WsLiquidationUpdate, type WsMessage, type WsOracleUpdates, type WsPartialLiquidatedPosition, type WsPerpMarketUpdates, type WsSpotMarketUpdates, type WsUserUpdates, createAptosClient, createAptosClientFromEnv, generateApiKey, getABIsForNetwork, getNetworkConfig, getNetworkModeFromEnv, getRandomId, getTopicFromCommand, getTopicFromMessage, nowInMiliseconds, parseEntryFunctionAbi, sleep, toSystemValue };
5991
+ export { ABIs, type AccountValueRankingEntry, type AddApiCreditsParams, type AddApiKey, type AddApiKeyParams, type Address, AdminEndpoints, type ApiCreditsChange, type ApiStatus, type BalanceChange, BaseEndpoints, type Borrow, type BorrowLendUpdate, type BorrowLending, type BorrowLendingAggregatedData, type BorrowLendingHistoricalData, type BoxOpeningEvent, type BoxReward, BoxRewardTier, type CancelAllPerpOrdersParams, type CancelAllSpotOrdersParams, type CancelPerpOrdersParams, type CancelSpotOrdersParams, type CanceledPerpOrderData, type CanceledPerpOrders, type CanceledPerpTriggerOrderData, type CanceledPerpTriggerOrders, type CanceledSpotOrderData, type CanceledSpotOrders, type ChangePerpOrderParams, type ChangeSpotOrderParams, type ChartCandle, ChartInterval, type CheckReferralCodeRequest, type CheckReferralCodeResponse, type ClaimDepositParams, type ClaimKickbackFeeParams, type ClaimReferralFee, type ClaimReferralFeesParams, type ClaimUserKickbackFee, type ClaimedKickback, type ClaimedReferralKickback, Client, type ClientConfig, type Content, type CreateUserParams, type Deposit, type DepositToVaultParams, type DepositTokenParams, EndpointsV1, type ErrorResponse, type ExchangeConfig, ExchangeProxies, type ExchangeStatsEntry, type FeeData, type FeeTier, type Fees, type FundingCheckpoint, type FundingPayment, type FundingRate, GLOBAL_DENOMINATOR, type GetAccountValueRankingRequest, type GetAccountValueRankingResponse, type GetAllVaultsIdsResponse, type GetBorrowLendingAggregatedStatsRequest, type GetBorrowLendingAggregatedStatsResponse, type GetBorrowLendingDataResponse, type GetBorrowLendingHistoricalDataRequest, type GetBorrowLendingHistoricalDataResponse, type GetChartCandlesInRangeRequest, type GetChartCandlesInRangeResponse, type GetExchangeStatsHistoryRequest, type GetExchangeStatsHistoryResponse, type GetIndexPriceHistoryRequest, type GetIndexPriceHistoryResponse, type GetIndexPricesResponse, type GetIndexerStatusResponse, type GetOrderBookDataRequest, type GetOrderBookDataResponse, type GetPerpMarketsConfigResponse, type GetPerpMarketsDataRequest, type GetPerpMarketsDataResponse, type GetPerpRecentTradesRequest, type GetPerpRecentTradesResponse, type GetPerpUserFillsRequest, type GetPerpUserFillsResponse, type GetPerpUserOrdersRequest, type GetPerpUserOrdersResponse, type GetPerpUserTriggerOrdersRequest, type GetPerpUserTriggerOrdersResponse, type GetPriceIndexesResponse, type GetServicesStatusResponse, type GetSpotMarketsConfigResponse, type GetSpotMarketsDataRequest, type GetSpotMarketsDataResponse, type GetSpotRecentTradesRequest, type GetSpotRecentTradesResponse, type GetSpotUserFillsRequest, type GetSpotUserFillsResponse, type GetSpotUserOrdersRequest, type GetSpotUserOrdersResponse, type GetTokenAggregatedStatsRequest, type GetTokenAggregatedStatsResponse, type GetTokenStatsHistoryRequest, type GetTokenStatsHistoryResponse, type GetTokensConfigResponse, type GetTopPointsRankingResponse, type GetUserAccountValueRankingRequest, type GetUserAccountValueRankingResponse, type GetUserAggregatedBoxRewardsStatsRequest, type GetUserAggregatedBoxRewardsStatsResponse, type GetUserAggregatedReferralStatsRequest, type GetUserAggregatedReferralStatsResponse, type GetUserAggregatedStatsRequest, type GetUserAggregatedStatsResponse, type GetUserAggregatedVaultStatsRequest, type GetUserAggregatedVaultStatsResponse, type GetUserBoxRewardsStatsHistoryRequest, type GetUserBoxRewardsStatsHistoryResponse, type GetUserBoxesHistoryRequest, type GetUserBoxesHistoryResponse, type GetUserClaimedKickbackHistoryRequest, type GetUserClaimedKickbackHistoryResponse, type GetUserClaimedReferralKickbackHistoryRequest, type GetUserClaimedReferralKickbackHistoryResponse, type GetUserDataRequest, type GetUserDataResponse, type GetUserDepositsRequest, type GetUserDepositsResponse, type GetUserFullLiquidationsHistoryRequest, type GetUserFundingHistoryRequest, type GetUserFundingHistoryResponse, type GetUserLiquidationsCancelHistoryResponse, type GetUserLiquidationsCancelOrdersHistoryRequest, type GetUserLiquidationsHistoryResponse, type GetUserPartialLiquidationsHistoryRequest, type GetUserPartialLiquidationsHistoryResponse, type GetUserPersonalPointsRankingRequest, type GetUserPersonalPointsRankingResponse, type GetUserPointsHistoryRequest, type GetUserPointsHistoryResponse, type GetUserPortfolioValueRequest, type GetUserPortfolioValueResponse, type GetUserReferralStatsHistoryRequest, type GetUserReferralStatsHistoryResponse, type GetUserRewardsValueRequest, type GetUserRewardsValueResponse, type GetUserTradeStatsHistoryRequest, type GetUserTradeStatsHistoryResponse, type GetUserTransferHistoryRequest, type GetUserTransferHistoryResponse, type GetUserVaultDepositsRequest, type GetUserVaultDepositsResponse, type GetUserVaultWithdrawsRequest, type GetUserVaultWithdrawsResponse, type GetUserVolumeForReferralRequest, type GetUserVolumeForReferralResponse, type GetUserWithdrawalsRequest, type GetUserWithdrawalsResponse, type GetUsersByAddressRequest, type GetUsersByAddressResponse, type GetVaultDepositsRequest, type GetVaultDepositsResponse, type GetVaultHistoricalDataRequest, type GetVaultHistoricalDataResponse, type GetVaultWithdrawalsRequest, type GetVaultWithdrawalsResponse, type GlobalLiquidation, type GlobalPartialLiquidation, type HistoricBoxReward, type HistoricalBoxRewardsStats, type HistoricalDeposit, type HistoricalFullLiquidation, type HistoricalFunding, type HistoricalLiquidatedBorrow, type HistoricalLiquidatedCollateral, type HistoricalLiquidatedLend, type HistoricalLiquidatedPosition, type HistoricalLiquidationCancelOrders, type HistoricalPartialLiquidatedPosition, type HistoricalPartialLiquidation, type HistoricalPerpOrder, type HistoricalPoints, type HistoricalReferralStats, type HistoricalSpotOrder, type HistoricalTokenStats, type HistoricalTradeStats, type HistoricalUserTransfer, type HistoricalVaultDeposit, type HistoricalVaultWithdraw, type HistoricalWithdraw, type IndexPriceHistory, type IndexPriceLive, type Lend, type LendTokenParams, type Liquidation, type LiquidationCancelledOrderData, type LiquidationCancelledTriggerOrderData, MAINNET_CONFIG, type MarginStep, Network, type NetworkConfig, type NetworkMode, type NodeStatus, type OpenBoxesRequest, type OpenBoxesResponse, type OpenBoxesSignRequest, type OracleUpdate, type OracleUpdates, type OrderBookData, OrderSide, OrderStatus, OrderType, type PaginationCursor, type PartialLiquidation, type PerpFill, type PerpMarketConfigEntry, type PerpMarketData, type PerpOrder, type PerpOrderData, type PerpOrderDataForMarket, type PerpOrderFills, type PerpOrderbookState, type PerpOrderbookUpdate, type PerpPosition, type PerpTrade, type PerpTradesUpdate, type PerpTriggerOrder, type PerpTriggerOrderTriggered, type PlaceMultiplePerpOrdersParams, type PlaceMultipleSpotOrdersParams, type PlacePerpLimitOrder, type PlacePerpMarketOrder, type PlacePerpOrderParams, type PlacePerpTriggerOrder, type PlacePerpTriggerOrderParams, type PlaceSpotLimitOrder, type PlaceSpotMarketOrder, type PlaceSpotOrderParams, type PointsRankingEntry, type PriceIndex, type RedeemTokenParams, type Referral, type ReferralUpdate, type RemoveApiKey, type RemoveApiKeyParams, type RemoveApiKeySignerParams, type RepayBorrow, type ReplaceMultipleOrdersParams, type ReplaceMultipleSpotOrdersParams, type SetAlias, type SetAliasNameParams, type SetAutoLend, type SetAutolendParams, type SetReferralCodeParams, type SetReferralParamsRequest, type SetReferralParamsResponse, type SpotFill, type SpotMarketConfigEntry, type SpotMarketData, type SpotOrder, type SpotOrderData, type SpotOrderDataForMarket, type SpotOrderFills, type SpotOrderbookState, type SpotOrderbookUpdate, type SpotTrade, type SpotTradesUpdate, Status, type StatusResponse, type SubServiceStatus, type SubmitSponsoredTransactionRequest, type SubmitSponsoredTransactionResponse, TESTNET_CONFIG, TestFaucet, type TimeResponse, type TokenAggregatedStats, type TokenConfigEntry, type TokenizeUserVaultInvestmentParams, type Topic, type Trade, TradeRole, TransferAction, type TransferToUserParams, type TriggerOrder, type TvlTokenEntry, type TxParams, type UpdateUserFeeTier, type User, type UserAggregatedBoxRewardsStats, type UserAggregatedReferralStats, type UserAggregatedStats, type UserAggregatedVaultStats, type UserBoxOpeningEvent, type UserPointsBreakdown, type UserPortfolioValue, type UserRewardsValue, UserStatus, type UserTransfer, type UtilizationCurve, type Vault, type VaultDeposit, type VaultHistoricalData, type VaultInvestment, type VaultWithdraw, type Withdraw, type WithdrawFromVaultParams, type WithdrawLend, type WithdrawTokenParams, type WsBorrowLendUpdate, type WsBoxOpeningUpdate, type WsCommand, type WsFill, type WsLiquidatedBorrow, type WsLiquidatedCollateral, type WsLiquidatedLend, type WsLiquidatedPosition, type WsLiquidationUpdate, type WsMessage, type WsOracleUpdates, type WsPartialLiquidatedPosition, type WsPerpMarketUpdates, type WsSpotMarketUpdates, type WsUserUpdates, createAptosClient, createAptosClientFromEnv, generateApiKey, getABIsForNetwork, getNetworkConfig, getNetworkModeFromEnv, getRandomId, getTopicFromCommand, getTopicFromMessage, nowInMiliseconds, parseEntryFunctionAbi, sleep, toSystemValue };
package/dist/index.js CHANGED
@@ -23536,6 +23536,7 @@ var EndpointsV1 = /* @__PURE__ */ ((EndpointsV12) => {
23536
23536
  EndpointsV12["GetIndexPrices"] = "/v1/get_index_prices";
23537
23537
  EndpointsV12["GetAccountValueRanking"] = "/v1/get_account_value_ranking";
23538
23538
  EndpointsV12["GetUserAccountValueRanking"] = "/v1/get_user_account_value_ranking";
23539
+ EndpointsV12["GetExchangeStatsHistory"] = "/v1/get_exchange_stats_history";
23539
23540
  return EndpointsV12;
23540
23541
  })(EndpointsV1 || {});
23541
23542
  var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
@@ -23891,13 +23892,15 @@ var AccountSequenceNumber = class {
23891
23892
  // src/client.ts
23892
23893
  var getRandomId = () => uuidv7();
23893
23894
  var Client = class _Client {
23894
- constructor(connection, enableWs, url, apiKey, chainId, params, networkMode = "testnet") {
23895
+ constructor(connection, config = {}) {
23895
23896
  this._apiKeySequenceNumber = 0;
23896
23897
  this._subscriptions = /* @__PURE__ */ new Map();
23897
23898
  this._gasUnitPrice = 100;
23898
23899
  this._expirationTimestampDelay = 20;
23899
23900
  // 20 seconds
23900
23901
  this.timeout = 5e3;
23902
+ // Same as below in init
23903
+ this.wsDebug = false;
23901
23904
  /////////////////////////////////// Sponsored transactions
23902
23905
  this.submitSponsoredTransaction = async (tx, signature) => {
23903
23906
  const payload = {
@@ -24335,27 +24338,27 @@ var Client = class _Client {
24335
24338
  const response = await this.sendGetJson("/time" /* Time */);
24336
24339
  return response.time;
24337
24340
  };
24341
+ const networkMode = config.networkMode || "testnet";
24338
24342
  const networkConfig = getNetworkConfig(networkMode);
24339
24343
  this._aptos = connection;
24340
- this._chainId = chainId || networkConfig.chainId;
24341
- this._apiKey = apiKey || generateApiKey();
24344
+ this._chainId = config.chainId || networkConfig.chainId;
24345
+ this._apiKey = config.apiKey || generateApiKey();
24342
24346
  this._subscriptions = /* @__PURE__ */ new Map();
24343
- this._serverUrl = url || networkConfig.apiUrl;
24347
+ this._serverUrl = config.url || networkConfig.apiUrl;
24344
24348
  this._sequenceNumberManager = new AccountSequenceNumber(this._aptos, this._apiKey);
24345
24349
  this._abis = getABIsForNetwork(networkMode);
24346
24350
  this._contractAddress = Object.values(this._abis)[0].address;
24347
- this._maxGas = params?.maxGas || 2e4;
24348
- this._gasUnitPrice = params?.gasUnitPrice || 100;
24349
- this._expirationTimestampDelay = params?.expirationTimestampSecs || 20;
24350
- if (enableWs) {
24351
- this.connectWebSocket();
24352
- }
24351
+ this._maxGas = config.params?.maxGas || 2e4;
24352
+ this._gasUnitPrice = config.params?.gasUnitPrice || 100;
24353
+ this._expirationTimestampDelay = config.params?.expirationTimestampSecs || 20;
24354
+ this.wsDebug = config.wsDebug || false;
24355
+ this.timeout = config.timeout || 5e3;
24353
24356
  }
24354
- static async init(connection, enableWs = true, url, apiKey, chainId, params, networkMode = "testnet") {
24355
- const id = chainId || await connection.getChainId();
24356
- const client = new _Client(connection, enableWs, url, apiKey, id, params, networkMode);
24357
- if (enableWs) {
24358
- client.connectWebSocket();
24357
+ static async init(connection, config = {}) {
24358
+ const id = config.chainId || await connection.getChainId();
24359
+ const client = new _Client(connection, { ...config, chainId: id });
24360
+ if (config.enableWs !== false) {
24361
+ await client.connectWebSocket();
24359
24362
  }
24360
24363
  return client;
24361
24364
  }
@@ -24363,10 +24366,7 @@ var Client = class _Client {
24363
24366
  * Create a new Client instance
24364
24367
  *
24365
24368
  * @param connection - Aptos connection instance
24366
- * @param networkMode - Network mode ('testnet' or 'mainnet'). Defaults to 'testnet'
24367
- * @param enableWs - Enable WebSocket connection. Defaults to true
24368
- * @param url - Custom API URL. If not provided, uses default URL based on network mode
24369
- * @param apiKey - API key account. If not provided, generates a new one
24369
+ * @param config - Client configuration options
24370
24370
  * @returns Promise<Client>
24371
24371
  *
24372
24372
  * @example
@@ -24375,23 +24375,24 @@ var Client = class _Client {
24375
24375
  *
24376
24376
  * @example
24377
24377
  * // Create a mainnet client
24378
- * const client = await Client.create(aptos, 'mainnet')
24378
+ * const client = await Client.create(aptos, { networkMode: 'mainnet' })
24379
+ *
24380
+ * @example
24381
+ * // Create an HTTP-only client (no WebSocket)
24382
+ * const client = await Client.create(aptos, { enableWs: false })
24379
24383
  *
24380
24384
  * @example
24381
24385
  * // Create a client with custom settings
24382
- * const client = await Client.create(
24383
- * aptos,
24384
- * 'mainnet',
24385
- * true, // enable WebSocket
24386
- * 'https://custom-api.example.com', // custom API URL
24387
- * myApiKeyAccount // custom API key
24388
- * )
24386
+ * const client = await Client.create(aptos, {
24387
+ * networkMode: 'mainnet',
24388
+ * url: 'https://custom-api.example.com',
24389
+ * apiKey: myApiKeyAccount,
24390
+ * wsDebug: true,
24391
+ * timeout: 10000,
24392
+ * })
24389
24393
  */
24390
- static async create(connection, networkMode = "testnet", enableWs = true, url, apiKey) {
24391
- const networkConfig = getNetworkConfig(networkMode);
24392
- const apiUrl = url || networkConfig.apiUrl;
24393
- const chainId = networkConfig.chainId;
24394
- return _Client.init(connection, enableWs, apiUrl, apiKey, chainId, void 0, networkMode);
24394
+ static async create(connection, config = {}) {
24395
+ return _Client.init(connection, config);
24395
24396
  }
24396
24397
  async setApiKey(apiKey) {
24397
24398
  this._apiKey = apiKey;
@@ -24417,19 +24418,48 @@ var Client = class _Client {
24417
24418
  this._expirationTimestampDelay = params.expirationTimestampSecs;
24418
24419
  }
24419
24420
  //////////////////////////////////////// Websocket functions
24421
+ _wsLog(...args) {
24422
+ if (this.wsDebug) console.log("[WS]", ...args);
24423
+ }
24424
+ setWsDebugActive(active) {
24425
+ this.wsDebug = active;
24426
+ }
24420
24427
  async connectWebSocket() {
24421
24428
  if (this._ws) {
24422
24429
  console.warn("WebSocket is already connected");
24423
24430
  return;
24424
24431
  }
24425
24432
  try {
24426
- this._ws = await _Client.initWebSocket(this._serverUrl, this.timeout);
24433
+ this._wsLog("Connecting to", this._serverUrl);
24434
+ this._ws = await this._initWebSocket(this._serverUrl, this.timeout);
24427
24435
  this._setupWebSocketHandlers();
24428
- return;
24436
+ this._wsLog("Connected");
24429
24437
  } catch (error) {
24438
+ this._wsLog("Connection failed:", error);
24430
24439
  throw new Error(`Failed to connect WebSocket: ${error}`);
24431
24440
  }
24432
24441
  }
24442
+ _initWebSocket(url, timeout) {
24443
+ return new Promise((resolve, reject) => {
24444
+ const wsUrl = `${url.replace("http", "ws").replace("https", "wss")}` + "/v1/ws" /* Ws */;
24445
+ this._wsLog("initWebSocket url:", wsUrl, "timeout:", timeout);
24446
+ const ws = new WebSocket(wsUrl);
24447
+ const timer = setTimeout(() => {
24448
+ this._wsLog("initWebSocket timeout after", timeout, "ms");
24449
+ reject(new Error("WebSocket connection timeout"));
24450
+ }, timeout);
24451
+ ws.onopen = () => {
24452
+ clearTimeout(timer);
24453
+ this._wsLog("initWebSocket opened");
24454
+ resolve(ws);
24455
+ };
24456
+ ws.onerror = (error) => {
24457
+ clearTimeout(timer);
24458
+ this._wsLog("initWebSocket error:", error);
24459
+ reject(error);
24460
+ };
24461
+ });
24462
+ }
24433
24463
  _setupWebSocketHandlers() {
24434
24464
  if (!this._ws) return;
24435
24465
  this._ws.onmessage = async (msg) => {
@@ -24440,49 +24470,52 @@ var Client = class _Client {
24440
24470
  data = msg.data;
24441
24471
  }
24442
24472
  const decodedMsg = JSON.parse(data);
24473
+ this._wsLog("Received:", decodedMsg.type, decodedMsg.content);
24443
24474
  const topic = getTopicFromMessage(decodedMsg);
24444
24475
  const callback = this._subscriptions.get(topic);
24445
24476
  if (callback) {
24446
24477
  callback(decodedMsg);
24478
+ } else {
24479
+ this._wsLog("No handler for topic:", topic);
24447
24480
  }
24448
24481
  };
24449
- }
24450
- static async initWebSocket(url, timeout = 5e3) {
24451
- return new Promise((resolve, reject) => {
24452
- const ws = new WebSocket(
24453
- `${url.replace("http", "ws").replace("https", "wss")}` + "/v1/ws" /* Ws */
24482
+ this._ws.onclose = (event) => {
24483
+ this._wsLog(
24484
+ "Closed: code=" + event.code,
24485
+ "reason=" + event.reason,
24486
+ "clean=" + event.wasClean
24454
24487
  );
24455
- const timer = setTimeout(() => {
24456
- reject(new Error("WebSocket connection timeout"));
24457
- }, timeout);
24458
- ws.onopen = () => {
24459
- clearTimeout(timer);
24460
- resolve(ws);
24461
- };
24462
- ws.onerror = (error) => {
24463
- clearTimeout(timer);
24464
- reject(error);
24465
- };
24466
- });
24488
+ this._ws = void 0;
24489
+ this._subscriptions.clear();
24490
+ this.onWsClose?.(event);
24491
+ };
24492
+ this._ws.onerror = (error) => {
24493
+ this._wsLog("Error:", error);
24494
+ };
24467
24495
  }
24468
24496
  async disconnectWebSocket() {
24469
24497
  if (!this._ws) {
24470
24498
  console.warn("WebSocket is not connected");
24471
24499
  return;
24472
24500
  }
24501
+ this._wsLog("Disconnecting, clearing", this._subscriptions.size, "subscriptions");
24473
24502
  this._subscriptions.clear();
24474
24503
  this._ws.close();
24475
24504
  this._ws = void 0;
24476
24505
  }
24477
24506
  // Method to check if WebSocket is connected
24478
24507
  isWebSocketConnected() {
24479
- return this._ws !== void 0 && this._ws.readyState === WebSocket.OPEN;
24508
+ const connected = this._ws !== void 0 && this._ws.readyState === WebSocket.OPEN;
24509
+ this._wsLog("isWebSocketConnected:", connected);
24510
+ return connected;
24480
24511
  }
24481
24512
  sendWsMessage(message) {
24482
24513
  if (!this._ws) throw new Error("WebSocket is not connected");
24483
24514
  return new Promise((resolve, reject) => {
24484
24515
  const topic = message.content.id;
24516
+ this._wsLog("Sending:", message.type, "id=" + topic);
24485
24517
  const timer = setTimeout(() => {
24518
+ this._wsLog("Timeout waiting for response:", message.type, "id=" + topic);
24486
24519
  reject(new Error(`Connection timed out after ${this.timeout} ms`));
24487
24520
  }, this.timeout);
24488
24521
  let handler = (response) => {
@@ -24490,11 +24523,13 @@ var Client = class _Client {
24490
24523
  this._subscriptions.delete(topic);
24491
24524
  if (response.type === "Error") {
24492
24525
  const errorMessage = response.content.message || "Unknown websocket error without message";
24526
+ this._wsLog("Error response:", errorMessage, "id=" + topic);
24493
24527
  reject(
24494
24528
  new Error(`WebSocket error (id: ${response.content.id}): ${errorMessage}`)
24495
24529
  );
24496
24530
  return;
24497
24531
  }
24532
+ this._wsLog("Ack received for:", message.type, "id=" + topic);
24498
24533
  resolve(response);
24499
24534
  };
24500
24535
  this._subscriptions.set(topic, handler);
@@ -25416,11 +25451,11 @@ import {
25416
25451
  SimpleTransaction as SimpleTransaction2
25417
25452
  } from "@aptos-labs/ts-sdk";
25418
25453
  var TestFaucet = class _TestFaucet extends client_default {
25419
- constructor(connection, enableWs, url, apiKey, networkMode = "testnet") {
25420
- super(connection, enableWs, url, apiKey, void 0, void 0, networkMode);
25454
+ constructor(connection, config = {}) {
25455
+ super(connection, config);
25421
25456
  }
25422
- static async create(connection, networkMode = "testnet", enableWs = false, url = "https://api.dev.neony.exchange", apiKey) {
25423
- return new _TestFaucet(connection, enableWs, url, apiKey, networkMode);
25457
+ static async create(connection, config = {}) {
25458
+ return new _TestFaucet(connection, { enableWs: false, ...config });
25424
25459
  }
25425
25460
  async initFaucetPayload() {
25426
25461
  const abi = this._abis.FaucetEntrypointsABI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nightlylabs/dex-sdk",
3
- "version": "0.3.38",
3
+ "version": "0.3.39",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {