ault-sdk-ts 0.0.2-alpha.21 → 0.0.2-alpha.22

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/README.md CHANGED
@@ -377,8 +377,18 @@ const candles = await dex.getOHLCV("AULT/USDT", {
377
377
  timeframe: "1h",
378
378
  limit: 100,
379
379
  });
380
+
381
+ // Protocol stats (24h window)
382
+ const stats = await dex.getStats(); // defaults to { window: "24h" }
383
+ console.log(stats.totals.quoteVolume); // "1234567.89" or null when markets span multiple quotes
384
+ console.log(stats.totals.tradeCount, stats.totals.traderCount);
385
+ for (const m of stats.markets) {
386
+ console.log(m.symbol, m.quoteVolume, m.tradeCount);
387
+ }
380
388
  ```
381
389
 
390
+ Monetary fields like `quoteVolume`, `estimatedFee`, and `averageSlippageBps` come back as canonical decimal strings, so parse them with a decimal library rather than `parseFloat`. `totals.quoteVolume` and its related fee fields are `null` when the markets that traded in the window span more than one quote asset, since summing notionals across quotes is meaningless. `markets[]` can briefly lag `totals` while the symbol map updates, so the per-market trade counts need not add up to `totals.tradeCount`.
391
+
382
392
  ### User Queries
383
393
 
384
394
  ```typescript
