ault-sdk-ts 0.0.2-alpha.26 → 0.0.2-alpha.27

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.js CHANGED
@@ -2585,6 +2585,192 @@ function createBankApi(context) {
2585
2585
  };
2586
2586
  }
2587
2587
 
2588
+ // src/utils/opaque-id.ts
2589
+ import { hexToBytes as viemHexToBytes, bytesToHex as viemBytesToHex } from "viem";
2590
+ function decodeHex(input) {
2591
+ const clean = input.startsWith("0x") || input.startsWith("0X") ? input.slice(2) : input;
2592
+ if (clean.length % 2 !== 0) {
2593
+ throw new Error(`invalid hex length: "${input}"`);
2594
+ }
2595
+ if (clean.length > 0 && !/^[0-9a-fA-F]+$/.test(clean)) {
2596
+ throw new Error(`invalid hex characters: "${input}"`);
2597
+ }
2598
+ return viemHexToBytes(`0x${clean}`);
2599
+ }
2600
+ function encodeHex(bytes) {
2601
+ return viemBytesToHex(bytes).slice(2);
2602
+ }
2603
+ function bytesEqual(a, b) {
2604
+ if (a.length !== b.length) return false;
2605
+ for (let i = 0; i < a.length; i++) {
2606
+ if (a[i] !== b[i]) return false;
2607
+ }
2608
+ return true;
2609
+ }
2610
+ var OpaqueId = class {
2611
+ constructor(bytes) {
2612
+ this.bytes = bytes;
2613
+ }
2614
+ toBytes() {
2615
+ return new Uint8Array(this.bytes);
2616
+ }
2617
+ toHex() {
2618
+ return encodeHex(this.bytes);
2619
+ }
2620
+ toBase64() {
2621
+ return bytesToBase64(this.bytes);
2622
+ }
2623
+ toString() {
2624
+ return this.toHex();
2625
+ }
2626
+ equalsBytes(other) {
2627
+ return bytesEqual(this.bytes, other.bytes);
2628
+ }
2629
+ };
2630
+ var MarketId = class _MarketId extends OpaqueId {
2631
+ static fromHex(hex) {
2632
+ return new _MarketId(_MarketId.assertNonEmpty(decodeHex(hex), `hex "${hex}"`));
2633
+ }
2634
+ static fromBase64(b64) {
2635
+ return new _MarketId(_MarketId.assertNonEmpty(base64ToBytes(b64), `base64 "${b64}"`));
2636
+ }
2637
+ static fromBytes(bytes) {
2638
+ return new _MarketId(_MarketId.assertNonEmpty(new Uint8Array(bytes), "bytes"));
2639
+ }
2640
+ static assertNonEmpty(bytes, source) {
2641
+ if (bytes.length === 0) {
2642
+ throw new Error(`MarketId: empty bytes from ${source}`);
2643
+ }
2644
+ return bytes;
2645
+ }
2646
+ equals(other) {
2647
+ return this.equalsBytes(other);
2648
+ }
2649
+ };
2650
+ var ORDER_ID_LENGTH = 16;
2651
+ var OrderId = class _OrderId extends OpaqueId {
2652
+ static fromHex(hex) {
2653
+ return new _OrderId(_OrderId.assertLength(decodeHex(hex), `hex "${hex}"`));
2654
+ }
2655
+ static fromBase64(b64) {
2656
+ return new _OrderId(_OrderId.assertLength(base64ToBytes(b64), `base64 "${b64}"`));
2657
+ }
2658
+ static fromBytes(bytes) {
2659
+ return new _OrderId(_OrderId.assertLength(new Uint8Array(bytes), "bytes"));
2660
+ }
2661
+ static assertLength(bytes, source) {
2662
+ if (bytes.length !== ORDER_ID_LENGTH) {
2663
+ throw new Error(
2664
+ `OrderId: expected ${ORDER_ID_LENGTH} bytes (chain layout), got ${bytes.length} from ${source}`
2665
+ );
2666
+ }
2667
+ return bytes;
2668
+ }
2669
+ equals(other) {
2670
+ return this.equalsBytes(other);
2671
+ }
2672
+ };
2673
+
2674
+ // src/core/cloid.ts
2675
+ var CLOID_BYTE_LENGTH = 8;
2676
+ var ORDER_ID_BYTE_LENGTH = ORDER_ID_LENGTH;
2677
+ function assertCloid(cloid) {
2678
+ if (cloid.length !== CLOID_BYTE_LENGTH) {
2679
+ throw new Error(`cloid must be exactly ${CLOID_BYTE_LENGTH} bytes, got ${cloid.length}`);
2680
+ }
2681
+ }
2682
+ function assertOrderRef(ref) {
2683
+ if (ref.length !== CLOID_BYTE_LENGTH && ref.length !== ORDER_ID_BYTE_LENGTH) {
2684
+ throw new Error(
2685
+ `cancel ref must be ${CLOID_BYTE_LENGTH} bytes (cloid) or ${ORDER_ID_BYTE_LENGTH} bytes (order_id), got ${ref.length}`
2686
+ );
2687
+ }
2688
+ }
2689
+
2690
+ // src/utils/address.ts
2691
+ import { fromBech32, toBech32, fromHex, toHex } from "@cosmjs/encoding";
2692
+ import { getAddress, isAddress } from "viem";
2693
+ function evmToAult(evmAddress) {
2694
+ const hex = evmAddress.toLowerCase().replace("0x", "");
2695
+ const bytes = fromHex(hex);
2696
+ return toBech32("ault", bytes);
2697
+ }
2698
+ function aultToEvm(aultAddress) {
2699
+ const { data } = fromBech32(aultAddress);
2700
+ return getAddress(`0x${toHex(data)}`);
2701
+ }
2702
+ function isValidAultAddress(address) {
2703
+ try {
2704
+ const { prefix, data } = fromBech32(address);
2705
+ return prefix === "ault" && data.length === 20;
2706
+ } catch {
2707
+ return false;
2708
+ }
2709
+ }
2710
+ function isValidEvmAddress(address) {
2711
+ if (!/^0[xX][a-fA-F0-9]{40}$/.test(address)) return false;
2712
+ const normalized = `0x${address.slice(2)}`;
2713
+ const body = normalized.slice(2);
2714
+ const allLower = body === body.toLowerCase();
2715
+ const allUpper = body === body.toUpperCase();
2716
+ if (allLower || allUpper) return true;
2717
+ return isAddress(normalized, { strict: true });
2718
+ }
2719
+ function addressEquals(a, b) {
2720
+ const ab = addressBytes(a);
2721
+ const bb = addressBytes(b);
2722
+ if (!ab || !bb || ab.length !== bb.length) return false;
2723
+ for (let i = 0; i < ab.length; i++) {
2724
+ if (ab[i] !== bb[i]) return false;
2725
+ }
2726
+ return true;
2727
+ }
2728
+ function addressBytes(s) {
2729
+ if (!s) return null;
2730
+ if (s.startsWith("0x") || s.startsWith("0X")) {
2731
+ const body = s.slice(2);
2732
+ if (!/^[a-fA-F0-9]+$/.test(body) || body.length !== 40) return null;
2733
+ return fromHex(body.toLowerCase());
2734
+ }
2735
+ try {
2736
+ const { data } = fromBech32(s);
2737
+ return data;
2738
+ } catch {
2739
+ return null;
2740
+ }
2741
+ }
2742
+ function isValidValidatorAddress(address) {
2743
+ try {
2744
+ const { prefix, data } = fromBech32(address);
2745
+ return prefix === "aultvaloper" && data.length === 20;
2746
+ } catch {
2747
+ return false;
2748
+ }
2749
+ }
2750
+ function assertValidatorAddress(address) {
2751
+ if (isValidValidatorAddress(address)) {
2752
+ return address;
2753
+ }
2754
+ throw new Error(`Invalid validator address format: ${address}`);
2755
+ }
2756
+
2757
+ // src/core/address.ts
2758
+ function normalizeAddress(address) {
2759
+ if (isValidAultAddress(address)) {
2760
+ return address;
2761
+ }
2762
+ if (isValidEvmAddress(address)) {
2763
+ return evmToAult(address);
2764
+ }
2765
+ throw new Error(`Invalid address format: ${address}`);
2766
+ }
2767
+ function normalizeAddresses(addresses) {
2768
+ return addresses.map(normalizeAddress);
2769
+ }
2770
+ function toBigInt(value) {
2771
+ return typeof value === "bigint" ? value : BigInt(value);
2772
+ }
2773
+
2588
2774
  // src/proto/gen/ault/clob/v1/query.ts
