ault-sdk-ts 0.6.0 → 0.7.1

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
@@ -38,6 +38,7 @@ __export(index_exports, {
38
38
  BondStatus: () => BondStatus,
39
39
  COIN_TYPE: () => COIN_TYPE,
40
40
  DEFAULT_CHAIN_ID: () => DEFAULT_CHAIN_ID,
41
+ DEFAULT_RETRYABLE_STATUSES: () => DEFAULT_RETRYABLE_STATUSES,
41
42
  DexWsClient: () => DexWsClient,
42
43
  EIP712_DOMAIN_TYPE: () => EIP712_DOMAIN_TYPE,
43
44
  EIP712_MSG_TYPES: () => EIP712_MSG_TYPES,
@@ -46,6 +47,7 @@ __export(index_exports, {
46
47
  GetAllTickersResponse: () => GetAllTickersResponse,
47
48
  GetBalanceQueryParams: () => GetBalanceQueryParams,
48
49
  GetBalanceResponse: () => GetBalanceResponse,
50
+ GetDBReadyResponse: () => GetDBReadyResponse,
49
51
  GetHealthResponse: () => GetHealthResponse,
50
52
  GetLiveResponse: () => GetLiveResponse,
51
53
  GetOHLCVParams: () => GetOHLCVParams,
@@ -102,6 +104,7 @@ __export(index_exports, {
102
104
  MarketType: () => MarketType,
103
105
  MissingMsgResponseError: () => MissingMsgResponseError,
104
106
  NETWORKS: () => NETWORKS,
107
+ NEXT_CURSOR_HEADER: () => NEXT_CURSOR_HEADER,
105
108
  NetworkError: () => NetworkError,
106
109
  ORDER_ID_LENGTH: () => ORDER_ID_LENGTH,
107
110
  OrderId: () => OrderId,
@@ -111,6 +114,7 @@ __export(index_exports, {
111
114
  SDK_VERSION: () => SDK_VERSION,
112
115
  SIGN_MODE_DIRECT: () => SIGN_MODE_DIRECT,
113
116
  SIGN_MODE_LEGACY_AMINO_JSON: () => SIGN_MODE_LEGACY_AMINO_JSON,
117
+ SIMULATION_PLACEHOLDER_PUBKEY: () => SIMULATION_PLACEHOLDER_PUBKEY,
114
118
  SearchUDFSymbolsQueryParams: () => SearchUDFSymbolsQueryParams,
115
119
  SearchUDFSymbolsResponse: () => SearchUDFSymbolsResponse,
116
120
  SearchUDFSymbolsResponseItem: () => SearchUDFSymbolsResponseItem,
@@ -120,6 +124,7 @@ __export(index_exports, {
120
124
  TxConfirmationUnavailableError: () => TxConfirmationUnavailableError,
121
125
  TxError: () => TxError,
122
126
  TxNotConfirmedError: () => TxNotConfirmedError,
127
+ TxSimulationError: () => TxSimulationError,
123
128
  ValidatorStatus: () => BondStatus,
124
129
  WebSocketError: () => WebSocketError,
125
130
  WithdrawRewardsPartialError: () => WithdrawRewardsPartialError,
@@ -137,10 +142,12 @@ __export(index_exports, {
137
142
  buildEip712TypedData: () => buildEip712TypedData,
138
143
  buildFetchOptions: () => buildFetchOptions,
139
144
  bytesToBase64: () => bytesToBase64,
145
+ collectPages: () => collectPages,
140
146
  computeEvmFeesPerGas: () => computeEvmFeesPerGas,
141
147
  computeFeeFreeGas: () => computeFeeFreeGas,
142
148
  computeFeeFreeGasCompound: () => computeFeeFreeGasCompound,
143
149
  computeRequiredFee: () => computeRequiredFee,
150
+ computeSimulatedGas: () => computeSimulatedGas,
144
151
  cosmosDecToDecimalString: () => cosmosDecToDecimalString,
145
152
  cosmosDecToProtoInt: () => cosmosDecToProtoInt,
146
153
  createAccountCache: () => createAccountCache,
@@ -232,6 +239,7 @@ __export(index_exports, {
232
239
  getTradeResponseFeeRateRegExp: () => getTradeResponseFeeRateRegExp,
233
240
  getTradeResponseInfoAddressOneRegExp: () => getTradeResponseInfoAddressOneRegExp,
234
241
  getTradeResponseInfoBlockHeightRegExp: () => getTradeResponseInfoBlockHeightRegExp,
242
+ getTradeResponseInfoEventIndexMax: () => getTradeResponseInfoEventIndexMax,
235
243
  getTradeResponseInfoEventIndexMin: () => getTradeResponseInfoEventIndexMin,
236
244
  getTradeResponsePriceRegExp: () => getTradeResponsePriceRegExp,
237
245
  getTradingFeesResponseMakerRegExp: () => getTradingFeesResponseMakerRegExp,
@@ -242,9 +250,13 @@ __export(index_exports, {
242
250
  isValidAultAddress: () => isValidAultAddress,
243
251
  isValidEvmAddress: () => isValidEvmAddress,
244
252
  isValidValidatorAddress: () => isValidValidatorAddress,
253
+ listCurrenciesResponseInfoContractDecimalsMax: () => listCurrenciesResponseInfoContractDecimalsMax,
254
+ listCurrenciesResponseInfoContractDecimalsMin: () => listCurrenciesResponseInfoContractDecimalsMin,
245
255
  listMarketsResponseInfoEscrowAddressOneRegExp: () => listMarketsResponseInfoEscrowAddressOneRegExp,
246
256
  listMarketsResponseMakerRegExp: () => listMarketsResponseMakerRegExp,
247
257
  listMarketsResponseTakerRegExp: () => listMarketsResponseTakerRegExp,
258
+ listMyTradesQueryBeforeIndexMax: () => listMyTradesQueryBeforeIndexMax,
259
+ listMyTradesQueryBeforeIndexMin: () => listMyTradesQueryBeforeIndexMin,
248
260
  listMyTradesQueryLimitDefault: () => listMyTradesQueryLimitDefault,
249
261
  listMyTradesQueryLimitMax: () => listMyTradesQueryLimitMax,
250
262
  listMyTradesResponseAmountRegExp: () => listMyTradesResponseAmountRegExp,
@@ -253,6 +265,7 @@ __export(index_exports, {
253
265
  listMyTradesResponseFeeRateRegExp: () => listMyTradesResponseFeeRateRegExp,
254
266
  listMyTradesResponseInfoAddressOneRegExp: () => listMyTradesResponseInfoAddressOneRegExp,
255
267
  listMyTradesResponseInfoBlockHeightRegExp: () => listMyTradesResponseInfoBlockHeightRegExp,
268
+ listMyTradesResponseInfoEventIndexMax: () => listMyTradesResponseInfoEventIndexMax,
256
269
  listMyTradesResponseInfoEventIndexMin: () => listMyTradesResponseInfoEventIndexMin,
257
270
  listMyTradesResponsePriceRegExp: () => listMyTradesResponsePriceRegExp,
258
271
  listOrdersQueryAddressOneRegExp: () => listOrdersQueryAddressOneRegExp,
@@ -270,6 +283,8 @@ __export(index_exports, {
270
283
  listOrdersResponseInfoRemainingDepositRegExp: () => listOrdersResponseInfoRemainingDepositRegExp,
271
284
  listOrdersResponsePriceRegExp: () => listOrdersResponsePriceRegExp,
272
285
  listOrdersResponseRemainingRegExp: () => listOrdersResponseRemainingRegExp,
286
+ listTradesQueryBeforeIndexMax: () => listTradesQueryBeforeIndexMax,
287
+ listTradesQueryBeforeIndexMin: () => listTradesQueryBeforeIndexMin,
273
288
  listTradesQueryLimitDefault: () => listTradesQueryLimitDefault,
274
289
  listTradesQueryLimitMax: () => listTradesQueryLimitMax,
275
290
  listTradesResponseAmountRegExp: () => listTradesResponseAmountRegExp,
@@ -278,6 +293,7 @@ __export(index_exports, {
278
293
  listTradesResponseFeeRateRegExp: () => listTradesResponseFeeRateRegExp,
279
294
  listTradesResponseInfoAddressOneRegExp: () => listTradesResponseInfoAddressOneRegExp,
280
295
  listTradesResponseInfoBlockHeightRegExp: () => listTradesResponseInfoBlockHeightRegExp,
296
+ listTradesResponseInfoEventIndexMax: () => listTradesResponseInfoEventIndexMax,
281
297
  listTradesResponseInfoEventIndexMin: () => listTradesResponseInfoEventIndexMin,
282
298
  listTradesResponsePriceRegExp: () => listTradesResponsePriceRegExp,
283
299
  mergeManifests: () => mergeManifests,
@@ -285,6 +301,7 @@ __export(index_exports, {
285
301
  normalizeSignature: () => normalizeSignature,
286
302
  normalizeSigner: () => normalizeSigner,
287
303
  normalizeTxHash: () => normalizeTxHash,
304
+ paginate: () => paginate,
288
305
  paginateAll: () => paginateAll,
289
306
  parseEvmChainIdFromCosmosChainId: () => parseEvmChainIdFromCosmosChainId,
290
307
  pollTxInclusion: () => pollTxInclusion,
@@ -294,6 +311,7 @@ __export(index_exports, {
294
311
  resolveSignerAddress: () => resolveSignerAddress,
295
312
  signAndBroadcastAgentTx: () => signAndBroadcastAgentTx,
296
313
  signAndBroadcastEip712: () => signAndBroadcastEip712,
314
+ simulateTx: () => simulateTx,
297
315
  stripEip712Domain: () => stripEip712Domain,
298
316
  toViemChain: () => toViemChain,
299
317
  validateEip712FieldOrder: () => validateEip712FieldOrder,
@@ -442,6 +460,14 @@ var TxError = class extends Error {
442
460
  this.confirmed = params.confirmed;
443
461
  }
444
462
  };
463
+ var TxSimulationError = class extends Error {
464
+ constructor(params) {
465
+ super(`Transaction simulation failed: ${params.rawLog}`);
466
+ this.name = "TxSimulationError";
467
+ this.chainCode = params.chainCode;
468
+ this.rawLog = params.rawLog;
469
+ }
470
+ };
445
471
  var TxNotConfirmedError = class extends TxError {
446
472
  constructor(params) {
447
473
  super(
@@ -488,13 +514,14 @@ var WithdrawRewardsPartialError = class extends Error {
488
514
  };
489
515
 
490
516
  // src/core/http.ts
517
+ var DEFAULT_RETRYABLE_STATUSES = [408, 429, 500, 502, 503, 504];
491
518
  var DEFAULT_OPTIONS = {
492
519
  timeout: 3e4,
493
520
  retries: 3,
494
521
  retryDelay: 1e3,
495
522
  exponentialBackoff: true,
496
523
  retryableMethods: ["GET", "HEAD", "OPTIONS"],
497
- retryableStatuses: [408, 429, 500, 502, 503, 504],
524
+ retryableStatuses: [...DEFAULT_RETRYABLE_STATUSES],
498
525
  retryOnTimeout: false
499
526
  };
500
527
  function ensureFetch(fetchFn) {
@@ -733,6 +760,8 @@ var GAS_CONSTANTS = {
733
760
  DENOM: "aault",
734
761
  /** Chain multiplier applied to min gas to derive max gas (120 = 1.2×). */
735
762
  FEE_FREE_GAS_MULTIPLIER: 120,
763
+ /** Headroom over simulated `gas_used` (130 = 1.3×). */
764
+ SIMULATED_GAS_MULTIPLIER: 130,
736
765
  // License module
737
766
  PER_LICENSE: 2e5,
738
767
  PER_KYC_MEMBER: 2e5,
@@ -763,11 +792,19 @@ var GAS_CONSTANTS = {
763
792
  // Accountx module
764
793
  OPEN_ACCOUNT: 96e3,
765
794
  // Staking module (cosmos-sdk standard, NOT fee-free — user pays gas).
795
+ // Staking gas depends on the delegator's state, so the builders simulate;
796
+ // these are the fallback (×FEE_FREE_GAS_MULTIPLIER) when simulate is down.
766
797
  DELEGATE: 22e4,
767
- UNDELEGATE: 22e4,
768
- BEGIN_REDELEGATE: 28e4,
798
+ UNDELEGATE: 26e4,
799
+ BEGIN_REDELEGATE: 4e5,
769
800
  WITHDRAW_DELEGATOR_REWARD: 22e4
770
801
  };
802
+ function computeSimulatedGas(gasUsed, multiplier = GAS_CONSTANTS.SIMULATED_GAS_MULTIPLIER) {
803
+ if (!Number.isInteger(multiplier) || multiplier < 100) {
804
+ throw new Error(`simulated gas multiplier must be an integer >= 100, got ${multiplier}`);
805
+ }
806
+ return (gasUsed * BigInt(multiplier) / 100n).toString();
807
+ }
771
808
  function computeFeeFreeGas(minGasPerOp, count, multiplier = GAS_CONSTANTS.FEE_FREE_GAS_MULTIPLIER) {
772
809
  return (BigInt(minGasPerOp) * BigInt(count) * BigInt(multiplier) / 100n).toString();
773
810
  }
@@ -11699,9 +11736,10 @@ async function dexFetch(url, init) {
11699
11736
  // src/rest/dex.generated.ts
11700
11737
  var dex_generated_exports = {};
11701
11738
  __export(dex_generated_exports, {
11739
+ DBReadyResponseDatabase: () => DBReadyResponseDatabase,
11740
+ DBReadyResponseStatus: () => DBReadyResponseStatus,
11702
11741
  GetStatsWindow: () => GetStatsWindow,
11703
11742
  GetUDFHistoryResolution: () => GetUDFHistoryResolution,
11704
- HealthResponseDatabase: () => HealthResponseDatabase,
11705
11743
  HealthResponseStatus: () => HealthResponseStatus,
11706
11744
  ListOrdersStatus: () => ListOrdersStatus,
11707
11745
  LiveResponseStatus: () => LiveResponseStatus,
@@ -11710,6 +11748,7 @@ __export(dex_generated_exports, {
11710
11748
  OrderInfoChainType: () => OrderInfoChainType,
11711
11749
  OrderResponseSide: () => OrderResponseSide,
11712
11750
  OrderResponseStatus: () => OrderResponseStatus,
11751
+ OrderResponseTimeInForce: () => OrderResponseTimeInForce,
11713
11752
  OrderResponseType: () => OrderResponseType,
11714
11753
  RangeQueryDayParameter: () => RangeQueryDayParameter,
11715
11754
  RangeQueryParameter: () => RangeQueryParameter,
@@ -11724,8 +11763,10 @@ __export(dex_generated_exports, {
11724
11763
  UDFSymbolInfoDataStatus: () => UDFSymbolInfoDataStatus,
11725
11764
  getAllTickers: () => getAllTickers,
11726
11765
  getBalance: () => getBalance,
11766
+ getDBReady: () => getDBReady,
11727
11767
  getGetAllTickersUrl: () => getGetAllTickersUrl,
11728
11768
  getGetBalanceUrl: () => getGetBalanceUrl,
11769
+ getGetDBReadyUrl: () => getGetDBReadyUrl,
11729
11770
  getGetHealthUrl: () => getGetHealthUrl,
11730
11771
  getGetLiveUrl: () => getGetLiveUrl,
11731
11772
  getGetOHLCVUrl: () => getGetOHLCVUrl,
@@ -11795,16 +11836,18 @@ var OrderInfoChainType = {
11795
11836
  unknown: "unknown"
11796
11837
  };
11797
11838
  var HealthResponseStatus = {
11798
- healthy: "healthy",
11799
- unhealthy: "unhealthy"
11839
+ healthy: "healthy"
11840
+ };
11841
+ var ReadyResponseStatus = {
11842
+ ready: "ready"
11800
11843
  };
11801
- var HealthResponseDatabase = {
11844
+ var DBReadyResponseStatus = {
11802
11845
  ok: "ok",
11803
- unreachable: "unreachable"
11846
+ unavailable: "unavailable"
11804
11847
  };
11805
- var ReadyResponseStatus = {
11806
- ready: "ready",
11807
- not_ready: "not ready"
11848
+ var DBReadyResponseDatabase = {
11849
+ ok: "ok",
11850
+ unreachable: "unreachable"
11808
11851
  };
11809
11852
  var LiveResponseStatus = {
11810
11853
  alive: "alive"
@@ -11813,7 +11856,10 @@ var MarketResponseType = {
11813
11856
  spot: "spot"
11814
11857
  };
11815
11858
  var StatsResponseWindow = {
11816
- "24h": "24h"
11859
+ "24h": "24h",
11860
+ "7d": "7d",
11861
+ "30d": "30d",
11862
+ all: "all"
11817
11863
  };
11818
11864
  var TradeResponseType = {
11819
11865
  limit: "limit",
@@ -11841,6 +11887,9 @@ var OrderResponseType = {
11841
11887
  twap: "twap",
11842
11888
  unknown: "unknown"
11843
11889
  };
11890
+ var OrderResponseTimeInForce = {
11891
+ ioc: "ioc"
11892
+ };
11844
11893
  var OrderResponseSide = {
11845
11894
  buy: "buy",
11846
11895
  sell: "sell"
@@ -11877,7 +11926,10 @@ var RangeQueryDayParameter = {
11877
11926
  allTime: "allTime"
11878
11927
  };
11879
11928
  var GetStatsWindow = {
11880
- "24h": "24h"
11929
+ "24h": "24h",
11930
+ "7d": "7d",
11931
+ "30d": "30d",
11932
+ all: "all"
11881
11933
  };
11882
11934
  var ListOrdersStatus = {
11883
11935
  open: "open",
@@ -11921,6 +11973,15 @@ var getLive = async (options) => {
11921
11973
  method: "GET"
11922
11974
  });
11923
11975
  };
11976
+ var getGetDBReadyUrl = () => {
11977
+ return `/db-ready`;
11978
+ };
11979
+ var getDBReady = async (options) => {
11980
+ return dexFetch(getGetDBReadyUrl(), {
11981
+ ...options,
11982
+ method: "GET"
11983
+ });
11984
+ };
11924
11985
  var getGetStatusUrl = () => {
11925
11986
  return `/api/v1/status`;
11926
11987
  };
@@ -12305,7 +12366,9 @@ function createDexApi(context) {
12305
12366
  getUDFHistory: bind(context, getUDFHistory),
12306
12367
  getUDFQuotes: bind(context, getUDFQuotes),
12307
12368
  getUDFMarks: bind(context, getUDFMarks),
12308
- getUDFTimescaleMarks: bind(context, getUDFTimescaleMarks)
12369
+ getUDFTimescaleMarks: bind(context, getUDFTimescaleMarks),
12370
+ getOpenAPISpec: bind(context, getOpenAPISpec),
12371
+ getDBReady: bind(context, getDBReady)
12309
12372
  };
12310
12373
  }
12311
12374
 
@@ -15700,446 +15763,199 @@ function buildEip712TypedData(context, msgs, evmChainId) {
15700
15763
  };
15701
15764
  }
15702
15765
 
15703
- // src/rest/feemarket.ts
15704
- async function fetchFeeMarketParams(network, fetchFn, fetchOptions) {
15705
- const data = await fetchJson(
15706
- `${network.restUrl}/cosmos/evm/feemarket/v1/params`,
15707
- {},
15708
- fetchOptions,
15709
- fetchFn
15710
- );
15711
- const raw = data.params ?? {};
15712
- return {
15713
- noBaseFee: raw.noBaseFee ?? raw.no_base_fee ?? false,
15714
- baseFee: raw.baseFee ?? raw.base_fee ?? "0",
15715
- minGasPrice: raw.minGasPrice ?? raw.min_gas_price ?? "0"
15716
- };
15717
- }
15718
- var ONE_E18 = 1000000000000000000n;
15719
- var DEFAULT_FEE_MARGIN_PERCENT = 20;
15720
- function marginFactorScaled(marginPercent) {
15721
- if (!Number.isFinite(marginPercent) || !Number.isInteger(marginPercent)) {
15722
- throw new Error(`marginPercent must be a non-negative integer, got ${marginPercent}`);
15766
+ // src/proto/tx-encode.ts
15767
+ var WIRE_VARINT = 0;
15768
+ var WIRE_LENGTH_DELIMITED = 2;
15769
+ var BinaryWriter35 = class {
15770
+ constructor() {
15771
+ this.chunks = [];
15723
15772
  }
15724
- if (marginPercent < 0) {
15725
- throw new Error(`marginPercent must be >= 0, got ${marginPercent}`);
15773
+ writeVarint(value) {
15774
+ let v = BigInt(value);
15775
+ const bytes = [];
15776
+ do {
15777
+ let byte = Number(v & 0x7fn);
15778
+ v >>= 7n;
15779
+ if (v > 0n) byte |= 128;
15780
+ bytes.push(byte);
15781
+ } while (v > 0n);
15782
+ this.chunks.push(new Uint8Array(bytes));
15783
+ return this;
15726
15784
  }
15727
- return BigInt(100 + marginPercent);
15728
- }
15729
- function computeRequiredFee(params, gas, options) {
15730
- const margin = marginFactorScaled(options?.marginPercent ?? DEFAULT_FEE_MARGIN_PERCENT);
15731
- const minGasPriceI = BigInt(cosmosDecToProtoInt(params.minGasPrice || "0"));
15732
- const baseFeeI = params.noBaseFee ? 0n : BigInt(cosmosDecToProtoInt(params.baseFee || "0"));
15733
- const effectiveI = baseFeeI > minGasPriceI ? baseFeeI : minGasPriceI;
15734
- if (effectiveI <= 0n) return "0";
15735
- const gasI = BigInt(gas);
15736
- if (gasI <= 0n) return "0";
15737
- const numerator = effectiveI * gasI * margin;
15738
- const denominator = ONE_E18 * 100n;
15739
- return ((numerator + denominator - 1n) / denominator).toString();
15740
- }
15741
- var DEFAULT_FEE_MARKET_TTL_MS = 3e3;
15742
- function createFeeMarketCache(ttlMs = DEFAULT_FEE_MARKET_TTL_MS) {
15743
- return { ttlMs, entries: /* @__PURE__ */ new Map() };
15744
- }
15745
- async function getCachedFeeMarketParams(cache, network, fetchFn, fetchOptions) {
15746
- const key = network.chainId;
15747
- const now = Date.now();
15748
- if (cache) {
15749
- const existing = cache.entries.get(key);
15750
- if (existing && now - existing.fetchedAt < cache.ttlMs) {
15751
- return existing.params;
15785
+ writeTag(fieldNumber, wireType) {
15786
+ return this.writeVarint(fieldNumber << 3 | wireType);
15787
+ }
15788
+ writeString(fieldNumber, value) {
15789
+ if (!value) return this;
15790
+ this.writeTag(fieldNumber, WIRE_LENGTH_DELIMITED);
15791
+ const bytes = new TextEncoder().encode(value);
15792
+ this.writeVarint(bytes.length);
15793
+ this.chunks.push(bytes);
15794
+ return this;
15795
+ }
15796
+ writeBool(fieldNumber, value) {
15797
+ if (!value) return this;
15798
+ this.writeTag(fieldNumber, WIRE_VARINT);
15799
+ this.writeVarint(value ? 1 : 0);
15800
+ return this;
15801
+ }
15802
+ writeUint64(fieldNumber, value) {
15803
+ const v = BigInt(value);
15804
+ if (v === 0n) return this;
15805
+ this.writeTag(fieldNumber, WIRE_VARINT);
15806
+ this.writeVarint(v);
15807
+ return this;
15808
+ }
15809
+ writeInt32(fieldNumber, value) {
15810
+ if (value === 0) return this;
15811
+ this.writeTag(fieldNumber, WIRE_VARINT);
15812
+ this.writeVarint(value);
15813
+ return this;
15814
+ }
15815
+ writeBytes(fieldNumber, value) {
15816
+ if (value.length === 0) return this;
15817
+ this.writeTag(fieldNumber, WIRE_LENGTH_DELIMITED);
15818
+ this.writeVarint(value.length);
15819
+ this.chunks.push(value);
15820
+ return this;
15821
+ }
15822
+ writeRepeatedString(fieldNumber, values) {
15823
+ for (const value of values) {
15824
+ this.writeString(fieldNumber, value);
15752
15825
  }
15826
+ return this;
15753
15827
  }
15754
- let params;
15755
- try {
15756
- params = await fetchFeeMarketParams(network, fetchFn, fetchOptions);
15757
- } catch (error) {
15758
- if (!isGatewayUnsupportedError(error)) throw error;
15759
- params = null;
15828
+ writeRepeatedUint64(fieldNumber, values) {
15829
+ for (const value of values) {
15830
+ this.writeTag(fieldNumber, WIRE_VARINT);
15831
+ this.writeVarint(BigInt(value));
15832
+ }
15833
+ return this;
15760
15834
  }
15761
- if (cache) {
15762
- cache.entries.set(key, { params, fetchedAt: now });
15835
+ writeRepeatedBytes(fieldNumber, values) {
15836
+ for (const value of values) {
15837
+ this.writeBytes(fieldNumber, value);
15838
+ }
15839
+ return this;
15763
15840
  }
15764
- return params;
15841
+ finish() {
15842
+ const total = this.chunks.reduce((sum, chunk) => sum + chunk.length, 0);
15843
+ const result = new Uint8Array(total);
15844
+ let offset = 0;
15845
+ for (const chunk of this.chunks) {
15846
+ result.set(chunk, offset);
15847
+ offset += chunk.length;
15848
+ }
15849
+ return result;
15850
+ }
15851
+ };
15852
+ function encodeAny(typeUrl, value) {
15853
+ const writer = new BinaryWriter35();
15854
+ writer.writeString(1, typeUrl);
15855
+ writer.writeBytes(2, value);
15856
+ return writer.finish();
15765
15857
  }
15766
- function isGatewayUnsupportedError(error) {
15767
- return error instanceof ApiError && (error.status === 404 || error.status === 501);
15858
+ function encodeCoin(denom, amount) {
15859
+ const writer = new BinaryWriter35();
15860
+ writer.writeString(1, denom);
15861
+ writer.writeString(2, amount);
15862
+ return writer.finish();
15768
15863
  }
15769
- function computeEvmFeesPerGas(params, options) {
15770
- const margin = marginFactorScaled(options?.marginPercent ?? DEFAULT_FEE_MARGIN_PERCENT);
15771
- const minGasPriceI = BigInt(cosmosDecToProtoInt(params.minGasPrice || "0"));
15772
- const baseFeeI = params.noBaseFee ? 0n : BigInt(cosmosDecToProtoInt(params.baseFee || "0"));
15773
- const effectiveI = baseFeeI > minGasPriceI ? baseFeeI : minGasPriceI;
15774
- if (effectiveI <= 0n) {
15775
- return { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n };
15864
+ function encodeFee(fee) {
15865
+ const writer = new BinaryWriter35();
15866
+ for (const coin of fee.amount) {
15867
+ const coinBytes = encodeCoin(coin.denom, coin.amount);
15868
+ writer.writeBytes(1, coinBytes);
15776
15869
  }
15777
- const numerator = effectiveI * margin;
15778
- const denominator = ONE_E18 * 100n;
15779
- const gasPriceWei = (numerator + denominator - 1n) / denominator;
15780
- return { maxFeePerGas: gasPriceWei, maxPriorityFeePerGas: gasPriceWei };
15870
+ writer.writeUint64(2, fee.gasLimit);
15871
+ return writer.finish();
15781
15872
  }
15782
- async function resolveEvmFeesPerGas(network, options) {
15783
- const params = await getCachedFeeMarketParams(
15784
- options?.cache,
15785
- network,
15786
- options?.fetchFn,
15787
- options?.fetchOptions
15788
- );
15789
- if (!params) return null;
15790
- let fees;
15791
- try {
15792
- fees = computeEvmFeesPerGas(params, { marginPercent: options?.marginPercent });
15793
- } catch {
15794
- return null;
15795
- }
15796
- if (fees.maxFeePerGas === 0n && fees.maxPriorityFeePerGas === 0n) return null;
15797
- return fees;
15873
+ function encodeModeInfoSingle(mode) {
15874
+ const writer = new BinaryWriter35();
15875
+ writer.writeInt32(1, mode);
15876
+ return writer.finish();
15798
15877
  }
15799
-
15800
- // src/eip712/signers.ts
15801
- var import_accounts = require("viem/accounts");
15802
- var AULT_SIGNER_MARKER = /* @__PURE__ */ Symbol.for("ault-sdk:signer");
15803
- function isAultSigner(obj) {
15804
- return typeof obj === "object" && obj !== null && AULT_SIGNER_MARKER in obj && obj[AULT_SIGNER_MARKER] === true;
15878
+ function encodeModeInfo(mode) {
15879
+ const writer = new BinaryWriter35();
15880
+ const singleBytes = encodeModeInfoSingle(mode);
15881
+ writer.writeBytes(1, singleBytes);
15882
+ return writer.finish();
15805
15883
  }
15806
- function normalizeSigner(input) {
15807
- if (!input) return null;
15808
- if (typeof input === "function") {
15809
- return { signTypedData: input };
15810
- }
15811
- if (typeof input === "object" && typeof input.signTypedData === "function") {
15812
- return input;
15884
+ function encodeSignerInfo(info) {
15885
+ const writer = new BinaryWriter35();
15886
+ const pubKeyAny = encodeAny(info.publicKey.typeUrl, info.publicKey.value);
15887
+ writer.writeBytes(1, pubKeyAny);
15888
+ const modeInfoBytes = encodeModeInfo(info.mode);
15889
+ writer.writeBytes(2, modeInfoBytes);
15890
+ writer.writeUint64(3, typeof info.sequence === "string" ? BigInt(info.sequence) : info.sequence);
15891
+ return writer.finish();
15892
+ }
15893
+ function encodeAuthInfo(authInfo) {
15894
+ const writer = new BinaryWriter35();
15895
+ for (const signerInfo of authInfo.signerInfos) {
15896
+ writer.writeBytes(1, encodeSignerInfo(signerInfo));
15813
15897
  }
15814
- throw new Error("Invalid signer: expected a signer object or signTypedData function.");
15898
+ writer.writeBytes(2, encodeFee(authInfo.fee));
15899
+ return writer.finish();
15815
15900
  }
15816
- function normalizeSignature(result) {
15817
- if (typeof result === "string") {
15818
- return result;
15901
+ function encodeTxBody(body) {
15902
+ const writer = new BinaryWriter35();
15903
+ for (const msg2 of body.messages) {
15904
+ writer.writeBytes(1, encodeAny(msg2.typeUrl, msg2.value));
15819
15905
  }
15820
- if (result && typeof result.signature === "string") {
15821
- return result.signature;
15906
+ if (body.memo) {
15907
+ writer.writeString(2, body.memo);
15822
15908
  }
15823
- throw new Error("Invalid signature response: expected hex string or { signature }.");
15824
- }
15825
- async function getSignerAddress(signer) {
15826
- if (typeof signer.address === "string") {
15827
- return signer.address;
15909
+ if (body.timeoutHeight) {
15910
+ writer.writeUint64(3, body.timeoutHeight);
15828
15911
  }
15829
- if (typeof signer.getAddress === "function") {
15830
- const address = await signer.getAddress();
15831
- return typeof address === "string" ? address : null;
15832
- }
15833
- return null;
15834
- }
15835
- async function resolveSignerAddress(signer, signerAddress) {
15836
- const raw = signerAddress ?? (signer ? await getSignerAddress(signer) : null);
15837
- if (!raw) {
15838
- throw new Error("signerAddress is required when the signer has no address.");
15839
- }
15840
- if (isValidAultAddress(raw)) {
15841
- return raw;
15842
- }
15843
- if (isValidEvmAddress(raw)) {
15844
- return evmToAult(raw);
15845
- }
15846
- throw new Error(`Invalid signerAddress: ${raw}`);
15847
- }
15848
- function stripEip712Domain(types) {
15849
- const { EIP712Domain: _removed, ...rest } = types;
15850
- return rest;
15851
- }
15852
- function createEip1193Signer(options) {
15853
- const method = options.method ?? "eth_signTypedData_v4";
15854
- return {
15855
- [AULT_SIGNER_MARKER]: true,
15856
- address: options.address,
15857
- signTypedData: async (typedData) => {
15858
- const payload = method === "eth_signTypedData_v4" ? JSON.stringify(typedData) : typedData;
15859
- const signature = await options.provider.request({
15860
- method,
15861
- params: [options.address, payload]
15862
- });
15863
- if (typeof signature !== "string") {
15864
- throw new Error("Provider did not return a signature string.");
15865
- }
15866
- return { signature };
15867
- }
15868
- };
15869
- }
15870
- function createViemSigner(wallet, options) {
15871
- const preferRpc = options?.preferRpc ?? true;
15872
- const getAddress3 = async () => {
15873
- if (wallet.address) return wallet.address;
15874
- if (wallet.getAddresses) {
15875
- const addresses = await wallet.getAddresses();
15876
- if (addresses?.length) return addresses[0];
15877
- }
15878
- return void 0;
15879
- };
15880
- return {
15881
- [AULT_SIGNER_MARKER]: true,
15882
- getAddress: async () => {
15883
- const addr = await getAddress3();
15884
- if (!addr) throw new Error("Viem wallet has no address");
15885
- return addr;
15886
- },
15887
- signTypedData: async (typedData) => {
15888
- if (preferRpc && wallet.request) {
15889
- const address = await getAddress3();
15890
- if (!address) {
15891
- throw new Error("Viem wallet has no address; pass signerAddress explicitly.");
15892
- }
15893
- const signature2 = await wallet.request({
15894
- method: "eth_signTypedData_v4",
15895
- params: [address, JSON.stringify(typedData)]
15896
- });
15897
- if (typeof signature2 !== "string") {
15898
- throw new Error("RPC signer did not return a signature string.");
15899
- }
15900
- return { signature: signature2 };
15901
- }
15902
- if (!wallet.signTypedData) {
15903
- throw new Error("Viem signer does not support signTypedData.");
15904
- }
15905
- const signature = await wallet.signTypedData({
15906
- domain: typedData.domain,
15907
- types: typedData.types,
15908
- primaryType: typedData.primaryType,
15909
- message: typedData.message
15910
- });
15911
- return { signature };
15912
- }
15913
- };
15914
- }
15915
- function createEthersSigner(signer) {
15916
- const sign = signer.signTypedData ?? signer._signTypedData;
15917
- if (!sign) {
15918
- throw new Error("Ethers signer must implement signTypedData or _signTypedData.");
15919
- }
15920
- return {
15921
- [AULT_SIGNER_MARKER]: true,
15922
- getAddress: () => signer.getAddress(),
15923
- signTypedData: async (typedData) => {
15924
- const types = stripEip712Domain(typedData.types);
15925
- const signature = await sign(typedData.domain, types, typedData.message);
15926
- return { signature };
15927
- }
15928
- };
15929
- }
15930
- function createPrivySigner(options) {
15931
- return {
15932
- [AULT_SIGNER_MARKER]: true,
15933
- address: options.address,
15934
- signTypedData: (typedData) => options.signTypedData(typedData, options.address ? { address: options.address } : void 0)
15935
- };
15936
- }
15937
- function createPrivateKeySigner(privateKey) {
15938
- const normalized = privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`;
15939
- const account = (0, import_accounts.privateKeyToAccount)(normalized);
15940
- return createViemSigner(account);
15941
- }
15942
-
15943
- // src/utils/tx-hash.ts
15944
- function normalizeTxHash(raw) {
15945
- if (!raw) return raw;
15946
- const stripped = raw.startsWith("0x") || raw.startsWith("0X") ? raw.slice(2) : raw;
15947
- return stripped.toLowerCase();
15912
+ return writer.finish();
15948
15913
  }
15949
-
15950
- // src/proto/tx-encode.ts
15951
- var WIRE_VARINT = 0;
15952
- var WIRE_LENGTH_DELIMITED = 2;
15953
- var BinaryWriter35 = class {
15954
- constructor() {
15955
- this.chunks = [];
15956
- }
15957
- writeVarint(value) {
15958
- let v = BigInt(value);
15959
- const bytes = [];
15960
- do {
15961
- let byte = Number(v & 0x7fn);
15962
- v >>= 7n;
15963
- if (v > 0n) byte |= 128;
15964
- bytes.push(byte);
15965
- } while (v > 0n);
15966
- this.chunks.push(new Uint8Array(bytes));
15967
- return this;
15968
- }
15969
- writeTag(fieldNumber, wireType) {
15970
- return this.writeVarint(fieldNumber << 3 | wireType);
15971
- }
15972
- writeString(fieldNumber, value) {
15973
- if (!value) return this;
15974
- this.writeTag(fieldNumber, WIRE_LENGTH_DELIMITED);
15975
- const bytes = new TextEncoder().encode(value);
15976
- this.writeVarint(bytes.length);
15977
- this.chunks.push(bytes);
15978
- return this;
15979
- }
15980
- writeBool(fieldNumber, value) {
15981
- if (!value) return this;
15982
- this.writeTag(fieldNumber, WIRE_VARINT);
15983
- this.writeVarint(value ? 1 : 0);
15984
- return this;
15985
- }
15986
- writeUint64(fieldNumber, value) {
15987
- const v = BigInt(value);
15988
- if (v === 0n) return this;
15989
- this.writeTag(fieldNumber, WIRE_VARINT);
15990
- this.writeVarint(v);
15991
- return this;
15992
- }
15993
- writeInt32(fieldNumber, value) {
15994
- if (value === 0) return this;
15995
- this.writeTag(fieldNumber, WIRE_VARINT);
15996
- this.writeVarint(value);
15997
- return this;
15998
- }
15999
- writeBytes(fieldNumber, value) {
16000
- if (value.length === 0) return this;
16001
- this.writeTag(fieldNumber, WIRE_LENGTH_DELIMITED);
16002
- this.writeVarint(value.length);
16003
- this.chunks.push(value);
16004
- return this;
16005
- }
16006
- writeRepeatedString(fieldNumber, values) {
16007
- for (const value of values) {
16008
- this.writeString(fieldNumber, value);
16009
- }
16010
- return this;
16011
- }
16012
- writeRepeatedUint64(fieldNumber, values) {
16013
- for (const value of values) {
16014
- this.writeTag(fieldNumber, WIRE_VARINT);
16015
- this.writeVarint(BigInt(value));
16016
- }
16017
- return this;
16018
- }
16019
- writeRepeatedBytes(fieldNumber, values) {
16020
- for (const value of values) {
16021
- this.writeBytes(fieldNumber, value);
16022
- }
16023
- return this;
16024
- }
16025
- finish() {
16026
- const total = this.chunks.reduce((sum, chunk) => sum + chunk.length, 0);
16027
- const result = new Uint8Array(total);
16028
- let offset = 0;
16029
- for (const chunk of this.chunks) {
16030
- result.set(chunk, offset);
16031
- offset += chunk.length;
16032
- }
16033
- return result;
16034
- }
16035
- };
16036
- function encodeAny(typeUrl, value) {
15914
+ function encodeTxRaw(txRaw) {
16037
15915
  const writer = new BinaryWriter35();
16038
- writer.writeString(1, typeUrl);
16039
- writer.writeBytes(2, value);
15916
+ writer.writeBytes(1, txRaw.bodyBytes);
15917
+ writer.writeBytes(2, txRaw.authInfoBytes);
15918
+ writer.writeRepeatedBytes(3, txRaw.signatures);
16040
15919
  return writer.finish();
16041
15920
  }
16042
- function encodeCoin(denom, amount) {
15921
+ function encodeEthSecp256k1PubKey(key) {
16043
15922
  const writer = new BinaryWriter35();
16044
- writer.writeString(1, denom);
16045
- writer.writeString(2, amount);
15923
+ writer.writeBytes(1, key);
16046
15924
  return writer.finish();
16047
15925
  }
16048
- function encodeFee(fee) {
15926
+ var SIGN_MODE_LEGACY_AMINO_JSON = 127;
15927
+ var SIGN_MODE_DIRECT = 1;
15928
+ function encodeTimestamp(seconds, nanos) {
16049
15929
  const writer = new BinaryWriter35();
16050
- for (const coin of fee.amount) {
16051
- const coinBytes = encodeCoin(coin.denom, coin.amount);
16052
- writer.writeBytes(1, coinBytes);
16053
- }
16054
- writer.writeUint64(2, fee.gasLimit);
15930
+ writer.writeUint64(1, seconds);
15931
+ writer.writeInt32(2, nanos);
16055
15932
  return writer.finish();
16056
15933
  }
16057
- function encodeModeInfoSingle(mode) {
15934
+ function encodeTxBodyAgent(body) {
16058
15935
  const writer = new BinaryWriter35();
16059
- writer.writeInt32(1, mode);
15936
+ for (const msg2 of body.messages) {
15937
+ writer.writeBytes(1, encodeAny(msg2.typeUrl, msg2.value));
15938
+ }
15939
+ if (body.memo) {
15940
+ writer.writeString(2, body.memo);
15941
+ }
15942
+ if (body.timeoutHeight) {
15943
+ writer.writeUint64(3, body.timeoutHeight);
15944
+ }
15945
+ writer.writeBool(4, body.unordered);
15946
+ const tsBytes = encodeTimestamp(body.timeoutTimestamp.seconds, body.timeoutTimestamp.nanos);
15947
+ writer.writeBytes(5, tsBytes);
15948
+ for (const opt of body.extensionOptions) {
15949
+ writer.writeBytes(1023, encodeAny(opt.typeUrl, opt.value));
15950
+ }
16060
15951
  return writer.finish();
16061
15952
  }
16062
- function encodeModeInfo(mode) {
15953
+ function encodeSignDoc(doc) {
16063
15954
  const writer = new BinaryWriter35();
16064
- const singleBytes = encodeModeInfoSingle(mode);
16065
- writer.writeBytes(1, singleBytes);
16066
- return writer.finish();
16067
- }
16068
- function encodeSignerInfo(info) {
16069
- const writer = new BinaryWriter35();
16070
- const pubKeyAny = encodeAny(info.publicKey.typeUrl, info.publicKey.value);
16071
- writer.writeBytes(1, pubKeyAny);
16072
- const modeInfoBytes = encodeModeInfo(info.mode);
16073
- writer.writeBytes(2, modeInfoBytes);
16074
- writer.writeUint64(3, typeof info.sequence === "string" ? BigInt(info.sequence) : info.sequence);
16075
- return writer.finish();
16076
- }
16077
- function encodeAuthInfo(authInfo) {
16078
- const writer = new BinaryWriter35();
16079
- for (const signerInfo of authInfo.signerInfos) {
16080
- writer.writeBytes(1, encodeSignerInfo(signerInfo));
16081
- }
16082
- writer.writeBytes(2, encodeFee(authInfo.fee));
16083
- return writer.finish();
16084
- }
16085
- function encodeTxBody(body) {
16086
- const writer = new BinaryWriter35();
16087
- for (const msg2 of body.messages) {
16088
- writer.writeBytes(1, encodeAny(msg2.typeUrl, msg2.value));
16089
- }
16090
- if (body.memo) {
16091
- writer.writeString(2, body.memo);
16092
- }
16093
- if (body.timeoutHeight) {
16094
- writer.writeUint64(3, body.timeoutHeight);
16095
- }
16096
- return writer.finish();
16097
- }
16098
- function encodeTxRaw(txRaw) {
16099
- const writer = new BinaryWriter35();
16100
- writer.writeBytes(1, txRaw.bodyBytes);
16101
- writer.writeBytes(2, txRaw.authInfoBytes);
16102
- writer.writeRepeatedBytes(3, txRaw.signatures);
16103
- return writer.finish();
16104
- }
16105
- function encodeEthSecp256k1PubKey(key) {
16106
- const writer = new BinaryWriter35();
16107
- writer.writeBytes(1, key);
16108
- return writer.finish();
16109
- }
16110
- var SIGN_MODE_LEGACY_AMINO_JSON = 127;
16111
- var SIGN_MODE_DIRECT = 1;
16112
- function encodeTimestamp(seconds, nanos) {
16113
- const writer = new BinaryWriter35();
16114
- writer.writeUint64(1, seconds);
16115
- writer.writeInt32(2, nanos);
16116
- return writer.finish();
16117
- }
16118
- function encodeTxBodyAgent(body) {
16119
- const writer = new BinaryWriter35();
16120
- for (const msg2 of body.messages) {
16121
- writer.writeBytes(1, encodeAny(msg2.typeUrl, msg2.value));
16122
- }
16123
- if (body.memo) {
16124
- writer.writeString(2, body.memo);
16125
- }
16126
- if (body.timeoutHeight) {
16127
- writer.writeUint64(3, body.timeoutHeight);
16128
- }
16129
- writer.writeBool(4, body.unordered);
16130
- const tsBytes = encodeTimestamp(body.timeoutTimestamp.seconds, body.timeoutTimestamp.nanos);
16131
- writer.writeBytes(5, tsBytes);
16132
- for (const opt of body.extensionOptions) {
16133
- writer.writeBytes(1023, encodeAny(opt.typeUrl, opt.value));
16134
- }
16135
- return writer.finish();
16136
- }
16137
- function encodeSignDoc(doc) {
16138
- const writer = new BinaryWriter35();
16139
- writer.writeBytes(1, doc.bodyBytes);
16140
- writer.writeBytes(2, doc.authInfoBytes);
16141
- writer.writeString(3, doc.chainId);
16142
- writer.writeUint64(4, doc.accountNumber);
15955
+ writer.writeBytes(1, doc.bodyBytes);
15956
+ writer.writeBytes(2, doc.authInfoBytes);
15957
+ writer.writeString(3, doc.chainId);
15958
+ writer.writeUint64(4, doc.accountNumber);
16143
15959
  return writer.finish();
16144
15960
  }
16145
15961
 
@@ -24502,338 +24318,709 @@ function mapAultTokenregistryV1Limiter(input, label = "value") {
24502
24318
  )
24503
24319
  };
24504
24320
  }
24505
- function mapAultTokenregistryV1MsgDisableTokenPair(input, label = "value") {
24506
- const record2 = asRecord(input);
24507
- const prefix = label ? `${label}.` : "";
24508
- return {
24509
- sender: requireString(record2["sender"], `${prefix}sender`),
24510
- erc20Address: requireString(record2["erc20Address"], `${prefix}erc20Address`)
24511
- };
24321
+ function mapAultTokenregistryV1MsgDisableTokenPair(input, label = "value") {
24322
+ const record2 = asRecord(input);
24323
+ const prefix = label ? `${label}.` : "";
24324
+ return {
24325
+ sender: requireString(record2["sender"], `${prefix}sender`),
24326
+ erc20Address: requireString(record2["erc20Address"], `${prefix}erc20Address`)
24327
+ };
24328
+ }
24329
+ function mapAultTokenregistryV1MsgDisableTransfers(input, label = "value") {
24330
+ const record2 = asRecord(input);
24331
+ const prefix = label ? `${label}.` : "";
24332
+ return {
24333
+ sender: requireString(record2["sender"], `${prefix}sender`)
24334
+ };
24335
+ }
24336
+ function mapAultTokenregistryV1MsgEnableTokenPair(input, label = "value") {
24337
+ const record2 = asRecord(input);
24338
+ const prefix = label ? `${label}.` : "";
24339
+ return {
24340
+ sender: requireString(record2["sender"], `${prefix}sender`),
24341
+ erc20Address: requireString(record2["erc20Address"], `${prefix}erc20Address`)
24342
+ };
24343
+ }
24344
+ function mapAultTokenregistryV1MsgEnableTransfers(input, label = "value") {
24345
+ const record2 = asRecord(input);
24346
+ const prefix = label ? `${label}.` : "";
24347
+ return {
24348
+ sender: requireString(record2["sender"], `${prefix}sender`)
24349
+ };
24350
+ }
24351
+ function mapAultTokenregistryV1MsgRegisterTokenPair(input, label = "value") {
24352
+ const record2 = asRecord(input);
24353
+ const prefix = label ? `${label}.` : "";
24354
+ return {
24355
+ sender: requireString(record2["sender"], `${prefix}sender`),
24356
+ erc20Address: requireString(record2["erc20Address"], `${prefix}erc20Address`),
24357
+ enabled: requireBool(record2["enabled"], `${prefix}enabled`),
24358
+ ...record2["transferLimit"] != null && {
24359
+ transferLimit: mapAultTokenregistryV1TransferLimitConfig(
24360
+ asRecord(record2["transferLimit"]),
24361
+ `${prefix}transferLimit`
24362
+ )
24363
+ }
24364
+ };
24365
+ }
24366
+ function mapAultTokenregistryV1MsgRemoveTransferLimit(input, label = "value") {
24367
+ const record2 = asRecord(input);
24368
+ const prefix = label ? `${label}.` : "";
24369
+ return {
24370
+ sender: requireString(record2["sender"], `${prefix}sender`),
24371
+ erc20Address: requireString(record2["erc20Address"], `${prefix}erc20Address`)
24372
+ };
24373
+ }
24374
+ function mapAultTokenregistryV1MsgSetTransferLimit(input, label = "value") {
24375
+ const record2 = asRecord(input);
24376
+ const prefix = label ? `${label}.` : "";
24377
+ return {
24378
+ sender: requireString(record2["sender"], `${prefix}sender`),
24379
+ erc20Address: requireString(record2["erc20Address"], `${prefix}erc20Address`),
24380
+ transferLimit: mapAultTokenregistryV1TransferLimitConfig(
24381
+ asRecord(record2["transferLimit"]),
24382
+ `${prefix}transferLimit`
24383
+ )
24384
+ };
24385
+ }
24386
+ function mapAultTokenregistryV1TransferLimitConfig(input, label = "value") {
24387
+ const record2 = asRecord(input);
24388
+ const prefix = label ? `${label}.` : "";
24389
+ return {
24390
+ hourly: mapAultTokenregistryV1Limiter(asRecord(record2["hourly"]), `${prefix}hourly`),
24391
+ daily: mapAultTokenregistryV1Limiter(asRecord(record2["daily"]), `${prefix}daily`)
24392
+ };
24393
+ }
24394
+ function mapCosmosBaseV1beta1Coin(input, label = "value") {
24395
+ const record2 = asRecord(input);
24396
+ const prefix = label ? `${label}.` : "";
24397
+ return {
24398
+ denom: requireString(record2["denom"], `${prefix}denom`),
24399
+ amount: requireString(record2["amount"], `${prefix}amount`)
24400
+ };
24401
+ }
24402
+ function mapCosmosDistributionV1beta1MsgWithdrawDelegatorReward(input, label = "value") {
24403
+ const record2 = asRecord(input);
24404
+ const prefix = label ? `${label}.` : "";
24405
+ return {
24406
+ delegatorAddress: requireString(record2["delegatorAddress"], `${prefix}delegatorAddress`),
24407
+ validatorAddress: requireString(record2["validatorAddress"], `${prefix}validatorAddress`)
24408
+ };
24409
+ }
24410
+ function mapCosmosStakingV1beta1MsgBeginRedelegate(input, label = "value") {
24411
+ const record2 = asRecord(input);
24412
+ const prefix = label ? `${label}.` : "";
24413
+ return {
24414
+ delegatorAddress: requireString(record2["delegatorAddress"], `${prefix}delegatorAddress`),
24415
+ validatorSrcAddress: requireString(
24416
+ record2["validatorSrcAddress"],
24417
+ `${prefix}validatorSrcAddress`
24418
+ ),
24419
+ validatorDstAddress: requireString(
24420
+ record2["validatorDstAddress"],
24421
+ `${prefix}validatorDstAddress`
24422
+ ),
24423
+ amount: mapCosmosBaseV1beta1Coin(asRecord(record2["amount"]), `${prefix}amount`)
24424
+ };
24425
+ }
24426
+ function mapCosmosStakingV1beta1MsgDelegate(input, label = "value") {
24427
+ const record2 = asRecord(input);
24428
+ const prefix = label ? `${label}.` : "";
24429
+ return {
24430
+ delegatorAddress: requireString(record2["delegatorAddress"], `${prefix}delegatorAddress`),
24431
+ validatorAddress: requireString(record2["validatorAddress"], `${prefix}validatorAddress`),
24432
+ amount: mapCosmosBaseV1beta1Coin(asRecord(record2["amount"]), `${prefix}amount`)
24433
+ };
24434
+ }
24435
+ function mapCosmosStakingV1beta1MsgUndelegate(input, label = "value") {
24436
+ const record2 = asRecord(input);
24437
+ const prefix = label ? `${label}.` : "";
24438
+ return {
24439
+ delegatorAddress: requireString(record2["delegatorAddress"], `${prefix}delegatorAddress`),
24440
+ validatorAddress: requireString(record2["validatorAddress"], `${prefix}validatorAddress`),
24441
+ amount: mapCosmosBaseV1beta1Coin(asRecord(record2["amount"]), `${prefix}amount`)
24442
+ };
24443
+ }
24444
+ function mapGoogleProtobufAny(input, label = "value") {
24445
+ const record2 = asRecord(input);
24446
+ const prefix = label ? `${label}.` : "";
24447
+ return {
24448
+ typeUrl: requireString(record2["typeUrl"], `${prefix}typeUrl`),
24449
+ value: requireBytes(record2["value"], `${prefix}value`)
24450
+ };
24451
+ }
24452
+ var MSG_ENCODERS = {
24453
+ "/ault.accountx.v1.MsgOpenAccount": (value) => MsgOpenAccount.encode(
24454
+ MsgOpenAccount.fromPartial(mapAultAccountxV1MsgOpenAccount(value))
24455
+ ).finish(),
24456
+ "/ault.accountx.v1.MsgUpdateFeeTiers": (value) => MsgUpdateFeeTiers.encode(
24457
+ MsgUpdateFeeTiers.fromPartial(mapAultAccountxV1MsgUpdateFeeTiers(value))
24458
+ ).finish(),
24459
+ "/ault.accountx.v1.MsgUpdateParams": (value) => MsgUpdateParams.encode(
24460
+ MsgUpdateParams.fromPartial(mapAultAccountxV1MsgUpdateParams(value))
24461
+ ).finish(),
24462
+ "/ault.accountx.v1.MsgUpdateTradingTiers": (value) => MsgUpdateTradingTiers.encode(
24463
+ MsgUpdateTradingTiers.fromPartial(mapAultAccountxV1MsgUpdateTradingTiers(value))
24464
+ ).finish(),
24465
+ "/ault.agent.v1.MsgApproveAgent": (value) => MsgApproveAgent.encode(
24466
+ MsgApproveAgent.fromPartial(mapAultAgentV1MsgApproveAgent(value))
24467
+ ).finish(),
24468
+ "/ault.agent.v1.MsgRevokeAgent": (value) => MsgRevokeAgent.encode(MsgRevokeAgent.fromPartial(mapAultAgentV1MsgRevokeAgent(value))).finish(),
24469
+ "/ault.agent.v1.MsgUpdateParams": (value) => MsgUpdateParams2.encode(
24470
+ MsgUpdateParams2.fromPartial(mapAultAgentV1MsgUpdateParams(value))
24471
+ ).finish(),
24472
+ "/ault.authority.v1.MsgGrantRole": (value) => MsgGrantRole.encode(MsgGrantRole.fromPartial(mapAultAuthorityV1MsgGrantRole(value))).finish(),
24473
+ "/ault.authority.v1.MsgRevokeRole": (value) => MsgRevokeRole.encode(
24474
+ MsgRevokeRole.fromPartial(mapAultAuthorityV1MsgRevokeRole(value))
24475
+ ).finish(),
24476
+ "/ault.clob.v1.MsgCancelOrders": (value) => MsgCancelOrders.encode(
24477
+ MsgCancelOrders.fromPartial(mapAultClobV1MsgCancelOrders(value))
24478
+ ).finish(),
24479
+ "/ault.clob.v1.MsgModifyOrders": (value) => MsgModifyOrders.encode(
24480
+ MsgModifyOrders.fromPartial(mapAultClobV1MsgModifyOrders(value))
24481
+ ).finish(),
24482
+ "/ault.clob.v1.MsgPlaceLimitOrder": (value) => MsgPlaceLimitOrder.encode(
24483
+ MsgPlaceLimitOrder.fromPartial(mapAultClobV1MsgPlaceLimitOrder(value))
24484
+ ).finish(),
24485
+ "/ault.clob.v1.MsgPlaceMarketOrder": (value) => MsgPlaceMarketOrder.encode(
24486
+ MsgPlaceMarketOrder.fromPartial(mapAultClobV1MsgPlaceMarketOrder(value))
24487
+ ).finish(),
24488
+ "/ault.clob.v1.MsgPlaceScaleOrder": (value) => MsgPlaceScaleOrder.encode(
24489
+ MsgPlaceScaleOrder.fromPartial(mapAultClobV1MsgPlaceScaleOrder(value))
24490
+ ).finish(),
24491
+ "/ault.clob.v1.MsgPlaceTwapOrder": (value) => MsgPlaceTwapOrder.encode(
24492
+ MsgPlaceTwapOrder.fromPartial(mapAultClobV1MsgPlaceTwapOrder(value))
24493
+ ).finish(),
24494
+ "/ault.clob.v1.MsgUpdateParams": (value) => MsgUpdateParams3.encode(
24495
+ MsgUpdateParams3.fromPartial(mapAultClobV1MsgUpdateParams(value))
24496
+ ).finish(),
24497
+ "/ault.license.v1.MsgApproveMember": (value) => MsgApproveMember.encode(
24498
+ MsgApproveMember.fromPartial(mapAultLicenseV1MsgApproveMember(value))
24499
+ ).finish(),
24500
+ "/ault.license.v1.MsgBatchApproveMember": (value) => MsgBatchApproveMember.encode(
24501
+ MsgBatchApproveMember.fromPartial(mapAultLicenseV1MsgBatchApproveMember(value))
24502
+ ).finish(),
24503
+ "/ault.license.v1.MsgBatchMintLicense": (value) => MsgBatchMintLicense.encode(
24504
+ MsgBatchMintLicense.fromPartial(mapAultLicenseV1MsgBatchMintLicense(value))
24505
+ ).finish(),
24506
+ "/ault.license.v1.MsgBatchRevokeMember": (value) => MsgBatchRevokeMember.encode(
24507
+ MsgBatchRevokeMember.fromPartial(mapAultLicenseV1MsgBatchRevokeMember(value))
24508
+ ).finish(),
24509
+ "/ault.license.v1.MsgBurnLicense": (value) => MsgBurnLicense.encode(
24510
+ MsgBurnLicense.fromPartial(mapAultLicenseV1MsgBurnLicense(value))
24511
+ ).finish(),
24512
+ "/ault.license.v1.MsgMintLicense": (value) => MsgMintLicense.encode(
24513
+ MsgMintLicense.fromPartial(mapAultLicenseV1MsgMintLicense(value))
24514
+ ).finish(),
24515
+ "/ault.license.v1.MsgRevokeLicense": (value) => MsgRevokeLicense.encode(
24516
+ MsgRevokeLicense.fromPartial(mapAultLicenseV1MsgRevokeLicense(value))
24517
+ ).finish(),
24518
+ "/ault.license.v1.MsgRevokeMember": (value) => MsgRevokeMember.encode(
24519
+ MsgRevokeMember.fromPartial(mapAultLicenseV1MsgRevokeMember(value))
24520
+ ).finish(),
24521
+ "/ault.license.v1.MsgSetKYCApprovers": (value) => MsgSetKYCApprovers.encode(
24522
+ MsgSetKYCApprovers.fromPartial(mapAultLicenseV1MsgSetKYCApprovers(value))
24523
+ ).finish(),
24524
+ "/ault.license.v1.MsgSetMinters": (value) => MsgSetMinters.encode(MsgSetMinters.fromPartial(mapAultLicenseV1MsgSetMinters(value))).finish(),
24525
+ "/ault.license.v1.MsgSetTokenURI": (value) => MsgSetTokenURI.encode(
24526
+ MsgSetTokenURI.fromPartial(mapAultLicenseV1MsgSetTokenURI(value))
24527
+ ).finish(),
24528
+ "/ault.license.v1.MsgTransferLicense": (value) => MsgTransferLicense.encode(
24529
+ MsgTransferLicense.fromPartial(mapAultLicenseV1MsgTransferLicense(value))
24530
+ ).finish(),
24531
+ "/ault.license.v1.MsgUpdateParams": (value) => MsgUpdateParams4.encode(
24532
+ MsgUpdateParams4.fromPartial(mapAultLicenseV1MsgUpdateParams(value))
24533
+ ).finish(),
24534
+ "/ault.market.v1.MsgCreateMarket": (value) => MsgCreateMarket.encode(
24535
+ MsgCreateMarket.fromPartial(mapAultMarketV1MsgCreateMarket(value))
24536
+ ).finish(),
24537
+ "/ault.market.v1.MsgHaltAllMarkets": (value) => MsgHaltAllMarkets.encode(
24538
+ MsgHaltAllMarkets.fromPartial(mapAultMarketV1MsgHaltAllMarkets(value))
24539
+ ).finish(),
24540
+ "/ault.market.v1.MsgHaltMarkets": (value) => MsgHaltMarkets.encode(
24541
+ MsgHaltMarkets.fromPartial(mapAultMarketV1MsgHaltMarkets(value))
24542
+ ).finish(),
24543
+ "/ault.market.v1.MsgResumeAllMarkets": (value) => MsgResumeAllMarkets.encode(
24544
+ MsgResumeAllMarkets.fromPartial(mapAultMarketV1MsgResumeAllMarkets(value))
24545
+ ).finish(),
24546
+ "/ault.market.v1.MsgResumeMarkets": (value) => MsgResumeMarkets.encode(
24547
+ MsgResumeMarkets.fromPartial(mapAultMarketV1MsgResumeMarkets(value))
24548
+ ).finish(),
24549
+ "/ault.market.v1.MsgUpdateMarket": (value) => MsgUpdateMarket.encode(
24550
+ MsgUpdateMarket.fromPartial(mapAultMarketV1MsgUpdateMarket(value))
24551
+ ).finish(),
24552
+ "/ault.market.v1.MsgUpdateMarketDeployer": (value) => MsgUpdateMarketDeployer.encode(
24553
+ MsgUpdateMarketDeployer.fromPartial(mapAultMarketV1MsgUpdateMarketDeployer(value))
24554
+ ).finish(),
24555
+ "/ault.market.v1.MsgUpdateParams": (value) => MsgUpdateParams5.encode(
24556
+ MsgUpdateParams5.fromPartial(mapAultMarketV1MsgUpdateParams(value))
24557
+ ).finish(),
24558
+ "/ault.miner.v1.MsgBatchSubmitWork": (value) => MsgBatchSubmitWork.encode(
24559
+ MsgBatchSubmitWork.fromPartial(mapAultMinerV1MsgBatchSubmitWork(value))
24560
+ ).finish(),
24561
+ "/ault.miner.v1.MsgCancelMiningDelegation": (value) => MsgCancelMiningDelegation.encode(
24562
+ MsgCancelMiningDelegation.fromPartial(mapAultMinerV1MsgCancelMiningDelegation(value))
24563
+ ).finish(),
24564
+ "/ault.miner.v1.MsgDelegateMining": (value) => MsgDelegateMining.encode(
24565
+ MsgDelegateMining.fromPartial(mapAultMinerV1MsgDelegateMining(value))
24566
+ ).finish(),
24567
+ "/ault.miner.v1.MsgRedelegateMining": (value) => MsgRedelegateMining.encode(
24568
+ MsgRedelegateMining.fromPartial(mapAultMinerV1MsgRedelegateMining(value))
24569
+ ).finish(),
24570
+ "/ault.miner.v1.MsgRegisterOperator": (value) => MsgRegisterOperator.encode(
24571
+ MsgRegisterOperator.fromPartial(mapAultMinerV1MsgRegisterOperator(value))
24572
+ ).finish(),
24573
+ "/ault.miner.v1.MsgSetOwnerVrfKey": (value) => MsgSetOwnerVrfKey.encode(
24574
+ MsgSetOwnerVrfKey.fromPartial(mapAultMinerV1MsgSetOwnerVrfKey(value))
24575
+ ).finish(),
24576
+ "/ault.miner.v1.MsgSubmitWork": (value) => MsgSubmitWork.encode(MsgSubmitWork.fromPartial(mapAultMinerV1MsgSubmitWork(value))).finish(),
24577
+ "/ault.miner.v1.MsgUnregisterOperator": (value) => MsgUnregisterOperator.encode(
24578
+ MsgUnregisterOperator.fromPartial(mapAultMinerV1MsgUnregisterOperator(value))
24579
+ ).finish(),
24580
+ "/ault.miner.v1.MsgUpdateOperatorInfo": (value) => MsgUpdateOperatorInfo.encode(
24581
+ MsgUpdateOperatorInfo.fromPartial(mapAultMinerV1MsgUpdateOperatorInfo(value))
24582
+ ).finish(),
24583
+ "/ault.miner.v1.MsgUpdateParams": (value) => MsgUpdateParams6.encode(
24584
+ MsgUpdateParams6.fromPartial(mapAultMinerV1MsgUpdateParams(value))
24585
+ ).finish(),
24586
+ "/ault.ratelimit.v1.MsgUpdateParams": (value) => MsgUpdateParams7.encode(
24587
+ MsgUpdateParams7.fromPartial(mapAultRatelimitV1MsgUpdateParams(value))
24588
+ ).finish(),
24589
+ "/ault.reward.v1.MsgApproveBuilder": (value) => MsgApproveBuilder.encode(
24590
+ MsgApproveBuilder.fromPartial(mapAultRewardV1MsgApproveBuilder(value))
24591
+ ).finish(),
24592
+ "/ault.reward.v1.MsgRevokeBuilder": (value) => MsgRevokeBuilder.encode(
24593
+ MsgRevokeBuilder.fromPartial(mapAultRewardV1MsgRevokeBuilder(value))
24594
+ ).finish(),
24595
+ "/ault.reward.v1.MsgSetDeployerShare": (value) => MsgSetDeployerShare.encode(
24596
+ MsgSetDeployerShare.fromPartial(mapAultRewardV1MsgSetDeployerShare(value))
24597
+ ).finish(),
24598
+ "/ault.reward.v1.MsgSetReferral": (value) => MsgSetReferral.encode(
24599
+ MsgSetReferral.fromPartial(mapAultRewardV1MsgSetReferral(value))
24600
+ ).finish(),
24601
+ "/ault.reward.v1.MsgSetReferralCode": (value) => MsgSetReferralCode.encode(
24602
+ MsgSetReferralCode.fromPartial(mapAultRewardV1MsgSetReferralCode(value))
24603
+ ).finish(),
24604
+ "/ault.reward.v1.MsgUpdateEligibleReferrers": (value) => MsgUpdateEligibleReferrers.encode(
24605
+ MsgUpdateEligibleReferrers.fromPartial(mapAultRewardV1MsgUpdateEligibleReferrers(value))
24606
+ ).finish(),
24607
+ "/ault.reward.v1.MsgUpdateFeeTierDiscounts": (value) => MsgUpdateFeeTierDiscounts.encode(
24608
+ MsgUpdateFeeTierDiscounts.fromPartial(mapAultRewardV1MsgUpdateFeeTierDiscounts(value))
24609
+ ).finish(),
24610
+ "/ault.reward.v1.MsgUpdateParams": (value) => MsgUpdateParams8.encode(
24611
+ MsgUpdateParams8.fromPartial(mapAultRewardV1MsgUpdateParams(value))
24612
+ ).finish(),
24613
+ "/ault.reward.v1.MsgUpdateRefereeDiscountRate": (value) => MsgUpdateRefereeDiscountRate.encode(
24614
+ MsgUpdateRefereeDiscountRate.fromPartial(mapAultRewardV1MsgUpdateRefereeDiscountRate(value))
24615
+ ).finish(),
24616
+ "/ault.reward.v1.MsgUpdateTradingTierBenefits": (value) => MsgUpdateTradingTierBenefits.encode(
24617
+ MsgUpdateTradingTierBenefits.fromPartial(mapAultRewardV1MsgUpdateTradingTierBenefits(value))
24618
+ ).finish(),
24619
+ "/ault.tokenregistry.v1.MsgDisableTokenPair": (value) => MsgDisableTokenPair.encode(
24620
+ MsgDisableTokenPair.fromPartial(mapAultTokenregistryV1MsgDisableTokenPair(value))
24621
+ ).finish(),
24622
+ "/ault.tokenregistry.v1.MsgDisableTransfers": (value) => MsgDisableTransfers.encode(
24623
+ MsgDisableTransfers.fromPartial(mapAultTokenregistryV1MsgDisableTransfers(value))
24624
+ ).finish(),
24625
+ "/ault.tokenregistry.v1.MsgEnableTokenPair": (value) => MsgEnableTokenPair.encode(
24626
+ MsgEnableTokenPair.fromPartial(mapAultTokenregistryV1MsgEnableTokenPair(value))
24627
+ ).finish(),
24628
+ "/ault.tokenregistry.v1.MsgEnableTransfers": (value) => MsgEnableTransfers.encode(
24629
+ MsgEnableTransfers.fromPartial(mapAultTokenregistryV1MsgEnableTransfers(value))
24630
+ ).finish(),
24631
+ "/ault.tokenregistry.v1.MsgRegisterTokenPair": (value) => MsgRegisterTokenPair.encode(
24632
+ MsgRegisterTokenPair.fromPartial(mapAultTokenregistryV1MsgRegisterTokenPair(value))
24633
+ ).finish(),
24634
+ "/ault.tokenregistry.v1.MsgRemoveTransferLimit": (value) => MsgRemoveTransferLimit.encode(
24635
+ MsgRemoveTransferLimit.fromPartial(mapAultTokenregistryV1MsgRemoveTransferLimit(value))
24636
+ ).finish(),
24637
+ "/ault.tokenregistry.v1.MsgSetTransferLimit": (value) => MsgSetTransferLimit.encode(
24638
+ MsgSetTransferLimit.fromPartial(mapAultTokenregistryV1MsgSetTransferLimit(value))
24639
+ ).finish(),
24640
+ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward": (value) => MsgWithdrawDelegatorReward.encode(
24641
+ MsgWithdrawDelegatorReward.fromPartial(
24642
+ mapCosmosDistributionV1beta1MsgWithdrawDelegatorReward(value)
24643
+ )
24644
+ ).finish(),
24645
+ "/cosmos.staking.v1beta1.MsgBeginRedelegate": (value) => MsgBeginRedelegate.encode(
24646
+ MsgBeginRedelegate.fromPartial(mapCosmosStakingV1beta1MsgBeginRedelegate(value))
24647
+ ).finish(),
24648
+ "/cosmos.staking.v1beta1.MsgDelegate": (value) => MsgDelegate.encode(MsgDelegate.fromPartial(mapCosmosStakingV1beta1MsgDelegate(value))).finish(),
24649
+ "/cosmos.staking.v1beta1.MsgUndelegate": (value) => MsgUndelegate.encode(
24650
+ MsgUndelegate.fromPartial(mapCosmosStakingV1beta1MsgUndelegate(value))
24651
+ ).finish()
24652
+ };
24653
+
24654
+ // src/eip712/simulate.ts
24655
+ var SIMULATE_PATH = "/cosmos/tx/v1beta1/simulate";
24656
+ var SIMULATION_PLACEHOLDER_PUBKEY = new Uint8Array([
24657
+ 2,
24658
+ 121,
24659
+ 190,
24660
+ 102,
24661
+ 126,
24662
+ 249,
24663
+ 220,
24664
+ 187,
24665
+ 172,
24666
+ 85,
24667
+ 160,
24668
+ 98,
24669
+ 149,
24670
+ 206,
24671
+ 135,
24672
+ 11,
24673
+ 7,
24674
+ 2,
24675
+ 155,
24676
+ 252,
24677
+ 219,
24678
+ 45,
24679
+ 206,
24680
+ 40,
24681
+ 217,
24682
+ 89,
24683
+ 242,
24684
+ 129,
24685
+ 91,
24686
+ 22,
24687
+ 248,
24688
+ 23,
24689
+ 152
24690
+ ]);
24691
+ var SIMULATION_PLACEHOLDER_SIGNATURE = new Uint8Array(64);
24692
+ var CHAIN_VERDICT_STATUSES = /* @__PURE__ */ new Set([400, 500]);
24693
+ var CHAIN_VERDICT_CODES = /* @__PURE__ */ new Set([2, 3]);
24694
+ async function simulateTx({
24695
+ network,
24696
+ msgs,
24697
+ memo = "",
24698
+ sequence,
24699
+ pubkeyBase64,
24700
+ placeholderGasLimit,
24701
+ placeholderFee,
24702
+ fetchFn,
24703
+ fetchOptions
24704
+ }) {
24705
+ const encodedMessages = msgs.map((msg2) => {
24706
+ const encoder = MSG_ENCODERS[msg2.typeUrl];
24707
+ if (!encoder) {
24708
+ throw new Error(`No encoder found for message type: ${msg2.typeUrl}`);
24709
+ }
24710
+ return { typeUrl: msg2.typeUrl, value: encoder(msg2.value) };
24711
+ });
24712
+ const pubkeyBytes = pubkeyBase64 ? base64ToBytes(pubkeyBase64) : SIMULATION_PLACEHOLDER_PUBKEY;
24713
+ const txRawBytes = encodeTxRaw({
24714
+ bodyBytes: encodeTxBody({ messages: encodedMessages, memo }),
24715
+ authInfoBytes: encodeAuthInfo({
24716
+ signerInfos: [
24717
+ {
24718
+ publicKey: {
24719
+ typeUrl: "/cosmos.evm.crypto.v1.ethsecp256k1.PubKey",
24720
+ value: encodeEthSecp256k1PubKey(pubkeyBytes)
24721
+ },
24722
+ mode: SIGN_MODE_LEGACY_AMINO_JSON,
24723
+ sequence
24724
+ }
24725
+ ],
24726
+ fee: { amount: [placeholderFee], gasLimit: BigInt(placeholderGasLimit) }
24727
+ }),
24728
+ signatures: [SIMULATION_PLACEHOLDER_SIGNATURE]
24729
+ });
24730
+ const url = `${network.restUrl}${SIMULATE_PATH}`;
24731
+ let response;
24732
+ try {
24733
+ response = await postJson(
24734
+ url,
24735
+ { tx_bytes: bytesToBase64(txRawBytes) },
24736
+ {
24737
+ ...fetchOptions,
24738
+ // 500 carries the verdict; never retry it. The rest of the caller's
24739
+ // policy stays.
24740
+ retryableStatuses: (fetchOptions?.retryableStatuses ?? DEFAULT_RETRYABLE_STATUSES).filter(
24741
+ (status) => status !== 500
24742
+ )
24743
+ },
24744
+ fetchFn
24745
+ );
24746
+ } catch (error) {
24747
+ const verdict = chainVerdict(error);
24748
+ if (verdict) {
24749
+ throw new TxSimulationError(verdict);
24750
+ }
24751
+ const detail = error instanceof Error ? error.message : String(error);
24752
+ console.warn(`[ault-sdk] tx simulation unavailable (${url}); using static gas: ${detail}`);
24753
+ return null;
24754
+ }
24755
+ const gasUsed = response.gas_info?.gas_used;
24756
+ if (typeof gasUsed !== "string" || !/^\d+$/.test(gasUsed) || gasUsed === "0") {
24757
+ console.warn(`[ault-sdk] tx simulation returned no usable gas_used (${url}); using static gas`);
24758
+ return null;
24759
+ }
24760
+ return { gasUsed: BigInt(gasUsed) };
24761
+ }
24762
+ function chainVerdict(error) {
24763
+ if (!(error instanceof ApiError) || typeof error.status !== "number") return null;
24764
+ if (!CHAIN_VERDICT_STATUSES.has(error.status) || !error.response) return null;
24765
+ let body;
24766
+ try {
24767
+ body = JSON.parse(error.response);
24768
+ } catch {
24769
+ return null;
24770
+ }
24771
+ if (typeof body !== "object" || body === null) return null;
24772
+ const { code, message } = body;
24773
+ if (typeof code !== "number" || !CHAIN_VERDICT_CODES.has(code)) return null;
24774
+ if (typeof message !== "string" || message.length === 0) return null;
24775
+ return { rawLog: message, chainCode: code };
24776
+ }
24777
+
24778
+ // src/rest/feemarket.ts
24779
+ async function fetchFeeMarketParams(network, fetchFn, fetchOptions) {
24780
+ const data = await fetchJson(
24781
+ `${network.restUrl}/cosmos/evm/feemarket/v1/params`,
24782
+ {},
24783
+ fetchOptions,
24784
+ fetchFn
24785
+ );
24786
+ const raw = data.params ?? {};
24787
+ return {
24788
+ noBaseFee: raw.noBaseFee ?? raw.no_base_fee ?? false,
24789
+ baseFee: raw.baseFee ?? raw.base_fee ?? "0",
24790
+ minGasPrice: raw.minGasPrice ?? raw.min_gas_price ?? "0"
24791
+ };
24792
+ }
24793
+ var ONE_E18 = 1000000000000000000n;
24794
+ var DEFAULT_FEE_MARGIN_PERCENT = 20;
24795
+ function marginFactorScaled(marginPercent) {
24796
+ if (!Number.isFinite(marginPercent) || !Number.isInteger(marginPercent)) {
24797
+ throw new Error(`marginPercent must be a non-negative integer, got ${marginPercent}`);
24798
+ }
24799
+ if (marginPercent < 0) {
24800
+ throw new Error(`marginPercent must be >= 0, got ${marginPercent}`);
24801
+ }
24802
+ return BigInt(100 + marginPercent);
24803
+ }
24804
+ function computeRequiredFee(params, gas, options) {
24805
+ const margin = marginFactorScaled(options?.marginPercent ?? DEFAULT_FEE_MARGIN_PERCENT);
24806
+ const minGasPriceI = BigInt(cosmosDecToProtoInt(params.minGasPrice || "0"));
24807
+ const baseFeeI = params.noBaseFee ? 0n : BigInt(cosmosDecToProtoInt(params.baseFee || "0"));
24808
+ const effectiveI = baseFeeI > minGasPriceI ? baseFeeI : minGasPriceI;
24809
+ if (effectiveI <= 0n) return "0";
24810
+ const gasI = BigInt(gas);
24811
+ if (gasI <= 0n) return "0";
24812
+ const numerator = effectiveI * gasI * margin;
24813
+ const denominator = ONE_E18 * 100n;
24814
+ return ((numerator + denominator - 1n) / denominator).toString();
24815
+ }
24816
+ var DEFAULT_FEE_MARKET_TTL_MS = 3e3;
24817
+ function createFeeMarketCache(ttlMs = DEFAULT_FEE_MARKET_TTL_MS) {
24818
+ return { ttlMs, entries: /* @__PURE__ */ new Map() };
24819
+ }
24820
+ async function getCachedFeeMarketParams(cache, network, fetchFn, fetchOptions) {
24821
+ const key = network.chainId;
24822
+ const now = Date.now();
24823
+ if (cache) {
24824
+ const existing = cache.entries.get(key);
24825
+ if (existing && now - existing.fetchedAt < cache.ttlMs) {
24826
+ return existing.params;
24827
+ }
24828
+ }
24829
+ let params;
24830
+ try {
24831
+ params = await fetchFeeMarketParams(network, fetchFn, fetchOptions);
24832
+ } catch (error) {
24833
+ if (!isGatewayUnsupportedError(error)) throw error;
24834
+ params = null;
24835
+ }
24836
+ if (cache) {
24837
+ cache.entries.set(key, { params, fetchedAt: now });
24838
+ }
24839
+ return params;
24840
+ }
24841
+ function isGatewayUnsupportedError(error) {
24842
+ return error instanceof ApiError && (error.status === 404 || error.status === 501);
24843
+ }
24844
+ function computeEvmFeesPerGas(params, options) {
24845
+ const margin = marginFactorScaled(options?.marginPercent ?? DEFAULT_FEE_MARGIN_PERCENT);
24846
+ const minGasPriceI = BigInt(cosmosDecToProtoInt(params.minGasPrice || "0"));
24847
+ const baseFeeI = params.noBaseFee ? 0n : BigInt(cosmosDecToProtoInt(params.baseFee || "0"));
24848
+ const effectiveI = baseFeeI > minGasPriceI ? baseFeeI : minGasPriceI;
24849
+ if (effectiveI <= 0n) {
24850
+ return { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n };
24851
+ }
24852
+ const numerator = effectiveI * margin;
24853
+ const denominator = ONE_E18 * 100n;
24854
+ const gasPriceWei = (numerator + denominator - 1n) / denominator;
24855
+ return { maxFeePerGas: gasPriceWei, maxPriorityFeePerGas: gasPriceWei };
24856
+ }
24857
+ async function resolveEvmFeesPerGas(network, options) {
24858
+ const params = await getCachedFeeMarketParams(
24859
+ options?.cache,
24860
+ network,
24861
+ options?.fetchFn,
24862
+ options?.fetchOptions
24863
+ );
24864
+ if (!params) return null;
24865
+ let fees;
24866
+ try {
24867
+ fees = computeEvmFeesPerGas(params, { marginPercent: options?.marginPercent });
24868
+ } catch {
24869
+ return null;
24870
+ }
24871
+ if (fees.maxFeePerGas === 0n && fees.maxPriorityFeePerGas === 0n) return null;
24872
+ return fees;
24512
24873
  }
24513
- function mapAultTokenregistryV1MsgDisableTransfers(input, label = "value") {
24514
- const record2 = asRecord(input);
24515
- const prefix = label ? `${label}.` : "";
24516
- return {
24517
- sender: requireString(record2["sender"], `${prefix}sender`)
24518
- };
24874
+
24875
+ // src/eip712/signers.ts
24876
+ var import_accounts = require("viem/accounts");
24877
+ var AULT_SIGNER_MARKER = /* @__PURE__ */ Symbol.for("ault-sdk:signer");
24878
+ function isAultSigner(obj) {
24879
+ return typeof obj === "object" && obj !== null && AULT_SIGNER_MARKER in obj && obj[AULT_SIGNER_MARKER] === true;
24519
24880
  }
24520
- function mapAultTokenregistryV1MsgEnableTokenPair(input, label = "value") {
24521
- const record2 = asRecord(input);
24522
- const prefix = label ? `${label}.` : "";
24523
- return {
24524
- sender: requireString(record2["sender"], `${prefix}sender`),
24525
- erc20Address: requireString(record2["erc20Address"], `${prefix}erc20Address`)
24526
- };
24881
+ function normalizeSigner(input) {
24882
+ if (!input) return null;
24883
+ if (typeof input === "function") {
24884
+ return { signTypedData: input };
24885
+ }
24886
+ if (typeof input === "object" && typeof input.signTypedData === "function") {
24887
+ return input;
24888
+ }
24889
+ throw new Error("Invalid signer: expected a signer object or signTypedData function.");
24527
24890
  }
24528
- function mapAultTokenregistryV1MsgEnableTransfers(input, label = "value") {
24529
- const record2 = asRecord(input);
24530
- const prefix = label ? `${label}.` : "";
24531
- return {
24532
- sender: requireString(record2["sender"], `${prefix}sender`)
24533
- };
24891
+ function normalizeSignature(result) {
24892
+ if (typeof result === "string") {
24893
+ return result;
24894
+ }
24895
+ if (result && typeof result.signature === "string") {
24896
+ return result.signature;
24897
+ }
24898
+ throw new Error("Invalid signature response: expected hex string or { signature }.");
24534
24899
  }
24535
- function mapAultTokenregistryV1MsgRegisterTokenPair(input, label = "value") {
24536
- const record2 = asRecord(input);
24537
- const prefix = label ? `${label}.` : "";
24538
- return {
24539
- sender: requireString(record2["sender"], `${prefix}sender`),
24540
- erc20Address: requireString(record2["erc20Address"], `${prefix}erc20Address`),
24541
- enabled: requireBool(record2["enabled"], `${prefix}enabled`),
24542
- ...record2["transferLimit"] != null && {
24543
- transferLimit: mapAultTokenregistryV1TransferLimitConfig(
24544
- asRecord(record2["transferLimit"]),
24545
- `${prefix}transferLimit`
24546
- )
24547
- }
24548
- };
24900
+ async function getSignerAddress(signer) {
24901
+ if (typeof signer.address === "string") {
24902
+ return signer.address;
24903
+ }
24904
+ if (typeof signer.getAddress === "function") {
24905
+ const address = await signer.getAddress();
24906
+ return typeof address === "string" ? address : null;
24907
+ }
24908
+ return null;
24549
24909
  }
24550
- function mapAultTokenregistryV1MsgRemoveTransferLimit(input, label = "value") {
24551
- const record2 = asRecord(input);
24552
- const prefix = label ? `${label}.` : "";
24553
- return {
24554
- sender: requireString(record2["sender"], `${prefix}sender`),
24555
- erc20Address: requireString(record2["erc20Address"], `${prefix}erc20Address`)
24556
- };
24910
+ async function resolveSignerAddress(signer, signerAddress) {
24911
+ const raw = signerAddress ?? (signer ? await getSignerAddress(signer) : null);
24912
+ if (!raw) {
24913
+ throw new Error("signerAddress is required when the signer has no address.");
24914
+ }
24915
+ if (isValidAultAddress(raw)) {
24916
+ return raw;
24917
+ }
24918
+ if (isValidEvmAddress(raw)) {
24919
+ return evmToAult(raw);
24920
+ }
24921
+ throw new Error(`Invalid signerAddress: ${raw}`);
24557
24922
  }
24558
- function mapAultTokenregistryV1MsgSetTransferLimit(input, label = "value") {
24559
- const record2 = asRecord(input);
24560
- const prefix = label ? `${label}.` : "";
24561
- return {
24562
- sender: requireString(record2["sender"], `${prefix}sender`),
24563
- erc20Address: requireString(record2["erc20Address"], `${prefix}erc20Address`),
24564
- transferLimit: mapAultTokenregistryV1TransferLimitConfig(
24565
- asRecord(record2["transferLimit"]),
24566
- `${prefix}transferLimit`
24567
- )
24568
- };
24923
+ function stripEip712Domain(types) {
24924
+ const { EIP712Domain: _removed, ...rest } = types;
24925
+ return rest;
24569
24926
  }
24570
- function mapAultTokenregistryV1TransferLimitConfig(input, label = "value") {
24571
- const record2 = asRecord(input);
24572
- const prefix = label ? `${label}.` : "";
24927
+ function createEip1193Signer(options) {
24928
+ const method = options.method ?? "eth_signTypedData_v4";
24573
24929
  return {
24574
- hourly: mapAultTokenregistryV1Limiter(asRecord(record2["hourly"]), `${prefix}hourly`),
24575
- daily: mapAultTokenregistryV1Limiter(asRecord(record2["daily"]), `${prefix}daily`)
24930
+ [AULT_SIGNER_MARKER]: true,
24931
+ address: options.address,
24932
+ signTypedData: async (typedData) => {
24933
+ const payload = method === "eth_signTypedData_v4" ? JSON.stringify(typedData) : typedData;
24934
+ const signature = await options.provider.request({
24935
+ method,
24936
+ params: [options.address, payload]
24937
+ });
24938
+ if (typeof signature !== "string") {
24939
+ throw new Error("Provider did not return a signature string.");
24940
+ }
24941
+ return { signature };
24942
+ }
24576
24943
  };
24577
24944
  }
24578
- function mapCosmosBaseV1beta1Coin(input, label = "value") {
24579
- const record2 = asRecord(input);
24580
- const prefix = label ? `${label}.` : "";
24581
- return {
24582
- denom: requireString(record2["denom"], `${prefix}denom`),
24583
- amount: requireString(record2["amount"], `${prefix}amount`)
24945
+ function createViemSigner(wallet, options) {
24946
+ const preferRpc = options?.preferRpc ?? true;
24947
+ const getAddress3 = async () => {
24948
+ if (wallet.address) return wallet.address;
24949
+ if (wallet.getAddresses) {
24950
+ const addresses = await wallet.getAddresses();
24951
+ if (addresses?.length) return addresses[0];
24952
+ }
24953
+ return void 0;
24584
24954
  };
24585
- }
24586
- function mapCosmosDistributionV1beta1MsgWithdrawDelegatorReward(input, label = "value") {
24587
- const record2 = asRecord(input);
24588
- const prefix = label ? `${label}.` : "";
24589
24955
  return {
24590
- delegatorAddress: requireString(record2["delegatorAddress"], `${prefix}delegatorAddress`),
24591
- validatorAddress: requireString(record2["validatorAddress"], `${prefix}validatorAddress`)
24956
+ [AULT_SIGNER_MARKER]: true,
24957
+ getAddress: async () => {
24958
+ const addr = await getAddress3();
24959
+ if (!addr) throw new Error("Viem wallet has no address");
24960
+ return addr;
24961
+ },
24962
+ signTypedData: async (typedData) => {
24963
+ if (preferRpc && wallet.request) {
24964
+ const address = await getAddress3();
24965
+ if (!address) {
24966
+ throw new Error("Viem wallet has no address; pass signerAddress explicitly.");
24967
+ }
24968
+ const signature2 = await wallet.request({
24969
+ method: "eth_signTypedData_v4",
24970
+ params: [address, JSON.stringify(typedData)]
24971
+ });
24972
+ if (typeof signature2 !== "string") {
24973
+ throw new Error("RPC signer did not return a signature string.");
24974
+ }
24975
+ return { signature: signature2 };
24976
+ }
24977
+ if (!wallet.signTypedData) {
24978
+ throw new Error("Viem signer does not support signTypedData.");
24979
+ }
24980
+ const signature = await wallet.signTypedData({
24981
+ domain: typedData.domain,
24982
+ types: typedData.types,
24983
+ primaryType: typedData.primaryType,
24984
+ message: typedData.message
24985
+ });
24986
+ return { signature };
24987
+ }
24592
24988
  };
24593
24989
  }
24594
- function mapCosmosStakingV1beta1MsgBeginRedelegate(input, label = "value") {
24595
- const record2 = asRecord(input);
24596
- const prefix = label ? `${label}.` : "";
24990
+ function createEthersSigner(signer) {
24991
+ const sign = signer.signTypedData ?? signer._signTypedData;
24992
+ if (!sign) {
24993
+ throw new Error("Ethers signer must implement signTypedData or _signTypedData.");
24994
+ }
24597
24995
  return {
24598
- delegatorAddress: requireString(record2["delegatorAddress"], `${prefix}delegatorAddress`),
24599
- validatorSrcAddress: requireString(
24600
- record2["validatorSrcAddress"],
24601
- `${prefix}validatorSrcAddress`
24602
- ),
24603
- validatorDstAddress: requireString(
24604
- record2["validatorDstAddress"],
24605
- `${prefix}validatorDstAddress`
24606
- ),
24607
- amount: mapCosmosBaseV1beta1Coin(asRecord(record2["amount"]), `${prefix}amount`)
24996
+ [AULT_SIGNER_MARKER]: true,
24997
+ getAddress: () => signer.getAddress(),
24998
+ signTypedData: async (typedData) => {
24999
+ const types = stripEip712Domain(typedData.types);
25000
+ const signature = await sign(typedData.domain, types, typedData.message);
25001
+ return { signature };
25002
+ }
24608
25003
  };
24609
25004
  }
24610
- function mapCosmosStakingV1beta1MsgDelegate(input, label = "value") {
24611
- const record2 = asRecord(input);
24612
- const prefix = label ? `${label}.` : "";
25005
+ function createPrivySigner(options) {
24613
25006
  return {
24614
- delegatorAddress: requireString(record2["delegatorAddress"], `${prefix}delegatorAddress`),
24615
- validatorAddress: requireString(record2["validatorAddress"], `${prefix}validatorAddress`),
24616
- amount: mapCosmosBaseV1beta1Coin(asRecord(record2["amount"]), `${prefix}amount`)
25007
+ [AULT_SIGNER_MARKER]: true,
25008
+ address: options.address,
25009
+ signTypedData: (typedData) => options.signTypedData(typedData, options.address ? { address: options.address } : void 0)
24617
25010
  };
24618
25011
  }
24619
- function mapCosmosStakingV1beta1MsgUndelegate(input, label = "value") {
24620
- const record2 = asRecord(input);
24621
- const prefix = label ? `${label}.` : "";
24622
- return {
24623
- delegatorAddress: requireString(record2["delegatorAddress"], `${prefix}delegatorAddress`),
24624
- validatorAddress: requireString(record2["validatorAddress"], `${prefix}validatorAddress`),
24625
- amount: mapCosmosBaseV1beta1Coin(asRecord(record2["amount"]), `${prefix}amount`)
24626
- };
25012
+ function createPrivateKeySigner(privateKey) {
25013
+ const normalized = privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`;
25014
+ const account = (0, import_accounts.privateKeyToAccount)(normalized);
25015
+ return createViemSigner(account);
24627
25016
  }
24628
- function mapGoogleProtobufAny(input, label = "value") {
24629
- const record2 = asRecord(input);
24630
- const prefix = label ? `${label}.` : "";
24631
- return {
24632
- typeUrl: requireString(record2["typeUrl"], `${prefix}typeUrl`),
24633
- value: requireBytes(record2["value"], `${prefix}value`)
24634
- };
25017
+
25018
+ // src/utils/tx-hash.ts
25019
+ function normalizeTxHash(raw) {
25020
+ if (!raw) return raw;
25021
+ const stripped = raw.startsWith("0x") || raw.startsWith("0X") ? raw.slice(2) : raw;
25022
+ return stripped.toLowerCase();
24635
25023
  }
24636
- var MSG_ENCODERS = {
24637
- "/ault.accountx.v1.MsgOpenAccount": (value) => MsgOpenAccount.encode(
24638
- MsgOpenAccount.fromPartial(mapAultAccountxV1MsgOpenAccount(value))
24639
- ).finish(),
24640
- "/ault.accountx.v1.MsgUpdateFeeTiers": (value) => MsgUpdateFeeTiers.encode(
24641
- MsgUpdateFeeTiers.fromPartial(mapAultAccountxV1MsgUpdateFeeTiers(value))
24642
- ).finish(),
24643
- "/ault.accountx.v1.MsgUpdateParams": (value) => MsgUpdateParams.encode(
24644
- MsgUpdateParams.fromPartial(mapAultAccountxV1MsgUpdateParams(value))
24645
- ).finish(),
24646
- "/ault.accountx.v1.MsgUpdateTradingTiers": (value) => MsgUpdateTradingTiers.encode(
24647
- MsgUpdateTradingTiers.fromPartial(mapAultAccountxV1MsgUpdateTradingTiers(value))
24648
- ).finish(),
24649
- "/ault.agent.v1.MsgApproveAgent": (value) => MsgApproveAgent.encode(
24650
- MsgApproveAgent.fromPartial(mapAultAgentV1MsgApproveAgent(value))
24651
- ).finish(),
24652
- "/ault.agent.v1.MsgRevokeAgent": (value) => MsgRevokeAgent.encode(MsgRevokeAgent.fromPartial(mapAultAgentV1MsgRevokeAgent(value))).finish(),
24653
- "/ault.agent.v1.MsgUpdateParams": (value) => MsgUpdateParams2.encode(
24654
- MsgUpdateParams2.fromPartial(mapAultAgentV1MsgUpdateParams(value))
24655
- ).finish(),
24656
- "/ault.authority.v1.MsgGrantRole": (value) => MsgGrantRole.encode(MsgGrantRole.fromPartial(mapAultAuthorityV1MsgGrantRole(value))).finish(),
24657
- "/ault.authority.v1.MsgRevokeRole": (value) => MsgRevokeRole.encode(
24658
- MsgRevokeRole.fromPartial(mapAultAuthorityV1MsgRevokeRole(value))
24659
- ).finish(),
24660
- "/ault.clob.v1.MsgCancelOrders": (value) => MsgCancelOrders.encode(
24661
- MsgCancelOrders.fromPartial(mapAultClobV1MsgCancelOrders(value))
24662
- ).finish(),
24663
- "/ault.clob.v1.MsgModifyOrders": (value) => MsgModifyOrders.encode(
24664
- MsgModifyOrders.fromPartial(mapAultClobV1MsgModifyOrders(value))
24665
- ).finish(),
24666
- "/ault.clob.v1.MsgPlaceLimitOrder": (value) => MsgPlaceLimitOrder.encode(
24667
- MsgPlaceLimitOrder.fromPartial(mapAultClobV1MsgPlaceLimitOrder(value))
24668
- ).finish(),
24669
- "/ault.clob.v1.MsgPlaceMarketOrder": (value) => MsgPlaceMarketOrder.encode(
24670
- MsgPlaceMarketOrder.fromPartial(mapAultClobV1MsgPlaceMarketOrder(value))
24671
- ).finish(),
24672
- "/ault.clob.v1.MsgPlaceScaleOrder": (value) => MsgPlaceScaleOrder.encode(
24673
- MsgPlaceScaleOrder.fromPartial(mapAultClobV1MsgPlaceScaleOrder(value))
24674
- ).finish(),
24675
- "/ault.clob.v1.MsgPlaceTwapOrder": (value) => MsgPlaceTwapOrder.encode(
24676
- MsgPlaceTwapOrder.fromPartial(mapAultClobV1MsgPlaceTwapOrder(value))
24677
- ).finish(),
24678
- "/ault.clob.v1.MsgUpdateParams": (value) => MsgUpdateParams3.encode(
24679
- MsgUpdateParams3.fromPartial(mapAultClobV1MsgUpdateParams(value))
24680
- ).finish(),
24681
- "/ault.license.v1.MsgApproveMember": (value) => MsgApproveMember.encode(
24682
- MsgApproveMember.fromPartial(mapAultLicenseV1MsgApproveMember(value))
24683
- ).finish(),
24684
- "/ault.license.v1.MsgBatchApproveMember": (value) => MsgBatchApproveMember.encode(
24685
- MsgBatchApproveMember.fromPartial(mapAultLicenseV1MsgBatchApproveMember(value))
24686
- ).finish(),
24687
- "/ault.license.v1.MsgBatchMintLicense": (value) => MsgBatchMintLicense.encode(
24688
- MsgBatchMintLicense.fromPartial(mapAultLicenseV1MsgBatchMintLicense(value))
24689
- ).finish(),
24690
- "/ault.license.v1.MsgBatchRevokeMember": (value) => MsgBatchRevokeMember.encode(
24691
- MsgBatchRevokeMember.fromPartial(mapAultLicenseV1MsgBatchRevokeMember(value))
24692
- ).finish(),
24693
- "/ault.license.v1.MsgBurnLicense": (value) => MsgBurnLicense.encode(
24694
- MsgBurnLicense.fromPartial(mapAultLicenseV1MsgBurnLicense(value))
24695
- ).finish(),
24696
- "/ault.license.v1.MsgMintLicense": (value) => MsgMintLicense.encode(
24697
- MsgMintLicense.fromPartial(mapAultLicenseV1MsgMintLicense(value))
24698
- ).finish(),
24699
- "/ault.license.v1.MsgRevokeLicense": (value) => MsgRevokeLicense.encode(
24700
- MsgRevokeLicense.fromPartial(mapAultLicenseV1MsgRevokeLicense(value))
24701
- ).finish(),
24702
- "/ault.license.v1.MsgRevokeMember": (value) => MsgRevokeMember.encode(
24703
- MsgRevokeMember.fromPartial(mapAultLicenseV1MsgRevokeMember(value))
24704
- ).finish(),
24705
- "/ault.license.v1.MsgSetKYCApprovers": (value) => MsgSetKYCApprovers.encode(
24706
- MsgSetKYCApprovers.fromPartial(mapAultLicenseV1MsgSetKYCApprovers(value))
24707
- ).finish(),
24708
- "/ault.license.v1.MsgSetMinters": (value) => MsgSetMinters.encode(MsgSetMinters.fromPartial(mapAultLicenseV1MsgSetMinters(value))).finish(),
24709
- "/ault.license.v1.MsgSetTokenURI": (value) => MsgSetTokenURI.encode(
24710
- MsgSetTokenURI.fromPartial(mapAultLicenseV1MsgSetTokenURI(value))
24711
- ).finish(),
24712
- "/ault.license.v1.MsgTransferLicense": (value) => MsgTransferLicense.encode(
24713
- MsgTransferLicense.fromPartial(mapAultLicenseV1MsgTransferLicense(value))
24714
- ).finish(),
24715
- "/ault.license.v1.MsgUpdateParams": (value) => MsgUpdateParams4.encode(
24716
- MsgUpdateParams4.fromPartial(mapAultLicenseV1MsgUpdateParams(value))
24717
- ).finish(),
24718
- "/ault.market.v1.MsgCreateMarket": (value) => MsgCreateMarket.encode(
24719
- MsgCreateMarket.fromPartial(mapAultMarketV1MsgCreateMarket(value))
24720
- ).finish(),
24721
- "/ault.market.v1.MsgHaltAllMarkets": (value) => MsgHaltAllMarkets.encode(
24722
- MsgHaltAllMarkets.fromPartial(mapAultMarketV1MsgHaltAllMarkets(value))
24723
- ).finish(),
24724
- "/ault.market.v1.MsgHaltMarkets": (value) => MsgHaltMarkets.encode(
24725
- MsgHaltMarkets.fromPartial(mapAultMarketV1MsgHaltMarkets(value))
24726
- ).finish(),
24727
- "/ault.market.v1.MsgResumeAllMarkets": (value) => MsgResumeAllMarkets.encode(
24728
- MsgResumeAllMarkets.fromPartial(mapAultMarketV1MsgResumeAllMarkets(value))
24729
- ).finish(),
24730
- "/ault.market.v1.MsgResumeMarkets": (value) => MsgResumeMarkets.encode(
24731
- MsgResumeMarkets.fromPartial(mapAultMarketV1MsgResumeMarkets(value))
24732
- ).finish(),
24733
- "/ault.market.v1.MsgUpdateMarket": (value) => MsgUpdateMarket.encode(
24734
- MsgUpdateMarket.fromPartial(mapAultMarketV1MsgUpdateMarket(value))
24735
- ).finish(),
24736
- "/ault.market.v1.MsgUpdateMarketDeployer": (value) => MsgUpdateMarketDeployer.encode(
24737
- MsgUpdateMarketDeployer.fromPartial(mapAultMarketV1MsgUpdateMarketDeployer(value))
24738
- ).finish(),
24739
- "/ault.market.v1.MsgUpdateParams": (value) => MsgUpdateParams5.encode(
24740
- MsgUpdateParams5.fromPartial(mapAultMarketV1MsgUpdateParams(value))
24741
- ).finish(),
24742
- "/ault.miner.v1.MsgBatchSubmitWork": (value) => MsgBatchSubmitWork.encode(
24743
- MsgBatchSubmitWork.fromPartial(mapAultMinerV1MsgBatchSubmitWork(value))
24744
- ).finish(),
24745
- "/ault.miner.v1.MsgCancelMiningDelegation": (value) => MsgCancelMiningDelegation.encode(
24746
- MsgCancelMiningDelegation.fromPartial(mapAultMinerV1MsgCancelMiningDelegation(value))
24747
- ).finish(),
24748
- "/ault.miner.v1.MsgDelegateMining": (value) => MsgDelegateMining.encode(
24749
- MsgDelegateMining.fromPartial(mapAultMinerV1MsgDelegateMining(value))
24750
- ).finish(),
24751
- "/ault.miner.v1.MsgRedelegateMining": (value) => MsgRedelegateMining.encode(
24752
- MsgRedelegateMining.fromPartial(mapAultMinerV1MsgRedelegateMining(value))
24753
- ).finish(),
24754
- "/ault.miner.v1.MsgRegisterOperator": (value) => MsgRegisterOperator.encode(
24755
- MsgRegisterOperator.fromPartial(mapAultMinerV1MsgRegisterOperator(value))
24756
- ).finish(),
24757
- "/ault.miner.v1.MsgSetOwnerVrfKey": (value) => MsgSetOwnerVrfKey.encode(
24758
- MsgSetOwnerVrfKey.fromPartial(mapAultMinerV1MsgSetOwnerVrfKey(value))
24759
- ).finish(),
24760
- "/ault.miner.v1.MsgSubmitWork": (value) => MsgSubmitWork.encode(MsgSubmitWork.fromPartial(mapAultMinerV1MsgSubmitWork(value))).finish(),
24761
- "/ault.miner.v1.MsgUnregisterOperator": (value) => MsgUnregisterOperator.encode(
24762
- MsgUnregisterOperator.fromPartial(mapAultMinerV1MsgUnregisterOperator(value))
24763
- ).finish(),
24764
- "/ault.miner.v1.MsgUpdateOperatorInfo": (value) => MsgUpdateOperatorInfo.encode(
24765
- MsgUpdateOperatorInfo.fromPartial(mapAultMinerV1MsgUpdateOperatorInfo(value))
24766
- ).finish(),
24767
- "/ault.miner.v1.MsgUpdateParams": (value) => MsgUpdateParams6.encode(
24768
- MsgUpdateParams6.fromPartial(mapAultMinerV1MsgUpdateParams(value))
24769
- ).finish(),
24770
- "/ault.ratelimit.v1.MsgUpdateParams": (value) => MsgUpdateParams7.encode(
24771
- MsgUpdateParams7.fromPartial(mapAultRatelimitV1MsgUpdateParams(value))
24772
- ).finish(),
24773
- "/ault.reward.v1.MsgApproveBuilder": (value) => MsgApproveBuilder.encode(
24774
- MsgApproveBuilder.fromPartial(mapAultRewardV1MsgApproveBuilder(value))
24775
- ).finish(),
24776
- "/ault.reward.v1.MsgRevokeBuilder": (value) => MsgRevokeBuilder.encode(
24777
- MsgRevokeBuilder.fromPartial(mapAultRewardV1MsgRevokeBuilder(value))
24778
- ).finish(),
24779
- "/ault.reward.v1.MsgSetDeployerShare": (value) => MsgSetDeployerShare.encode(
24780
- MsgSetDeployerShare.fromPartial(mapAultRewardV1MsgSetDeployerShare(value))
24781
- ).finish(),
24782
- "/ault.reward.v1.MsgSetReferral": (value) => MsgSetReferral.encode(
24783
- MsgSetReferral.fromPartial(mapAultRewardV1MsgSetReferral(value))
24784
- ).finish(),
24785
- "/ault.reward.v1.MsgSetReferralCode": (value) => MsgSetReferralCode.encode(
24786
- MsgSetReferralCode.fromPartial(mapAultRewardV1MsgSetReferralCode(value))
24787
- ).finish(),
24788
- "/ault.reward.v1.MsgUpdateEligibleReferrers": (value) => MsgUpdateEligibleReferrers.encode(
24789
- MsgUpdateEligibleReferrers.fromPartial(mapAultRewardV1MsgUpdateEligibleReferrers(value))
24790
- ).finish(),
24791
- "/ault.reward.v1.MsgUpdateFeeTierDiscounts": (value) => MsgUpdateFeeTierDiscounts.encode(
24792
- MsgUpdateFeeTierDiscounts.fromPartial(mapAultRewardV1MsgUpdateFeeTierDiscounts(value))
24793
- ).finish(),
24794
- "/ault.reward.v1.MsgUpdateParams": (value) => MsgUpdateParams8.encode(
24795
- MsgUpdateParams8.fromPartial(mapAultRewardV1MsgUpdateParams(value))
24796
- ).finish(),
24797
- "/ault.reward.v1.MsgUpdateRefereeDiscountRate": (value) => MsgUpdateRefereeDiscountRate.encode(
24798
- MsgUpdateRefereeDiscountRate.fromPartial(mapAultRewardV1MsgUpdateRefereeDiscountRate(value))
24799
- ).finish(),
24800
- "/ault.reward.v1.MsgUpdateTradingTierBenefits": (value) => MsgUpdateTradingTierBenefits.encode(
24801
- MsgUpdateTradingTierBenefits.fromPartial(mapAultRewardV1MsgUpdateTradingTierBenefits(value))
24802
- ).finish(),
24803
- "/ault.tokenregistry.v1.MsgDisableTokenPair": (value) => MsgDisableTokenPair.encode(
24804
- MsgDisableTokenPair.fromPartial(mapAultTokenregistryV1MsgDisableTokenPair(value))
24805
- ).finish(),
24806
- "/ault.tokenregistry.v1.MsgDisableTransfers": (value) => MsgDisableTransfers.encode(
24807
- MsgDisableTransfers.fromPartial(mapAultTokenregistryV1MsgDisableTransfers(value))
24808
- ).finish(),
24809
- "/ault.tokenregistry.v1.MsgEnableTokenPair": (value) => MsgEnableTokenPair.encode(
24810
- MsgEnableTokenPair.fromPartial(mapAultTokenregistryV1MsgEnableTokenPair(value))
24811
- ).finish(),
24812
- "/ault.tokenregistry.v1.MsgEnableTransfers": (value) => MsgEnableTransfers.encode(
24813
- MsgEnableTransfers.fromPartial(mapAultTokenregistryV1MsgEnableTransfers(value))
24814
- ).finish(),
24815
- "/ault.tokenregistry.v1.MsgRegisterTokenPair": (value) => MsgRegisterTokenPair.encode(
24816
- MsgRegisterTokenPair.fromPartial(mapAultTokenregistryV1MsgRegisterTokenPair(value))
24817
- ).finish(),
24818
- "/ault.tokenregistry.v1.MsgRemoveTransferLimit": (value) => MsgRemoveTransferLimit.encode(
24819
- MsgRemoveTransferLimit.fromPartial(mapAultTokenregistryV1MsgRemoveTransferLimit(value))
24820
- ).finish(),
24821
- "/ault.tokenregistry.v1.MsgSetTransferLimit": (value) => MsgSetTransferLimit.encode(
24822
- MsgSetTransferLimit.fromPartial(mapAultTokenregistryV1MsgSetTransferLimit(value))
24823
- ).finish(),
24824
- "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward": (value) => MsgWithdrawDelegatorReward.encode(
24825
- MsgWithdrawDelegatorReward.fromPartial(
24826
- mapCosmosDistributionV1beta1MsgWithdrawDelegatorReward(value)
24827
- )
24828
- ).finish(),
24829
- "/cosmos.staking.v1beta1.MsgBeginRedelegate": (value) => MsgBeginRedelegate.encode(
24830
- MsgBeginRedelegate.fromPartial(mapCosmosStakingV1beta1MsgBeginRedelegate(value))
24831
- ).finish(),
24832
- "/cosmos.staking.v1beta1.MsgDelegate": (value) => MsgDelegate.encode(MsgDelegate.fromPartial(mapCosmosStakingV1beta1MsgDelegate(value))).finish(),
24833
- "/cosmos.staking.v1beta1.MsgUndelegate": (value) => MsgUndelegate.encode(
24834
- MsgUndelegate.fromPartial(mapCosmosStakingV1beta1MsgUndelegate(value))
24835
- ).finish()
24836
- };
24837
25024
 
24838
25025
  // src/eip712/sign-and-broadcast.ts
24839
25026
  async function queryAccount(network, address, fetchFn, fetchOptions) {
@@ -24892,6 +25079,9 @@ function createAccountCache() {
24892
25079
  function getNextSequence(sequence) {
24893
25080
  return String(BigInt(sequence) + 1n);
24894
25081
  }
25082
+ function isSequenceMismatch(rawLog) {
25083
+ return rawLog.includes("account sequence mismatch") || rawLog.includes("incorrect account sequence");
25084
+ }
24895
25085
  function clearCachedSequence(cache) {
24896
25086
  if (cache) {
24897
25087
  cache.nextSequence = null;
@@ -24994,6 +25184,8 @@ async function signAndBroadcastEip712({
24994
25184
  feeDenom,
24995
25185
  feeAmount,
24996
25186
  confirmationTimeoutMs,
25187
+ simulateGas = false,
25188
+ simulatedGasMultiplier,
24997
25189
  wait = true,
24998
25190
  fetchFn,
24999
25191
  fetchOptions,
@@ -25020,15 +25212,46 @@ async function signAndBroadcastEip712({
25020
25212
  if (!sequence) {
25021
25213
  throw new Error(`Unable to resolve account sequence for signer ${resolvedSignerAddress}.`);
25022
25214
  }
25023
- const resolvedGas = gasLimit ?? network.eip712GasLimit ?? GAS_CONSTANTS.EIP712_GAS_LIMIT;
25024
- const resolvedFeeAmount = feeAmount ?? network.eip712FeeAmount ?? await resolveDynamicFeeAmount(network, resolvedGas, feeMarketCache, fetchFn, fetchOptions);
25215
+ let resolvedGas = gasLimit ?? network.eip712GasLimit ?? GAS_CONSTANTS.EIP712_GAS_LIMIT;
25216
+ const resolvedFeeDenom = feeDenom ?? network.eip712FeeDenom ?? GAS_CONSTANTS.DENOM;
25217
+ const feeOverride = feeAmount ?? network.eip712FeeAmount;
25218
+ const feeFor = async (gas) => feeOverride ?? await resolveDynamicFeeAmount(network, gas, feeMarketCache, fetchFn, fetchOptions);
25219
+ let resolvedFeeAmount;
25220
+ if (simulateGas) {
25221
+ let simulated;
25222
+ try {
25223
+ simulated = await simulateTx({
25224
+ network,
25225
+ msgs,
25226
+ memo,
25227
+ sequence,
25228
+ pubkeyBase64: cache?.pubkeyBase64 ?? accountInfo?.pubkeyBase64 ?? null,
25229
+ placeholderGasLimit: resolvedGas,
25230
+ placeholderFee: { denom: resolvedFeeDenom, amount: await feeFor(resolvedGas) },
25231
+ fetchFn,
25232
+ fetchOptions
25233
+ });
25234
+ } catch (error) {
25235
+ if (error instanceof TxSimulationError && isSequenceMismatch(error.rawLog)) {
25236
+ clearCachedSequence(cache);
25237
+ }
25238
+ throw error;
25239
+ }
25240
+ if (simulated) {
25241
+ resolvedGas = computeSimulatedGas(
25242
+ simulated.gasUsed,
25243
+ simulatedGasMultiplier ?? GAS_CONSTANTS.SIMULATED_GAS_MULTIPLIER
25244
+ );
25245
+ }
25246
+ }
25247
+ resolvedFeeAmount = await feeFor(resolvedGas);
25025
25248
  const context = {
25026
25249
  chainId: network.chainId,
25027
25250
  accountNumber,
25028
25251
  sequence,
25029
25252
  fee: {
25030
25253
  amount: resolvedFeeAmount,
25031
- denom: feeDenom ?? network.eip712FeeDenom ?? GAS_CONSTANTS.DENOM,
25254
+ denom: resolvedFeeDenom,
25032
25255
  gas: resolvedGas
25033
25256
  },
25034
25257
  memo
@@ -25367,6 +25590,40 @@ function createParallelQueryApi(lowLevel) {
25367
25590
 
25368
25591
  // src/high-level/cloid-lookup.ts
25369
25592
  var import_encoding3 = require("@cosmjs/encoding");
25593
+
25594
+ // src/rest/pagination.ts
25595
+ var NEXT_CURSOR_HEADER = "X-Next-Cursor";
25596
+ async function* paginate(fetchPage, params = {}) {
25597
+ let cursor = params.cursor;
25598
+ const seen = new Set(cursor ? [cursor] : []);
25599
+ for (; ; ) {
25600
+ const res = await fetchPage(cursor ? { cursor } : {});
25601
+ if (res.status !== 200 || !Array.isArray(res.data)) {
25602
+ throw new ApiError(`paginated endpoint returned unexpected status ${res.status}`, res.status);
25603
+ }
25604
+ const next = res.headers.get(NEXT_CURSOR_HEADER);
25605
+ if (next && seen.has(next)) {
25606
+ throw new ApiError("pagination cursor repeated; aborting to prevent an infinite loop");
25607
+ }
25608
+ yield { rows: res.data, nextCursor: next };
25609
+ if (!next) return;
25610
+ seen.add(next);
25611
+ cursor = next;
25612
+ }
25613
+ }
25614
+ async function collectPages(fetchPage, max, params = {}) {
25615
+ if (!Number.isInteger(max) || max < 1) {
25616
+ throw new ApiError(`collectPages max must be a positive integer, got ${max}`);
25617
+ }
25618
+ const rows = [];
25619
+ for await (const page of paginate(fetchPage, params)) {
25620
+ rows.push(...page.rows);
25621
+ if (rows.length >= max) return rows.slice(0, max);
25622
+ }
25623
+ return rows;
25624
+ }
25625
+
25626
+ // src/high-level/cloid-lookup.ts
25370
25627
  function createCloidLookupApi(lowLevel) {
25371
25628
  async function findOrderByCloid(orderer, cloid) {
25372
25629
  const addr = normalizeAddress(orderer);
@@ -25380,20 +25637,30 @@ function createCloidLookupApi(lowLevel) {
25380
25637
  return { source: "chain-twap", order: chain.twap };
25381
25638
  }
25382
25639
  const wantHex = (0, import_encoding3.toHex)(bytes);
25383
- const LIMIT = 200;
25384
- const res = await lowLevel.rest.dex.listOrders({ address: addr, cloid: wantHex, limit: LIMIT });
25385
- if (res.status !== 200) {
25386
- throw new Error(`dex-api listOrders returned unexpected status ${res.status}`);
25387
- }
25388
- const orders = res.data.filter((o) => o.clientOrderId?.toLowerCase() === wantHex);
25389
- if (orders.length === 0) {
25390
- return { source: "none", order: null };
25640
+ const LIMIT = 500;
25641
+ const MAX_PAGES = 10;
25642
+ const orders = [];
25643
+ let exhausted = false;
25644
+ let pages = 0;
25645
+ for await (const page of paginate(
25646
+ (p) => lowLevel.rest.dex.listOrders({ address: addr, cloid: wantHex, limit: LIMIT, ...p })
25647
+ )) {
25648
+ orders.push(...page.rows.filter((o) => o.clientOrderId?.toLowerCase() === wantHex));
25649
+ pages += 1;
25650
+ if (!page.nextCursor) {
25651
+ exhausted = true;
25652
+ break;
25653
+ }
25654
+ if (pages >= MAX_PAGES) break;
25391
25655
  }
25392
- if (res.data.length >= LIMIT) {
25656
+ if (!exhausted) {
25393
25657
  throw new Error(
25394
- `cloid ${wantHex} has too many historical matches to disambiguate (>= ${LIMIT}); dex-api needs a canonical (orderer, cloid) latest lookup`
25658
+ `cloid ${wantHex} has too many historical matches to disambiguate (> ${MAX_PAGES * LIMIT} rows); dex-api needs a canonical (orderer, cloid) latest lookup`
25395
25659
  );
25396
25660
  }
25661
+ if (orders.length === 0) {
25662
+ return { source: "none", order: null };
25663
+ }
25397
25664
  const order = orders.reduce((latest, next) => {
25398
25665
  if (next.timestamp !== latest.timestamp) {
25399
25666
  return next.timestamp > latest.timestamp ? next : latest;
@@ -26649,6 +26916,13 @@ function createRewardTxApi({ signerAddress, exec, getGas }) {
26649
26916
  }
26650
26917
 
26651
26918
  // src/high-level/tx/staking.ts
26919
+ function stakingGasOptions(gas, fallbackMinGas, gasLimit) {
26920
+ return {
26921
+ gasLimit: gasLimit ?? computeFeeFreeGas(fallbackMinGas, 1, gas.FEE_FREE_GAS_MULTIPLIER),
26922
+ simulateGas: gasLimit == null,
26923
+ simulatedGasMultiplier: gas.SIMULATED_GAS_MULTIPLIER
26924
+ };
26925
+ }
26652
26926
  function createStakingTxApi({ signerAddress, exec, getGas }) {
26653
26927
  return {
26654
26928
  async delegate({ validatorAddress, amount, gasLimit, feeAmount, memo, confirmationTimeoutMs }) {
@@ -26662,7 +26936,7 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
26662
26936
  })
26663
26937
  ],
26664
26938
  {
26665
- gasLimit: gasLimit ?? computeFeeFreeGas(gas.DELEGATE, 1, gas.FEE_FREE_GAS_MULTIPLIER),
26939
+ ...stakingGasOptions(gas, gas.DELEGATE, gasLimit),
26666
26940
  feeAmount,
26667
26941
  memo,
26668
26942
  confirmationTimeoutMs
@@ -26687,7 +26961,7 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
26687
26961
  })
26688
26962
  ],
26689
26963
  {
26690
- gasLimit: gasLimit ?? computeFeeFreeGas(gas.UNDELEGATE, 1, gas.FEE_FREE_GAS_MULTIPLIER),
26964
+ ...stakingGasOptions(gas, gas.UNDELEGATE, gasLimit),
26691
26965
  feeAmount,
26692
26966
  memo,
26693
26967
  confirmationTimeoutMs
@@ -26714,7 +26988,7 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
26714
26988
  })
26715
26989
  ],
26716
26990
  {
26717
- gasLimit: gasLimit ?? computeFeeFreeGas(gas.BEGIN_REDELEGATE, 1, gas.FEE_FREE_GAS_MULTIPLIER),
26991
+ ...stakingGasOptions(gas, gas.BEGIN_REDELEGATE, gasLimit),
26718
26992
  feeAmount,
26719
26993
  memo,
26720
26994
  confirmationTimeoutMs
@@ -26733,7 +27007,7 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
26733
27007
  }
26734
27008
  const normalized = validatorAddresses.map(assertValidatorAddress);
26735
27009
  const gas = getGas();
26736
- const resolvedGasLimit = gasLimit ?? computeFeeFreeGas(gas.WITHDRAW_DELEGATOR_REWARD, 1, gas.FEE_FREE_GAS_MULTIPLIER);
27010
+ const gasOptions = stakingGasOptions(gas, gas.WITHDRAW_DELEGATOR_REWARD, gasLimit);
26737
27011
  const results = [];
26738
27012
  const partial = [];
26739
27013
  for (let i = 0; i < normalized.length; i++) {
@@ -26746,7 +27020,7 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
26746
27020
  validatorAddress
26747
27021
  })
26748
27022
  ],
26749
- { gasLimit: resolvedGasLimit, feeAmount, memo, confirmationTimeoutMs }
27023
+ { ...gasOptions, feeAmount, memo, confirmationTimeoutMs }
26750
27024
  );
26751
27025
  results.push(result);
26752
27026
  partial.push({ txHash: result.txHash, validatorAddress });
@@ -26935,6 +27209,8 @@ function createTxExecutor(options) {
26935
27209
  feeAmount: txOptions?.feeAmount,
26936
27210
  memo: txOptions?.memo ?? defaultMemo,
26937
27211
  confirmationTimeoutMs: txOptions?.confirmationTimeoutMs ?? defaultConfirmationTimeoutMs,
27212
+ simulateGas: txOptions?.simulateGas ?? false,
27213
+ simulatedGasMultiplier: txOptions?.simulatedGasMultiplier,
26938
27214
  wait: txOptions?.wait ?? true,
26939
27215
  fetchFn: options.fetchFn,
26940
27216
  fetchOptions,
@@ -26957,6 +27233,8 @@ function createTxExecutor(options) {
26957
27233
  var import_zod = require("zod");
26958
27234
  var ManifestGasSchema = import_zod.z.object({
26959
27235
  FEE_FREE_GAS_MULTIPLIER: import_zod.z.number().int().positive(),
27236
+ // Under 100% signs less gas than the simulation already burned.
27237
+ SIMULATED_GAS_MULTIPLIER: import_zod.z.number().int().min(100),
26960
27238
  PER_LICENSE: import_zod.z.number().int().positive(),
26961
27239
  PER_KYC_MEMBER: import_zod.z.number().int().positive(),
26962
27240
  PER_DELEGATE_MINING: import_zod.z.number().int().positive(),
@@ -27763,15 +28041,18 @@ var PageResponseSchema = import_zod3.z.object({
27763
28041
  // src/rest/dex-types.generated.ts
27764
28042
  var zod = __toESM(require("zod"), 1);
27765
28043
  var GetHealthResponse = zod.object({
27766
- status: zod.enum(["healthy", "unhealthy"]),
27767
- database: zod.enum(["ok", "unreachable"])
28044
+ status: zod.enum(["healthy"])
27768
28045
  });
27769
28046
  var GetReadyResponse = zod.object({
27770
- status: zod.enum(["ready", "not ready"])
28047
+ status: zod.enum(["ready"])
27771
28048
  });
27772
28049
  var GetLiveResponse = zod.object({
27773
28050
  status: zod.enum(["alive"])
27774
28051
  });
28052
+ var GetDBReadyResponse = zod.object({
28053
+ status: zod.enum(["ok", "unavailable"]),
28054
+ database: zod.enum(["ok", "unreachable"])
28055
+ });
27775
28056
  var GetStatusResponse = zod.object({
27776
28057
  last_indexed_height: zod.number(),
27777
28058
  last_indexed_at: zod.iso.datetime({})
@@ -27863,6 +28144,8 @@ var ListMarketsResponseItem = zod.object({
27863
28144
  )
27864
28145
  });
27865
28146
  var ListMarketsResponse = zod.array(ListMarketsResponseItem);
28147
+ var listCurrenciesResponseInfoContractDecimalsMin = 0;
28148
+ var listCurrenciesResponseInfoContractDecimalsMax = 255;
27866
28149
  var ListCurrenciesResponse = zod.record(
27867
28150
  zod.string(),
27868
28151
  zod.object({
@@ -27873,7 +28156,9 @@ var ListCurrenciesResponse = zod.record(
27873
28156
  deposit: zod.boolean().nullish(),
27874
28157
  withdraw: zod.boolean().nullish(),
27875
28158
  fee: zod.number().nullish(),
27876
- precision: zod.number(),
28159
+ precision: zod.number().describe(
28160
+ "The DEX trading precision \u2014 always 18: every amount on every\nendpoint (balances, orders, trades, portfolio) is normalized to\n18-decimal units regardless of the token contract's own\ndecimals. The raw contract decimals are available in\n`info.contractDecimals`.\n"
28161
+ ),
27877
28162
  limits: zod.object({
27878
28163
  amount: zod.object({
27879
28164
  min: zod.number().nullish(),
@@ -27885,7 +28170,11 @@ var ListCurrenciesResponse = zod.record(
27885
28170
  }).optional()
27886
28171
  }),
27887
28172
  networks: zod.looseObject({}).optional(),
27888
- info: zod.looseObject({})
28173
+ info: zod.object({
28174
+ contractDecimals: zod.number().min(listCurrenciesResponseInfoContractDecimalsMin).max(listCurrenciesResponseInfoContractDecimalsMax).describe(
28175
+ "The token contract's own decimals (raw ERC20 decimals). Amounts\non the API are NOT in these units \u2014 see `precision`.\n"
28176
+ )
28177
+ })
27889
28178
  })
27890
28179
  );
27891
28180
  var GetTickerParams = zod.object({
@@ -27979,11 +28268,20 @@ var GetOrderbookResponse = zod.object({
27979
28268
  var ListTradesParams = zod.object({
27980
28269
  symbol: zod.string().describe("URL-encoded trading pair (e.g., `AULT%2FUSDT`)")
27981
28270
  });
27982
- var listTradesQueryLimitDefault = 50;
28271
+ var listTradesQueryLimitDefault = 100;
27983
28272
  var listTradesQueryLimitMax = 500;
28273
+ var listTradesQueryBeforeIndexMin = 0;
28274
+ var listTradesQueryBeforeIndexMax = 4294967295;
27984
28275
  var ListTradesQueryParams = zod.object({
27985
28276
  limit: zod.number().min(1).max(listTradesQueryLimitMax).default(listTradesQueryLimitDefault),
27986
- since: zod.number().optional().describe("Unix timestamp in milliseconds")
28277
+ since: zod.number().optional().describe("Unix timestamp in milliseconds"),
28278
+ cursor: zod.string().optional().describe(
28279
+ 'Opaque pagination cursor. Take it verbatim from the previous page\'s\n`X-Next-Cursor` header (or follow the `Link: rel="next"` URL) and\nrepeat every other query parameter; the cursor is bound to that\nfilter set and a different one is rejected with 400. `limit` may\nchange between pages. No `X-Next-Cursor` on a response means the\nfeed is exhausted. Clients must not build or parse cursors.\n'
28280
+ ),
28281
+ before_height: zod.number().min(1).optional().describe(
28282
+ "Deprecated in favour of `cursor`; still honoured, and ignored when\n`cursor` is also present.\n\nComposite pagination cursor, upper half. Returns only trades\nstrictly older (in feed order) than the row identified by\n(`before_height`, `before_index`) \u2014 take both values from the\nlast row's `info.block_height` / `info.event_index`. Must be\npassed together with `before_index`. Unlike `since`, the cursor\ncannot skip or repeat trades when many share one timestamp.\n"
28283
+ ),
28284
+ before_index: zod.number().min(listTradesQueryBeforeIndexMin).max(listTradesQueryBeforeIndexMax).optional().describe("Composite pagination cursor, lower half. See `before_height`.")
27987
28285
  });
27988
28286
  var listTradesResponsePriceRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
27989
28287
  var listTradesResponseAmountRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
@@ -27993,6 +28291,7 @@ var listTradesResponseFeeRateRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
27993
28291
  var listTradesResponseInfoAddressOneRegExp = new RegExp("^ault1[a-z0-9]{38,}$");
27994
28292
  var listTradesResponseInfoBlockHeightRegExp = new RegExp("^\\d+$");
27995
28293
  var listTradesResponseInfoEventIndexMin = 0;
28294
+ var listTradesResponseInfoEventIndexMax = 4294967295;
27996
28295
  var ListTradesResponseItem = zod.object({
27997
28296
  id: zod.string(),
27998
28297
  order: zod.string().nullish(),
@@ -28002,10 +28301,11 @@ var ListTradesResponseItem = zod.object({
28002
28301
  type: zod.union([
28003
28302
  zod.literal("limit"),
28004
28303
  zod.literal("market"),
28304
+ zod.literal("twap"),
28005
28305
  zod.literal("unknown"),
28006
28306
  zod.literal(null)
28007
28307
  ]).nullish().describe(
28008
- "Order type resolved via JOIN to orders table. Null if order not found. `unknown` is the fallback for a chain code the API doesn't recognize."
28308
+ "Order type resolved via JOIN to orders table. `twap` marks a TWAP slice execution (chain code 2). Null if order not found. `unknown` is the fallback for a chain code the API doesn't recognize."
28009
28309
  ),
28010
28310
  cloid: zod.string().nullish().describe(
28011
28311
  "Client order id (hex, 8 bytes) resolved via JOIN to orders table. Null when the order carried none, the row predates cloid indexing, or on the public trades feed (cloids are private to the orderer)."
@@ -28039,8 +28339,8 @@ var ListTradesResponseItem = zod.object({
28039
28339
  "Atto-precision amount the orderer received for this fill,\nsuffixed with the chain denom. Empty string when the chain did\nnot record this side.\n"
28040
28340
  ),
28041
28341
  block_height: zod.string().regex(listTradesResponseInfoBlockHeightRegExp).describe("Decimal-string block height for parity with the WS trade event."),
28042
- event_index: zod.number().min(listTradesResponseInfoEventIndexMin).describe(
28043
- "The trade's event position within its block. Together with\n`block_height` it is the row's composite pagination cursor for the\ntrade feed. `created_at` cannot serve this role because every trade\nin a block shares one timestamp.\n"
28342
+ event_index: zod.number().min(listTradesResponseInfoEventIndexMin).max(listTradesResponseInfoEventIndexMax).describe(
28343
+ "The trade's event position within its block. With `block_height`\nit forms the row's composite pagination cursor: pass the last\nrow's pair as `before_height`/`before_index` to fetch the next\n(older) page.\n"
28044
28344
  )
28045
28345
  }).describe(
28046
28346
  "Exchange-specific extension on `TradeResponse`. Mirrors the\n`Info` struct populated in `internal/domain/trade/service.go`.\n"
@@ -28066,6 +28366,7 @@ var getTradeResponseFeeRateRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
28066
28366
  var getTradeResponseInfoAddressOneRegExp = new RegExp("^ault1[a-z0-9]{38,}$");
28067
28367
  var getTradeResponseInfoBlockHeightRegExp = new RegExp("^\\d+$");
28068
28368
  var getTradeResponseInfoEventIndexMin = 0;
28369
+ var getTradeResponseInfoEventIndexMax = 4294967295;
28069
28370
  var GetTradeResponse = zod.object({
28070
28371
  id: zod.string(),
28071
28372
  order: zod.string().nullish(),
@@ -28075,10 +28376,11 @@ var GetTradeResponse = zod.object({
28075
28376
  type: zod.union([
28076
28377
  zod.literal("limit"),
28077
28378
  zod.literal("market"),
28379
+ zod.literal("twap"),
28078
28380
  zod.literal("unknown"),
28079
28381
  zod.literal(null)
28080
28382
  ]).nullish().describe(
28081
- "Order type resolved via JOIN to orders table. Null if order not found. `unknown` is the fallback for a chain code the API doesn't recognize."
28383
+ "Order type resolved via JOIN to orders table. `twap` marks a TWAP slice execution (chain code 2). Null if order not found. `unknown` is the fallback for a chain code the API doesn't recognize."
28082
28384
  ),
28083
28385
  cloid: zod.string().nullish().describe(
28084
28386
  "Client order id (hex, 8 bytes) resolved via JOIN to orders table. Null when the order carried none, the row predates cloid indexing, or on the public trades feed (cloids are private to the orderer)."
@@ -28112,8 +28414,8 @@ var GetTradeResponse = zod.object({
28112
28414
  "Atto-precision amount the orderer received for this fill,\nsuffixed with the chain denom. Empty string when the chain did\nnot record this side.\n"
28113
28415
  ),
28114
28416
  block_height: zod.string().regex(getTradeResponseInfoBlockHeightRegExp).describe("Decimal-string block height for parity with the WS trade event."),
28115
- event_index: zod.number().min(getTradeResponseInfoEventIndexMin).describe(
28116
- "The trade's event position within its block. Together with\n`block_height` it is the row's composite pagination cursor for the\ntrade feed. `created_at` cannot serve this role because every trade\nin a block shares one timestamp.\n"
28417
+ event_index: zod.number().min(getTradeResponseInfoEventIndexMin).max(getTradeResponseInfoEventIndexMax).describe(
28418
+ "The trade's event position within its block. With `block_height`\nit forms the row's composite pagination cursor: pass the last\nrow's pair as `before_height`/`before_index` to fetch the next\n(older) page.\n"
28117
28419
  )
28118
28420
  }).describe(
28119
28421
  "Exchange-specific extension on `TradeResponse`. Mirrors the\n`Info` struct populated in `internal/domain/trade/service.go`.\n"
@@ -28135,7 +28437,7 @@ var GetTradingFeesResponse = zod.record(
28135
28437
  })
28136
28438
  );
28137
28439
  var GetStatsQueryParams = zod.object({
28138
- window: zod.enum(["24h"]).optional().describe("Rolling window. Only `24h` is supported; defaults to `24h`.")
28440
+ window: zod.enum(["24h", "7d", "30d", "all"]).optional().describe("Precomputed reporting window. Defaults to `24h`.")
28139
28441
  });
28140
28442
  var getStatsResponseTotalsQuoteVolumeRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
28141
28443
  var getStatsResponseTotalsEstimatedFeeRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
@@ -28147,7 +28449,7 @@ var getStatsResponseMarketsItemBaseVolumeRegExp = new RegExp("^-?\\d+(\\.\\d+)?$
28147
28449
  var getStatsResponseMarketsItemEstimatedFeeRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
28148
28450
  var getStatsResponseMarketsItemTakerFeeRateRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
28149
28451
  var GetStatsResponse = zod.object({
28150
- window: zod.enum(["24h"]),
28452
+ window: zod.enum(["24h", "7d", "30d", "all"]),
28151
28453
  totals: zod.object({
28152
28454
  quoteVolume: zod.string().regex(getStatsResponseTotalsQuoteVolumeRegExp).nullable().describe(
28153
28455
  "Total quote volume over the window as a canonical decimal string.\nNull when contributing markets span more than one quote (then\n`estimatedFee` and `quoteAsset` are null too).\n"
@@ -28162,12 +28464,12 @@ var GetStatsResponse = zod.object({
28162
28464
  traderCount: zod.number().describe("Distinct trading addresses in the window."),
28163
28465
  activeMarkets: zod.number().describe("Number of markets with at least one fill in the window."),
28164
28466
  dailyActiveUsers: zod.number().nullable().describe(
28165
- "Distinct trading addresses in the window. Currently an alias of\n`traderCount`; separate so a precise DAU source can diverge later.\n"
28467
+ "Distinct trading addresses over 24 hours. An alias of\n`traderCount` for the `24h` response and null for longer windows;\nseparate so a precise DAU source can diverge later.\n"
28166
28468
  ),
28167
28469
  averageSlippageBps: zod.string().regex(getStatsResponseTotalsAverageSlippageBpsRegExp).nullable().describe(
28168
28470
  "Volume-weighted taker slippage (fill vs book-mid) in bps as a\ndecimal string. Null with no benchmarkable taker fill or when\nfills span more than one quote.\n"
28169
28471
  ),
28170
- depositUsdcVolume24h: zod.string().regex(getStatsResponseTotalsDepositUsdcVolume24hRegExp).nullable().describe("Reserved. Currently always null."),
28472
+ depositUsdcVolume24h: zod.string().regex(getStatsResponseTotalsDepositUsdcVolume24hRegExp).nullable().describe("24h USDC deposit volume when available; null for longer windows."),
28171
28473
  builderCodesFee24h: zod.string().regex(getStatsResponseTotalsBuilderCodesFee24hRegExp).nullable().describe("Reserved. Currently always null.")
28172
28474
  }).describe("Protocol-wide aggregates for the window."),
28173
28475
  markets: zod.array(
@@ -28189,8 +28491,8 @@ var listOrdersQueryAddressOneRegExp = new RegExp("^ault1[a-z0-9]{38,}$");
28189
28491
  var listOrdersQueryAddressTwoRegExp = new RegExp("^0x[a-f0-9]{40}$");
28190
28492
  var listOrdersQueryMarketIdRegExp = new RegExp("^[0-9a-fA-F]+$");
28191
28493
  var listOrdersQueryCloidRegExp = new RegExp("^([0-9a-fA-F]{16})?$");
28192
- var listOrdersQueryLimitDefault = 50;
28193
- var listOrdersQueryLimitMax = 200;
28494
+ var listOrdersQueryLimitDefault = 100;
28495
+ var listOrdersQueryLimitMax = 500;
28194
28496
  var ListOrdersQueryParams = zod.object({
28195
28497
  address: zod.union([
28196
28498
  zod.string().regex(listOrdersQueryAddressOneRegExp).describe(
@@ -28209,7 +28511,10 @@ var ListOrdersQueryParams = zod.object({
28209
28511
  "Client order id (cloid) to filter by, as a hex string. A\nnon-empty value must decode to exactly 8 bytes (16 hex chars);\nanything else returns 400. An absent or empty (`cloid=`) value\napplies no cloid filter, matching how `market_id` behaves.\nCombined with `address`, a set cloid returns the orders carrying\nit. cloid uniqueness is only enforced for currently-resting\norders, so closed orders that reused the cloid may also match and\nmore than one order can be returned.\n"
28210
28512
  ),
28211
28513
  since: zod.number().optional().describe("Return orders created after this Unix timestamp (milliseconds)"),
28212
- limit: zod.number().min(1).max(listOrdersQueryLimitMax).default(listOrdersQueryLimitDefault)
28514
+ limit: zod.number().min(1).max(listOrdersQueryLimitMax).default(listOrdersQueryLimitDefault),
28515
+ cursor: zod.string().optional().describe(
28516
+ 'Opaque pagination cursor. Take it verbatim from the previous page\'s\n`X-Next-Cursor` header (or follow the `Link: rel="next"` URL) and\nrepeat every other query parameter; the cursor is bound to that\nfilter set and a different one is rejected with 400. `limit` may\nchange between pages. No `X-Next-Cursor` on a response means the\nfeed is exhausted. Clients must not build or parse cursors.\n'
28517
+ )
28213
28518
  });
28214
28519
  var listOrdersResponsePriceRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
28215
28520
  var listOrdersResponseAmountRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
@@ -28230,8 +28535,12 @@ var ListOrdersResponseItem = zod.object({
28230
28535
  lastTradeTimestamp: zod.number().nullish().describe("Timestamp (ms) of the last trade executed against this order. Null if no trades."),
28231
28536
  status: zod.enum(["open", "closed", "canceled", "unknown"]).describe("`unknown` is the fallback for a chain status code the API doesn't recognize."),
28232
28537
  symbol: zod.string(),
28233
- type: zod.enum(["limit", "market", "twap", "unknown"]).describe("`unknown` is the fallback for a chain type code the API doesn't recognize."),
28234
- timeInForce: zod.string().nullish(),
28538
+ type: zod.enum(["limit", "market", "twap", "unknown"]).describe(
28539
+ "`unknown` is the fallback for a chain type code the API doesn't recognize. A `twap` row (chain order_type=2) is a TWAP slice execution \u2014 the TWAP parent lives in `twap_orders` and is not returned by the order endpoints."
28540
+ ),
28541
+ timeInForce: zod.union([zod.literal("ioc"), zod.literal(null)]).nullable().describe(
28542
+ "CCXT-collapsed time-in-force. `ioc` for an immediate-or-cancel\norder (chain TIF code 1); null for the default (GTT/GTC) or an\nunrecognized code. Always present (never omitted). The WS\n`orderUpdates` payload exposes the same `ioc`-or-absent value.\n"
28543
+ ),
28235
28544
  side: zod.enum(["buy", "sell"]),
28236
28545
  price: zod.string().regex(listOrdersResponsePriceRegExp),
28237
28546
  average: zod.string().nullish().describe("Average execution price as decimal string. Null when filled is 0."),
@@ -28273,10 +28582,10 @@ var ListOrdersResponseItem = zod.object({
28273
28582
  "Granular chain-level status \u2014 the WS view exposes the same\nstring. The CCXT view at `OrderResponse.status` collapses these\ninto open | closed | canceled. `unknown` is the fallback for a\nchain code the API doesn't recognize.\n"
28274
28583
  ),
28275
28584
  chain_type: zod.enum(["limit", "market", "twap", "unknown"]).describe(
28276
- "Granular chain-level order type. The CCXT view at\n`OrderResponse.type` collapses these into limit | market.\n`unknown` is the fallback for a chain code the API doesn't\nrecognize.\n"
28585
+ "Granular chain-level order type. Mirrors the dbindexer\n`orders.order_type` column (0=limit, 1=market, 2=twap). TWAP\nslice executions are stored as individual order rows and surface\nhere as `twap`. `unknown` is the fallback for a chain code the\nAPI doesn't recognize.\n"
28277
28586
  ),
28278
- close_reason: zod.string().nullish().describe(
28279
- "Free-form chain close reason for a terminal order \u2014 e.g.\n`completed`, `canceled`, `expired`, `ioc_canceled`, `self_trade`,\n`post_only_rejected`, `replaced`. Null while the order is still live.\n"
28587
+ close_reason: zod.string().nullable().describe(
28588
+ "Free-form chain close reason for a terminal order \u2014 e.g.\n`completed`, `canceled`, `expired`, `ioc_canceled`,\n`self_trade`, `post_only_rejected`, `replaced`. Null while the\norder is still live. Lets consumers tell an IOC-cancelled or\nself-trade-prevented close apart from the generic `canceled` close.\n"
28280
28589
  )
28281
28590
  }).describe(
28282
28591
  "Exchange-specific extension on `OrderResponse`. Mirrors the\n`info` map populated in `internal/domain/order/service.go`.\n"
@@ -28307,8 +28616,12 @@ var GetOrderResponse = zod.object({
28307
28616
  lastTradeTimestamp: zod.number().nullish().describe("Timestamp (ms) of the last trade executed against this order. Null if no trades."),
28308
28617
  status: zod.enum(["open", "closed", "canceled", "unknown"]).describe("`unknown` is the fallback for a chain status code the API doesn't recognize."),
28309
28618
  symbol: zod.string(),
28310
- type: zod.enum(["limit", "market", "twap", "unknown"]).describe("`unknown` is the fallback for a chain type code the API doesn't recognize."),
28311
- timeInForce: zod.string().nullish(),
28619
+ type: zod.enum(["limit", "market", "twap", "unknown"]).describe(
28620
+ "`unknown` is the fallback for a chain type code the API doesn't recognize. A `twap` row (chain order_type=2) is a TWAP slice execution \u2014 the TWAP parent lives in `twap_orders` and is not returned by the order endpoints."
28621
+ ),
28622
+ timeInForce: zod.union([zod.literal("ioc"), zod.literal(null)]).nullable().describe(
28623
+ "CCXT-collapsed time-in-force. `ioc` for an immediate-or-cancel\norder (chain TIF code 1); null for the default (GTT/GTC) or an\nunrecognized code. Always present (never omitted). The WS\n`orderUpdates` payload exposes the same `ioc`-or-absent value.\n"
28624
+ ),
28312
28625
  side: zod.enum(["buy", "sell"]),
28313
28626
  price: zod.string().regex(getOrderResponsePriceRegExp),
28314
28627
  average: zod.string().nullish().describe("Average execution price as decimal string. Null when filled is 0."),
@@ -28350,10 +28663,10 @@ var GetOrderResponse = zod.object({
28350
28663
  "Granular chain-level status \u2014 the WS view exposes the same\nstring. The CCXT view at `OrderResponse.status` collapses these\ninto open | closed | canceled. `unknown` is the fallback for a\nchain code the API doesn't recognize.\n"
28351
28664
  ),
28352
28665
  chain_type: zod.enum(["limit", "market", "twap", "unknown"]).describe(
28353
- "Granular chain-level order type. The CCXT view at\n`OrderResponse.type` collapses these into limit | market.\n`unknown` is the fallback for a chain code the API doesn't\nrecognize.\n"
28666
+ "Granular chain-level order type. Mirrors the dbindexer\n`orders.order_type` column (0=limit, 1=market, 2=twap). TWAP\nslice executions are stored as individual order rows and surface\nhere as `twap`. `unknown` is the fallback for a chain code the\nAPI doesn't recognize.\n"
28354
28667
  ),
28355
- close_reason: zod.string().nullish().describe(
28356
- "Free-form chain close reason for a terminal order \u2014 e.g.\n`completed`, `canceled`, `expired`, `ioc_canceled`, `self_trade`,\n`post_only_rejected`, `replaced`. Null while the order is still live.\n"
28668
+ close_reason: zod.string().nullable().describe(
28669
+ "Free-form chain close reason for a terminal order \u2014 e.g.\n`completed`, `canceled`, `expired`, `ioc_canceled`,\n`self_trade`, `post_only_rejected`, `replaced`. Null while the\norder is still live. Lets consumers tell an IOC-cancelled or\nself-trade-prevented close apart from the generic `canceled` close.\n"
28357
28670
  )
28358
28671
  }).describe(
28359
28672
  "Exchange-specific extension on `OrderResponse`. Mirrors the\n`info` map populated in `internal/domain/order/service.go`.\n"
@@ -28361,13 +28674,22 @@ var GetOrderResponse = zod.object({
28361
28674
  }).describe(
28362
28675
  "All numeric fields (price, amount, filled, remaining, cost,\nfee.cost, fee.rate, average, triggerPrice, stopPrice) are canonical\ndecimal strings.\n"
28363
28676
  );
28364
- var listMyTradesQueryLimitDefault = 50;
28677
+ var listMyTradesQueryLimitDefault = 100;
28365
28678
  var listMyTradesQueryLimitMax = 500;
28679
+ var listMyTradesQueryBeforeIndexMin = 0;
28680
+ var listMyTradesQueryBeforeIndexMax = 4294967295;
28366
28681
  var ListMyTradesQueryParams = zod.object({
28367
28682
  address: zod.string().describe("Blockchain address of the trader"),
28368
28683
  symbol: zod.string().optional().describe("Symbol to filter by (e.g., AULT/USDT)"),
28369
28684
  since: zod.number().optional().describe("Unix timestamp in milliseconds"),
28370
- limit: zod.number().min(1).max(listMyTradesQueryLimitMax).default(listMyTradesQueryLimitDefault)
28685
+ limit: zod.number().min(1).max(listMyTradesQueryLimitMax).default(listMyTradesQueryLimitDefault),
28686
+ cursor: zod.string().optional().describe(
28687
+ 'Opaque pagination cursor. Take it verbatim from the previous page\'s\n`X-Next-Cursor` header (or follow the `Link: rel="next"` URL) and\nrepeat every other query parameter; the cursor is bound to that\nfilter set and a different one is rejected with 400. `limit` may\nchange between pages. No `X-Next-Cursor` on a response means the\nfeed is exhausted. Clients must not build or parse cursors.\n'
28688
+ ),
28689
+ before_height: zod.number().min(1).optional().describe(
28690
+ "Deprecated in favour of `cursor`; still honoured, and ignored when\n`cursor` is also present.\n\nComposite pagination cursor, upper half. Returns only trades\nstrictly older (in feed order) than the row identified by\n(`before_height`, `before_index`) \u2014 take both values from the\nlast row's `info.block_height` / `info.event_index`. Must be\npassed together with `before_index`. Unlike `since`, the cursor\ncannot skip or repeat trades when many share one timestamp.\n"
28691
+ ),
28692
+ before_index: zod.number().min(listMyTradesQueryBeforeIndexMin).max(listMyTradesQueryBeforeIndexMax).optional().describe("Composite pagination cursor, lower half. See `before_height`.")
28371
28693
  });
28372
28694
  var listMyTradesResponsePriceRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
28373
28695
  var listMyTradesResponseAmountRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
@@ -28377,6 +28699,7 @@ var listMyTradesResponseFeeRateRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
28377
28699
  var listMyTradesResponseInfoAddressOneRegExp = new RegExp("^ault1[a-z0-9]{38,}$");
28378
28700
  var listMyTradesResponseInfoBlockHeightRegExp = new RegExp("^\\d+$");
28379
28701
  var listMyTradesResponseInfoEventIndexMin = 0;
28702
+ var listMyTradesResponseInfoEventIndexMax = 4294967295;
28380
28703
  var ListMyTradesResponseItem = zod.object({
28381
28704
  id: zod.string(),
28382
28705
  order: zod.string().nullish(),
@@ -28386,10 +28709,11 @@ var ListMyTradesResponseItem = zod.object({
28386
28709
  type: zod.union([
28387
28710
  zod.literal("limit"),
28388
28711
  zod.literal("market"),
28712
+ zod.literal("twap"),
28389
28713
  zod.literal("unknown"),
28390
28714
  zod.literal(null)
28391
28715
  ]).nullish().describe(
28392
- "Order type resolved via JOIN to orders table. Null if order not found. `unknown` is the fallback for a chain code the API doesn't recognize."
28716
+ "Order type resolved via JOIN to orders table. `twap` marks a TWAP slice execution (chain code 2). Null if order not found. `unknown` is the fallback for a chain code the API doesn't recognize."
28393
28717
  ),
28394
28718
  cloid: zod.string().nullish().describe(
28395
28719
  "Client order id (hex, 8 bytes) resolved via JOIN to orders table. Null when the order carried none, the row predates cloid indexing, or on the public trades feed (cloids are private to the orderer)."
@@ -28423,8 +28747,8 @@ var ListMyTradesResponseItem = zod.object({
28423
28747
  "Atto-precision amount the orderer received for this fill,\nsuffixed with the chain denom. Empty string when the chain did\nnot record this side.\n"
28424
28748
  ),
28425
28749
  block_height: zod.string().regex(listMyTradesResponseInfoBlockHeightRegExp).describe("Decimal-string block height for parity with the WS trade event."),
28426
- event_index: zod.number().min(listMyTradesResponseInfoEventIndexMin).describe(
28427
- "The trade's event position within its block. Together with\n`block_height` it is the row's composite pagination cursor for the\ntrade feed. `created_at` cannot serve this role because every trade\nin a block shares one timestamp.\n"
28750
+ event_index: zod.number().min(listMyTradesResponseInfoEventIndexMin).max(listMyTradesResponseInfoEventIndexMax).describe(
28751
+ "The trade's event position within its block. With `block_height`\nit forms the row's composite pagination cursor: pass the last\nrow's pair as `before_height`/`before_index` to fetch the next\n(older) page.\n"
28428
28752
  )
28429
28753
  }).describe(
28430
28754
  "Exchange-specific extension on `TradeResponse`. Mirrors the\n`Info` struct populated in `internal/domain/trade/service.go`.\n"
@@ -28453,12 +28777,17 @@ var GetOHLCVParams = zod.object({
28453
28777
  symbol: zod.string().describe("URL-encoded trading pair (e.g., `AULT%2FUSDT`)")
28454
28778
  });
28455
28779
  var getOHLCVQueryTimeframeDefault = `1m`;
28456
- var getOHLCVQueryLimitDefault = 100;
28780
+ var getOHLCVQueryLimitDefault = 500;
28457
28781
  var getOHLCVQueryLimitMax = 1e3;
28458
28782
  var GetOHLCVQueryParams = zod.object({
28459
28783
  timeframe: zod.string().default(getOHLCVQueryTimeframeDefault).describe("Timeframe: 1m, 5m, 15m, 30m, 1h, 4h, 1d. Also accepts TV format: 1, 5, 15, 60, 1D"),
28460
- limit: zod.number().min(1).max(getOHLCVQueryLimitMax).default(getOHLCVQueryLimitDefault),
28461
- since: zod.number().optional().describe("Unix timestamp in milliseconds")
28784
+ limit: zod.number().min(1).max(getOHLCVQueryLimitMax).default(getOHLCVQueryLimitDefault).describe(
28785
+ "Bars per page, oldest first within the page. Without `since` the\npage holds the newest `limit` bars and the cursor walks back in\ntime; with `since` it holds the first `limit` bars from `since`\nand the cursor walks forward.\n"
28786
+ ),
28787
+ since: zod.number().optional().describe("Unix timestamp in milliseconds"),
28788
+ cursor: zod.string().optional().describe(
28789
+ 'Opaque pagination cursor. Take it verbatim from the previous page\'s\n`X-Next-Cursor` header (or follow the `Link: rel="next"` URL) and\nrepeat every other query parameter; the cursor is bound to that\nfilter set and a different one is rejected with 400. `limit` may\nchange between pages. No `X-Next-Cursor` on a response means the\nfeed is exhausted. Clients must not build or parse cursors.\n'
28790
+ )
28462
28791
  });
28463
28792
  var GetOHLCVResponseItem = zod.tuple([
28464
28793
  zod.number().describe("timestamp in milliseconds"),
@@ -28536,7 +28865,7 @@ var GetUDFHistoryQueryParams = zod.object({
28536
28865
  resolution: zod.enum(["1", "5", "15", "30", "60", "1D", "1W", "1M"]),
28537
28866
  from: zod.number().describe("Unix seconds"),
28538
28867
  to: zod.number().describe("Unix seconds"),
28539
- countback: zod.number().min(1).max(getUDFHistoryQueryCountbackMax).optional()
28868
+ countback: zod.number().min(1).max(getUDFHistoryQueryCountbackMax).optional().describe("Values above 1000 are clamped to 1000 server-side.")
28540
28869
  });
28541
28870
  var GetUDFHistoryResponse = zod.object({
28542
28871
  s: zod.enum(["ok", "no_data", "error"]),
@@ -28550,7 +28879,7 @@ var GetUDFHistoryResponse = zod.object({
28550
28879
  nextTime: zod.number().optional().describe('Unix seconds of next available bar (when s = "no_data")')
28551
28880
  });
28552
28881
  var GetUDFQuotesQueryParams = zod.object({
28553
- symbols: zod.string().describe("Comma-separated list of symbols")
28882
+ symbols: zod.string().describe("Comma-separated list of symbols, at most 100 (400 above that)")
28554
28883
  });
28555
28884
  var GetUDFQuotesResponse = zod.object({
28556
28885
  s: zod.enum(["ok", "error"]),
@@ -28613,7 +28942,7 @@ function createDexWs(url, options) {
28613
28942
  }
28614
28943
 
28615
28944
  // src/index.ts
28616
- var SDK_VERSION = "0.6.0";
28945
+ var SDK_VERSION = "0.7.1";
28617
28946
  // Annotate the CommonJS export names for ESM import in node:
28618
28947
  0 && (module.exports = {
28619
28948
  AGENT_DEFAULTS,
@@ -28624,6 +28953,7 @@ var SDK_VERSION = "0.6.0";
28624
28953
  BondStatus,
28625
28954
  COIN_TYPE,
28626
28955
  DEFAULT_CHAIN_ID,
28956
+ DEFAULT_RETRYABLE_STATUSES,
28627
28957
  DexWsClient,
28628
28958
  EIP712_DOMAIN_TYPE,
28629
28959
  EIP712_MSG_TYPES,
@@ -28632,6 +28962,7 @@ var SDK_VERSION = "0.6.0";
28632
28962
  GetAllTickersResponse,
28633
28963
  GetBalanceQueryParams,
28634
28964
  GetBalanceResponse,
28965
+ GetDBReadyResponse,
28635
28966
  GetHealthResponse,
28636
28967
  GetLiveResponse,
28637
28968
  GetOHLCVParams,
@@ -28688,6 +29019,7 @@ var SDK_VERSION = "0.6.0";
28688
29019
  MarketType,
28689
29020
  MissingMsgResponseError,
28690
29021
  NETWORKS,
29022
+ NEXT_CURSOR_HEADER,
28691
29023
  NetworkError,
28692
29024
  ORDER_ID_LENGTH,
28693
29025
  OrderId,
@@ -28697,6 +29029,7 @@ var SDK_VERSION = "0.6.0";
28697
29029
  SDK_VERSION,
28698
29030
  SIGN_MODE_DIRECT,
28699
29031
  SIGN_MODE_LEGACY_AMINO_JSON,
29032
+ SIMULATION_PLACEHOLDER_PUBKEY,
28700
29033
  SearchUDFSymbolsQueryParams,
28701
29034
  SearchUDFSymbolsResponse,
28702
29035
  SearchUDFSymbolsResponseItem,
@@ -28706,6 +29039,7 @@ var SDK_VERSION = "0.6.0";
28706
29039
  TxConfirmationUnavailableError,
28707
29040
  TxError,
28708
29041
  TxNotConfirmedError,
29042
+ TxSimulationError,
28709
29043
  ValidatorStatus,
28710
29044
  WebSocketError,
28711
29045
  WithdrawRewardsPartialError,
@@ -28723,10 +29057,12 @@ var SDK_VERSION = "0.6.0";
28723
29057
  buildEip712TypedData,
28724
29058
  buildFetchOptions,
28725
29059
  bytesToBase64,
29060
+ collectPages,
28726
29061
  computeEvmFeesPerGas,
28727
29062
  computeFeeFreeGas,
28728
29063
  computeFeeFreeGasCompound,
28729
29064
  computeRequiredFee,
29065
+ computeSimulatedGas,
28730
29066
  cosmosDecToDecimalString,
28731
29067
  cosmosDecToProtoInt,
28732
29068
  createAccountCache,
@@ -28818,6 +29154,7 @@ var SDK_VERSION = "0.6.0";
28818
29154
  getTradeResponseFeeRateRegExp,
28819
29155
  getTradeResponseInfoAddressOneRegExp,
28820
29156
  getTradeResponseInfoBlockHeightRegExp,
29157
+ getTradeResponseInfoEventIndexMax,
28821
29158
  getTradeResponseInfoEventIndexMin,
28822
29159
  getTradeResponsePriceRegExp,
28823
29160
  getTradingFeesResponseMakerRegExp,
@@ -28828,9 +29165,13 @@ var SDK_VERSION = "0.6.0";
28828
29165
  isValidAultAddress,
28829
29166
  isValidEvmAddress,
28830
29167
  isValidValidatorAddress,
29168
+ listCurrenciesResponseInfoContractDecimalsMax,
29169
+ listCurrenciesResponseInfoContractDecimalsMin,
28831
29170
  listMarketsResponseInfoEscrowAddressOneRegExp,
28832
29171
  listMarketsResponseMakerRegExp,
28833
29172
  listMarketsResponseTakerRegExp,
29173
+ listMyTradesQueryBeforeIndexMax,
29174
+ listMyTradesQueryBeforeIndexMin,
28834
29175
  listMyTradesQueryLimitDefault,
28835
29176
  listMyTradesQueryLimitMax,
28836
29177
  listMyTradesResponseAmountRegExp,
@@ -28839,6 +29180,7 @@ var SDK_VERSION = "0.6.0";
28839
29180
  listMyTradesResponseFeeRateRegExp,
28840
29181
  listMyTradesResponseInfoAddressOneRegExp,
28841
29182
  listMyTradesResponseInfoBlockHeightRegExp,
29183
+ listMyTradesResponseInfoEventIndexMax,
28842
29184
  listMyTradesResponseInfoEventIndexMin,
28843
29185
  listMyTradesResponsePriceRegExp,
28844
29186
  listOrdersQueryAddressOneRegExp,
@@ -28856,6 +29198,8 @@ var SDK_VERSION = "0.6.0";
28856
29198
  listOrdersResponseInfoRemainingDepositRegExp,
28857
29199
  listOrdersResponsePriceRegExp,
28858
29200
  listOrdersResponseRemainingRegExp,
29201
+ listTradesQueryBeforeIndexMax,
29202
+ listTradesQueryBeforeIndexMin,
28859
29203
  listTradesQueryLimitDefault,
28860
29204
  listTradesQueryLimitMax,
28861
29205
  listTradesResponseAmountRegExp,
@@ -28864,6 +29208,7 @@ var SDK_VERSION = "0.6.0";
28864
29208
  listTradesResponseFeeRateRegExp,
28865
29209
  listTradesResponseInfoAddressOneRegExp,
28866
29210
  listTradesResponseInfoBlockHeightRegExp,
29211
+ listTradesResponseInfoEventIndexMax,
28867
29212
  listTradesResponseInfoEventIndexMin,
28868
29213
  listTradesResponsePriceRegExp,
28869
29214
  mergeManifests,
@@ -28871,6 +29216,7 @@ var SDK_VERSION = "0.6.0";
28871
29216
  normalizeSignature,
28872
29217
  normalizeSigner,
28873
29218
  normalizeTxHash,
29219
+ paginate,
28874
29220
  paginateAll,
28875
29221
  parseEvmChainIdFromCosmosChainId,
28876
29222
  pollTxInclusion,
@@ -28880,6 +29226,7 @@ var SDK_VERSION = "0.6.0";
28880
29226
  resolveSignerAddress,
28881
29227
  signAndBroadcastAgentTx,
28882
29228
  signAndBroadcastEip712,
29229
+ simulateTx,
28883
29230
  stripEip712Domain,
28884
29231
  toViemChain,
28885
29232
  validateEip712FieldOrder,