package/dist/index.cjs CHANGED
@@ -59,6 +59,8 @@ __export(index_exports, {
59
59
  GetOrderbookResponse: () => GetOrderbookResponse,
60
60
  GetReadyResponse: () => GetReadyResponse,
61
61
  GetSDKManifestResponse: () => GetSDKManifestResponse,
62
+ GetStatsQueryParams: () => GetStatsQueryParams,
63
+ GetStatsResponse: () => GetStatsResponse,
62
64
  GetStatusResponse: () => GetStatusResponse,
63
65
  GetTickerParams: () => GetTickerParams,
64
66
  GetTickerResponse: () => GetTickerResponse,
@@ -204,6 +206,15 @@ __export(index_exports, {
204
206
  getOrderbookQueryLimitDefault: () => getOrderbookQueryLimitDefault,
205
207
  getOrderbookQueryLimitMax: () => getOrderbookQueryLimitMax,
206
208
  getOrderbookResponseMarketIdRegExp: () => getOrderbookResponseMarketIdRegExp,
209
+ getStatsResponseMarketsItemBaseVolumeRegExp: () => getStatsResponseMarketsItemBaseVolumeRegExp,
210
+ getStatsResponseMarketsItemEstimatedFeeRegExp: () => getStatsResponseMarketsItemEstimatedFeeRegExp,
211
+ getStatsResponseMarketsItemQuoteVolumeRegExp: () => getStatsResponseMarketsItemQuoteVolumeRegExp,
212
+ getStatsResponseMarketsItemTakerFeeRateRegExp: () => getStatsResponseMarketsItemTakerFeeRateRegExp,
213
+ getStatsResponseTotalsAverageSlippageBpsRegExp: () => getStatsResponseTotalsAverageSlippageBpsRegExp,
214
+ getStatsResponseTotalsBuilderCodesFee24hRegExp: () => getStatsResponseTotalsBuilderCodesFee24hRegExp,
215
+ getStatsResponseTotalsDepositUsdcVolume24hRegExp: () => getStatsResponseTotalsDepositUsdcVolume24hRegExp,
216
+ getStatsResponseTotalsEstimatedFeeRegExp: () => getStatsResponseTotalsEstimatedFeeRegExp,
217
+ getStatsResponseTotalsQuoteVolumeRegExp: () => getStatsResponseTotalsQuoteVolumeRegExp,
207
218
  getTradingFeesResponseMakerRegExp: () => getTradingFeesResponseMakerRegExp,
208
219
  getTradingFeesResponseTakerRegExp: () => getTradingFeesResponseTakerRegExp,
209
220
  getUDFHistoryQueryCountbackMax: () => getUDFHistoryQueryCountbackMax,
@@ -10878,6 +10889,7 @@ async function dexFetch(url, init) {
10878
10889
  // src/rest/dex.generated.ts
10879
10890
  var dex_generated_exports = {};
10880
10891
  __export(dex_generated_exports, {
10892
+ GetStatsWindow: () => GetStatsWindow,
10881
10893
  GetUDFHistoryResolution: () => GetUDFHistoryResolution,
10882
10894
  HealthResponseDatabase: () => HealthResponseDatabase,
10883
10895
  HealthResponseStatus: () => HealthResponseStatus,
@@ -10890,6 +10902,7 @@ __export(dex_generated_exports, {
10890
10902
  OrderResponseStatus: () => OrderResponseStatus,
10891
10903
  OrderResponseType: () => OrderResponseType,
10892
10904
  ReadyResponseStatus: () => ReadyResponseStatus,
10905
+ StatsResponseWindow: () => StatsResponseWindow,
10893
10906
  TradeResponseSide: () => TradeResponseSide,
10894
10907
  TradeResponseTakerOrMaker: () => TradeResponseTakerOrMaker,
10895
10908
  TradeResponseType: () => TradeResponseType,
@@ -10909,6 +10922,7 @@ __export(dex_generated_exports, {
10909
10922
  getGetOrderbookUrl: () => getGetOrderbookUrl,
10910
10923
  getGetReadyUrl: () => getGetReadyUrl,
10911
10924
  getGetSDKManifestUrl: () => getGetSDKManifestUrl,
10925
+ getGetStatsUrl: () => getGetStatsUrl,
10912
10926
  getGetStatusUrl: () => getGetStatusUrl,
10913
10927
  getGetTickerUrl: () => getGetTickerUrl,
10914
10928
  getGetTradingFeesUrl: () => getGetTradingFeesUrl,
@@ -10933,6 +10947,7 @@ __export(dex_generated_exports, {
10933
10947
  getReady: () => getReady,
10934
10948
  getSDKManifest: () => getSDKManifest,
10935
10949
  getSearchUDFSymbolsUrl: () => getSearchUDFSymbolsUrl,
10950
+ getStats: () => getStats,
10936
10951
  getStatus: () => getStatus,
10937
10952
  getTicker: () => getTicker,
10938
10953
  getTradingFees: () => getTradingFees,
@@ -10982,6 +10997,9 @@ var LiveResponseStatus = {
10982
10997
  var MarketResponseType = {
10983
10998
  spot: "spot"
10984
10999
  };
11000
+ var StatsResponseWindow = {
11001
+ "24h": "24h"
11002
+ };
10985
11003
  var TradeResponseType = {
10986
11004
  limit: "limit",
10987
11005
  market: "market"
@@ -11025,6 +11043,9 @@ var UDFQuoteDataS = {
11025
11043
  ok: "ok",
11026
11044
  error: "error"
11027
11045
  };
11046
+ var GetStatsWindow = {
11047
+ "24h": "24h"
11048
+ };
11028
11049
  var ListOrdersStatus = {
11029
11050
  open: "open",
11030
11051
  closed: "closed",
@@ -11162,6 +11183,22 @@ var getTradingFees = async (options) => {
11162
11183
  method: "GET"
11163
11184
  });
11164
11185
  };
11186
+ var getGetStatsUrl = (params) => {
11187
+ const normalizedParams = new URLSearchParams();
11188
+ Object.entries(params || {}).forEach(([key, value]) => {
11189
+ if (value !== void 0) {
11190
+ normalizedParams.append(key, value === null ? "null" : value.toString());
11191
+ }
11192
+ });
11193
+ const stringifiedParams = normalizedParams.toString();
11194
+ return stringifiedParams.length > 0 ? `/api/v1/stats?${stringifiedParams}` : `/api/v1/stats`;
11195
+ };
11196
+ var getStats = async (params, options) => {
11197
+ return dexFetch(getGetStatsUrl(params), {
11198
+ ...options,
11199
+ method: "GET"
11200
+ });
11201
+ };
11165
11202
  var getListOrdersUrl = (params) => {
11166
11203
  const normalizedParams = new URLSearchParams();
11167
11204
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -11384,6 +11421,7 @@ function createDexApi(context) {
11384
11421
  getOrder: bind(context, getOrder),
11385
11422
  listMyTrades: bind(context, listMyTrades),
11386
11423
  getBalance: bind(context, getBalance),
11424
+ getStats: bind(context, getStats),
11387
11425
  getUDFConfig: bind(context, getUDFConfig),
11388
11426
  getUDFTime: bind(context, getUDFTime),
11389
11427
  getUDFSymbol: bind(context, getUDFSymbol),
@@ -24253,6 +24291,57 @@ var GetTradingFeesResponse = zod.record(
24253
24291
  info: zod.looseObject({})
24254
24292
  })
24255
24293
  );
24294
+ var GetStatsQueryParams = zod.object({
24295
+ window: zod.enum(["24h"]).optional().describe("Rolling window. Only `24h` is supported; defaults to `24h`.")
24296
+ });
24297
+ var getStatsResponseTotalsQuoteVolumeRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
24298
+ var getStatsResponseTotalsEstimatedFeeRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
24299
+ var getStatsResponseTotalsAverageSlippageBpsRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
24300
+ var getStatsResponseTotalsDepositUsdcVolume24hRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
24301
+ var getStatsResponseTotalsBuilderCodesFee24hRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
24302
+ var getStatsResponseMarketsItemQuoteVolumeRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
24303
+ var getStatsResponseMarketsItemBaseVolumeRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
24304
+ var getStatsResponseMarketsItemEstimatedFeeRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
24305
+ var getStatsResponseMarketsItemTakerFeeRateRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
24306
+ var GetStatsResponse = zod.object({
24307
+ window: zod.enum(["24h"]),
24308
+ totals: zod.object({
24309
+ quoteVolume: zod.string().regex(getStatsResponseTotalsQuoteVolumeRegExp).nullable().describe(
24310
+ "Total quote volume over the window as a canonical decimal string.\nNull when the markets that had volume span more than one quote\nasset, since summing notionals in different quotes is meaningless \u2014\n`quoteVolume`, `estimatedFee`, and `quoteAsset` are null together in\nthat case.\n"
24311
+ ),
24312
+ quoteAsset: zod.string().nullable().describe(
24313
+ 'The shared quote asset ticker of the markets that had volume in the\nwindow. Null in two cases: when those markets span more than one\nquote (then `quoteVolume` and `estimatedFee` are also null), or when\nno market had volume in the window (an idle window \u2014 then\n`quoteVolume` and `estimatedFee` are "0" rather than null, since a\nzero total is well-defined regardless of quote). To distinguish the\ntwo null causes, read `quoteVolume`: null means multi-quote, "0"\nmeans idle.\n'
24314
+ ),
24315
+ estimatedFee: zod.string().regex(getStatsResponseTotalsEstimatedFeeRegExp).nullable().describe(
24316
+ "Estimated total fees (`\u03A3 quoteVolume \xD7 takerFeeRate`) as a canonical\ndecimal string. An estimate from the fee schedule, not booked\nrevenue. Null when the markets that had volume span more than one\nquote (see `quoteVolume`).\n"
24317
+ ),
24318
+ tradeCount: zod.number().describe("Number of fills (maker legs) in the window."),
24319
+ traderCount: zod.number().describe("Distinct trading addresses in the window."),
24320
+ activeMarkets: zod.number().describe("Number of markets with at least one fill in the window."),
24321
+ dailyActiveUsers: zod.number().nullable().describe(
24322
+ "Distinct trading addresses in the window (active-traders\napproximation). Currently an exact alias of `traderCount`; carried\nas a separate nullable field so a future precise DAU source can\ndiverge without an API change. Never null today.\n"
24323
+ ),
24324
+ averageSlippageBps: zod.string().regex(getStatsResponseTotalsAverageSlippageBpsRegExp).nullable().describe(
24325
+ "Volume-weighted taker slippage (fill vs book-mid) in basis points as\na canonical decimal string. Null when the window has no taker fill\nwith a snapshot to benchmark against, or when benchmarked fills span\nmore than one quote asset (the weights are quote-denominated, so a\nsingle figure across quotes would mix notionals).\n"
24326
+ ),
24327
+ depositUsdcVolume24h: zod.string().regex(getStatsResponseTotalsDepositUsdcVolume24hRegExp).nullable().describe("Reserved. Currently always null."),
24328
+ builderCodesFee24h: zod.string().regex(getStatsResponseTotalsBuilderCodesFee24hRegExp).nullable().describe("Reserved. Currently always null.")
24329
+ }).describe("Protocol-wide aggregates for the window."),
24330
+ markets: zod.array(
24331
+ zod.object({
24332
+ symbol: zod.string(),
24333
+ base: zod.string(),
24334
+ quote: zod.string(),
24335
+ quoteVolume: zod.string().regex(getStatsResponseMarketsItemQuoteVolumeRegExp),
24336
+ baseVolume: zod.string().regex(getStatsResponseMarketsItemBaseVolumeRegExp),
24337
+ estimatedFee: zod.string().regex(getStatsResponseMarketsItemEstimatedFeeRegExp),
24338
+ tradeCount: zod.number(),
24339
+ takerFeeRate: zod.string().regex(getStatsResponseMarketsItemTakerFeeRateRegExp)
24340
+ }).describe("Per-market aggregates for the window.")
24341
+ )
24342
+ }).describe(
24343
+ "Protocol stats overview for a rolling window. Monetary fields are\ncanonical decimal strings; counts are integers.\n"
24344
+ );
24256
24345
  var listOrdersQueryAddressOneRegExp = new RegExp("^ault1[a-z0-9]{38,}$");
24257
24346
  var listOrdersQueryAddressTwoRegExp = new RegExp("^0x[a-f0-9]{40}$");
24258
24347
  var listOrdersQueryMarketIdRegExp = new RegExp("^[0-9a-fA-F]+$");
@@ -24309,7 +24398,7 @@ var ListOrdersResponseItem = zod.object({
24309
24398
  currency: zod.string().optional().describe('Quote currency ticker (e.g., "USDT")'),
24310
24399
  rate: zod.string().regex(listOrdersResponseFeeRateRegExp).optional().describe("Fee rate from the market, decimal string.")
24311
24400
  }).optional().describe(
24312
- "Fee for the order. `cost` is `cost * taker_fee_rate` \u2014 applied to\nthe realized cost above, so it is more accurate than the previous\n`filled * price * taker_fee_rate` approximation. The rate is the\nmarket's taker rate; per-trade maker/taker resolution depends on\nthe dbindexer `is_taker` column landing first.\n"
24401
+ "Fee for the order. `cost` is `cost * taker_fee_rate` \u2014 applied to\nthe realized cost above, so it is more accurate than the previous\n`filled * price * taker_fee_rate` approximation. The rate is the\nmarket's taker rate; this stays an estimate because the indexer\nrecords no realized per-trade fee amount to sum.\n"
24313
24402
  ),
24314
24403
  reduceOnly: zod.boolean().optional(),
24315
24404
  postOnly: zod.boolean().optional(),
@@ -24373,7 +24462,7 @@ var GetOrderResponse = zod.object({
24373
24462
  currency: zod.string().optional().describe('Quote currency ticker (e.g., "USDT")'),
24374
24463
  rate: zod.string().regex(getOrderResponseFeeRateRegExp).optional().describe("Fee rate from the market, decimal string.")
24375
24464
  }).optional().describe(
24376
- "Fee for the order. `cost` is `cost * taker_fee_rate` \u2014 applied to\nthe realized cost above, so it is more accurate than the previous\n`filled * price * taker_fee_rate` approximation. The rate is the\nmarket's taker rate; per-trade maker/taker resolution depends on\nthe dbindexer `is_taker` column landing first.\n"
24465
+ "Fee for the order. `cost` is `cost * taker_fee_rate` \u2014 applied to\nthe realized cost above, so it is more accurate than the previous\n`filled * price * taker_fee_rate` approximation. The rate is the\nmarket's taker rate; this stays an estimate because the indexer\nrecords no realized per-trade fee amount to sum.\n"
24377
24466
  ),
24378
24467
  reduceOnly: zod.boolean().optional(),
24379
24468
  postOnly: zod.boolean().optional(),
@@ -24629,7 +24718,7 @@ function createDexWs(url, options) {
24629
24718
  }
24630
24719
 
24631
24720
  // src/index.ts
24632
- var SDK_VERSION = "0.0.2-alpha.21";
24721
+ var SDK_VERSION = "0.0.2-alpha.22";
24633
24722
  // Annotate the CommonJS export names for ESM import in node:
24634
24723
  0 && (module.exports = {
24635
24724
  AGENT_DEFAULTS,
@@ -24661,6 +24750,8 @@ var SDK_VERSION = "0.0.2-alpha.21";
24661
24750
  GetOrderbookResponse,
24662
24751
  GetReadyResponse,
24663
24752
  GetSDKManifestResponse,
24753
+ GetStatsQueryParams,
24754
+ GetStatsResponse,
24664
24755
  GetStatusResponse,
24665
24756
  GetTickerParams,
24666
24757
  GetTickerResponse,
@@ -24806,6 +24897,15 @@ var SDK_VERSION = "0.0.2-alpha.21";
24806
24897
  getOrderbookQueryLimitDefault,
24807
24898
  getOrderbookQueryLimitMax,
24808
24899
  getOrderbookResponseMarketIdRegExp,
24900
+ getStatsResponseMarketsItemBaseVolumeRegExp,
24901
+ getStatsResponseMarketsItemEstimatedFeeRegExp,
24902
+ getStatsResponseMarketsItemQuoteVolumeRegExp,
24903
+ getStatsResponseMarketsItemTakerFeeRateRegExp,
24904
+ getStatsResponseTotalsAverageSlippageBpsRegExp,
24905
+ getStatsResponseTotalsBuilderCodesFee24hRegExp,
24906
+ getStatsResponseTotalsDepositUsdcVolume24hRegExp,
24907
+ getStatsResponseTotalsEstimatedFeeRegExp,
24908
+ getStatsResponseTotalsQuoteVolumeRegExp,
24809
24909
  getTradingFeesResponseMakerRegExp,
24810
24910
  getTradingFeesResponseTakerRegExp,
24811
24911
  getUDFHistoryQueryCountbackMax,