@trinaryex/sdk 3.1.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { IndexerClient } from './queries';
2
- import { BalancesAtHubParams, DiscoveryFilters, DiscoveryResult, FillsPage, FillsParams, HistoryPageParams, HubItemOrderbook, HubItemsPage, InventoryBalances, OpenOrdersPage, PackageIds, PoolMetadata, ReadOnlyClientConfig, Sweepable, TradeHubDetail, TradesPage, TradesParams } from './types';
2
+ import { BalancesAtHubParams, DiscoveryFilters, DiscoveryResult, FillsPage, FillsParams, HistoryPageParams, HubItemOrderbook, HubItemsPage, ItemSearchPage, InventoryBalances, OpenOrdersPage, PackageIds, PoolMetadata, ReadOnlyClientConfig, Sweepable, TradeHubDetail, TradesPage, TradesParams } from './types';
3
3
  export declare class ReadOnlyClient {
4
4
  readonly ids: PackageIds;
5
5
  readonly indexer: IndexerClient;
@@ -7,6 +7,9 @@ export declare class ReadOnlyClient {
7
7
  discover(filters?: DiscoveryFilters): Promise<DiscoveryResult>;
8
8
  hub(hubId: string): Promise<TradeHubDetail>;
9
9
  itemsAtHub(hubId: string): Promise<HubItemsPage>;
10
+ searchItems(query: string, opts?: {
11
+ limit?: number;
12
+ }): Promise<ItemSearchPage>;
10
13
  resolvePool(params: {
11
14
  storageUnitId: string;
12
15
  assetId: string;
@@ -1,7 +1,7 @@
1
1
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
2
2
  import { ClientWithCoreApi } from '@mysten/sui/client';
3
3
  import { IndexerClient } from './queries';
4
- import { BalancesAtHubParams, CancelAllOrdersParams, CancelOrderParams, ClaimSettledParams, CurrencyBalances, DepositCurrencyParams, DepositItemsParams, DiscoveryFilters, DiscoveryResult, EnsureAccountResult, FillsPage, FillsParams, HistoryPageParams, HubItemOrderbook, HubItemsPage, InventoryBalances, LimitOrderParams, MarketOrderParams, ModifyOrderParams, OpenOrdersPage, PackageIds, PoolMetadata, Sweepable, TradeHubDetail, TradesPage, TradesParams, TradingAccount, TransactionExecutor, TriexClientConfig, TxResult, WithdrawCurrencyParams, WithdrawItemsParams } from './types';
4
+ import { BalancesAtHubParams, CancelAllOrdersParams, CancelOrderParams, ClaimSettledParams, CurrencyBalances, DepositCurrencyParams, DepositItemsParams, DiscoveryFilters, DiscoveryResult, EnsureAccountResult, FillsPage, FillsParams, HistoryPageParams, HubItemOrderbook, HubItemsPage, ItemSearchPage, InventoryBalances, LimitOrderParams, MarketOrderParams, ModifyOrderParams, OpenOrdersPage, PackageIds, PoolMetadata, Sweepable, TradeHubDetail, TradesPage, TradesParams, TradingAccount, TransactionExecutor, TriexClientConfig, TxResult, WithdrawCurrencyParams, WithdrawItemsParams } from './types';
5
5
  export declare class TriexClient {
6
6
  readonly suiClient: ClientWithCoreApi;
7
7
  readonly ids: PackageIds;
@@ -52,6 +52,9 @@ declare class MarketApi {
52
52
  discover(filters?: DiscoveryFilters): Promise<DiscoveryResult>;
53
53
  hub(hubId: string): Promise<TradeHubDetail>;
54
54
  itemsAtHub(hubId: string): Promise<HubItemsPage>;
55
+ searchItems(query: string, opts?: {
56
+ limit?: number;
57
+ }): Promise<ItemSearchPage>;
55
58
  resolvePool(params: {
56
59
  storageUnitId: string;
57
60
  assetId: string;
package/dist/index.d.ts CHANGED
@@ -15,5 +15,5 @@ export type { BookLevel } from './book';
15
15
  export { iterateDiscovery, iterateFills, iterateTrades } from './paging';
16
16
  export type { IterateOptions } from './paging';
17
17
  export { untilIndexed } from './wait';
18
- export type { TriexNetwork, PackageIds, TriexClientConfig, ReadOnlyClientConfig, TransactionExecutor, ObjectChange, TxResult, OrderSide, TradingAccount, CurrencyBalances, AssetBalance, InventoryBalances, TradeHubDetail, HubVaultInfo, HubLocation, HubItem, HubItemsPage, CollectionHub, Orderbook, HubItemOrderbook, HubItemMarket, OrderbookOrder, PoolMetadata, DiscoveryOrder, DiscoveryResult, DiscoveryFilters, OpenOrder, OpenOrdersPage, Fill, FillsPage, Trade, TradesPage, BalancesAtHubParams, HistoryPageParams, FillsParams, TradesParams, Sweepable, SweepablePool, SweepableItem, EnsureAccountResult, DepositCurrencyParams, DepositItemsParams, WithdrawCurrencyParams, WithdrawItemsParams, LimitOrderParams, MarketOrderParams, CancelOrderParams, CancelAllOrdersParams, ModifyOrderParams, ClaimSettledParams, } from './types';
18
+ export type { TriexNetwork, PackageIds, TriexClientConfig, ReadOnlyClientConfig, TransactionExecutor, ObjectChange, TxResult, OrderSide, TradingAccount, CurrencyBalances, AssetBalance, InventoryBalances, TradeHubDetail, HubVaultInfo, HubLocation, HubItem, HubItemsPage, ItemRecipe, ItemRecipeComponent, ItemSearchPage, ItemSearchResult, CollectionHub, Orderbook, HubItemOrderbook, HubItemMarket, OrderbookOrder, PoolMetadata, DiscoveryOrder, DiscoveryResult, DiscoveryFilters, OpenOrder, OpenOrdersPage, Fill, FillsPage, Trade, TradesPage, BalancesAtHubParams, HistoryPageParams, FillsParams, TradesParams, Sweepable, SweepablePool, SweepableItem, EnsureAccountResult, DepositCurrencyParams, DepositItemsParams, WithdrawCurrencyParams, WithdrawItemsParams, LimitOrderParams, MarketOrderParams, CancelOrderParams, CancelAllOrdersParams, ModifyOrderParams, ClaimSettledParams, } from './types';
19
19
  export type { OwnedItemReceipt, CharacterInfo, SsuOwnerInfo, ObjectRef, } from './onchain';
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 ae(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 ae(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 E(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 E(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 E(e, t, n, r) {
250
250
  }
251
251
  return a;
252
252
  }
253
- async function D(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 D(e, t, n) {
272
272
  }
273
273
  return null;
274
274
  }
275
- async function O(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 O(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 O(e, t, n) {
298
298
  charOwnerCapId: s
299
299
  } : null;
300
300
  }
301
- async function k(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 k(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 k(e, n, r, i) {
316
316
  }
317
317
  //#endregion
318
318
  //#region src/transactions.ts
319
- var oe = /* @__PURE__ */ i({
320
- cancelAllOrdersItem: () => L,
321
- cancelOrderItem: () => I,
322
- depositCoin: () => M,
323
- depositMulticoinObject: () => se,
324
- generateProofAsOwner: () => j,
325
- modifyOrderItem: () => R,
326
- newBalanceManager: () => A,
327
- placeLimitOrderItem: () => P,
328
- placeMarketOrderItem: () => F,
329
- redeemReceipt: () => de,
330
- sourceItemsFromHangar: () => N,
331
- withdrawAllCoin: () => le,
332
- withdrawAllMulticoin: () => ue,
333
- withdrawCoin: () => ce,
334
- withdrawSettledAmounts: () => z
319
+ var se = /* @__PURE__ */ i({
320
+ cancelAllOrdersItem: () => R,
321
+ cancelOrderItem: () => L,
322
+ depositCoin: () => j,
323
+ depositMulticoinObject: () => ce,
324
+ generateProofAsOwner: () => A,
325
+ modifyOrderItem: () => z,
326
+ newBalanceManager: () => k,
327
+ placeLimitOrderItem: () => F,
328
+ placeMarketOrderItem: () => I,
329
+ redeemReceipt: () => N,
330
+ sourceItemsFromHangar: () => P,
331
+ withdrawAllCoin: () => ue,
332
+ withdrawAllMulticoin: () => M,
333
+ withdrawCoin: () => le,
334
+ withdrawSettledAmounts: () => B
335
335
  });
336
- function A(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 j(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 M(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 se(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 ce(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 le(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 ue(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 ue(e, t, n, r, i) {
382
382
  ]
383
383
  });
384
384
  }
385
- function de(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: [
@@ -395,7 +395,7 @@ function de(e, t, n, r) {
395
395
  ]
396
396
  });
397
397
  }
398
- function N(e, t, n, r) {
398
+ function P(e, t, n, r) {
399
399
  let i = e.object(r.characterId), a = e.moveCall({
400
400
  target: `${t.world}::character::borrow_owner_cap`,
401
401
  typeArguments: [r.capTypeArg],
@@ -426,7 +426,7 @@ function N(e, t, n, r) {
426
426
  arguments: [n, c]
427
427
  });
428
428
  }
429
- function P(e, t, n) {
429
+ function F(e, t, n) {
430
430
  e.moveCall({
431
431
  target: `${t.triex}::multicoin_pool::place_limit_order`,
432
432
  typeArguments: [t.credCoinType],
@@ -444,7 +444,7 @@ function P(e, t, n) {
444
444
  ]
445
445
  });
446
446
  }
447
- function F(e, t, n) {
447
+ function I(e, t, n) {
448
448
  e.moveCall({
449
449
  target: `${t.triex}::multicoin_pool::place_market_order`,
450
450
  typeArguments: [t.credCoinType],
@@ -459,7 +459,7 @@ function F(e, t, n) {
459
459
  ]
460
460
  });
461
461
  }
462
- function I(e, t, n) {
462
+ function L(e, t, n) {
463
463
  e.moveCall({
464
464
  target: `${t.triex}::multicoin_pool::cancel_order`,
465
465
  typeArguments: [t.credCoinType],
@@ -472,7 +472,7 @@ function I(e, t, n) {
472
472
  ]
473
473
  });
474
474
  }
475
- function L(e, t, n) {
475
+ function R(e, t, n) {
476
476
  e.moveCall({
477
477
  target: `${t.triex}::multicoin_pool::cancel_all_orders`,
478
478
  typeArguments: [t.credCoinType],
@@ -484,7 +484,7 @@ function L(e, t, n) {
484
484
  ]
485
485
  });
486
486
  }
487
- function R(e, t, n) {
487
+ function z(e, t, n) {
488
488
  e.moveCall({
489
489
  target: `${t.triex}::multicoin_pool::modify_order`,
490
490
  typeArguments: [t.credCoinType],
@@ -498,7 +498,7 @@ function R(e, t, n) {
498
498
  ]
499
499
  });
500
500
  }
501
- function z(e, t, n) {
501
+ function B(e, t, n) {
502
502
  e.moveCall({
503
503
  target: `${t.triex}::multicoin_pool::withdraw_settled_amounts`,
504
504
  typeArguments: [n.quoteCoinType ?? t.credCoinType],
@@ -511,7 +511,7 @@ function z(e, t, n) {
511
511
  }
512
512
  //#endregion
513
513
  //#region src/funding.ts
514
- async function B(e, t, n, r, i, a = "Insufficient wallet balance to fund this transaction.") {
514
+ async function V(e, t, n, r, i, a = "Insufficient wallet balance to fund this transaction.") {
515
515
  let o = e.core, s = [], c = 0n, l;
516
516
  for (let e = 0; e < 40 && c < i; e++) {
517
517
  let e = await o.listCoins({
@@ -533,23 +533,23 @@ async function B(e, t, n, r, i, a = "Insufficient wallet balance to fund this tr
533
533
  let [p] = t.splitCoins(f, [t.pure.u64(i)]);
534
534
  return p;
535
535
  }
536
- async function V(e, t, n, r, i) {
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 E(e, n, i.owner, { assetId: a.toString() }), f = (i.vaultCollectionId || await ae(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
- se(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([O(e, i.ssuObjectId, i.owner), D(e, n, i.owner)]), _ = async (o, s, c, l) => {
551
- let u = await ne(e, o);
552
- N(t, n, r, {
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
+ P(t, n, r, {
553
553
  ssuObjectId: i.ssuObjectId,
554
554
  characterId: c,
555
555
  capRef: u,
@@ -561,13 +561,13 @@ async function V(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([k(e, i.ssuObjectId, h.ssuOwnerCapId, a.toString()), k(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 k(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;
@@ -581,25 +581,25 @@ async function V(e, t, n, r, i) {
581
581
  }
582
582
  //#endregion
583
583
  //#region src/money.ts
584
- var fe = 1000000000n, H = 1n, U = 1000000000n, pe = 18446744073709551615n;
585
- function me(e, t) {
584
+ var de = 1000000000n, U = 1n, W = 1000000000n, fe = 18446744073709551615n;
585
+ function pe(e, t) {
586
586
  let n = typeof e == "number" ? e.toString() : e.trim();
587
587
  if (!/^\d+(\.\d+)?$/.test(n)) throw Error(`toBase: invalid amount "${e}"`);
588
588
  let [r, i = ""] = n.split("."), a = (i + "0".repeat(t)).slice(0, t);
589
589
  return BigInt(r) * 10n ** BigInt(t) + BigInt(a || "0");
590
590
  }
591
- function he(e, t) {
591
+ function me(e, t) {
592
592
  let n = e < 0n, r = n ? -e : e, i = 10n ** BigInt(t), a = r / i, o = (r % i).toString().padStart(t, "0").replace(/0+$/, ""), s = n ? "-" : "";
593
593
  return o ? `${s}${a}.${o}` : `${s}${a}`;
594
594
  }
595
- function W(e, t) {
596
- return e * t * H / 1n;
595
+ function G(e, t) {
596
+ return e * t * U / 1n;
597
597
  }
598
- function G(e, t, n) {
599
- return W(e, t) * (U + n) / U;
598
+ function he(e, t, n) {
599
+ return G(e, t) * (W + n) / W;
600
600
  }
601
601
  function ge(e, t) {
602
- return e * t / U + 2n;
602
+ return e * t / W + 2n;
603
603
  }
604
604
  function _e(e, t, n) {
605
605
  let r = t, i = 0n;
@@ -608,7 +608,7 @@ function _e(e, t, n) {
608
608
  let e = t.remainingQuantity < r ? t.remainingQuantity : r;
609
609
  i += e * t.price, r -= e;
610
610
  }
611
- let a = i * n / U;
611
+ let a = i * n / W;
612
612
  return {
613
613
  quote: i,
614
614
  fee: a,
@@ -799,13 +799,37 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
799
799
  }).transform((e) => ({
800
800
  hubId: e.hub_id,
801
801
  collectionId: e.collection_id
802
- })), J = n.object({
802
+ })), ke = n.object({
803
+ asset_id: n.string(),
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({
803
827
  asset_id: n.string(),
804
828
  amount: K
805
829
  }).transform((e) => ({
806
830
  assetId: e.asset_id,
807
831
  amount: e.amount
808
- })), ke = n.object({
832
+ })), Ne = n.object({
809
833
  storage_unit_id: n.string(),
810
834
  collection_id: n.string(),
811
835
  warehouse: n.array(J),
@@ -819,7 +843,7 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
819
843
  marketplace: e.marketplace,
820
844
  hangar: e.hangar,
821
845
  orgVaults: e.org_vaults
822
- })), Ae = n.object({
846
+ })), Pe = n.object({
823
847
  pool_id: n.string(),
824
848
  order_id: n.string(),
825
849
  encoded_order_id: n.string().optional(),
@@ -847,13 +871,13 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
847
871
  storageUnitId: e.storage_unit_id,
848
872
  quoteAssetSymbol: e.quote_asset_symbol,
849
873
  quoteAssetDecimals: e.quote_asset_decimals
850
- })), je = n.object({
851
- data: n.array(Ae),
874
+ })), Fe = n.object({
875
+ data: n.array(Pe),
852
876
  next_cursor: n.string().nullable()
853
877
  }).transform((e) => ({
854
878
  orders: e.data,
855
879
  nextCursor: e.next_cursor
856
- })), Me = n.object({
880
+ })), Ie = n.object({
857
881
  event_digest: n.string(),
858
882
  pool_id: n.string(),
859
883
  order_id: n.string(),
@@ -877,13 +901,13 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
877
901
  role: e.role,
878
902
  takerIsBid: e.taker_is_bid,
879
903
  filledAt: e.filled_at
880
- })), Ne = n.object({
881
- data: n.array(Me),
904
+ })), Le = n.object({
905
+ data: n.array(Ie),
882
906
  next_cursor: n.string().nullable()
883
907
  }).transform((e) => ({
884
908
  fills: e.data,
885
909
  nextCursor: e.next_cursor
886
- })), Pe = n.object({
910
+ })), Re = n.object({
887
911
  event_digest: n.string(),
888
912
  pool_id: n.string(),
889
913
  order_id: n.string(),
@@ -911,13 +935,13 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
911
935
  tradedAt: e.traded_at,
912
936
  assetId: e.asset_id,
913
937
  storageUnitId: e.storage_unit_id
914
- })), Fe = n.object({
915
- data: n.array(Pe),
938
+ })), ze = n.object({
939
+ data: n.array(Re),
916
940
  next_cursor: n.string().nullable()
917
941
  }).transform((e) => ({
918
942
  trades: e.data,
919
943
  nextCursor: e.next_cursor
920
- })), Ie = n.object({
944
+ })), Be = n.object({
921
945
  base: K,
922
946
  quote: K,
923
947
  cred: K
@@ -925,15 +949,15 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
925
949
  base: e.base,
926
950
  quote: e.quote,
927
951
  cred: e.cred
928
- })), Le = n.object({
952
+ })), Ve = n.object({
929
953
  pool_id: n.string(),
930
954
  collection_id: n.string(),
931
955
  asset_id: n.string(),
932
956
  quote_asset_id: n.string().nullable(),
933
957
  storage_unit_id: n.string(),
934
958
  vault_config_id: n.string(),
935
- settled: Ie,
936
- owed: Ie,
959
+ settled: Be,
960
+ owed: Be,
937
961
  open_order_count: n.number()
938
962
  }).transform((e) => ({
939
963
  poolId: e.pool_id,
@@ -945,7 +969,7 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
945
969
  settled: e.settled,
946
970
  owed: e.owed,
947
971
  openOrderCount: e.open_order_count
948
- })), Re = n.object({
972
+ })), He = n.object({
949
973
  collection_id: n.string(),
950
974
  asset_id: n.string(),
951
975
  amount: K,
@@ -957,11 +981,11 @@ var K = n.union([n.string(), n.number()]).transform((e, t) => {
957
981
  amount: e.amount,
958
982
  storageUnitId: e.storage_unit_id,
959
983
  vaultConfigId: e.vault_config_id
960
- })), ze = n.object({
984
+ })), Ue = n.object({
961
985
  balance_manager_id: n.string(),
962
986
  as_of_checkpoint: n.string().nullable(),
963
- pools: n.array(Le),
964
- items: n.array(Re)
987
+ pools: n.array(Ve),
988
+ items: n.array(He)
965
989
  }).transform((e) => ({
966
990
  balanceManagerId: e.balance_manager_id,
967
991
  asOfCheckpoint: e.as_of_checkpoint,
@@ -1053,11 +1077,17 @@ var X = class {
1053
1077
  async hubItems(e) {
1054
1078
  return Y(De, await this.get(`/v1/hubs/${encodeURIComponent(e)}/items`, void 0, u.HubNotFound), "hubItems");
1055
1079
  }
1080
+ async searchItems(e, t) {
1081
+ return Y(Me, await this.get("/v1/world/items/search", {
1082
+ q: e,
1083
+ limit: t
1084
+ }), "searchItems");
1085
+ }
1056
1086
  async collectionHub(e) {
1057
1087
  return Y(Oe, await this.get(`/v1/collections/${encodeURIComponent(e)}/hub`, void 0, u.HubNotFound), "collectionHub");
1058
1088
  }
1059
1089
  async inventoryBalances(e) {
1060
- return Y(ke, await this.get("/v1/inventory/balances", {
1090
+ return Y(Ne, await this.get("/v1/inventory/balances", {
1061
1091
  storage_unit_id: e.storageUnitId,
1062
1092
  owner_address: e.address,
1063
1093
  balance_manager_id: e.balanceManagerId,
@@ -1066,14 +1096,14 @@ var X = class {
1066
1096
  }, u.HubNotFound), "inventoryBalances");
1067
1097
  }
1068
1098
  async openOrders(e, t) {
1069
- return Y(je, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/open-orders`, {
1099
+ return Y(Fe, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/open-orders`, {
1070
1100
  before: t?.before,
1071
1101
  after: t?.after,
1072
1102
  limit: t?.limit
1073
1103
  }, u.BalanceManagerNotFound), "openOrders");
1074
1104
  }
1075
1105
  async fills(e, t) {
1076
- return Y(Ne, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/fills`, {
1106
+ return Y(Le, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/fills`, {
1077
1107
  before: t?.before,
1078
1108
  after: t?.after,
1079
1109
  limit: t?.limit,
@@ -1082,10 +1112,10 @@ var X = class {
1082
1112
  }, u.BalanceManagerNotFound), "fills");
1083
1113
  }
1084
1114
  async sweepable(e) {
1085
- return Y(ze, 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");
1086
1116
  }
1087
1117
  async trades(e, t) {
1088
- return Y(Fe, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/trades`, {
1118
+ return Y(ze, await this.get(`/v1/balance-managers/${encodeURIComponent(e)}/trades`, {
1089
1119
  before: t?.before,
1090
1120
  after: t?.after,
1091
1121
  limit: t?.limit,
@@ -1093,7 +1123,7 @@ var X = class {
1093
1123
  asset_id: t?.assetId
1094
1124
  }, u.BalanceManagerNotFound), "trades");
1095
1125
  }
1096
- }, Be = class {
1126
+ }, We = class {
1097
1127
  suiClient;
1098
1128
  ids;
1099
1129
  indexer;
@@ -1105,7 +1135,7 @@ var X = class {
1105
1135
  market;
1106
1136
  orders;
1107
1137
  constructor(e) {
1108
- 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 He(this), this.balances = new Ue(this), this.market = new We(this), this.orders = new Ge(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);
1109
1139
  }
1110
1140
  requireExecutor() {
1111
1141
  if (!this.executor) throw new d(u.ExecutorRequired, "This operation writes on-chain and requires an `executor`.");
@@ -1132,7 +1162,7 @@ var X = class {
1132
1162
  let n = await this.resolveBalanceManagerId(t), r = new e();
1133
1163
  return {
1134
1164
  tx: r,
1135
- bm: n ? r.object(n) : A(r, this.ids)[0],
1165
+ bm: n ? r.object(n) : k(r, this.ids)[0],
1136
1166
  existingBmId: n
1137
1167
  };
1138
1168
  }
@@ -1140,7 +1170,7 @@ var X = class {
1140
1170
  n || e.transferObjects([t], r);
1141
1171
  let i = await m(this.requireExecutor(), e);
1142
1172
  if (!n) {
1143
- let e = Ve(i);
1173
+ let e = Ge(i);
1144
1174
  e && this.rememberBalanceManagerId(e);
1145
1175
  }
1146
1176
  return Z(i);
@@ -1151,7 +1181,7 @@ var X = class {
1151
1181
  return t;
1152
1182
  }
1153
1183
  };
1154
- function Ve(e) {
1184
+ function Ge(e) {
1155
1185
  return g(e, "::balance_manager::BalanceManager")?.objectId ?? null;
1156
1186
  }
1157
1187
  function Z(e) {
@@ -1161,7 +1191,7 @@ function Z(e) {
1161
1191
  raw: e.raw
1162
1192
  };
1163
1193
  }
1164
- var He = class {
1194
+ var Ke = class {
1165
1195
  c;
1166
1196
  constructor(e) {
1167
1197
  this.c = e;
@@ -1179,9 +1209,9 @@ var He = class {
1179
1209
  balanceManagerId: r,
1180
1210
  created: !1
1181
1211
  };
1182
- let i = this.c.requireExecutor(), a = new e(), o = A(a, this.c.ids);
1212
+ let i = this.c.requireExecutor(), a = new e(), o = k(a, this.c.ids);
1183
1213
  a.transferObjects([o], n);
1184
- let s = Ve(await m(i, a));
1214
+ let s = Ge(await m(i, a));
1185
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).");
1186
1216
  return this.c.rememberBalanceManagerId(s), {
1187
1217
  balanceManagerId: s,
@@ -1192,14 +1222,14 @@ var He = class {
1192
1222
  if (e.amount <= 0n) throw new d(u.ValidationFailed, "Deposit amount must be positive.");
1193
1223
  let t = this.c.requireAddress();
1194
1224
  this.c.requireExecutor();
1195
- let { tx: n, bm: r, existingBmId: i } = await this.c.beginBmTx(t), a = await B(this.c.suiClient, n, t, this.c.ids.credCoinType, e.amount, "Insufficient CRED in the wallet for this deposit.");
1196
- return M(n, this.c.ids, r, a), this.c.finishBmTx(n, r, i, t);
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.");
1226
+ return j(n, this.c.ids, r, a), this.c.finishBmTx(n, r, i, t);
1197
1227
  }
1198
1228
  async depositItems(e) {
1199
1229
  let t = this.c.requireAddress();
1200
1230
  this.c.requireExecutor();
1201
- let n = await this.c.indexer.hubVault(e.storageUnitId), r = w(e.storageUnitId), { tx: i, bm: a, existingBmId: o } = await this.c.beginBmTx(t);
1202
- for (let s of e.items) await V(this.c.suiClient, i, this.c.ids, a, {
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);
1232
+ for (let s of e.items) await H(this.c.suiClient, i, this.c.ids, a, {
1203
1233
  owner: t,
1204
1234
  ssuObjectId: r,
1205
1235
  vaultConfigId: n.vaultConfigId,
@@ -1212,20 +1242,20 @@ var He = class {
1212
1242
  return this.c.finishBmTx(i, a, o, t);
1213
1243
  }
1214
1244
  async withdrawCurrency(t) {
1215
- 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 ? le(a, this.c.ids, o) : ce(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);
1216
1246
  return a.transferObjects([s], n), Z(await m(i, a));
1217
1247
  }
1218
1248
  async withdrawItems(t) {
1219
- 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;
1220
1250
  if (!s) {
1221
- let e = await D(this.c.suiClient, this.c.ids, n);
1251
+ let e = await E(this.c.suiClient, this.c.ids, n);
1222
1252
  if (!e) throw new d(u.CharacterNotFound, `No on-chain character resolved for ${n} — pass characterId explicitly.`);
1223
1253
  s = e.characterId;
1224
1254
  }
1225
- let c = await O(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);
1226
1256
  for (let e of t.items) {
1227
- let t = ue(l, this.c.ids, f, a.collectionId, BigInt(e.assetId));
1228
- de(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, {
1229
1259
  ssuObjectId: o,
1230
1260
  characterId: s,
1231
1261
  vaultConfigId: a.vaultConfigId,
@@ -1245,8 +1275,8 @@ var He = class {
1245
1275
  poolId: e.poolId,
1246
1276
  quoteCoinType: e.quoteAssetId ?? void 0
1247
1277
  })), a.length === 0) throw new d(u.ValidationFailed, "Nothing settled to claim — no pools with claimable balances.");
1248
- let o = new e(), s = o.object(r), c = j(o, this.c.ids, s)[0];
1249
- for (let e of a) z(o, this.c.ids, {
1278
+ let o = new e(), s = o.object(r), c = A(o, this.c.ids, s)[0];
1279
+ for (let e of a) B(o, this.c.ids, {
1250
1280
  poolId: e.poolId,
1251
1281
  bm: s,
1252
1282
  proof: c,
@@ -1254,14 +1284,14 @@ var He = class {
1254
1284
  });
1255
1285
  return Z(await m(i, o));
1256
1286
  }
1257
- }, Ue = class {
1287
+ }, qe = class {
1258
1288
  c;
1259
1289
  constructor(e) {
1260
1290
  this.c = e;
1261
1291
  }
1262
1292
  async atHub(e) {
1263
1293
  let t = e.address ?? this.c.requireAddress(), n = await this.c.resolveBalanceManagerId(t) ?? void 0, r = e.inventoryKey;
1264
- return !r && e.includeHangar && (r = (await D(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({
1265
1295
  ...e,
1266
1296
  address: t,
1267
1297
  balanceManagerId: n,
@@ -1269,14 +1299,14 @@ var He = class {
1269
1299
  });
1270
1300
  }
1271
1301
  async currency(e) {
1272
- 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)]);
1273
1303
  return {
1274
1304
  wallet: n,
1275
- 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,
1276
1306
  balanceManagerId: r
1277
1307
  };
1278
1308
  }
1279
- }, We = class {
1309
+ }, Je = class {
1280
1310
  c;
1281
1311
  constructor(e) {
1282
1312
  this.c = e;
@@ -1296,6 +1326,9 @@ var He = class {
1296
1326
  itemsAtHub(e) {
1297
1327
  return this.c.indexer.hubItems(e);
1298
1328
  }
1329
+ searchItems(e, t) {
1330
+ return this.c.indexer.searchItems(e, t?.limit);
1331
+ }
1299
1332
  async resolvePool(e) {
1300
1333
  let t = await this.c.indexer.hubVault(e.storageUnitId), n = await this.c.indexer.resolvePool({
1301
1334
  collectionId: t.collectionId,
@@ -1318,7 +1351,7 @@ var He = class {
1318
1351
  poolMetadata(e) {
1319
1352
  return this.c.indexer.poolMetadata(e);
1320
1353
  }
1321
- }, Ge = class {
1354
+ }, Ye = class {
1322
1355
  c;
1323
1356
  constructor(e) {
1324
1357
  this.c = e;
@@ -1328,9 +1361,9 @@ var He = class {
1328
1361
  let t = this.c.requireAddress();
1329
1362
  this.c.requireExecutor();
1330
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);
1331
- if (!n) await V(this.c.suiClient, a, this.c.ids, o, {
1364
+ if (!n) await H(this.c.suiClient, a, this.c.ids, o, {
1332
1365
  owner: t,
1333
- ssuObjectId: w(e.storageUnitId),
1366
+ ssuObjectId: S(e.storageUnitId),
1334
1367
  vaultConfigId: r.vaultConfigId,
1335
1368
  vaultCollectionId: r.collectionId,
1336
1369
  assetId: BigInt(e.assetId),
@@ -1342,13 +1375,13 @@ var He = class {
1342
1375
  let n = e.quoteDeposit;
1343
1376
  if (n === void 0) {
1344
1377
  let t = await this.c.indexer.poolMetadata(i);
1345
- n = G(e.price, e.quantity, t.feeRateScaled);
1378
+ n = he(e.price, e.quantity, t.feeRateScaled);
1346
1379
  }
1347
1380
  if (n <= 0n) throw new d(u.ValidationFailed, "Invalid quote deposit amount.");
1348
1381
  await this.depositQuoteDeficit(a, o, s, t, n);
1349
1382
  }
1350
- let c = j(a, this.c.ids, o)[0];
1351
- return P(a, this.c.ids, {
1383
+ let c = A(a, this.c.ids, o)[0];
1384
+ return F(a, this.c.ids, {
1352
1385
  poolId: i,
1353
1386
  bm: o,
1354
1387
  proof: c,
@@ -1365,9 +1398,9 @@ var He = class {
1365
1398
  let t = this.c.requireAddress();
1366
1399
  this.c.requireExecutor();
1367
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);
1368
- if (!n) await V(this.c.suiClient, a, this.c.ids, o, {
1401
+ if (!n) await H(this.c.suiClient, a, this.c.ids, o, {
1369
1402
  owner: t,
1370
- ssuObjectId: w(e.storageUnitId),
1403
+ ssuObjectId: S(e.storageUnitId),
1371
1404
  vaultConfigId: r.vaultConfigId,
1372
1405
  vaultCollectionId: r.collectionId,
1373
1406
  assetId: BigInt(e.assetId),
@@ -1380,8 +1413,8 @@ var He = class {
1380
1413
  let n = await this.c.indexer.poolMetadata(i), r = e.quoteBudget + ge(e.quantity, n.feeRateScaled);
1381
1414
  await this.depositQuoteDeficit(a, o, s, t, r);
1382
1415
  }
1383
- let c = j(a, this.c.ids, o)[0];
1384
- return F(a, this.c.ids, {
1416
+ let c = A(a, this.c.ids, o)[0];
1417
+ return I(a, this.c.ids, {
1385
1418
  poolId: i,
1386
1419
  bm: o,
1387
1420
  proof: c,
@@ -1391,8 +1424,8 @@ var He = class {
1391
1424
  }), this.c.finishBmTx(a, o, s, t);
1392
1425
  }
1393
1426
  async cancel(e) {
1394
- let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = j(t, this.c.ids, n)[0];
1395
- return I(t, this.c.ids, {
1427
+ let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = A(t, this.c.ids, n)[0];
1428
+ return L(t, this.c.ids, {
1396
1429
  poolId: r,
1397
1430
  bm: n,
1398
1431
  proof: a,
@@ -1400,8 +1433,8 @@ var He = class {
1400
1433
  }), i();
1401
1434
  }
1402
1435
  async cancelAll(e) {
1403
- let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = j(t, this.c.ids, n)[0];
1404
- return L(t, this.c.ids, {
1436
+ let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = A(t, this.c.ids, n)[0];
1437
+ return R(t, this.c.ids, {
1405
1438
  poolId: r,
1406
1439
  bm: n,
1407
1440
  proof: a
@@ -1409,8 +1442,8 @@ var He = class {
1409
1442
  }
1410
1443
  async modify(e) {
1411
1444
  if (e.newQuantity <= 0n) throw new d(u.ValidationFailed, "Modified quantity must be positive.");
1412
- let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = j(t, this.c.ids, n)[0];
1413
- return R(t, this.c.ids, {
1445
+ let { tx: t, bm: n, poolId: r, execute: i } = await this.beginCancelTx(e), a = A(t, this.c.ids, n)[0];
1446
+ return z(t, this.c.ids, {
1414
1447
  poolId: r,
1415
1448
  bm: n,
1416
1449
  proof: a,
@@ -1451,10 +1484,10 @@ var He = class {
1451
1484
  return n;
1452
1485
  }
1453
1486
  async depositQuoteDeficit(e, t, n, r, i) {
1454
- 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;
1455
1488
  if (o === 0n) return;
1456
- let s = await B(this.c.suiClient, e, r, this.c.ids.credCoinType, o, "Insufficient CRED to fund the balance manager for this order.");
1457
- M(e, this.c.ids, t, s);
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.");
1490
+ j(e, this.c.ids, t, s);
1458
1491
  }
1459
1492
  async beginCancelTx(t) {
1460
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();
@@ -1465,7 +1498,7 @@ var He = class {
1465
1498
  execute: async () => Z(await m(i, s))
1466
1499
  };
1467
1500
  }
1468
- }, Ke = class {
1501
+ }, Xe = class {
1469
1502
  ids;
1470
1503
  indexer;
1471
1504
  constructor(e) {
@@ -1486,6 +1519,9 @@ var He = class {
1486
1519
  itemsAtHub(e) {
1487
1520
  return this.indexer.hubItems(e);
1488
1521
  }
1522
+ searchItems(e, t) {
1523
+ return this.indexer.searchItems(e, t?.limit);
1524
+ }
1489
1525
  async resolvePool(e) {
1490
1526
  let t = await this.indexer.hubVault(e.storageUnitId), n = await this.indexer.resolvePool({
1491
1527
  collectionId: t.collectionId,
@@ -1526,7 +1562,7 @@ var He = class {
1526
1562
  };
1527
1563
  //#endregion
1528
1564
  //#region src/book.ts
1529
- function qe(e) {
1565
+ function Ze(e) {
1530
1566
  let t = [];
1531
1567
  for (let n of e) {
1532
1568
  let e = t[t.length - 1];
@@ -1544,11 +1580,11 @@ function Q(e) {
1544
1580
  function $(e) {
1545
1581
  return e.asks[0] ?? null;
1546
1582
  }
1547
- function Je(e) {
1583
+ function Qe(e) {
1548
1584
  let t = Q(e), n = $(e);
1549
1585
  return !t || !n ? null : (t.price + n.price) / 2n;
1550
1586
  }
1551
- function Ye(e) {
1587
+ function $e(e) {
1552
1588
  let t = Q(e), n = $(e);
1553
1589
  if (!t || !n) return null;
1554
1590
  let r = n.price - t.price, i = (t.price + n.price) / 2n;
@@ -1560,19 +1596,19 @@ function Ye(e) {
1560
1596
  bps: Number(r * 10000n / i)
1561
1597
  };
1562
1598
  }
1563
- function Xe(e) {
1599
+ function et(e) {
1564
1600
  let t = 0n;
1565
1601
  for (let n of e) t += n.remainingQuantity;
1566
1602
  return t;
1567
1603
  }
1568
- function Ze(e) {
1604
+ function tt(e) {
1569
1605
  let t = 0n, n = 0n;
1570
1606
  for (let r of e) t += r.baseQuantity, n += r.quoteQuantity;
1571
1607
  return t === 0n ? null : n / t;
1572
1608
  }
1573
1609
  //#endregion
1574
1610
  //#region src/paging.ts
1575
- async function* Qe(e, t, n) {
1611
+ async function* nt(e, t, n) {
1576
1612
  let r = n?.maxItems ?? 1e4, i = t?.cursor, a = 0;
1577
1613
  for (;;) {
1578
1614
  let n = await e.discovery({
@@ -1584,7 +1620,7 @@ async function* Qe(e, t, n) {
1584
1620
  i = n.nextCursor;
1585
1621
  }
1586
1622
  }
1587
- async function* $e(e, t, n, r) {
1623
+ async function* rt(e, t, n, r) {
1588
1624
  let i = r?.maxItems ?? 1e4, a = n?.before, o = 0;
1589
1625
  for (;;) {
1590
1626
  let r = await e.fills(t, {
@@ -1596,7 +1632,7 @@ async function* $e(e, t, n, r) {
1596
1632
  a = r.fills[r.fills.length - 1].filledAt;
1597
1633
  }
1598
1634
  }
1599
- async function* et(e, t, n, r) {
1635
+ async function* it(e, t, n, r) {
1600
1636
  let i = r?.maxItems ?? 1e4, a = n?.before, o = 0;
1601
1637
  for (;;) {
1602
1638
  let r = await e.trades(t, {
@@ -1610,7 +1646,7 @@ async function* et(e, t, n, r) {
1610
1646
  }
1611
1647
  //#endregion
1612
1648
  //#region src/wait.ts
1613
- async function tt(e, t) {
1649
+ async function at(e, t) {
1614
1650
  let n = t?.timeoutMs ?? 3e4, r = t?.intervalMs ?? 2e3, i = Date.now() + n;
1615
1651
  for (;;) {
1616
1652
  let a = await e();
@@ -1620,4 +1656,4 @@ async function tt(e, t) {
1620
1656
  }
1621
1657
  }
1622
1658
  //#endregion
1623
- export { o as CLOCK_ID, a as DEFAULT_INDEXER_URL, U as FEE_RATE_SCALING, pe as GTC_EXPIRE, X as IndexerClient, H as MULTICOIN_PRICE_SCALING, c as NETWORK_PRESETS, Ke as ReadOnlyClient, s as STILLNESS_PACKAGE_IDS, fe as TRIEX_PRICE_SCALING, Be as TriexClient, d as TriexClientError, u as TriexError, qe as aggregateLevels, $ as bestAsk, Q as bestBid, G as computeBidQuoteDeposit, W as computeItemQuote, Xe as depth, _e as estimateMarketBuyCost, m as executeAndNormalize, p as explainMoveAbort, D as fetchCharacterInfo, k as fetchInventorySlotQuantity, O as fetchSsuOwnerInfo, g as findCreatedObject, E as findOwnedItemReceipts, he as fromBase, T as getBalanceManagerCurrencyBalance, ie as getBalanceManagerItemBalance, ne as getObjectRef, ae as getRegistryMulticoinCollectionId, re as getWalletCurrencyBalance, Qe as iterateDiscovery, $e as iterateFills, et as iterateTrades, ge as marketBuyRoundingBuffer, Je as midPrice, h as normalizeExecuteResult, B as prepareWalletCoinInput, l as resolvePackageIds, V as sourceItemsIntoBalanceManager, Ye as spread, me as toBase, w as toSsuObjectId, oe as transactions, tt as untilIndexed, Ze 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 };
package/dist/queries.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BalancesAtHubParams, CollectionHub, DiscoveryFilters, DiscoveryResult, FillsPage, FillsParams, HistoryPageParams, HubItemMarket, HubItemsPage, HubLocation, HubVaultInfo, InventoryBalances, OpenOrdersPage, Orderbook, PoolMetadata, Sweepable, TradesPage, TradesParams } from './types';
1
+ import { BalancesAtHubParams, CollectionHub, DiscoveryFilters, DiscoveryResult, FillsPage, FillsParams, HistoryPageParams, HubItemMarket, HubItemsPage, ItemSearchPage, HubLocation, HubVaultInfo, InventoryBalances, OpenOrdersPage, Orderbook, PoolMetadata, Sweepable, TradesPage, TradesParams } from './types';
2
2
  export declare class IndexerClient {
3
3
  private readonly baseUrl;
4
4
  private readonly apiKey;
@@ -20,6 +20,7 @@ export declare class IndexerClient {
20
20
  hubVault(hubId: string): Promise<HubVaultInfo>;
21
21
  hubLocation(hubId: string): Promise<HubLocation | null>;
22
22
  hubItems(hubId: string): Promise<HubItemsPage>;
23
+ searchItems(query: string, limit?: number): Promise<ItemSearchPage>;
23
24
  collectionHub(collectionId: string): Promise<CollectionHub>;
24
25
  inventoryBalances(params: BalancesAtHubParams & {
25
26
  balanceManagerId?: string;
package/dist/schemas.d.ts CHANGED
@@ -600,6 +600,181 @@ export declare const CollectionHubSchema: z.ZodPipe<z.ZodObject<{
600
600
  hub_id: string;
601
601
  collection_id: string;
602
602
  }>>;
603
+ export declare const ItemRecipeComponentSchema: z.ZodPipe<z.ZodObject<{
604
+ asset_id: z.ZodString;
605
+ quantity: z.ZodNumber;
606
+ }, z.core.$strip>, z.ZodTransform<{
607
+ assetId: string;
608
+ quantity: number;
609
+ }, {
610
+ asset_id: string;
611
+ quantity: number;
612
+ }>>;
613
+ export declare const ItemRecipeSchema: z.ZodPipe<z.ZodObject<{
614
+ output_quantity: z.ZodNumber;
615
+ components: z.ZodArray<z.ZodPipe<z.ZodObject<{
616
+ asset_id: z.ZodString;
617
+ quantity: z.ZodNumber;
618
+ }, z.core.$strip>, z.ZodTransform<{
619
+ assetId: string;
620
+ quantity: number;
621
+ }, {
622
+ asset_id: string;
623
+ quantity: number;
624
+ }>>>;
625
+ }, z.core.$strip>, z.ZodTransform<{
626
+ outputQuantity: number;
627
+ components: {
628
+ assetId: string;
629
+ quantity: number;
630
+ }[];
631
+ }, {
632
+ output_quantity: number;
633
+ components: {
634
+ assetId: string;
635
+ quantity: number;
636
+ }[];
637
+ }>>;
638
+ export declare const ItemSearchResultSchema: z.ZodPipe<z.ZodObject<{
639
+ asset_id: z.ZodString;
640
+ name: z.ZodNullable<z.ZodString>;
641
+ symbol: z.ZodNullable<z.ZodString>;
642
+ mass: z.ZodNumber;
643
+ recipes: z.ZodArray<z.ZodPipe<z.ZodObject<{
644
+ output_quantity: z.ZodNumber;
645
+ components: z.ZodArray<z.ZodPipe<z.ZodObject<{
646
+ asset_id: z.ZodString;
647
+ quantity: z.ZodNumber;
648
+ }, z.core.$strip>, z.ZodTransform<{
649
+ assetId: string;
650
+ quantity: number;
651
+ }, {
652
+ asset_id: string;
653
+ quantity: number;
654
+ }>>>;
655
+ }, z.core.$strip>, z.ZodTransform<{
656
+ outputQuantity: number;
657
+ components: {
658
+ assetId: string;
659
+ quantity: number;
660
+ }[];
661
+ }, {
662
+ output_quantity: number;
663
+ components: {
664
+ assetId: string;
665
+ quantity: number;
666
+ }[];
667
+ }>>>;
668
+ }, z.core.$strip>, z.ZodTransform<{
669
+ assetId: string;
670
+ name: string | null;
671
+ symbol: string | null;
672
+ mass: number;
673
+ recipes: {
674
+ outputQuantity: number;
675
+ components: {
676
+ assetId: string;
677
+ quantity: number;
678
+ }[];
679
+ }[];
680
+ }, {
681
+ asset_id: string;
682
+ name: string | null;
683
+ symbol: string | null;
684
+ mass: number;
685
+ recipes: {
686
+ outputQuantity: number;
687
+ components: {
688
+ assetId: string;
689
+ quantity: number;
690
+ }[];
691
+ }[];
692
+ }>>;
693
+ export declare const ItemSearchPageSchema: z.ZodPipe<z.ZodObject<{
694
+ data: z.ZodArray<z.ZodPipe<z.ZodObject<{
695
+ asset_id: z.ZodString;
696
+ name: z.ZodNullable<z.ZodString>;
697
+ symbol: z.ZodNullable<z.ZodString>;
698
+ mass: z.ZodNumber;
699
+ recipes: z.ZodArray<z.ZodPipe<z.ZodObject<{
700
+ output_quantity: z.ZodNumber;
701
+ components: z.ZodArray<z.ZodPipe<z.ZodObject<{
702
+ asset_id: z.ZodString;
703
+ quantity: z.ZodNumber;
704
+ }, z.core.$strip>, z.ZodTransform<{
705
+ assetId: string;
706
+ quantity: number;
707
+ }, {
708
+ asset_id: string;
709
+ quantity: number;
710
+ }>>>;
711
+ }, z.core.$strip>, z.ZodTransform<{
712
+ outputQuantity: number;
713
+ components: {
714
+ assetId: string;
715
+ quantity: number;
716
+ }[];
717
+ }, {
718
+ output_quantity: number;
719
+ components: {
720
+ assetId: string;
721
+ quantity: number;
722
+ }[];
723
+ }>>>;
724
+ }, z.core.$strip>, z.ZodTransform<{
725
+ assetId: string;
726
+ name: string | null;
727
+ symbol: string | null;
728
+ mass: number;
729
+ recipes: {
730
+ outputQuantity: number;
731
+ components: {
732
+ assetId: string;
733
+ quantity: number;
734
+ }[];
735
+ }[];
736
+ }, {
737
+ asset_id: string;
738
+ name: string | null;
739
+ symbol: string | null;
740
+ mass: number;
741
+ recipes: {
742
+ outputQuantity: number;
743
+ components: {
744
+ assetId: string;
745
+ quantity: number;
746
+ }[];
747
+ }[];
748
+ }>>>;
749
+ }, z.core.$strip>, z.ZodTransform<{
750
+ items: {
751
+ assetId: string;
752
+ name: string | null;
753
+ symbol: string | null;
754
+ mass: number;
755
+ recipes: {
756
+ outputQuantity: number;
757
+ components: {
758
+ assetId: string;
759
+ quantity: number;
760
+ }[];
761
+ }[];
762
+ }[];
763
+ }, {
764
+ data: {
765
+ assetId: string;
766
+ name: string | null;
767
+ symbol: string | null;
768
+ mass: number;
769
+ recipes: {
770
+ outputQuantity: number;
771
+ components: {
772
+ assetId: string;
773
+ quantity: number;
774
+ }[];
775
+ }[];
776
+ }[];
777
+ }>>;
603
778
  export declare const AssetBalanceSchema: z.ZodPipe<z.ZodObject<{
604
779
  asset_id: z.ZodString;
605
780
  amount: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<bigint, string | number>>;
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Transaction } from '@mysten/sui/transactions';
2
2
  import { ClientWithCoreApi } from '@mysten/sui/client';
3
3
  import { z } from 'zod';
4
- import { AssetBalanceSchema, CollectionHubSchema, DiscoveryOrderSchema, DiscoveryResultSchema, FillSchema, FillsPageSchema, HubItemOrderbookSchema, HubItemSchema, HubItemsPageSchema, HubLocationSchema, HubVaultSchema, InventoryBalancesSchema, OpenOrderSchema, OpenOrdersPageSchema, OrderbookOrderSchema, PoolMetadataSchema, SweepableItemSchema, SweepablePoolSchema, SweepableSchema, TradeSchema, TradesPageSchema } from './schemas';
4
+ import { AssetBalanceSchema, CollectionHubSchema, DiscoveryOrderSchema, DiscoveryResultSchema, FillSchema, FillsPageSchema, HubItemOrderbookSchema, HubItemSchema, HubItemsPageSchema, HubLocationSchema, ItemRecipeComponentSchema, ItemRecipeSchema, ItemSearchPageSchema, ItemSearchResultSchema, HubVaultSchema, InventoryBalancesSchema, OpenOrderSchema, OpenOrdersPageSchema, OrderbookOrderSchema, PoolMetadataSchema, SweepableItemSchema, SweepablePoolSchema, SweepableSchema, TradeSchema, TradesPageSchema } from './schemas';
5
5
  export interface ObjectChange {
6
6
  type: string;
7
7
  objectId?: string;
@@ -53,6 +53,10 @@ export type HubLocation = z.output<typeof HubLocationSchema>;
53
53
  export type HubItem = z.output<typeof HubItemSchema>;
54
54
  export type HubItemsPage = z.output<typeof HubItemsPageSchema>;
55
55
  export type CollectionHub = z.output<typeof CollectionHubSchema>;
56
+ export type ItemRecipeComponent = z.output<typeof ItemRecipeComponentSchema>;
57
+ export type ItemRecipe = z.output<typeof ItemRecipeSchema>;
58
+ export type ItemSearchResult = z.output<typeof ItemSearchResultSchema>;
59
+ export type ItemSearchPage = z.output<typeof ItemSearchPageSchema>;
56
60
  export type AssetBalance = z.output<typeof AssetBalanceSchema>;
57
61
  export type InventoryBalances = z.output<typeof InventoryBalancesSchema>;
58
62
  export type OpenOrder = z.output<typeof OpenOrderSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trinaryex/sdk",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "description": "Trading SDK for Trinary Exchange — market data, order books, and on-chain trading (Sui) for bots, analytics tools, and CLIs.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",