2589
2775
  import { BinaryReader as BinaryReader16, BinaryWriter as BinaryWriter16 } from "@bufbuild/protobuf/wire";
2590
2776
 
@@ -3050,7 +3236,8 @@ function createBaseOrderResponse() {
3050
3236
  remainingDeposit: "",
3051
3237
  deadline: void 0,
3052
3238
  postOnly: false,
3053
- feeInfo: void 0
3239
+ feeInfo: void 0,
3240
+ cloid: new Uint8Array(0)
3054
3241
  };
3055
3242
  }
3056
3243
  var OrderResponse = {
@@ -3094,6 +3281,9 @@ var OrderResponse = {
3094
3281
  if (message.feeInfo !== void 0) {
3095
3282
  FeeInfo.encode(message.feeInfo, writer.uint32(98).fork()).join();
3096
3283
  }
3284
+ if (message.cloid.length !== 0) {
3285
+ writer.uint32(106).bytes(message.cloid);
3286
+ }
3097
3287
  return writer;
3098
3288
  },
3099
3289
  decode(input, length) {
@@ -3187,6 +3377,13 @@ var OrderResponse = {
3187
3377
  message.feeInfo = FeeInfo.decode(reader, reader.uint32());
3188
3378
  continue;
3189
3379
  }
3380
+ case 13: {
3381
+ if (tag !== 106) {
3382
+ break;
3383
+ }
3384
+ message.cloid = reader.bytes();
3385
+ continue;
3386
+ }
3190
3387
  }
3191
3388
  if ((tag & 7) === 4 || tag === 0) {
3192
3389
  break;
@@ -3208,7 +3405,8 @@ var OrderResponse = {
3208
3405
  remainingDeposit: isSet15(object2.remainingDeposit) ? globalThis.String(object2.remainingDeposit) : isSet15(object2.remaining_deposit) ? globalThis.String(object2.remaining_deposit) : "",
3209
3406
  deadline: isSet15(object2.deadline) ? fromJsonTimestamp2(object2.deadline) : void 0,
3210
3407
  postOnly: isSet15(object2.postOnly) ? globalThis.Boolean(object2.postOnly) : isSet15(object2.post_only) ? globalThis.Boolean(object2.post_only) : false,
3211
- feeInfo: isSet15(object2.feeInfo) ? FeeInfo.fromJSON(object2.feeInfo) : isSet15(object2.fee_info) ? FeeInfo.fromJSON(object2.fee_info) : void 0
3408
+ feeInfo: isSet15(object2.feeInfo) ? FeeInfo.fromJSON(object2.feeInfo) : isSet15(object2.fee_info) ? FeeInfo.fromJSON(object2.fee_info) : void 0,
3409
+ cloid: isSet15(object2.cloid) ? bytesFromBase644(object2.cloid) : new Uint8Array(0)
3212
3410
  };
3213
3411
  },
3214
3412
  toJSON(message) {
@@ -3249,6 +3447,9 @@ var OrderResponse = {
3249
3447
  if (message.feeInfo !== void 0) {
3250
3448
  obj.feeInfo = FeeInfo.toJSON(message.feeInfo);
3251
3449
  }
3450
+ if (message.cloid.length !== 0) {
3451
+ obj.cloid = base64FromBytes4(message.cloid);
3452
+ }
3252
3453
  return obj;
3253
3454
  },
3254
3455
  create(base) {
@@ -3268,6 +3469,7 @@ var OrderResponse = {
3268
3469
  message.deadline = object2.deadline ?? void 0;
3269
3470
  message.postOnly = object2.postOnly ?? false;
3270
3471
  message.feeInfo = object2.feeInfo !== void 0 && object2.feeInfo !== null ? FeeInfo.fromPartial(object2.feeInfo) : void 0;
3472
+ message.cloid = object2.cloid ?? new Uint8Array(0);
3271
3473
  return message;
3272
3474
  }
3273
3475
  };
@@ -3336,6 +3538,20 @@ function createClobApi(context) {
3336
3538
  QueryOrderResponse
3337
3539
  );
3338
3540
  },
3541
+ async getOrderByCloid(orderer, cloid) {
3542
+ assertCloid(cloid);
3543
+ const path = `/ault/clob/v1/orders/by-cloid/${encodeURIComponent(
3544
+ normalizeAddress(orderer)
3545
+ )}/${encodeURIComponent(bytesToBase64(cloid))}`;
3546
+ try {
3547
+ return await fetchProtoJson(context, path, QueryOrderResponse);
3548
+ } catch (err) {
3549
+ if (err instanceof ApiError && err.status === 404) {
3550
+ return { order: void 0 };
3551
+ }
3552
+ throw err;
3553
+ }
3554
+ },
3339
3555
  async getOrders(params = {}) {
3340
3556
  const query = buildQuery({
3341
3557
  market_id: params.marketId ? normalizeMarketId(params.marketId) : void 0,
@@ -10478,6 +10694,8 @@ __export(dex_generated_exports, {
10478
10694
  OrderResponseSide: () => OrderResponseSide,
10479
10695
  OrderResponseStatus: () => OrderResponseStatus,
10480
10696
  OrderResponseType: () => OrderResponseType,
10697
+ RangeQueryDayParameter: () => RangeQueryDayParameter,
10698
+ RangeQueryParameter: () => RangeQueryParameter,
10481
10699
  ReadyResponseStatus: () => ReadyResponseStatus,
10482
10700
  StatsResponseWindow: () => StatsResponseWindow,
10483
10701
  TradeResponseSide: () => TradeResponseSide,
@@ -10586,7 +10804,8 @@ var TradeResponseSide = {
10586
10804
  sell: "sell"
10587
10805
  };
10588
10806
  var TradeResponseTakerOrMaker = {
10589
- taker: "taker"
10807
+ taker: "taker",
10808
+ maker: "maker"
10590
10809
  };
10591
10810
  var OrderResponseStatus = {
10592
10811
  open: "open",
@@ -10620,6 +10839,18 @@ var UDFQuoteDataS = {
10620
10839
  ok: "ok",
10621
10840
  error: "error"
10622
10841
  };
10842
+ var RangeQueryParameter = {
10843
+ day: "day",
10844
+ week: "week",
10845
+ month: "month",
10846
+ allTime: "allTime"
10847
+ };
10848
+ var RangeQueryDayParameter = {
10849
+ day: "day",
10850
+ week: "week",
10851
+ month: "month",
10852
+ allTime: "allTime"
10853
+ };
10623
10854
  var GetStatsWindow = {
10624
10855
  "24h": "24h"
10625
10856
  };
@@ -11043,73 +11274,6 @@ function createDexApi(context) {
11043
11274
  };
11044
11275
  }
11045
11276
 
11046
- // src/utils/address.ts
11047
- import { fromBech32, toBech32, fromHex, toHex } from "@cosmjs/encoding";
11048
- import { getAddress, isAddress } from "viem";
11049
- function evmToAult(evmAddress) {
11050
- const hex = evmAddress.toLowerCase().replace("0x", "");
11051
- const bytes = fromHex(hex);
11052
- return toBech32("ault", bytes);
11053
- }
11054
- function aultToEvm(aultAddress) {
11055
- const { data } = fromBech32(aultAddress);
11056
- return getAddress(`0x${toHex(data)}`);
11057
- }
11058
- function isValidAultAddress(address) {
11059
- try {
11060
- const { prefix, data } = fromBech32(address);
11061
- return prefix === "ault" && data.length === 20;
11062
- } catch {
11063
- return false;
11064
- }
11065
- }
11066
- function isValidEvmAddress(address) {
11067
- if (!/^0[xX][a-fA-F0-9]{40}$/.test(address)) return false;
11068
- const normalized = `0x${address.slice(2)}`;
11069
- const body = normalized.slice(2);
11070
- const allLower = body === body.toLowerCase();
11071
- const allUpper = body === body.toUpperCase();
11072
- if (allLower || allUpper) return true;
11073
- return isAddress(normalized, { strict: true });
11074
- }
11075
- function addressEquals(a, b) {
11076
- const ab = addressBytes(a);
11077
- const bb = addressBytes(b);
11078
- if (!ab || !bb || ab.length !== bb.length) return false;
11079
- for (let i = 0; i < ab.length; i++) {
11080
- if (ab[i] !== bb[i]) return false;
11081
- }
11082
- return true;
11083
- }
11084
- function addressBytes(s) {
11085
- if (!s) return null;
11086
- if (s.startsWith("0x") || s.startsWith("0X")) {
11087
- const body = s.slice(2);
11088
- if (!/^[a-fA-F0-9]+$/.test(body) || body.length !== 40) return null;
11089
- return fromHex(body.toLowerCase());
11090
- }
11091
- try {
11092
- const { data } = fromBech32(s);
11093
- return data;
11094
- } catch {
11095
- return null;
11096
- }
11097
- }
11098
- function isValidValidatorAddress(address) {
11099
- try {
11100
- const { prefix, data } = fromBech32(address);
11101
- return prefix === "aultvaloper" && data.length === 20;
11102
- } catch {
11103
- return false;
11104
- }
11105
- }
11106
- function assertValidatorAddress(address) {
11107
- if (isValidValidatorAddress(address)) {
11108
- return address;
11109
- }
11110
- throw new Error(`Invalid validator address format: ${address}`);
11111
- }
11112
-
11113
11277
  // src/ws/client.ts
11114
11278
  import { toHex as toHex2 } from "@cosmjs/encoding";
11115
11279
  var NORMAL_CLOSURE = 1e3;
@@ -12325,14 +12489,16 @@ var EIP712_MSG_TYPES = {
12325
12489
  { name: "market_id", type: "string", jsName: "marketId" },
12326
12490
  { name: "is_buy", type: "bool", jsName: "isBuy" },
12327
12491
  { name: "deadline", type: "string" },
12492
+ { name: "cloid", type: "string" },
12328
12493
  { name: "builder_fee_rate", type: "string", jsName: "builderFeeRate" },
12329
12494
  { name: "builder_address", type: "string", jsName: "builderAddress" }
12330
12495
  ],
12331
12496
  timestampFields: ["deadline"],
12332
- optionalFields: ["builder_address", "builder_fee_rate"],
12497
+ optionalFields: ["builder_address", "builder_fee_rate", "cloid"],
12333
12498
  fieldSemantics: {
12334
12499
  builder_address: { isAddress: true },
12335
12500
  builder_fee_rate: { isLegacyDec: true },
12501
+ cloid: { isBinary: true },
12336
12502
  market_id: { isBinary: true },
12337
12503
  price: { isLegacyDec: true },
12338
12504
  quantity: { isLegacyDec: true }
@@ -12348,13 +12514,21 @@ var EIP712_MSG_TYPES = {
12348
12514
  { name: "market_id", type: "string", jsName: "marketId" },
12349
12515
  { name: "is_buy", type: "bool", jsName: "isBuy" },
12350
12516
  { name: "deposit", type: "string" },
12517
+ { name: "cloid", type: "string" },
12351
12518
  { name: "builder_fee_rate", type: "string", jsName: "builderFeeRate" },
12352
12519
  { name: "builder_address", type: "string", jsName: "builderAddress" }
12353
12520
  ],
12354
- optionalFields: ["builder_address", "builder_fee_rate", "price_tolerance", "worst_price"],
12521
+ optionalFields: [
12522
+ "builder_address",
12523
+ "builder_fee_rate",
12524
+ "cloid",
12525
+ "price_tolerance",
12526
+ "worst_price"
12527
+ ],
12355
12528
  fieldSemantics: {
12356
12529
  builder_address: { isAddress: true },
12357
12530
  builder_fee_rate: { isLegacyDec: true },
12531
+ cloid: { isBinary: true },
12358
12532
  deposit: { isLegacyDec: true },
12359
12533
  market_id: { isBinary: true },
12360
12534
  price_tolerance: { isLegacyDec: true },
@@ -13884,6 +14058,9 @@ function mapValueToAmino(value, fields, nestedTypes, durationFields, timestampFi
13884
14058
  if (field.type === "string" && raw === "") {
13885
14059
  continue;
13886
14060
  }
14061
+ if (raw instanceof Uint8Array && raw.length === 0) {
14062
+ continue;
14063
+ }
13887
14064
  if (field.type.endsWith("[]") && Array.isArray(raw) && raw.length === 0) {
13888
14065
  continue;
13889
14066
  }
@@ -15144,7 +15321,8 @@ function createBaseMsgPlaceLimitOrder() {
15144
15321
  deadline: void 0,
15145
15322
  postOnly: false,
15146
15323
  builderAddress: "",
15147
- builderFeeRate: ""
15324
+ builderFeeRate: "",
15325
+ cloid: new Uint8Array(0)
15148
15326
  };
15149
15327
  }
15150
15328
  var MsgPlaceLimitOrder = {
@@ -15176,6 +15354,9 @@ var MsgPlaceLimitOrder = {
15176
15354
  if (message.builderFeeRate !== "") {
15177
15355
  writer.uint32(74).string(message.builderFeeRate);
15178
15356
  }
15357
+ if (message.cloid.length !== 0) {
15358
+ writer.uint32(82).bytes(message.cloid);
15359
+ }
15179
15360
  return writer;
15180
15361
  },
15181
15362
  decode(input, length) {
@@ -15248,6 +15429,13 @@ var MsgPlaceLimitOrder = {
15248
15429
  message.builderFeeRate = reader.string();
15249
15430
  continue;
15250
15431
  }
15432
+ case 10: {
15433
+ if (tag !== 82) {
15434
+ break;
15435
+ }
15436
+ message.cloid = reader.bytes();
15437
+ continue;
15438
+ }
15251
15439
  }
15252
15440
  if ((tag & 7) === 4 || tag === 0) {
15253
15441
  break;
@@ -15266,7 +15454,8 @@ var MsgPlaceLimitOrder = {
15266
15454
  deadline: isSet35(object2.deadline) ? fromJsonTimestamp7(object2.deadline) : void 0,
15267
15455
  postOnly: isSet35(object2.postOnly) ? globalThis.Boolean(object2.postOnly) : isSet35(object2.post_only) ? globalThis.Boolean(object2.post_only) : false,
15268
15456
  builderAddress: isSet35(object2.builderAddress) ? globalThis.String(object2.builderAddress) : isSet35(object2.builder_address) ? globalThis.String(object2.builder_address) : "",
15269
- builderFeeRate: isSet35(object2.builderFeeRate) ? globalThis.String(object2.builderFeeRate) : isSet35(object2.builder_fee_rate) ? globalThis.String(object2.builder_fee_rate) : ""
15457
+ builderFeeRate: isSet35(object2.builderFeeRate) ? globalThis.String(object2.builderFeeRate) : isSet35(object2.builder_fee_rate) ? globalThis.String(object2.builder_fee_rate) : "",
15458
+ cloid: isSet35(object2.cloid) ? bytesFromBase648(object2.cloid) : new Uint8Array(0)
15270
15459
  };
15271
15460
  },
15272
15461
  toJSON(message) {
@@ -15298,6 +15487,9 @@ var MsgPlaceLimitOrder = {
15298
15487
  if (message.builderFeeRate !== "") {
15299
15488
  obj.builderFeeRate = message.builderFeeRate;
15300
15489
  }
15490
+ if (message.cloid.length !== 0) {
15491
+ obj.cloid = base64FromBytes8(message.cloid);
15492
+ }
15301
15493
  return obj;
15302
15494
  },
15303
15495
  create(base) {
@@ -15314,11 +15506,12 @@ var MsgPlaceLimitOrder = {
15314
15506
  message.postOnly = object2.postOnly ?? false;
15315
15507
  message.builderAddress = object2.builderAddress ?? "";
15316
15508
  message.builderFeeRate = object2.builderFeeRate ?? "";
15509
+ message.cloid = object2.cloid ?? new Uint8Array(0);
15317
15510
  return message;
15318
15511
  }
15319
15512
  };
15320
15513
  function createBaseMsgPlaceLimitOrderResponse() {
15321
- return { orderId: new Uint8Array(0), escrowedAmount: void 0 };
15514
+ return { orderId: new Uint8Array(0), escrowedAmount: void 0, cloid: new Uint8Array(0) };
15322
15515
  }
15323
15516
  var MsgPlaceLimitOrderResponse = {
15324
15517
  encode(message, writer = new BinaryWriter38()) {
@@ -15328,6 +15521,9 @@ var MsgPlaceLimitOrderResponse = {
15328
15521
  if (message.escrowedAmount !== void 0) {
15329
15522
  Coin.encode(message.escrowedAmount, writer.uint32(18).fork()).join();
15330
15523
  }
15524
+ if (message.cloid.length !== 0) {
15525
+ writer.uint32(26).bytes(message.cloid);
15526
+ }
15331
15527
  return writer;
15332
15528
  },
15333
15529
  decode(input, length) {
@@ -15351,6 +15547,13 @@ var MsgPlaceLimitOrderResponse = {
15351
15547
  message.escrowedAmount = Coin.decode(reader, reader.uint32());
15352
15548
  continue;
15353
15549
  }
15550
+ case 3: {
15551
+ if (tag !== 26) {
15552
+ break;
15553
+ }
15554
+ message.cloid = reader.bytes();
15555
+ continue;
15556
+ }
15354
15557
  }
15355
15558
  if ((tag & 7) === 4 || tag === 0) {
15356
15559
  break;
@@ -15362,7 +15565,8 @@ var MsgPlaceLimitOrderResponse = {
15362
15565
  fromJSON(object2) {
15363
15566
  return {
15364
15567
  orderId: isSet35(object2.orderId) ? bytesFromBase648(object2.orderId) : isSet35(object2.order_id) ? bytesFromBase648(object2.order_id) : new Uint8Array(0),
15365
- escrowedAmount: isSet35(object2.escrowedAmount) ? Coin.fromJSON(object2.escrowedAmount) : isSet35(object2.escrowed_amount) ? Coin.fromJSON(object2.escrowed_amount) : void 0
15568
+ escrowedAmount: isSet35(object2.escrowedAmount) ? Coin.fromJSON(object2.escrowedAmount) : isSet35(object2.escrowed_amount) ? Coin.fromJSON(object2.escrowed_amount) : void 0,
15569
+ cloid: isSet35(object2.cloid) ? bytesFromBase648(object2.cloid) : new Uint8Array(0)
15366
15570
  };
15367
15571
  },
15368
15572
  toJSON(message) {
@@ -15373,6 +15577,9 @@ var MsgPlaceLimitOrderResponse = {
15373
15577
  if (message.escrowedAmount !== void 0) {
15374
15578
  obj.escrowedAmount = Coin.toJSON(message.escrowedAmount);
15375
15579
  }
15580
+ if (message.cloid.length !== 0) {
15581
+ obj.cloid = base64FromBytes8(message.cloid);
15582
+ }
15376
15583
  return obj;
15377
15584
  },
15378
15585
  create(base) {
@@ -15382,6 +15589,7 @@ var MsgPlaceLimitOrderResponse = {
15382
15589
  const message = createBaseMsgPlaceLimitOrderResponse();
15383
15590
  message.orderId = object2.orderId ?? new Uint8Array(0);
15384
15591
  message.escrowedAmount = object2.escrowedAmount !== void 0 && object2.escrowedAmount !== null ? Coin.fromPartial(object2.escrowedAmount) : void 0;
15592
+ message.cloid = object2.cloid ?? new Uint8Array(0);
15385
15593
  return message;
15386
15594
  }
15387
15595
  };
@@ -15394,7 +15602,8 @@ function createBaseMsgPlaceMarketOrder() {
15394
15602
  worstPrice: "",
15395
15603
  priceTolerance: "",
15396
15604
  builderAddress: "",
15397
- builderFeeRate: ""
15605
+ builderFeeRate: "",
15606
+ cloid: new Uint8Array(0)
15398
15607
  };
15399
15608
  }
15400
15609
  var MsgPlaceMarketOrder = {
@@ -15423,6 +15632,9 @@ var MsgPlaceMarketOrder = {
15423
15632
  if (message.builderFeeRate !== "") {
15424
15633
  writer.uint32(66).string(message.builderFeeRate);
15425
15634
  }
15635
+ if (message.cloid.length !== 0) {
15636
+ writer.uint32(74).bytes(message.cloid);
15637
+ }
15426
15638
  return writer;
15427
15639
  },
15428
15640
  decode(input, length) {
@@ -15488,6 +15700,13 @@ var MsgPlaceMarketOrder = {
15488
15700
  message.builderFeeRate = reader.string();
15489
15701
  continue;
15490
15702
  }
15703
+ case 9: {
15704
+ if (tag !== 74) {
15705
+ break;
15706
+ }
15707
+ message.cloid = reader.bytes();
15708
+ continue;
15709
+ }
15491
15710
  }
15492
15711
  if ((tag & 7) === 4 || tag === 0) {
15493
15712
  break;
@@ -15505,7 +15724,8 @@ var MsgPlaceMarketOrder = {
15505
15724
  worstPrice: isSet35(object2.worstPrice) ? globalThis.String(object2.worstPrice) : isSet35(object2.worst_price) ? globalThis.String(object2.worst_price) : "",
15506
15725
  priceTolerance: isSet35(object2.priceTolerance) ? globalThis.String(object2.priceTolerance) : isSet35(object2.price_tolerance) ? globalThis.String(object2.price_tolerance) : "",
15507
15726
  builderAddress: isSet35(object2.builderAddress) ? globalThis.String(object2.builderAddress) : isSet35(object2.builder_address) ? globalThis.String(object2.builder_address) : "",
15508
- builderFeeRate: isSet35(object2.builderFeeRate) ? globalThis.String(object2.builderFeeRate) : isSet35(object2.builder_fee_rate) ? globalThis.String(object2.builder_fee_rate) : ""
15727
+ builderFeeRate: isSet35(object2.builderFeeRate) ? globalThis.String(object2.builderFeeRate) : isSet35(object2.builder_fee_rate) ? globalThis.String(object2.builder_fee_rate) : "",
15728
+ cloid: isSet35(object2.cloid) ? bytesFromBase648(object2.cloid) : new Uint8Array(0)
15509
15729
  };
15510
15730
  },
15511
15731
  toJSON(message) {
@@ -15534,6 +15754,9 @@ var MsgPlaceMarketOrder = {
15534
15754
  if (message.builderFeeRate !== "") {
15535
15755
  obj.builderFeeRate = message.builderFeeRate;
15536
15756
  }
15757
+ if (message.cloid.length !== 0) {
15758
+ obj.cloid = base64FromBytes8(message.cloid);
15759
+ }
15537
15760
  return obj;
15538
15761
  },
15539
15762
  create(base) {
@@ -15549,11 +15772,12 @@ var MsgPlaceMarketOrder = {
15549
15772
  message.priceTolerance = object2.priceTolerance ?? "";
15550
15773
  message.builderAddress = object2.builderAddress ?? "";
15551
15774
  message.builderFeeRate = object2.builderFeeRate ?? "";
15775
+ message.cloid = object2.cloid ?? new Uint8Array(0);
15552
15776
  return message;
15553
15777
  }
15554
15778
  };
15555
15779
  function createBaseMsgPlaceMarketOrderResponse() {
15556
- return { orderId: new Uint8Array(0), escrowedAmount: void 0 };
15780
+ return { orderId: new Uint8Array(0), escrowedAmount: void 0, cloid: new Uint8Array(0) };
15557
15781
  }
15558
15782
  var MsgPlaceMarketOrderResponse = {
15559
15783
  encode(message, writer = new BinaryWriter38()) {
@@ -15563,6 +15787,9 @@ var MsgPlaceMarketOrderResponse = {
15563
15787
  if (message.escrowedAmount !== void 0) {
15564
15788
  Coin.encode(message.escrowedAmount, writer.uint32(18).fork()).join();
15565
15789
  }
15790
+ if (message.cloid.length !== 0) {
15791
+ writer.uint32(26).bytes(message.cloid);
15792
+ }
15566
15793
  return writer;
15567
15794
  },
15568
15795
  decode(input, length) {
@@ -15586,6 +15813,13 @@ var MsgPlaceMarketOrderResponse = {
15586
15813
  message.escrowedAmount = Coin.decode(reader, reader.uint32());
15587
15814
  continue;
15588
15815
  }
15816
+ case 3: {
15817
+ if (tag !== 26) {
15818
+ break;
15819
+ }
15820
+ message.cloid = reader.bytes();
15821
+ continue;
15822
+ }
15589
15823
  }
15590
15824
  if ((tag & 7) === 4 || tag === 0) {
15591
15825
  break;
@@ -15597,7 +15831,8 @@ var MsgPlaceMarketOrderResponse = {
15597
15831
  fromJSON(object2) {
15598
15832
  return {
15599
15833
  orderId: isSet35(object2.orderId) ? bytesFromBase648(object2.orderId) : isSet35(object2.order_id) ? bytesFromBase648(object2.order_id) : new Uint8Array(0),
15600
- escrowedAmount: isSet35(object2.escrowedAmount) ? Coin.fromJSON(object2.escrowedAmount) : isSet35(object2.escrowed_amount) ? Coin.fromJSON(object2.escrowed_amount) : void 0
15834
+ escrowedAmount: isSet35(object2.escrowedAmount) ? Coin.fromJSON(object2.escrowedAmount) : isSet35(object2.escrowed_amount) ? Coin.fromJSON(object2.escrowed_amount) : void 0,
15835
+ cloid: isSet35(object2.cloid) ? bytesFromBase648(object2.cloid) : new Uint8Array(0)
15601
15836
  };
15602
15837
  },
15603
15838
  toJSON(message) {
@@ -15608,6 +15843,9 @@ var MsgPlaceMarketOrderResponse = {
15608
15843
  if (message.escrowedAmount !== void 0) {
15609
15844
  obj.escrowedAmount = Coin.toJSON(message.escrowedAmount);
15610
15845
  }
15846
+ if (message.cloid.length !== 0) {
15847
+ obj.cloid = base64FromBytes8(message.cloid);
15848
+ }
15611
15849
  return obj;
15612
15850
  },
15613
15851
  create(base) {
@@ -15617,6 +15855,7 @@ var MsgPlaceMarketOrderResponse = {
15617
15855
  const message = createBaseMsgPlaceMarketOrderResponse();
15618
15856
  message.orderId = object2.orderId ?? new Uint8Array(0);
15619
15857
  message.escrowedAmount = object2.escrowedAmount !== void 0 && object2.escrowedAmount !== null ? Coin.fromPartial(object2.escrowedAmount) : void 0;
15858
+ message.cloid = object2.cloid ?? new Uint8Array(0);
15620
15859
  return message;
15621
15860
  }
15622
15861
  };
@@ -20961,7 +21200,8 @@ function mapAultClobV1MsgPlaceLimitOrder(input, label = "value") {
20961
21200
  builderAddress: requireStringOrDefault(record2["builderAddress"], `${prefix}builderAddress`),
20962
21201
  builderFeeRate: cosmosDecToProtoInt(
20963
21202
  requireStringOrDefault(record2["builderFeeRate"], `${prefix}builderFeeRate`)
20964
- )
21203
+ ),
21204
+ cloid: requireBytesOrDefault(record2["cloid"], `${prefix}cloid`)
20965
21205
  };
20966
21206
  }
20967
21207
  function mapAultClobV1MsgPlaceMarketOrder(input, label = "value") {
@@ -20981,7 +21221,8 @@ function mapAultClobV1MsgPlaceMarketOrder(input, label = "value") {
20981
21221
  builderAddress: requireStringOrDefault(record2["builderAddress"], `${prefix}builderAddress`),
20982
21222
  builderFeeRate: cosmosDecToProtoInt(
20983
21223
  requireStringOrDefault(record2["builderFeeRate"], `${prefix}builderFeeRate`)
20984
- )
21224
+ ),
21225
+ cloid: requireBytesOrDefault(record2["cloid"], `${prefix}cloid`)
20985
21226
  };
20986
21227
  }
20987
21228
  function mapAultClobV1MsgPlaceScaleOrder(input, label = "value") {
@@ -22369,23 +22610,6 @@ function autoDetectSigner(input) {
22369
22610
  );
22370
22611
  }
22371
22612
 
22372
- // src/core/address.ts
22373
- function normalizeAddress(address) {
22374
- if (isValidAultAddress(address)) {
22375
- return address;
22376
- }
22377
- if (isValidEvmAddress(address)) {
22378
- return evmToAult(address);
22379
- }
22380
- throw new Error(`Invalid address format: ${address}`);
22381
- }
22382
- function normalizeAddresses(addresses) {
22383
- return addresses.map(normalizeAddress);
22384
- }
22385
- function toBigInt(value) {
22386
- return typeof value === "bigint" ? value : BigInt(value);
22387
- }
22388
-
22389
22613
  // src/high-level/query-helpers.ts
22390
22614
  var BATCH_SIZE = 50;
22391
22615
  async function batchMap(items, fn) {
@@ -22475,6 +22699,43 @@ function createParallelQueryApi(lowLevel) {
22475
22699
  };
22476
22700
  }
22477
22701
 
22702
+ // src/high-level/cloid-lookup.ts
22703
+ import { fromHex as fromHex2, toHex as toHex3 } from "@cosmjs/encoding";
22704
+ function createCloidLookupApi(lowLevel) {
22705
+ async function findOrderByCloid(orderer, cloid) {
22706
+ const addr = normalizeAddress(orderer);
22707
+ const bytes = typeof cloid === "string" ? fromHex2(cloid) : cloid;
22708
+ assertCloid(bytes);
22709
+ const chain = await lowLevel.rest.clob.getOrderByCloid(addr, bytes);
22710
+ if (chain.order) {
22711
+ return { source: "chain", order: chain.order };
22712
+ }
22713
+ const wantHex = toHex3(bytes);
22714
+ const LIMIT = 200;
22715
+ const res = await lowLevel.rest.dex.listOrders({ address: addr, cloid: wantHex, limit: LIMIT });
22716
+ if (res.status !== 200) {
22717
+ throw new Error(`dex-api listOrders returned unexpected status ${res.status}`);
22718
+ }
22719
+ const orders = res.data.filter((o) => o.clientOrderId?.toLowerCase() === wantHex);
22720
+ if (orders.length === 0) {
22721
+ return { source: "none", order: null };
22722
+ }
22723
+ if (res.data.length >= LIMIT) {
22724
+ throw new Error(
22725
+ `cloid ${wantHex} has too many historical matches to disambiguate (>= ${LIMIT}); dex-api needs a canonical (orderer, cloid) latest lookup`
22726
+ );
22727
+ }
22728
+ const order = orders.reduce((latest, next) => {
22729
+ if (next.timestamp !== latest.timestamp) {
22730
+ return next.timestamp > latest.timestamp ? next : latest;
22731
+ }
22732
+ return next.id > latest.id ? next : latest;
22733
+ });
22734
+ return { source: "dex", order };
22735
+ }
22736
+ return { findOrderByCloid };
22737
+ }
22738
+
22478
22739
  // src/high-level/tx/accountx.ts
22479
22740
  function createAccountxTxApi({
22480
22741
  signerAddress,
@@ -22598,6 +22859,7 @@ function createAuthorityTxApi({ signerAddress, exec }) {
22598
22859
 
22599
22860
  // src/core/clob-msgs.ts
22600
22861
  function buildLimitOrderMsg(sender, params) {
22862
+ if (params.cloid !== void 0) assertCloid(params.cloid);
22601
22863
  return msg.clob.placeLimitOrder({
22602
22864
  sender,
22603
22865
  marketId: params.marketId,
@@ -22605,6 +22867,7 @@ function buildLimitOrderMsg(sender, params) {
22605
22867
  price: params.price,
22606
22868
  quantity: params.quantity,
22607
22869
  deadline: params.deadline,
22870
+ ...params.cloid !== void 0 && { cloid: params.cloid },
22608
22871
  ...params.postOnly !== void 0 && { postOnly: params.postOnly },
22609
22872
  ...params.builderAddress !== void 0 && {
22610
22873
  builderAddress: normalizeAddress(params.builderAddress)
@@ -22613,11 +22876,13 @@ function buildLimitOrderMsg(sender, params) {
22613
22876
  });
22614
22877
  }
22615
22878
  function buildMarketOrderMsg(sender, params) {
22879
+ if (params.cloid !== void 0) assertCloid(params.cloid);
22616
22880
  return msg.clob.placeMarketOrder({
22617
22881
  sender,
22618
22882
  marketId: params.marketId,
22619
22883
  isBuy: params.isBuy,
22620
22884
  deposit: params.deposit,
22885
+ ...params.cloid !== void 0 && { cloid: params.cloid },
22621
22886
  ...params.worstPrice !== void 0 && { worstPrice: params.worstPrice },
22622
22887
  ...params.priceTolerance !== void 0 && { priceTolerance: params.priceTolerance },
22623
22888
  ...params.builderAddress !== void 0 && {
@@ -22627,6 +22892,7 @@ function buildMarketOrderMsg(sender, params) {
22627
22892
  });
22628
22893
  }
22629
22894
  function buildCancelOrdersMsg(sender, orderIds) {
22895
+ for (const ref of orderIds) assertOrderRef(ref);
22630
22896
  return msg.clob.cancelOrders({ sender, orderIds });
22631
22897
  }
22632
22898
  function buildScaleOrderMsg(sender, params) {
@@ -22647,93 +22913,8 @@ function buildScaleOrderMsg(sender, params) {
22647
22913
  });
22648
22914
  }
22649
22915
 
22650
- // src/utils/opaque-id.ts
22651
- import { hexToBytes as viemHexToBytes, bytesToHex as viemBytesToHex } from "viem";
22652
- function decodeHex(input) {
22653
- const clean = input.startsWith("0x") || input.startsWith("0X") ? input.slice(2) : input;
22654
- if (clean.length % 2 !== 0) {
22655
- throw new Error(`invalid hex length: "${input}"`);
22656
- }
22657
- if (clean.length > 0 && !/^[0-9a-fA-F]+$/.test(clean)) {
22658
- throw new Error(`invalid hex characters: "${input}"`);
22659
- }
22660
- return viemHexToBytes(`0x${clean}`);
22661
- }
22662
- function encodeHex(bytes) {
22663
- return viemBytesToHex(bytes).slice(2);
22664
- }
22665
- function bytesEqual(a, b) {
22666
- if (a.length !== b.length) return false;
22667
- for (let i = 0; i < a.length; i++) {
22668
- if (a[i] !== b[i]) return false;
22669
- }
22670
- return true;
22671
- }
22672
- var OpaqueId = class {
22673
- constructor(bytes) {
22674
- this.bytes = bytes;
22675
- }
22676
- toBytes() {
22677
- return new Uint8Array(this.bytes);
22678
- }
22679
- toHex() {
22680
- return encodeHex(this.bytes);
22681
- }
22682
- toBase64() {
22683
- return bytesToBase64(this.bytes);
22684
- }
22685
- toString() {
22686
- return this.toHex();
22687
- }
22688
- equalsBytes(other) {
22689
- return bytesEqual(this.bytes, other.bytes);
22690
- }
22691
- };
22692
- var MarketId = class _MarketId extends OpaqueId {
22693
- static fromHex(hex) {
22694
- return new _MarketId(_MarketId.assertNonEmpty(decodeHex(hex), `hex "${hex}"`));
22695
- }
22696
- static fromBase64(b64) {
22697
- return new _MarketId(_MarketId.assertNonEmpty(base64ToBytes(b64), `base64 "${b64}"`));
22698
- }
22699
- static fromBytes(bytes) {
22700
- return new _MarketId(_MarketId.assertNonEmpty(new Uint8Array(bytes), "bytes"));
22701
- }
22702
- static assertNonEmpty(bytes, source) {
22703
- if (bytes.length === 0) {
22704
- throw new Error(`MarketId: empty bytes from ${source}`);
22705
- }
22706
- return bytes;
22707
- }
22708
- equals(other) {
22709
- return this.equalsBytes(other);
22710
- }
22711
- };
22712
- var ORDER_ID_LENGTH = 16;
22713
- var OrderId = class _OrderId extends OpaqueId {
22714
- static fromHex(hex) {
22715
- return new _OrderId(_OrderId.assertLength(decodeHex(hex), `hex "${hex}"`));
22716
- }
22717
- static fromBase64(b64) {
22718
- return new _OrderId(_OrderId.assertLength(base64ToBytes(b64), `base64 "${b64}"`));
22719
- }
22720
- static fromBytes(bytes) {
22721
- return new _OrderId(_OrderId.assertLength(new Uint8Array(bytes), "bytes"));
22722
- }
22723
- static assertLength(bytes, source) {
22724
- if (bytes.length !== ORDER_ID_LENGTH) {
22725
- throw new Error(
22726
- `OrderId: expected ${ORDER_ID_LENGTH} bytes (chain layout), got ${bytes.length} from ${source}`
22727
- );
22728
- }
22729
- return bytes;
22730
- }
22731
- equals(other) {
22732
- return this.equalsBytes(other);
22733
- }
22734
- };
22735
-
22736
22916
  // src/core/clob-responses.ts
22917
+ import { toHex as toHex4 } from "@cosmjs/encoding";
22737
22918
  async function withWaitDecode(wait, run, decode) {
22738
22919
  const w = wait ?? false;
22739
22920
  const res = await run(w);
@@ -22753,26 +22934,25 @@ function findResponse(msgResponses, typeUrl, txHash) {
22753
22934
  function coinOrUndefined(coin) {
22754
22935
  return coin && coin.denom !== "" ? coin : void 0;
22755
22936
  }
22756
- function decodeLimitOrderResult(msgResponses, base) {
22757
- const decoded = MsgPlaceLimitOrderResponse.decode(
22758
- findResponse(msgResponses, LIMIT_RESPONSE_TYPE, base.txHash)
22759
- );
22760
- return {
22761
- ...base,
22762
- orderId: OrderId.fromBytes(decoded.orderId).toHex(),
22763
- ...coinOrUndefined(decoded.escrowedAmount) && { escrowedAmount: decoded.escrowedAmount }
22764
- };
22765
- }
22766
- function decodeMarketOrderResult(msgResponses, base) {
22767
- const decoded = MsgPlaceMarketOrderResponse.decode(
22768
- findResponse(msgResponses, MARKET_RESPONSE_TYPE, base.txHash)
22769
- );
22770
- return {
22771
- ...base,
22772
- orderId: OrderId.fromBytes(decoded.orderId).toHex(),
22773
- ...coinOrUndefined(decoded.escrowedAmount) && { escrowedAmount: decoded.escrowedAmount }
22937
+ function decodePlaceOrder(codec, typeUrl) {
22938
+ return (msgResponses, base) => {
22939
+ const decoded = codec.decode(findResponse(msgResponses, typeUrl, base.txHash));
22940
+ return {
22941
+ ...base,
22942
+ orderId: OrderId.fromBytes(decoded.orderId).toHex(),
22943
+ ...decoded.cloid?.length ? { cloid: toHex4(decoded.cloid) } : {},
22944
+ ...coinOrUndefined(decoded.escrowedAmount) && { escrowedAmount: decoded.escrowedAmount }
22945
+ };
22774
22946
  };
22775
22947
  }
22948
+ var decodeLimitOrderResult = decodePlaceOrder(
22949
+ MsgPlaceLimitOrderResponse,
22950
+ LIMIT_RESPONSE_TYPE
22951
+ );
22952
+ var decodeMarketOrderResult = decodePlaceOrder(
22953
+ MsgPlaceMarketOrderResponse,
22954
+ MARKET_RESPONSE_TYPE
22955
+ );
22776
22956
  function decodeScaleOrderResult(msgResponses, base) {
22777
22957
  const decoded = MsgPlaceScaleOrderResponse.decode(
22778
22958
  findResponse(msgResponses, SCALE_RESPONSE_TYPE, base.txHash)
@@ -22793,8 +22973,8 @@ function decodeCancelOrdersResult(msgResponses, base) {
22793
22973
  );
22794
22974
  return {
22795
22975
  ...base,
22796
- succeeded: decoded.succeeded.map((id) => OrderId.fromBytes(id).toHex()),
22797
- failed: decoded.failed.map((id) => OrderId.fromBytes(id).toHex())
22976
+ succeeded: decoded.succeeded.map((id) => toHex4(id)),
22977
+ failed: decoded.failed.map((id) => toHex4(id))
22798
22978
  };
22799
22979
  }
22800
22980
 
@@ -24141,7 +24321,7 @@ function createStaticResolver(optsOrNetwork, legacyManifest) {
24141
24321
  // src/agent/attach.ts
24142
24322
  import { secp256k1 as secp256k12 } from "@noble/curves/secp256k1";
24143
24323
  import { keccak256 as keccak2562, hexToBytes as hexToBytes4 } from "viem";
24144
- import { toHex as toHex3 } from "@cosmjs/encoding";
24324
+ import { toHex as toHex5 } from "@cosmjs/encoding";
24145
24325
 
24146
24326
  // src/agent/sign-and-broadcast.ts
24147
24327
  import { secp256k1 } from "@noble/curves/secp256k1";
@@ -24451,7 +24631,7 @@ function deriveAgentAddress(privateKeyHex) {
24451
24631
  const uncompressedPubkey = secp256k12.getPublicKey(privKeyBytes, false);
24452
24632
  const pubkeyHash = hexToBytes4(keccak2562(uncompressedPubkey.slice(1)));
24453
24633
  const evmAddressBytes = pubkeyHash.slice(12);
24454
- const evmHex = `0x${toHex3(evmAddressBytes)}`;
24634
+ const evmHex = `0x${toHex5(evmAddressBytes)}`;
24455
24635
  return evmToAult(evmHex);
24456
24636
  }
24457
24637
  function buildAgentSurface(options, ctx) {
@@ -24548,6 +24728,7 @@ async function buildClient(options, resolver) {
24548
24728
  ...createStakingTxApi(ctx),
24549
24729
  ...createTokenRegistryTxApi(ctx),
24550
24730
  ...createParallelQueryApi(lowLevel),
24731
+ ...createCloidLookupApi(lowLevel),
24551
24732
  // Agent surface — populated by attachAgent, cleared by detachAgent.
24552
24733
  asAgent: null,
24553
24734
  attachAgent(opts) {
@@ -24827,15 +25008,23 @@ var ListTradesResponseItem = zod.object({
24827
25008
  symbol: zod.string(),
24828
25009
  type: zod.union([zod.literal("limit"), zod.literal("market"), zod.literal(null)]).nullish().describe("Order type resolved via JOIN to orders table. Null if order not found."),
24829
25010
  side: zod.enum(["buy", "sell"]),
24830
- takerOrMaker: zod.enum(["taker"]).optional().describe("Always 'taker' \u2014 on-chain DEX treats all executed trades as taker fills."),
25011
+ takerOrMaker: zod.enum(["taker", "maker"]).optional().describe(
25012
+ "Which leg of the match this fill is. Each match writes a maker leg and a taker leg; the public market feed returns only the maker leg so a market's trades aren't double-counted, while the per-orderer feed returns whichever leg belongs to that orderer."
25013
+ ),
24831
25014
  price: zod.string().regex(listTradesResponsePriceRegExp),
24832
25015
  amount: zod.string().regex(listTradesResponseAmountRegExp),
24833
25016
  cost: zod.string().regex(listTradesResponseCostRegExp).describe("price * amount"),
24834
25017
  fee: zod.object({
24835
- cost: zod.string().regex(listTradesResponseFeeCostRegExp).optional().describe("Fee cost in quote currency, decimal string."),
24836
- currency: zod.string().optional().describe('Quote currency ticker (e.g., "USDT")'),
24837
- rate: zod.string().regex(listTradesResponseFeeRateRegExp).optional().describe("Taker fee rate from the market, decimal string.")
24838
- }).optional().describe("Estimated fee for the trade: cost = amount * price * taker_fee_rate"),
25018
+ cost: zod.string().regex(listTradesResponseFeeCostRegExp).optional().describe("Fee cost in `currency` units, decimal string."),
25019
+ currency: zod.string().optional().describe(
25020
+ 'Ticker of the fee denom (e.g., "USDT", or "AULT" for a base-denom fee). The quote ticker for the rate-estimated fallback.'
25021
+ ),
25022
+ rate: zod.string().regex(listTradesResponseFeeRateRegExp).optional().describe(
25023
+ "This leg's fee rate from the market, decimal string: the maker rate for the maker leg, the taker rate otherwise."
25024
+ )
25025
+ }).optional().describe(
25026
+ "Fee charged on the fill. When the indexer recorded a realized fee, cost and currency report it verbatim; the currency follows the denom the filled leg received, which is the base asset on a taker buy, not always the quote. For rows that predate fee indexing, cost falls back to the estimate amount * price * rate in the quote currency, where rate is this leg's rate (maker_fee_rate for the maker leg, otherwise taker_fee_rate)."
25027
+ ),
24839
25028
  info: zod.object({
24840
25029
  address: zod.string().regex(listTradesResponseInfoAddressOneRegExp).describe(
24841
25030
  "Cosmos bech32 account address. The HRP is fixed to `ault` for\naccounts (validators use `aultvaloper`, which this schema rejects).\nLowercased and checksum-verified by the API; mixed-case bech32 is\nrejected to avoid silent EIP-55-style ambiguity.\n"
@@ -24921,6 +25110,7 @@ var GetStatsResponse = zod.object({
24921
25110
  var listOrdersQueryAddressOneRegExp = new RegExp("^ault1[a-z0-9]{38,}$");
24922
25111
  var listOrdersQueryAddressTwoRegExp = new RegExp("^0x[a-f0-9]{40}$");
24923
25112
  var listOrdersQueryMarketIdRegExp = new RegExp("^[0-9a-fA-F]+$");
25113
+ var listOrdersQueryCloidRegExp = new RegExp("^([0-9a-fA-F]{16})?$");
24924
25114
  var listOrdersQueryLimitDefault = 50;
24925
25115
  var listOrdersQueryLimitMax = 200;
24926
25116
  var ListOrdersQueryParams = zod.object({
@@ -24937,6 +25127,9 @@ var ListOrdersQueryParams = zod.object({
24937
25127
  status: zod.enum(["open", "closed", "canceled"]).optional(),
24938
25128
  symbol: zod.string().optional().describe("Symbol to filter by (e.g., AULT/USDT). Alternative to market_id."),
24939
25129
  market_id: zod.string().regex(listOrdersQueryMarketIdRegExp).optional().describe("Hex-encoded binary market ID to filter by. Takes precedence over symbol."),
25130
+ cloid: zod.string().regex(listOrdersQueryCloidRegExp).optional().describe(
25131
+ "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"
25132
+ ),
24940
25133
  since: zod.number().optional().describe("Return orders created after this Unix timestamp (milliseconds)"),
24941
25134
  limit: zod.number().min(1).max(listOrdersQueryLimitMax).default(listOrdersQueryLimitDefault)
24942
25135
  });
@@ -24951,7 +25144,9 @@ var listOrdersResponseInfoBlockHeightRegExp = new RegExp("^\\d+$");
24951
25144
  var listOrdersResponseInfoRemainingDepositRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
24952
25145
  var ListOrdersResponseItem = zod.object({
24953
25146
  id: zod.string(),
24954
- clientOrderId: zod.string().nullish().describe("Always null \u2014 not applicable for on-chain DEX orders."),
25147
+ clientOrderId: zod.string().nullish().describe(
25148
+ "The order's cloid (client order id) as a hex string, or null when the order was placed without one."
25149
+ ),
24955
25150
  timestamp: zod.number(),
24956
25151
  datetime: zod.iso.datetime({}),
24957
25152
  lastTradeTimestamp: zod.number().nullish().describe("Timestamp (ms) of the last trade executed against this order. Null if no trades."),
@@ -25015,7 +25210,9 @@ var getOrderResponseInfoBlockHeightRegExp = new RegExp("^\\d+$");
25015
25210
  var getOrderResponseInfoRemainingDepositRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
25016
25211
  var GetOrderResponse = zod.object({
25017
25212
  id: zod.string(),
25018
- clientOrderId: zod.string().nullish().describe("Always null \u2014 not applicable for on-chain DEX orders."),
25213
+ clientOrderId: zod.string().nullish().describe(
25214
+ "The order's cloid (client order id) as a hex string, or null when the order was placed without one."
25215
+ ),
25019
25216
  timestamp: zod.number(),
25020
25217
  datetime: zod.iso.datetime({}),
25021
25218
  lastTradeTimestamp: zod.number().nullish().describe("Timestamp (ms) of the last trade executed against this order. Null if no trades."),
@@ -25087,15 +25284,23 @@ var ListMyTradesResponseItem = zod.object({
25087
25284
  symbol: zod.string(),
25088
25285
  type: zod.union([zod.literal("limit"), zod.literal("market"), zod.literal(null)]).nullish().describe("Order type resolved via JOIN to orders table. Null if order not found."),
25089
25286
  side: zod.enum(["buy", "sell"]),
25090
- takerOrMaker: zod.enum(["taker"]).optional().describe("Always 'taker' \u2014 on-chain DEX treats all executed trades as taker fills."),
25287
+ takerOrMaker: zod.enum(["taker", "maker"]).optional().describe(
25288
+ "Which leg of the match this fill is. Each match writes a maker leg and a taker leg; the public market feed returns only the maker leg so a market's trades aren't double-counted, while the per-orderer feed returns whichever leg belongs to that orderer."
25289
+ ),
25091
25290
  price: zod.string().regex(listMyTradesResponsePriceRegExp),
25092
25291
  amount: zod.string().regex(listMyTradesResponseAmountRegExp),
25093
25292
  cost: zod.string().regex(listMyTradesResponseCostRegExp).describe("price * amount"),
25094
25293
  fee: zod.object({
25095
- cost: zod.string().regex(listMyTradesResponseFeeCostRegExp).optional().describe("Fee cost in quote currency, decimal string."),
25096
- currency: zod.string().optional().describe('Quote currency ticker (e.g., "USDT")'),
25097
- rate: zod.string().regex(listMyTradesResponseFeeRateRegExp).optional().describe("Taker fee rate from the market, decimal string.")
25098
- }).optional().describe("Estimated fee for the trade: cost = amount * price * taker_fee_rate"),
25294
+ cost: zod.string().regex(listMyTradesResponseFeeCostRegExp).optional().describe("Fee cost in `currency` units, decimal string."),
25295
+ currency: zod.string().optional().describe(
25296
+ 'Ticker of the fee denom (e.g., "USDT", or "AULT" for a base-denom fee). The quote ticker for the rate-estimated fallback.'
25297
+ ),
25298
+ rate: zod.string().regex(listMyTradesResponseFeeRateRegExp).optional().describe(
25299
+ "This leg's fee rate from the market, decimal string: the maker rate for the maker leg, the taker rate otherwise."
25300
+ )
25301
+ }).optional().describe(
25302
+ "Fee charged on the fill. When the indexer recorded a realized fee, cost and currency report it verbatim; the currency follows the denom the filled leg received, which is the base asset on a taker buy, not always the quote. For rows that predate fee indexing, cost falls back to the estimate amount * price * rate in the quote currency, where rate is this leg's rate (maker_fee_rate for the maker leg, otherwise taker_fee_rate)."
25303
+ ),
25099
25304
  info: zod.object({
25100
25305
  address: zod.string().regex(listMyTradesResponseInfoAddressOneRegExp).describe(
25101
25306
  "Cosmos bech32 account address. The HRP is fixed to `ault` for\naccounts (validators use `aultvaloper`, which this schema rejects).\nLowercased and checksum-verified by the API; mixed-case bech32 is\nrejected to avoid silent EIP-55-style ambiguity.\n"
@@ -25294,7 +25499,7 @@ function createDexWs(url, options) {
25294
25499
  }
25295
25500
 
25296
25501
  // src/index.ts
25297
- var SDK_VERSION = "0.0.2-alpha.26";
25502
+ var SDK_VERSION = "0.0.2-alpha.27";
25298
25503
  export {
25299
25504
  AGENT_DEFAULTS,
25300
25505
  AULT_SIGNER_MARKER,
@@ -25367,6 +25572,7 @@ export {
25367
25572
  MissingMsgResponseError,
25368
25573
  NETWORKS,
25369
25574
  NetworkError,
25575
+ ORDER_ID_LENGTH,
25370
25576
  OrderId,
25371
25577
  PageResponseSchema,
25372
25578
  REST_CONTEXT_BRAND,
@@ -25508,6 +25714,7 @@ export {
25508
25714
  listMyTradesResponsePriceRegExp,
25509
25715
  listOrdersQueryAddressOneRegExp,
25510
25716
  listOrdersQueryAddressTwoRegExp,
25717
+ listOrdersQueryCloidRegExp,
25511
25718
  listOrdersQueryLimitDefault,
25512
25719
  listOrdersQueryLimitMax,
25513
25720
  listOrdersQueryMarketIdRegExp,