@trinaryex/sdk 3.0.0 → 3.2.0

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
@@ -133,42 +133,42 @@ function b(e, t) {
133
133
  asset_id: t
134
134
  }).toBytes();
135
135
  }
136
- var x = t.struct("MultiCoinBalance", {
136
+ var ee = t.struct("MultiCoinBalance", {
137
137
  id: t.Address,
138
138
  collection: t.Address,
139
139
  asset_id: t.u64(),
140
140
  amount: t.u64()
141
- }), ee = t.u64();
142
- function te(e) {
141
+ }), te = t.u64();
142
+ function ne(e) {
143
143
  return e && typeof e == "object" && "fields" in e ? e.fields : e;
144
144
  }
145
- function S(e) {
145
+ function re(e) {
146
146
  if (typeof e == "string") return e;
147
147
  if (e && typeof e == "object") {
148
148
  let t = e;
149
149
  if (typeof t.objectId == "string") return t.objectId;
150
150
  if (typeof t.id == "string") return t.id;
151
151
  if (typeof t.bytes == "string") return t.bytes;
152
- if (t.id) return S(t.id);
152
+ if (t.id) return re(t.id);
153
153
  }
154
154
  return null;
155
155
  }
156
- var C = (e) => e.core;
157
- function w(e) {
156
+ var x = (e) => e.core;
157
+ function S(e) {
158
158
  return "0x" + BigInt(e).toString(16).padStart(64, "0");
159
159
  }
160
- async function ne(e, t) {
161
- let { object: n } = await C(e).getObject({ objectId: t });
160
+ async function ie(e, t) {
161
+ let { object: n } = await x(e).getObject({ objectId: t });
162
162
  return {
163
163
  objectId: n.objectId,
164
164
  version: n.version,
165
165
  digest: n.digest
166
166
  };
167
167
  }
168
- async function re(e, t, n) {
168
+ async function ae(e, t, n) {
169
169
  let r = 0n, i;
170
170
  for (let a = 0; a < 40; a++) {
171
- let a = await C(e).listCoins({
171
+ let a = await x(e).listCoins({
172
172
  owner: t,
173
173
  coinType: n,
174
174
  limit: 50,
@@ -180,23 +180,23 @@ async function re(e, t, n) {
180
180
  }
181
181
  return r;
182
182
  }
183
- async function T(e, t, n) {
184
- let r = (await C(e).getObject({
183
+ async function C(e, t, n) {
184
+ let r = (await x(e).getObject({
185
185
  objectId: n,
186
186
  include: { json: !0 }
187
- }).catch(() => null))?.object?.json, i = S(te(r?.balances)?.id);
187
+ }).catch(() => null))?.object?.json, i = re(ne(r?.balances)?.id);
188
188
  if (!i) return 0n;
189
- let a = `${t.triex}::balance_manager::BalanceKey<${t.credCoinType}>`, o = await C(e).getDynamicField({
189
+ let a = `${t.triex}::balance_manager::BalanceKey<${t.credCoinType}>`, o = await x(e).getDynamicField({
190
190
  parentId: i,
191
191
  name: {
192
192
  type: a,
193
193
  bcs: v()
194
194
  }
195
195
  }).catch(() => null);
196
- return o ? BigInt(ee.parse(o.dynamicField.value.bcs)) : 0n;
196
+ return o ? BigInt(te.parse(o.dynamicField.value.bcs)) : 0n;
197
197
  }
198
- async function ie(e, t, n, r, i) {
199
- let a = `${t.triex}::balance_manager::MultiCoinBalanceKey`, o = await C(e).getDynamicObjectField({
198
+ async function w(e, t, n, r, i) {
199
+ let a = `${t.triex}::balance_manager::MultiCoinBalanceKey`, o = await x(e).getDynamicObjectField({
200
200
  parentId: n,
201
201
  name: {
202
202
  type: a,
@@ -208,14 +208,14 @@ async function ie(e, t, n, r, i) {
208
208
  hasKey: !1,
209
209
  balance: 0n
210
210
  };
211
- let s = x.parse(o.object.content);
211
+ let s = ee.parse(o.object.content);
212
212
  return {
213
213
  hasKey: !0,
214
214
  balance: BigInt(s.amount)
215
215
  };
216
216
  }
217
- async function E(e, n) {
218
- let r = `${n.triex}::registry::MultiCoinCollectionKey`, i = await C(e).getDynamicField({
217
+ async function T(e, n) {
218
+ let r = `${n.triex}::registry::MultiCoinCollectionKey`, i = await x(e).getDynamicField({
219
219
  parentId: n.triexRegistry,
220
220
  name: {
221
221
  type: r,
@@ -225,10 +225,10 @@ async function E(e, n) {
225
225
  if (!i) throw Error("Registry MultiCoin collection id not found (registry not initialized?).");
226
226
  return t.Address.parse(i.dynamicField.value.bcs);
227
227
  }
228
- async function D(e, t, n, r) {
228
+ async function oe(e, t, n, r) {
229
229
  let i = `${t.multicoin}::multicoin::Balance`, a = [], o;
230
230
  for (let t = 0; t < 40; t++) {
231
- let t = await C(e).listOwnedObjects({
231
+ let t = await x(e).listOwnedObjects({
232
232
  owner: n,
233
233
  type: i,
234
234
  limit: 50,
@@ -236,7 +236,7 @@ async function D(e, t, n, r) {
236
236
  ...o ? { cursor: o } : {}
237
237
  });
238
238
  for (let e of t?.objects ?? []) try {
239
- let t = x.parse(e.content);
239
+ let t = ee.parse(e.content);
240
240
  if (r?.assetId && String(t.asset_id) !== r.assetId) continue;
241
241
  a.push({
242
242
  objectId: e.objectId,
@@ -250,18 +250,18 @@ async function D(e, t, n, r) {
250
250
  }
251
251
  return a;
252
252
  }
253
- async function O(e, t, n) {
253
+ async function E(e, t, n) {
254
254
  let r = [t.worldOriginal];
255
255
  t.world !== t.worldOriginal && r.push(t.world);
256
256
  for (let t of r) {
257
- let r = `${t}::character::PlayerProfile`, i = (await C(e).listOwnedObjects({
257
+ let r = `${t}::character::PlayerProfile`, i = (await x(e).listOwnedObjects({
258
258
  owner: n,
259
259
  type: r,
260
260
  include: { json: !0 },
261
261
  limit: 1
262
262
  }).catch(() => null))?.objects?.[0]?.json, a = typeof i?.character_id == "string" ? i.character_id : null;
263
263
  if (!a) continue;
264
- let o = (await C(e).getObject({
264
+ let o = (await x(e).getObject({
265
265
  objectId: a,
266
266
  include: { json: !0 }
267
267
  }).catch(() => null))?.object?.json?.owner_cap_id;
@@ -272,13 +272,13 @@ async function O(e, t, n) {
272
272
  }
273
273
  return null;
274
274
  }
275
- async function k(e, t, n) {
276
- let r = (await C(e).getObject({
275
+ async function D(e, t, n) {
276
+ let r = (await x(e).getObject({
277
277
  objectId: t,
278
278
  include: { json: !0 }
279
279
  }).catch(() => null))?.object?.json?.owner_cap_id;
280
280
  if (typeof r != "string") return null;
281
- let i = (await C(e).getObject({ objectId: r }).catch(() => null))?.object?.owner;
281
+ let i = (await x(e).getObject({ objectId: r }).catch(() => null))?.object?.owner;
282
282
  if (!i || typeof i != "object") return null;
283
283
  let a = null;
284
284
  if (i.AddressOwner) {
@@ -286,7 +286,7 @@ async function k(e, t, n) {
286
286
  a = i.AddressOwner;
287
287
  } else i.ObjectOwner && (a = i.ObjectOwner);
288
288
  if (!a) return null;
289
- let o = (await C(e).getObject({
289
+ let o = (await x(e).getObject({
290
290
  objectId: a,
291
291
  include: { json: !0 }
292
292
  }).catch(() => null))?.object?.json;
@@ -298,8 +298,8 @@ async function k(e, t, n) {
298
298
  charOwnerCapId: s
299
299
  } : null;
300
300
  }
301
- async function A(e, n, r, i) {
302
- let a = await C(e).getDynamicField({
301
+ async function O(e, n, r, i) {
302
+ let a = await x(e).getDynamicField({
303
303
  parentId: n,
304
304
  name: {
305
305
  type: "0x2::object::ID",
@@ -307,7 +307,7 @@ async function A(e, n, r, i) {
307
307
  }
308
308
  }).catch(() => null);
309
309
  if (!a) return 0n;
310
- let o = (await C(e).getObject({
310
+ let o = (await x(e).getObject({
311
311
  objectId: a.dynamicField.fieldId,
312
312
  include: { json: !0 }
313
313
  }).catch(() => null))?.object?.json?.value?.items?.contents ?? [], s = 0n;
@@ -316,63 +316,63 @@ async function A(e, n, r, i) {
316
316
  }
317
317
  //#endregion
318
318
  //#region src/transactions.ts
319
- var ae = /* @__PURE__ */ i({
319
+ var se = /* @__PURE__ */ i({
320
320
  cancelAllOrdersItem: () => R,
321
321
  cancelOrderItem: () => L,
322
- depositCoin: () => N,
323
- depositMulticoinObject: () => oe,
324
- generateProofAsOwner: () => M,
322
+ depositCoin: () => j,
323
+ depositMulticoinObject: () => ce,
324
+ generateProofAsOwner: () => A,
325
325
  modifyOrderItem: () => z,
326
- newBalanceManager: () => j,
326
+ newBalanceManager: () => k,
327
327
  placeLimitOrderItem: () => F,
328
328
  placeMarketOrderItem: () => I,
329
- redeemReceipt: () => ue,
329
+ redeemReceipt: () => N,
330
330
  sourceItemsFromHangar: () => P,
331
- withdrawAllCoin: () => ce,
332
- withdrawAllMulticoin: () => le,
333
- withdrawCoin: () => se,
331
+ withdrawAllCoin: () => ue,
332
+ withdrawAllMulticoin: () => M,
333
+ withdrawCoin: () => le,
334
334
  withdrawSettledAmounts: () => B
335
335
  });
336
- function j(e, t) {
336
+ function k(e, t) {
337
337
  return e.moveCall({
338
338
  target: `${t.triex}::balance_manager::new`,
339
339
  arguments: []
340
340
  });
341
341
  }
342
- function M(e, t, n) {
342
+ function A(e, t, n) {
343
343
  return e.moveCall({
344
344
  target: `${t.triex}::balance_manager::generate_proof_as_owner`,
345
345
  arguments: [n]
346
346
  });
347
347
  }
348
- function N(e, t, n, r, i = t.credCoinType) {
348
+ function j(e, t, n, r, i = t.credCoinType) {
349
349
  e.moveCall({
350
350
  target: `${t.triex}::balance_manager::deposit`,
351
351
  typeArguments: [i],
352
352
  arguments: [n, r]
353
353
  });
354
354
  }
355
- function oe(e, t, n, r) {
355
+ function ce(e, t, n, r) {
356
356
  e.moveCall({
357
357
  target: `${t.triex}::balance_manager::deposit_multicoin`,
358
358
  arguments: [n, e.object(r)]
359
359
  });
360
360
  }
361
- function se(e, t, n, r, i = t.credCoinType) {
361
+ function le(e, t, n, r, i = t.credCoinType) {
362
362
  return e.moveCall({
363
363
  target: `${t.triex}::balance_manager::withdraw`,
364
364
  typeArguments: [i],
365
365
  arguments: [n, e.pure.u64(r)]
366
366
  });
367
367
  }
368
- function ce(e, t, n, r = t.credCoinType) {
368
+ function ue(e, t, n, r = t.credCoinType) {
369
369
  return e.moveCall({
370
370
  target: `${t.triex}::balance_manager::withdraw_all`,
371
371
  typeArguments: [r],
372
372
  arguments: [n]
373
373
  });
374
374
  }
375
- function le(e, t, n, r, i) {
375
+ function M(e, t, n, r, i) {
376
376
  return e.moveCall({
377
377
  target: `${t.triex}::balance_manager::withdraw_all_multicoin`,
378
378
  arguments: [
@@ -382,7 +382,7 @@ function le(e, t, n, r, i) {
382
382
  ]
383
383
  });
384
384
  }
385
- function ue(e, t, n, r) {
385
+ function N(e, t, n, r) {
386
386
  e.moveCall({
387
387
  target: `${t.warehouseReceipts}::receipt::redeem_receipt`,
388
388
  arguments: [
@@ -536,19 +536,19 @@ async function V(e, t, n, r, i, a = "Insufficient wallet balance to fund this tr
536
536
  async function H(e, t, n, r, i) {
537
537
  let { assetId: a, amount: o } = i;
538
538
  if (o <= 0n) throw new d(u.ValidationFailed, "Item amount must be positive.");
539
- let s = i.deficitMode && i.balanceManagerId ? await ie(e, n, i.balanceManagerId, i.vaultCollectionId, a) : {
539
+ let s = i.deficitMode && i.balanceManagerId ? await w(e, n, i.balanceManagerId, i.vaultCollectionId, a) : {
540
540
  hasKey: !1,
541
541
  balance: 0n
542
542
  }, c = i.deficitMode ? o - s.balance : o;
543
543
  if (c <= 0n) return;
544
- let l = await D(e, n, i.owner, { assetId: a.toString() }), f = (i.vaultCollectionId || await E(e, n)).trim().toLowerCase(), p = l.filter((e) => e.amount > 0n && (!e.collectionId || e.collectionId.toLowerCase() === f)).sort((e, t) => e.amount > t.amount ? -1 : 1), m = 0n;
544
+ let l = await oe(e, n, i.owner, { assetId: a.toString() }), f = (i.vaultCollectionId || await T(e, n)).trim().toLowerCase(), p = l.filter((e) => e.amount > 0n && (!e.collectionId || e.collectionId.toLowerCase() === f)).sort((e, t) => e.amount > t.amount ? -1 : 1), m = 0n;
545
545
  for (let e of p) {
546
546
  if (m >= c) break;
547
- oe(t, n, r, e.objectId), m += e.amount;
547
+ ce(t, n, r, e.objectId), m += e.amount;
548
548
  }
549
549
  if (c -= m, c <= 0n) return;
550
- let [h, g] = await Promise.all([k(e, i.ssuObjectId, i.owner), O(e, n, i.owner)]), _ = async (o, s, c, l) => {
551
- let u = await ne(e, o);
550
+ let [h, g] = await Promise.all([D(e, i.ssuObjectId, i.owner), E(e, n, i.owner)]), _ = async (o, s, c, l) => {
551
+ let u = await ie(e, o);
552
552
  P(t, n, r, {
553
553
  ssuObjectId: i.ssuObjectId,
554
554
  characterId: c,
@@ -561,13 +561,13 @@ async function H(e, t, n, r, i) {
561
561
  });
562
562
  }, v = `${n.worldOriginal}::storage_unit::StorageUnit`, y = `${n.worldOriginal}::character::Character`;
563
563
  if (h) {
564
- let [t, n] = await Promise.all([A(e, i.ssuObjectId, h.ssuOwnerCapId, a.toString()), A(e, i.ssuObjectId, h.charOwnerCapId, a.toString())]), r = t >= c ? c : t, o = c - r, s = o <= n ? o : n;
564
+ let [t, n] = await Promise.all([O(e, i.ssuObjectId, h.ssuOwnerCapId, a.toString()), O(e, i.ssuObjectId, h.charOwnerCapId, a.toString())]), r = t >= c ? c : t, o = c - r, s = o <= n ? o : n;
565
565
  if (r + s < c) throw new d(u.InsufficientBalance, `Insufficient items in the hub inventory (SSU slot: ${t}, character slot: ${n}, needed: ${c}).`);
566
566
  r > 0n && await _(h.ssuOwnerCapId, v, h.characterId, r), s > 0n && await _(h.charOwnerCapId, y, h.characterId, s);
567
567
  return;
568
568
  }
569
569
  if (g) {
570
- let t = await A(e, i.ssuObjectId, g.ownerCapId, a.toString());
570
+ let t = await O(e, i.ssuObjectId, g.ownerCapId, a.toString());
571
571
  if (t < c) throw new d(u.InsufficientBalance, `Insufficient items (need ${o}, BM holds ${s.balance}, wallet receipts cover ${m}, hangar slot holds ${t}).`);
572
572
  await _(g.ownerCapId, y, g.characterId, c);
573
573
  return;
@@ -595,13 +595,13 @@ function me(e, t) {
595
595
  function G(e, t) {
596
596
  return e * t * U / 1n;
597
597
  }
598
- function K(e, t, n) {
598
+ function he(e, t, n) {
599
599
  return G(e, t) * (W + n) / W;
600
600
  }
601
- function he(e, t) {
601
+ function ge(e, t) {
602
602
  return e * t / W + 2n;
603
603
  }
604
- function ge(e, t, n) {
604
+ function _e(e, t, n) {
605
605
  let r = t, i = 0n;
606
606
  for (let t of e) {
607
607
  if (r <= 0n) break;
@@ -618,7 +618,7 @@ function ge(e, t, n) {
618
618
  }
619
619
  //#endregion
620
620
  //#region src/schemas.ts
621
- var q = n.union([n.string(), n.number()]).transform((e, t) => {
621
+ var K = n.union([n.string(), n.number()]).transform((e, t) => {
622
622
  try {
623
623
  return BigInt(e);
624
624
  } catch {
@@ -627,14 +627,14 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
627
627
  message: `not an integer: ${e}`
628
628
  }), n.NEVER;
629
629
  }
630
- }), _e = n.object({
630
+ }), ve = n.object({
631
631
  pool_id: n.string(),
632
632
  order_id: n.string(),
633
- price: q,
633
+ price: K,
634
634
  is_bid: n.boolean(),
635
635
  balance_manager_id: n.string(),
636
- remaining_quantity: q,
637
- filled_quantity: q,
636
+ remaining_quantity: K,
637
+ filled_quantity: K,
638
638
  expires_at: n.number().nullable(),
639
639
  last_activity_at: n.number(),
640
640
  asset_id: n.string(),
@@ -667,22 +667,22 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
667
667
  quoteAssetDecimals: e.quote_asset_decimals,
668
668
  traderAddress: e.trader_address,
669
669
  traderName: e.trader_name
670
- })), ve = n.object({
671
- data: n.array(_e),
670
+ })), ye = n.object({
671
+ data: n.array(ve),
672
672
  next_cursor: n.string().nullable(),
673
673
  prev_cursor: n.string().nullable()
674
674
  }).transform((e) => ({
675
675
  orders: e.data,
676
676
  nextCursor: e.next_cursor,
677
677
  prevCursor: e.prev_cursor
678
- })), ye = n.object({ pool_id: n.string().nullable() }).transform((e) => ({ poolId: e.pool_id })), be = n.object({
678
+ })), be = n.object({ pool_id: n.string().nullable() }).transform((e) => ({ poolId: e.pool_id })), q = n.object({
679
679
  encodedOrderId: n.string(),
680
- quantity: q,
681
- filledQuantity: q,
682
- expireTimestamp: q,
683
- lastUpdatedTimestamp: q,
680
+ quantity: K,
681
+ filledQuantity: K,
682
+ expireTimestamp: K,
683
+ lastUpdatedTimestamp: K,
684
684
  status: n.number(),
685
- price: q
685
+ price: K
686
686
  }).transform((e) => ({
687
687
  orderId: e.encodedOrderId,
688
688
  quantity: e.quantity,
@@ -693,8 +693,8 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
693
693
  status: e.status,
694
694
  price: e.price
695
695
  })), xe = n.object({
696
- bids: n.array(be),
697
- asks: n.array(be)
696
+ bids: n.array(q),
697
+ asks: n.array(q)
698
698
  }), Se = n.object({
699
699
  pool_id: n.string(),
700
700
  pool_name: n.string(),
@@ -724,6 +724,22 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
724
724
  feeRateScaled: e.fee === null ? 0n : BigInt(e.fee),
725
725
  feeRate: e.fee_rate
726
726
  })), Ce = n.object({
727
+ hub_id: n.string(),
728
+ collection_id: n.string(),
729
+ vault_config_id: n.string().nullable(),
730
+ pool_id: n.string().nullable(),
731
+ metadata: Se.nullable(),
732
+ bids: n.array(q),
733
+ asks: n.array(q)
734
+ }).transform((e) => ({
735
+ hubId: e.hub_id,
736
+ collectionId: e.collection_id,
737
+ vaultConfigId: e.vault_config_id,
738
+ poolId: e.pool_id,
739
+ metadata: e.metadata,
740
+ bids: e.bids,
741
+ asks: e.asks
742
+ })), we = n.object({
727
743
  hub_id: n.string(),
728
744
  collection_id: n.string(),
729
745
  vault_config_id: n.string()
@@ -731,7 +747,7 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
731
747
  hubId: e.hub_id,
732
748
  collectionId: e.collection_id,
733
749
  vaultConfigId: e.vault_config_id
734
- })), we = n.object({
750
+ })), Te = n.object({
735
751
  hub_id: n.string(),
736
752
  assembly_item_id: n.string(),
737
753
  assembly_tenant: n.string(),
@@ -763,7 +779,7 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
763
779
  isPublic: e.is_public,
764
780
  regionId: e.region_id,
765
781
  solarSystemName: e.solar_system_name
766
- })), Te = n.object({
782
+ })), Ee = n.object({
767
783
  asset_id: n.string(),
768
784
  has_bids: n.boolean(),
769
785
  has_asks: n.boolean()
@@ -771,25 +787,49 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
771
787
  assetId: e.asset_id,
772
788
  hasBids: e.has_bids,
773
789
  hasAsks: e.has_asks
774
- })), Ee = n.object({
775
- data: n.array(Te),
790
+ })), De = n.object({
791
+ data: n.array(Ee),
776
792
  next_cursor: n.string().nullable()
777
793
  }).transform((e) => ({
778
794
  items: e.data,
779
795
  nextCursor: e.next_cursor
780
- })), De = n.object({
796
+ })), Oe = n.object({
781
797
  hub_id: n.string(),
782
798
  collection_id: n.string()
783
799
  }).transform((e) => ({
784
800
  hubId: e.hub_id,
785
801
  collectionId: e.collection_id
786
- })), J = n.object({
802
+ })), ke = n.object({
787
803
  asset_id: n.string(),
788
- amount: q
804
+ quantity: n.number()
805
+ }).transform((e) => ({
806
+ assetId: e.asset_id,
807
+ quantity: e.quantity
808
+ })), Ae = n.object({
809
+ output_quantity: n.number(),
810
+ components: n.array(ke)
811
+ }).transform((e) => ({
812
+ outputQuantity: e.output_quantity,
813
+ components: e.components
814
+ })), je = n.object({
815
+ asset_id: n.string(),
816
+ name: n.string().nullable(),
817
+ symbol: n.string().nullable(),
818
+ mass: n.number(),
819
+ recipes: n.array(Ae)
820
+ }).transform((e) => ({
821
+ assetId: e.asset_id,
822
+ name: e.name,
823
+ symbol: e.symbol,
824
+ mass: e.mass,
825
+ recipes: e.recipes
826
+ })), Me = n.object({ data: n.array(je) }).transform((e) => ({ items: e.data })), J = n.object({
827
+ asset_id: n.string(),
828
+ amount: K
789
829
  }).transform((e) => ({
790
830
  assetId: e.asset_id,
791
831
  amount: e.amount
792
- })), Oe = n.object({
832
+ })), Ne = n.object({
793
833
  storage_unit_id: n.string(),
794
834
  collection_id: n.string(),
795
835
  warehouse: n.array(J),
@@ -803,14 +843,14 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
803
843
  marketplace: e.marketplace,
804
844
  hangar: e.hangar,
805
845
  orgVaults: e.org_vaults
806
- })), ke = n.object({
846
+ })), Pe = n.object({
807
847
  pool_id: n.string(),
808
848
  order_id: n.string(),
809
849
  encoded_order_id: n.string().optional(),
810
850
  side: n.enum(["buy", "sell"]),
811
- price: q,
812
- remaining_quantity: q,
813
- filled_quantity: q,
851
+ price: K,
852
+ remaining_quantity: K,
853
+ filled_quantity: K,
814
854
  expires_at: n.number(),
815
855
  updated_at: n.number(),
816
856
  asset_id: n.string(),
@@ -831,21 +871,21 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
831
871
  storageUnitId: e.storage_unit_id,
832
872
  quoteAssetSymbol: e.quote_asset_symbol,
833
873
  quoteAssetDecimals: e.quote_asset_decimals
834
- })), Ae = n.object({
835
- data: n.array(ke),
874
+ })), Fe = n.object({
875
+ data: n.array(Pe),
836
876
  next_cursor: n.string().nullable()
837
877
  }).transform((e) => ({
838
878
  orders: e.data,
839
879
  nextCursor: e.next_cursor
840
- })), je = n.object({
880
+ })), Ie = n.object({
841
881
  event_digest: n.string(),
842
882
  pool_id: n.string(),
843
883
  order_id: n.string(),
844
884
  counterparty_balance_manager_id: n.string(),
845
- price: q,
846
- base_quantity: q,
847
- quote_quantity: q,
848
- fee: q,
885
+ price: K,
886
+ base_quantity: K,
887
+ quote_quantity: K,
888
+ fee: K,
849
889
  role: n.enum(["maker", "taker"]),
850
890
  taker_is_bid: n.boolean(),
851
891
  filled_at: n.number()
@@ -861,21 +901,21 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
861
901
  role: e.role,
862
902
  takerIsBid: e.taker_is_bid,
863
903
  filledAt: e.filled_at
864
- })), Me = n.object({
865
- data: n.array(je),
904
+ })), Le = n.object({
905
+ data: n.array(Ie),
866
906
  next_cursor: n.string().nullable()
867
907
  }).transform((e) => ({
868
908
  fills: e.data,
869
909
  nextCursor: e.next_cursor
870
- })), Ne = n.object({
910
+ })), Re = n.object({
871
911
  event_digest: n.string(),
872
912
  pool_id: n.string(),
873
913
  order_id: n.string(),
874
914
  counterparty_balance_manager_id: n.string(),
875
- price: q,
876
- base_quantity: q,
877
- quote_quantity: q,
878
- fee: q,
915
+ price: K,
916
+ base_quantity: K,
917
+ quote_quantity: K,
918
+ fee: K,
879
919
  role: n.enum(["maker", "taker"]),
880
920
  side: n.enum(["buy", "sell"]),
881
921
  traded_at: n.number(),
@@ -895,29 +935,29 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
895
935
  tradedAt: e.traded_at,
896
936
  assetId: e.asset_id,
897
937
  storageUnitId: e.storage_unit_id
898
- })), Pe = n.object({
899
- data: n.array(Ne),
938
+ })), ze = n.object({
939
+ data: n.array(Re),
900
940
  next_cursor: n.string().nullable()
901
941
  }).transform((e) => ({
902
942
  trades: e.data,
903
943
  nextCursor: e.next_cursor
904
- })), Fe = n.object({
905
- base: q,
906
- quote: q,
907
- cred: q
944
+ })), Be = n.object({
945
+ base: K,
946
+ quote: K,
947
+ cred: K
908
948
  }).transform((e) => ({
909
949
  base: e.base,
910
950
  quote: e.quote,
911
951
  cred: e.cred
912
- })), Ie = n.object({
952
+ })), Ve = n.object({
913
953
  pool_id: n.string(),
914
954
  collection_id: n.string(),
915
955
  asset_id: n.string(),
916
956
  quote_asset_id: n.string().nullable(),
917
957
  storage_unit_id: n.string(),
918
958
  vault_config_id: n.string(),
919
- settled: Fe,
920
- owed: Fe,
959
+ settled: Be,
960
+ owed: Be,
921
961
  open_order_count: n.number()
922
962
  }).transform((e) => ({
923
963
  poolId: e.pool_id,
@@ -929,10 +969,10 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
929
969
  settled: e.settled,
930
970
  owed: e.owed,
931
971
  openOrderCount: e.open_order_count
932
- })), Le = n.object({
972
+ })), He = n.object({
933
973
  collection_id: n.string(),
934
974
  asset_id: n.string(),
935
- amount: q,
975
+ amount: K,
936
976
  storage_unit_id: n.string(),
937
977
  vault_config_id: n.string()
938
978
  }).transform((e) => ({
@@ -941,11 +981,11 @@ var q = n.union([n.string(), n.number()]).transform((e, t) => {
941
981
  amount: e.amount,
942
982
  storageUnitId: e.storage_unit_id,
943
983
  vaultConfigId: e.vault_config_id
944
- })), Re = n.object({
984
+ })), Ue = n.object({
945
985
  balance_manager_id: n.string(),
946
986
  as_of_checkpoint: n.string().nullable(),
947
- pools: n.array(Ie),
948
- items: n.array(Le)
987
+ pools: n.array(Ve),
988
+ items: n.array(He)
949
989
  }).transform((e) => ({
950
990
  balanceManagerId: e.balance_manager_id,
951
991
  asOfCheckpoint: e.as_of_checkpoint,
@@ -994,7 +1034,7 @@ var X = class {
994
1034
  return await i.json();
995
1035
  }
996
1036
  async discovery(e) {
997
- return Y(ve, await this.get("/v1/discovery", {
1037
+ return Y(ye, await this.get("/v1/discovery", {
998
1038
  storage_unit_ids: e?.storageUnitIds?.join(","),
999
1039
  asset_id: e?.assetId,
1000
1040
  balance_manager_id: e?.balanceManagerId,
@@ -1005,12 +1045,15 @@ var X = class {
1005
1045
  }), "discovery");
1006
1046
  }
1007
1047
  async resolvePool(e) {
1008
- return Y(ye, await this.get("/v1/pools/resolve", {
1048
+ return Y(be, await this.get("/v1/pools/resolve", {
1009
1049
  collection_id: e.collectionId,
1010
1050
  asset_id: e.assetId,
1011
1051
  quote_type: e.quoteType
1012
1052
  }), "resolvePool").poolId;
1013
1053
  }
1054
+ async hubItemOrderbook(e) {
1055
+ return Y(Ce, await this.get(`/v1/hubs/${encodeURIComponent(e.hubId)}/items/${encodeURIComponent(e.assetId)}/orderbook`, { quote_type: e.quoteType }, u.HubNotFound), "hubItemOrderbook");
1056
+ }
1014
1057
  async orderbook(e) {
1015
1058
  return {
1016
1059
  poolId: e,
@@ -1021,24 +1064,30 @@ var X = class {
1021
1064
  return Y(Se, await this.get(`/v1/pools/${encodeURIComponent(e)}/metadata`, void 0, u.PoolNotFound), "poolMetadata");
1022
1065
  }
1023
1066
  async hubVault(e) {
1024
- return Y(Ce, await this.get(`/v1/hubs/${encodeURIComponent(e)}/vault`, void 0, u.HubNotFound), "hubVault");
1067
+ return Y(we, await this.get(`/v1/hubs/${encodeURIComponent(e)}/vault`, void 0, u.HubNotFound), "hubVault");
1025
1068
  }
1026
1069
  async hubLocation(e) {
1027
1070
  try {
1028
- return Y(we, await this.get(`/v1/hubs/${encodeURIComponent(e)}/location`, void 0, u.HubNotFound), "hubLocation");
1071
+ return Y(Te, await this.get(`/v1/hubs/${encodeURIComponent(e)}/location`, void 0, u.HubNotFound), "hubLocation");
1029
1072
  } catch (e) {
1030
1073
  if (e instanceof d && e.status === 404) return null;
1031
1074
  throw e;
1032
1075
  }
1033
1076
  }
1034
1077
  async hubItems(e) {
1035
- return Y(Ee, await this.get(`/v1/hubs/${encodeURIComponent(e)}/items`, void 0, u.HubNotFound), "hubItems");
1078
+ return Y(De, await this.get(`/v1/hubs/${encodeURIComponent(e)}/items`, void 0, u.HubNotFound), "hubItems");
1079
+ }
1080
+ async searchItems(e, t) {
1081
+ return Y(Me, await this.get("/v1/assets/search", {
1082
+ q: e,
1083
+ limit: t
1084
+ }), "searchItems");
1036
1085
  }
1037
1086
  async collectionHub(e) {
1038
- return Y(De, await this.get(`/v1/collections/${encodeURIComponent(e)}/hub`, void 0, u.HubNotFound), "collectionHub");
1087
+ return Y(Oe, await this.get(`/v1/collections/${encodeURIComponent(e)}/hub`, void 0, u.HubNotFound), "collectionHub");
1039
1088
  }
1040
1089
  async inventoryBalances(e) {
1041
- return Y(Oe, await this.get("/v1/inventory/balances", {
1090
+ return Y(Ne, await this.get("/v1/inventory/balances", {
1042
1091
  storage_unit_id: e.storageUnitId,
1043
1092
  owner_address: e.address,
1044
1093
  balance_manager_id: e.balanceManagerId,
@@ -1047,14 +1096,14 @@ var X = class {
1047
1096
  }, u.HubNotFound), "inventoryBalances");
1048
1097
  }
1049
1098
  async openOrders(e, t) {
1050
- return Y(Ae, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/open-orders`, {
1099
+ return Y(Fe, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/open-orders`, {
1051
1100
  before: t?.before,
1052
1101
  after: t?.after,
1053
1102
  limit: t?.limit
1054
1103
  }, u.BalanceManagerNotFound), "openOrders");
1055
1104
  }
1056
1105
  async fills(e, t) {
1057
- return Y(Me, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/fills`, {
1106
+ return Y(Le, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/fills`, {
1058
1107
  before: t?.before,
1059
1108
  after: t?.after,
1060
1109
  limit: t?.limit,
@@ -1063,10 +1112,10 @@ var X = class {
1063
1112
  }, u.BalanceManagerNotFound), "fills");
1064
1113
  }
1065
1114
  async sweepable(e) {
1066
- return Y(Re, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/sweepable`, void 0, u.BalanceManagerNotFound), "sweepable");
1115
+ return Y(Ue, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/sweepable`, void 0, u.BalanceManagerNotFound), "sweepable");
1067
1116
  }
1068
1117
  async trades(e, t) {
1069
- return Y(Pe, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/trades`, {
1118
+ return Y(ze, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/trades`, {
1070
1119
  before: t?.before,
1071
1120
  after: t?.after,
1072
1121
  limit: t?.limit,
@@ -1074,7 +1123,7 @@ var X = class {
1074
1123
  asset_id: t?.assetId
1075
1124
  }, u.BalanceManagerNotFound), "trades");
1076
1125
  }
1077
- }, ze = class {
1126
+ }, We = class {
1078
1127
  suiClient;
1079
1128
  ids;
1080
1129
  indexer;
@@ -1086,7 +1135,7 @@ var X = class {
1086
1135
  market;
1087
1136
  orders;
1088
1137
  constructor(e) {
1089
- this.suiClient = e.suiClient, this.executor = e.executor, this.address = e.address, this.ids = l(e.network ?? "testnet", e.packageIds), this.indexer = new X(e.indexerUrl ?? "https://api.trinary.exchange", e.apiKey), this.account = new Ve(this), this.balances = new He(this), this.market = new Ue(this), this.orders = new We(this);
1138
+ this.suiClient = e.suiClient, this.executor = e.executor, this.address = e.address, this.ids = l(e.network ?? "testnet", e.packageIds), this.indexer = new X(e.indexerUrl ?? "https://api.trinary.exchange", e.apiKey), this.account = new Ke(this), this.balances = new qe(this), this.market = new Je(this), this.orders = new Ye(this);
1090
1139
  }
1091
1140
  requireExecutor() {
1092
1141
  if (!this.executor) throw new d(u.ExecutorRequired, "This operation writes on-chain and requires an `executor`.");
@@ -1113,7 +1162,7 @@ var X = class {
1113
1162
  let n = await this.resolveBalanceManagerId(t), r = new e();
1114
1163
  return {
1115
1164
  tx: r,
1116
- bm: n ? r.object(n) : j(r, this.ids)[0],
1165
+ bm: n ? r.object(n) : k(r, this.ids)[0],
1117
1166
  existingBmId: n
1118
1167
  };
1119
1168
  }
@@ -1121,7 +1170,7 @@ var X = class {
1121
1170
  n || e.transferObjects([t], r);
1122
1171
  let i = await m(this.requireExecutor(), e);
1123
1172
  if (!n) {
1124
- let e = Be(i);
1173
+ let e = Ge(i);
1125
1174
  e && this.rememberBalanceManagerId(e);
1126
1175
  }
1127
1176
  return Z(i);
@@ -1132,7 +1181,7 @@ var X = class {
1132
1181
  return t;
1133
1182
  }
1134
1183
  };
1135
- function Be(e) {
1184
+ function Ge(e) {
1136
1185
  return g(e, "::balance_manager::BalanceManager")?.objectId ?? null;
1137
1186
  }
1138
1187
  function Z(e) {
@@ -1142,7 +1191,7 @@ function Z(e) {
1142
1191
  raw: e.raw
1143
1192
  };
1144
1193
  }
1145
- var Ve = class {
1194
+ var Ke = class {
1146
1195
  c;
1147
1196
  constructor(e) {
1148
1197
  this.c = e;
@@ -1160,9 +1209,9 @@ var Ve = class {
1160
1209
  balanceManagerId: r,
1161
1210
  created: !1
1162
1211
  };
1163
- let i = this.c.requireExecutor(), a = new e(), o = j(a, this.c.ids);
1212
+ let i = this.c.requireExecutor(), a = new e(), o = k(a, this.c.ids);
1164
1213
  a.transferObjects([o], n);
1165
- let s = Be(await m(i, a));
1214
+ let s = Ge(await m(i, a));
1166
1215
  if (!s) throw new d(u.UnexpectedResponse, "Balance manager created but no created-object info found — have the executor include effects+objectTypes (v2) or objectChanges (legacy).");
1167
1216
  return this.c.rememberBalanceManagerId(s), {
1168
1217
  balanceManagerId: s,
@@ -1174,12 +1223,12 @@ var Ve = class {
1174
1223
  let t = this.c.requireAddress();
1175
1224
  this.c.requireExecutor();
1176
1225
  let { tx: n, bm: r, existingBmId: i } = await this.c.beginBmTx(t), a = await V(this.c.suiClient, n, t, this.c.ids.credCoinType, e.amount, "Insufficient CRED in the wallet for this deposit.");
1177
- return N(n, this.c.ids, r, a), this.c.finishBmTx(n, r, i, t);
1226
+ return j(n, this.c.ids, r, a), this.c.finishBmTx(n, r, i, t);
1178
1227
  }
1179
1228
  async depositItems(e) {
1180
1229
  let t = this.c.requireAddress();
1181
1230
  this.c.requireExecutor();
1182
- let n = await this.c.indexer.hubVault(e.storageUnitId), r = w(e.storageUnitId), { tx: i, bm: a, existingBmId: o } = await this.c.beginBmTx(t);
1231
+ let n = await this.c.indexer.hubVault(e.storageUnitId), r = S(e.storageUnitId), { tx: i, bm: a, existingBmId: o } = await this.c.beginBmTx(t);
1183
1232
  for (let s of e.items) await H(this.c.suiClient, i, this.c.ids, a, {
1184
1233
  owner: t,
1185
1234
  ssuObjectId: r,
@@ -1193,20 +1242,20 @@ var Ve = class {
1193
1242
  return this.c.finishBmTx(i, a, o, t);
1194
1243
  }
1195
1244
  async withdrawCurrency(t) {
1196
- let n = this.c.requireAddress(), r = await this.c.requireBalanceManagerId(n), i = this.c.requireExecutor(), a = new e(), o = a.object(r), s = t?.amount === void 0 ? ce(a, this.c.ids, o) : se(a, this.c.ids, o, t.amount);
1245
+ let n = this.c.requireAddress(), r = await this.c.requireBalanceManagerId(n), i = this.c.requireExecutor(), a = new e(), o = a.object(r), s = t?.amount === void 0 ? ue(a, this.c.ids, o) : le(a, this.c.ids, o, t.amount);
1197
1246
  return a.transferObjects([s], n), Z(await m(i, a));
1198
1247
  }
1199
1248
  async withdrawItems(t) {
1200
- let n = this.c.requireAddress(), r = await this.c.requireBalanceManagerId(n), i = this.c.requireExecutor(), a = await this.c.indexer.hubVault(t.storageUnitId), o = w(t.storageUnitId), s = t.characterId;
1249
+ let n = this.c.requireAddress(), r = await this.c.requireBalanceManagerId(n), i = this.c.requireExecutor(), a = await this.c.indexer.hubVault(t.storageUnitId), o = S(t.storageUnitId), s = t.characterId;
1201
1250
  if (!s) {
1202
- let e = await O(this.c.suiClient, this.c.ids, n);
1251
+ let e = await E(this.c.suiClient, this.c.ids, n);
1203
1252
  if (!e) throw new d(u.CharacterNotFound, `No on-chain character resolved for ${n} — pass characterId explicitly.`);
1204
1253
  s = e.characterId;
1205
1254
  }
1206
- let c = await k(this.c.suiClient, o, n), l = new e(), f = l.object(r);
1255
+ let c = await D(this.c.suiClient, o, n), l = new e(), f = l.object(r);
1207
1256
  for (let e of t.items) {
1208
- let t = le(l, this.c.ids, f, a.collectionId, BigInt(e.assetId));
1209
- ue(l, this.c.ids, t, {
1257
+ let t = M(l, this.c.ids, f, a.collectionId, BigInt(e.assetId));
1258
+ N(l, this.c.ids, t, {
1210
1259
  ssuObjectId: o,
1211
1260
  characterId: s,
1212
1261
  vaultConfigId: a.vaultConfigId,
@@ -1226,7 +1275,7 @@ var Ve = class {
1226
1275
  poolId: e.poolId,
1227
1276
  quoteCoinType: e.quoteAssetId ?? void 0
1228
1277
  })), a.length === 0) throw new d(u.ValidationFailed, "Nothing settled to claim — no pools with claimable balances.");
1229
- let o = new e(), s = o.object(r), c = M(o, this.c.ids, s)[0];
1278
+ let o = new e(), s = o.object(r), c = A(o, this.c.ids, s)[0];
1230
1279
  for (let e of a) B(o, this.c.ids, {
1231
1280
  poolId: e.poolId,
1232
1281
  bm: s,
@@ -1235,14 +1284,14 @@ var Ve = class {
1235
1284
  });
1236
1285
  return Z(await m(i, o));
1237
1286
  }
1238
- }, He = class {
1287
+ }, qe = class {
1239
1288
  c;
1240
1289
  constructor(e) {
1241
1290
  this.c = e;
1242
1291
  }
1243
1292
  async atHub(e) {
1244
1293
  let t = e.address ?? this.c.requireAddress(), n = await this.c.resolveBalanceManagerId(t) ?? void 0, r = e.inventoryKey;
1245
- return !r && e.includeHangar && (r = (await O(this.c.suiClient, this.c.ids, t))?.ownerCapId), this.c.indexer.inventoryBalances({
1294
+ return !r && e.includeHangar && (r = (await E(this.c.suiClient, this.c.ids, t))?.ownerCapId), this.c.indexer.inventoryBalances({
1246
1295
  ...e,
1247
1296
  address: t,
1248
1297
  balanceManagerId: n,
@@ -1250,14 +1299,14 @@ var Ve = class {
1250
1299
  });
1251
1300
  }
1252
1301
  async currency(e) {
1253
- let t = this.c.requireAddress(e), [n, r] = await Promise.all([re(this.c.suiClient, t, this.c.ids.credCoinType), this.c.resolveBalanceManagerId(t)]);
1302
+ let t = this.c.requireAddress(e), [n, r] = await Promise.all([ae(this.c.suiClient, t, this.c.ids.credCoinType), this.c.resolveBalanceManagerId(t)]);
1254
1303
  return {
1255
1304
  wallet: n,
1256
- balanceManager: r ? await T(this.c.suiClient, this.c.ids, r) : 0n,
1305
+ balanceManager: r ? await C(this.c.suiClient, this.c.ids, r) : 0n,
1257
1306
  balanceManagerId: r
1258
1307
  };
1259
1308
  }
1260
- }, Ue = class {
1309
+ }, Je = class {
1261
1310
  c;
1262
1311
  constructor(e) {
1263
1312
  this.c = e;
@@ -1277,6 +1326,9 @@ var Ve = class {
1277
1326
  itemsAtHub(e) {
1278
1327
  return this.c.indexer.hubItems(e);
1279
1328
  }
1329
+ searchItems(e, t) {
1330
+ return this.c.indexer.searchItems(e, t?.limit);
1331
+ }
1280
1332
  async resolvePool(e) {
1281
1333
  let t = await this.c.indexer.hubVault(e.storageUnitId), n = await this.c.indexer.resolvePool({
1282
1334
  collectionId: t.collectionId,
@@ -1286,13 +1338,20 @@ var Ve = class {
1286
1338
  return n;
1287
1339
  }
1288
1340
  async orderbook(e) {
1289
- let t = await this.resolvePool(e);
1290
- return this.c.indexer.orderbook(t);
1341
+ let t = await this.c.indexer.hubItemOrderbook({
1342
+ hubId: e.storageUnitId,
1343
+ assetId: e.assetId
1344
+ });
1345
+ if (!t.poolId) throw new d(u.PoolNotFound, `No pool for item ${e.assetId} at hub ${e.storageUnitId}.`);
1346
+ return {
1347
+ ...t,
1348
+ poolId: t.poolId
1349
+ };
1291
1350
  }
1292
1351
  poolMetadata(e) {
1293
1352
  return this.c.indexer.poolMetadata(e);
1294
1353
  }
1295
- }, We = class {
1354
+ }, Ye = class {
1296
1355
  c;
1297
1356
  constructor(e) {
1298
1357
  this.c = e;
@@ -1304,7 +1363,7 @@ var Ve = class {
1304
1363
  let n = e.side === "buy", r = await this.c.indexer.hubVault(e.storageUnitId), i = await this.requirePool(r.collectionId, e), { tx: a, bm: o, existingBmId: s } = await this.c.beginBmTx(t);
1305
1364
  if (!n) await H(this.c.suiClient, a, this.c.ids, o, {
1306
1365
  owner: t,
1307
- ssuObjectId: w(e.storageUnitId),
1366
+ ssuObjectId: S(e.storageUnitId),
1308
1367
  vaultConfigId: r.vaultConfigId,
1309
1368
  vaultCollectionId: r.collectionId,
1310
1369
  assetId: BigInt(e.assetId),
@@ -1316,12 +1375,12 @@ var Ve = class {
1316
1375
  let n = e.quoteDeposit;
1317
1376
  if (n === void 0) {
1318
1377
  let t = await this.c.indexer.poolMetadata(i);
1319
- n = K(e.price, e.quantity, t.feeRateScaled);
1378
+ n = he(e.price, e.quantity, t.feeRateScaled);
1320
1379
  }
1321
1380
  if (n <= 0n) throw new d(u.ValidationFailed, "Invalid quote deposit amount.");
1322
1381
  await this.depositQuoteDeficit(a, o, s, t, n);
1323
1382
  }
1324
- let c = M(a, this.c.ids, o)[0];
1383
+ let c = A(a, this.c.ids, o)[0];
1325
1384
  return F(a, this.c.ids, {
1326
1385
  poolId: i,
1327
1386
  bm: o,
@@ -1341,7 +1400,7 @@ var Ve = class {
1341
1400
  let n = e.side === "buy", r = await this.c.indexer.hubVault(e.storageUnitId), i = await this.requirePool(r.collectionId, e), { tx: a, bm: o, existingBmId: s } = await this.c.beginBmTx(t);
1342
1401
  if (!n) await H(this.c.suiClient, a, this.c.ids, o, {
1343
1402
  owner: t,
1344
- ssuObjectId: w(e.storageUnitId),
1403
+ ssuObjectId: S(e.storageUnitId),
1345
1404
  vaultConfigId: r.vaultConfigId,
1346
1405
  vaultCollectionId: r.collectionId,
1347
1406
  assetId: BigInt(e.assetId),
@@ -1351,10 +1410,10 @@ var Ve = class {
1351
1410
  });
1352
1411
  else {
1353
1412
  if (!e.quoteBudget || e.quoteBudget <= 0n) throw new d(u.ValidationFailed, "Market buys require `quoteBudget` (see estimateMarketBuyCost).");
1354
- let n = await this.c.indexer.poolMetadata(i), r = e.quoteBudget + he(e.quantity, n.feeRateScaled);
1413
+ let n = await this.c.indexer.poolMetadata(i), r = e.quoteBudget + ge(e.quantity, n.feeRateScaled);
1355
1414
  await this.depositQuoteDeficit(a, o, s, t, r);
1356
1415
  }
1357
- let c = M(a, this.c.ids, o)[0];
1416
+ let c = A(a, this.c.ids, o)[0];
1358
1417
  return I(a, this.c.ids, {
1359
1418
  poolId: i,
1360
1419
  bm: o,
@@ -1365,7 +1424,7 @@ var Ve = class {
1365
1424
  }), this.c.finishBmTx(a, o, s, t);
1366
1425
  }
1367
1426
  async cancel(e) {
1368
- let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = M(t, this.c.ids, n)[0];
1427
+ let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = A(t, this.c.ids, n)[0];
1369
1428
  return L(t, this.c.ids, {
1370
1429
  poolId: r,
1371
1430
  bm: n,
@@ -1374,7 +1433,7 @@ var Ve = class {
1374
1433
  }), i();
1375
1434
  }
1376
1435
  async cancelAll(e) {
1377
- let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = M(t, this.c.ids, n)[0];
1436
+ let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = A(t, this.c.ids, n)[0];
1378
1437
  return R(t, this.c.ids, {
1379
1438
  poolId: r,
1380
1439
  bm: n,
@@ -1383,7 +1442,7 @@ var Ve = class {
1383
1442
  }
1384
1443
  async modify(e) {
1385
1444
  if (e.newQuantity <= 0n) throw new d(u.ValidationFailed, "Modified quantity must be positive.");
1386
- let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = M(t, this.c.ids, n)[0];
1445
+ let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = A(t, this.c.ids, n)[0];
1387
1446
  return z(t, this.c.ids, {
1388
1447
  poolId: r,
1389
1448
  bm: n,
@@ -1425,10 +1484,10 @@ var Ve = class {
1425
1484
  return n;
1426
1485
  }
1427
1486
  async depositQuoteDeficit(e, t, n, r, i) {
1428
- let a = n ? await T(this.c.suiClient, this.c.ids, n) : 0n, o = i > a ? i - a : 0n;
1487
+ let a = n ? await C(this.c.suiClient, this.c.ids, n) : 0n, o = i > a ? i - a : 0n;
1429
1488
  if (o === 0n) return;
1430
1489
  let s = await V(this.c.suiClient, e, r, this.c.ids.credCoinType, o, "Insufficient CRED to fund the balance manager for this order.");
1431
- N(e, this.c.ids, t, s);
1490
+ j(e, this.c.ids, t, s);
1432
1491
  }
1433
1492
  async beginCancelTx(t) {
1434
1493
  let n = this.c.requireAddress(), r = await this.c.requireBalanceManagerId(n), i = this.c.requireExecutor(), a = await this.c.indexer.hubVault(t.storageUnitId), o = await this.requirePool(a.collectionId, t), s = new e();
@@ -1439,7 +1498,7 @@ var Ve = class {
1439
1498
  execute: async () => Z(await m(i, s))
1440
1499
  };
1441
1500
  }
1442
- }, Ge = class {
1501
+ }, Xe = class {
1443
1502
  ids;
1444
1503
  indexer;
1445
1504
  constructor(e) {
@@ -1460,6 +1519,9 @@ var Ve = class {
1460
1519
  itemsAtHub(e) {
1461
1520
  return this.indexer.hubItems(e);
1462
1521
  }
1522
+ searchItems(e, t) {
1523
+ return this.indexer.searchItems(e, t?.limit);
1524
+ }
1463
1525
  async resolvePool(e) {
1464
1526
  let t = await this.indexer.hubVault(e.storageUnitId), n = await this.indexer.resolvePool({
1465
1527
  collectionId: t.collectionId,
@@ -1469,8 +1531,15 @@ var Ve = class {
1469
1531
  return n;
1470
1532
  }
1471
1533
  async orderbook(e) {
1472
- let t = await this.resolvePool(e);
1473
- return this.indexer.orderbook(t);
1534
+ let t = await this.indexer.hubItemOrderbook({
1535
+ hubId: e.storageUnitId,
1536
+ assetId: e.assetId
1537
+ });
1538
+ if (!t.poolId) throw new d(u.PoolNotFound, `No pool for item ${e.assetId} at hub ${e.storageUnitId}.`);
1539
+ return {
1540
+ ...t,
1541
+ poolId: t.poolId
1542
+ };
1474
1543
  }
1475
1544
  poolMetadata(e) {
1476
1545
  return this.indexer.poolMetadata(e);
@@ -1493,7 +1562,7 @@ var Ve = class {
1493
1562
  };
1494
1563
  //#endregion
1495
1564
  //#region src/book.ts
1496
- function Ke(e) {
1565
+ function Ze(e) {
1497
1566
  let t = [];
1498
1567
  for (let n of e) {
1499
1568
  let e = t[t.length - 1];
@@ -1511,11 +1580,11 @@ function Q(e) {
1511
1580
  function $(e) {
1512
1581
  return e.asks[0] ?? null;
1513
1582
  }
1514
- function qe(e) {
1583
+ function Qe(e) {
1515
1584
  let t = Q(e), n = $(e);
1516
1585
  return !t || !n ? null : (t.price + n.price) / 2n;
1517
1586
  }
1518
- function Je(e) {
1587
+ function $e(e) {
1519
1588
  let t = Q(e), n = $(e);
1520
1589
  if (!t || !n) return null;
1521
1590
  let r = n.price - t.price, i = (t.price + n.price) / 2n;
@@ -1527,19 +1596,19 @@ function Je(e) {
1527
1596
  bps: Number(r * 10000n / i)
1528
1597
  };
1529
1598
  }
1530
- function Ye(e) {
1599
+ function et(e) {
1531
1600
  let t = 0n;
1532
1601
  for (let n of e) t += n.remainingQuantity;
1533
1602
  return t;
1534
1603
  }
1535
- function Xe(e) {
1604
+ function tt(e) {
1536
1605
  let t = 0n, n = 0n;
1537
1606
  for (let r of e) t += r.baseQuantity, n += r.quoteQuantity;
1538
1607
  return t === 0n ? null : n / t;
1539
1608
  }
1540
1609
  //#endregion
1541
1610
  //#region src/paging.ts
1542
- async function* Ze(e, t, n) {
1611
+ async function* nt(e, t, n) {
1543
1612
  let r = n?.maxItems ?? 1e4, i = t?.cursor, a = 0;
1544
1613
  for (;;) {
1545
1614
  let n = await e.discovery({
@@ -1551,7 +1620,7 @@ async function* Ze(e, t, n) {
1551
1620
  i = n.nextCursor;
1552
1621
  }
1553
1622
  }
1554
- async function* Qe(e, t, n, r) {
1623
+ async function* rt(e, t, n, r) {
1555
1624
  let i = r?.maxItems ?? 1e4, a = n?.before, o = 0;
1556
1625
  for (;;) {
1557
1626
  let r = await e.fills(t, {
@@ -1563,7 +1632,7 @@ async function* Qe(e, t, n, r) {
1563
1632
  a = r.fills[r.fills.length - 1].filledAt;
1564
1633
  }
1565
1634
  }
1566
- async function* $e(e, t, n, r) {
1635
+ async function* it(e, t, n, r) {
1567
1636
  let i = r?.maxItems ?? 1e4, a = n?.before, o = 0;
1568
1637
  for (;;) {
1569
1638
  let r = await e.trades(t, {
@@ -1577,7 +1646,7 @@ async function* $e(e, t, n, r) {
1577
1646
  }
1578
1647
  //#endregion
1579
1648
  //#region src/wait.ts
1580
- async function et(e, t) {
1649
+ async function at(e, t) {
1581
1650
  let n = t?.timeoutMs ?? 3e4, r = t?.intervalMs ?? 2e3, i = Date.now() + n;
1582
1651
  for (;;) {
1583
1652
  let a = await e();
@@ -1587,4 +1656,4 @@ async function et(e, t) {
1587
1656
  }
1588
1657
  }
1589
1658
  //#endregion
1590
- export { o as CLOCK_ID, a as DEFAULT_INDEXER_URL, W as FEE_RATE_SCALING, fe as GTC_EXPIRE, X as IndexerClient, U as MULTICOIN_PRICE_SCALING, c as NETWORK_PRESETS, Ge as ReadOnlyClient, s as STILLNESS_PACKAGE_IDS, de as TRIEX_PRICE_SCALING, ze as TriexClient, d as TriexClientError, u as TriexError, Ke as aggregateLevels, $ as bestAsk, Q as bestBid, K as computeBidQuoteDeposit, G as computeItemQuote, Ye as depth, ge as estimateMarketBuyCost, m as executeAndNormalize, p as explainMoveAbort, O as fetchCharacterInfo, A as fetchInventorySlotQuantity, k as fetchSsuOwnerInfo, g as findCreatedObject, D as findOwnedItemReceipts, me as fromBase, T as getBalanceManagerCurrencyBalance, ie as getBalanceManagerItemBalance, ne as getObjectRef, E as getRegistryMulticoinCollectionId, re as getWalletCurrencyBalance, Ze as iterateDiscovery, Qe as iterateFills, $e as iterateTrades, he as marketBuyRoundingBuffer, qe as midPrice, h as normalizeExecuteResult, V as prepareWalletCoinInput, l as resolvePackageIds, H as sourceItemsIntoBalanceManager, Je as spread, pe as toBase, w as toSsuObjectId, ae as transactions, et as untilIndexed, Xe as vwap };
1659
+ export { o as CLOCK_ID, a as DEFAULT_INDEXER_URL, W as FEE_RATE_SCALING, fe as GTC_EXPIRE, X as IndexerClient, U as MULTICOIN_PRICE_SCALING, c as NETWORK_PRESETS, Xe as ReadOnlyClient, s as STILLNESS_PACKAGE_IDS, de as TRIEX_PRICE_SCALING, We as TriexClient, d as TriexClientError, u as TriexError, Ze as aggregateLevels, $ as bestAsk, Q as bestBid, he as computeBidQuoteDeposit, G as computeItemQuote, et as depth, _e as estimateMarketBuyCost, m as executeAndNormalize, p as explainMoveAbort, E as fetchCharacterInfo, O as fetchInventorySlotQuantity, D as fetchSsuOwnerInfo, g as findCreatedObject, oe as findOwnedItemReceipts, me as fromBase, C as getBalanceManagerCurrencyBalance, w as getBalanceManagerItemBalance, ie as getObjectRef, T as getRegistryMulticoinCollectionId, ae as getWalletCurrencyBalance, nt as iterateDiscovery, rt as iterateFills, it as iterateTrades, ge as marketBuyRoundingBuffer, Qe as midPrice, h as normalizeExecuteResult, V as prepareWalletCoinInput, l as resolvePackageIds, H as sourceItemsIntoBalanceManager, $e as spread, pe as toBase, S as toSsuObjectId, se as transactions, at as untilIndexed, tt as vwap };