@trinaryex/sdk 3.9.0 → 5.0.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.
Files changed (47) hide show
  1. package/DESIGN.md +253 -71
  2. package/README.md +220 -16
  3. package/dist/ReadOnlyClient.d.ts +42 -8
  4. package/dist/TriexClient.d.ts +73 -8
  5. package/dist/armature/OrgClient.d.ts +372 -0
  6. package/dist/armature/OrgClientGroups.d.ts +186 -0
  7. package/dist/armature/OrgsApi.d.ts +69 -0
  8. package/dist/armature/actions.d.ts +75 -0
  9. package/dist/armature/create.d.ts +27 -0
  10. package/dist/armature/currency.d.ts +64 -0
  11. package/dist/armature/executors.d.ts +44 -0
  12. package/dist/armature/governance.d.ts +194 -0
  13. package/dist/armature/harness.d.ts +96 -0
  14. package/dist/armature/lifecycle.d.ts +84 -0
  15. package/dist/armature/plan.d.ts +39 -0
  16. package/dist/armature/proposals.d.ts +51 -0
  17. package/dist/armature/queries.d.ts +16 -0
  18. package/dist/armature/schemas.d.ts +559 -0
  19. package/dist/armature/trading.d.ts +114 -0
  20. package/dist/armature/transactions.d.ts +160 -0
  21. package/dist/armature/treasury.d.ts +41 -0
  22. package/dist/armature/tree.d.ts +13 -0
  23. package/dist/armature/types.d.ts +59 -0
  24. package/dist/armature/upgrade.d.ts +27 -0
  25. package/dist/armature/vault.d.ts +94 -0
  26. package/dist/coins/CoinsApi.d.ts +53 -0
  27. package/dist/coins/funding.d.ts +6 -0
  28. package/dist/coins/money.d.ts +36 -0
  29. package/dist/coins/onchain.d.ts +162 -0
  30. package/dist/coins/schemas.d.ts +456 -0
  31. package/dist/coins/transactions.d.ts +82 -0
  32. package/dist/coins/types.d.ts +115 -0
  33. package/dist/errors.d.ts +11 -1
  34. package/dist/funding.d.ts +2 -2
  35. package/dist/http.d.ts +3 -0
  36. package/dist/index.d.ts +63 -8
  37. package/dist/index.js +10620 -959
  38. package/dist/money.d.ts +15 -0
  39. package/dist/moveAbort.d.ts +28 -0
  40. package/dist/moveAbortCatalog.generated.d.ts +9 -0
  41. package/dist/onchain.d.ts +55 -3
  42. package/dist/paging.d.ts +9 -3
  43. package/dist/queries.d.ts +35 -7
  44. package/dist/schemas.d.ts +2257 -50
  45. package/dist/transactions.d.ts +63 -1
  46. package/dist/types.d.ts +118 -7
  47. package/package.json +3 -1
package/README.md CHANGED
@@ -115,9 +115,9 @@ const book = await ro.orderbook({ storageUnitId, assetId })
115
115
  console.log('mid', midPrice(book), 'spread', spread(book)?.bps, 'bps')
116
116
  console.log('bid levels', aggregateLevels(book.bids))
117
117
 
118
- // Stream a balance manager's full trade history (auto-pagination) …
118
+ // Stream a trading account's full trade history (auto-pagination) …
119
119
  const history = []
120
- for await (const trade of iterateTrades(ro.indexer, balanceManagerId)) {
120
+ for await (const trade of iterateTrades(ro.indexer, tradingAccountId)) {
121
121
  history.push(trade) // { price, baseQuantity, quoteQuantity, fee, side, tradedAt, … }
122
122
  }
123
123
  // … and summarize it.
@@ -130,12 +130,15 @@ console.log('lifetime VWAP', vwap(history))
130
130
  import { estimateMarketBuyCost } from '@trinaryex/sdk'
131
131
 
132
132
  // 1. Fund + place in ONE atomic transaction: the SDK deposits only the
133
- // deficit (existing balance-manager funds are consumed first), creates
133
+ // deficit (existing trading-account funds are consumed first), creates
134
134
  // the trading account if missing, and rolls everything back on failure.
135
135
  await client.orders.limit({ storageUnitId, assetId, side: 'sell', price, quantity })
136
136
 
137
- // Market buys need a worst-case budget from the current book:
138
- const est = estimateMarketBuyCost(book.asks, quantity, meta.feeRateScaled)
137
+ // Market buys need a budget from the current book, at YOUR taker rate
138
+ // (fee tiers lower it as your trailing fee turnover grows):
139
+ const fees = await client.orders.fees({ storageUnitId, assetId })
140
+ const taker = fees.account?.takerFeeRate ?? fees.entryTakerFeeRate
141
+ const est = estimateMarketBuyCost(book.asks, quantity, taker)
139
142
  await client.orders.market({ storageUnitId, assetId, side: 'buy', quantity, quoteBudget: est.total })
140
143
 
141
144
  // 2. Watch state. The indexer trails the chain by seconds — untilIndexed()
@@ -157,6 +160,7 @@ await client.account.withdrawItems({ storageUnitId, items: [{ assetId }] })
157
160
 
158
161
  // Housekeeping.
159
162
  await client.orders.cancel({ storageUnitId, assetId, orderId })
163
+ await client.orders.cancelMany({ storageUnitId, assetId, orderIds })
160
164
  await client.orders.cancelAll({ storageUnitId, assetId })
161
165
  ```
162
166
 
@@ -178,21 +182,35 @@ try {
178
182
  case TriexError.InsufficientBalance: // top up and retry
179
183
  case TriexError.PoolNotFound: // no market for this item at this hub
180
184
  case TriexError.TransactionFailed: // on-chain abort, e.message explains why
181
- console.error(e.message) // e.g. "…Max 100 open orders per balance manager…"
185
+ console.error(e.message) // e.g. "…Max 100 open orders per trading account…"
182
186
  }
183
187
  }
184
188
 
185
189
  // Or translate raw Sui errors from anywhere:
186
190
  explainMoveAbort(rawError) // "No liquidity available (EEmptyOrderbook)" | null
191
+
192
+ // …or get the parts separately instead of one prose string:
193
+ explainMoveAbortDetailed(rawError)
194
+ // { module: 'order_info', constant: 'EPOSTOrderCrossesOrderbook', code: 5,
195
+ // explanation: 'POST-ONLY order would cross the book — use a plain limit order',
196
+ // resolution: 'resolved', source: 'packages/triex/sources/book/order_info.move:18', … }
187
197
  ```
188
198
 
199
+ A failed transaction's `effects.status.error` carries only the raw `u64` abort code —
200
+ no constant name — so the SDK parses that string and resolves the code against
201
+ `MOVE_ABORT_CATALOG`, generated from the contract sources. `resolution` tells you
202
+ whether the abort was `resolved`, came from a dependency package
203
+ (`external-module`), or is a code the catalog doesn't know yet (`unknown-code`).
204
+
189
205
  | Code | Raised when | Recovery |
190
206
  |---|---|---|
191
207
  | `Unauthorized` | API key missing/revoked/wrong tier (HTTP 401/403) | fix `TRINARY_API_KEY` |
192
208
  | `RateLimited` | compute-unit budget exhausted (HTTP 429) | wait `e.retryAfterMs`, retry |
193
209
  | `IndexerError` | 5xx / unexpected HTTP failure (`e.status` set) | retry with backoff |
194
210
  | `UnexpectedResponse` | response didn't match the pinned schema | report — API drift |
195
- | `HubNotFound` / `PoolNotFound` / `BalanceManagerNotFound` | unknown id for the target resource | check inputs |
211
+ | `HubNotFound` / `PoolNotFound` / `TradingAccountNotFound` / `OrderNotFound` / `FillNotFound` / `CharacterNotFound` / `TribeNotFound` / `ItemNotFound` / `SolarSystemNotFound` | unknown id for the target resource | check inputs (a system *name* may simply be unreported yet — try its id) |
212
+ | `RouteNotFound` | a route endpoint name is unknown/unreported, or the pair is unreachable with these ship parameters | check names via `spatial.autocompleteSystems`, or raise `maxJumpRangeLy` |
213
+ | `TransactionFailed` | the transaction aborted on-chain | `e.message` carries the decoded abort |
196
214
  | `InsufficientBalance` | wallet/hangar/BM can't fund the operation | deposit / top up |
197
215
  | `CollectionMismatch` | item receipts from a different deployment | wrong network/receipts |
198
216
  | `CharacterNotFound` | hangar flows need an on-chain character | pass `characterId` / create one |
@@ -203,26 +221,186 @@ explainMoveAbort(rawError) // "No liquidity available (EEmptyOrderbook)" | null
203
221
 
204
222
  | Group | Methods |
205
223
  |---|---|
206
- | `account` | `get` · `ensure` · `depositCurrency` · `depositItems` · `withdrawCurrency` · `withdrawItems` · `sweepable` · `claimSettled` · `owners` |
224
+ | `account` | `get` · `ensure` · `register` · `depositCurrency` · `depositItems` · `withdrawCurrency` · `withdrawItems` · `sweepable` · `claimSettled` · `owners` · `mintCap` · `revokeCap` · `caps` |
207
225
  | `balances` | `atHub` (items: warehouse/marketplace/hangar) · `currency` (CRED wallet + BM, fullnode) |
208
- | `market` | `discover` · `hub` · `itemsAtHub` · `resolvePool` · `orderbook` · `poolMetadata` |
226
+ | `market` | `discover` · `hub` · `itemsAtHub` · `searchItems` · `resolvePool` · `orderbook` · `poolMetadata` · `createPool` · `claimOperatorShare` |
227
+ | `market` (feeds & prices) | `recentTrades` · `displayPrices` · `displayPrice` · `hubEconomics` · `topPoolsByFees` · `stats` |
209
228
  | `market` (locations) | `hubLocations` · `itemLocations` · `nearbyHubs` · `nearbyHubsBySystem` · `hubsEnriched` · `assemblyOwners` · `assembliesEnriched` · `solarSystemNames` |
210
- | `orders` | `limit` · `market` · `cancel` · `cancelAll` · `modify` · `openOrders` · `fills` · `trades` |
229
+ | `orders` | `fees` · `limit` · `market` · `cancel` · `cancelMany` · `cancelAll` · `modify` · `openOrders` · `fills` · `trades` · `get` (any order, any state) · `fill` (by event digest) |
211
230
  | `spatial` | `system` · `systems` · `nearbySystems` · `systemsNearCoordinates` · `autocompleteSystems` · `stats` |
212
- | helpers | `aggregateLevels` · `midPrice` · `spread` · `depth` · `vwap` · `estimateMarketBuyCost` · `iterateDiscovery/Fills/Trades` · `untilIndexed` · `explainMoveAbort` · `toBase` / `fromBase` |
231
+ | `routing` | `route` · `compare` · `stats` |
232
+ | `characters` | `get` · `byAddress` · `byName` · `batch` · `tribe` |
233
+ | `world` | `items` · `item` · `recipes` · `recipesFor` |
234
+ | `coins` | `list` · `resolvePool` · `orderbook` · `tradeParams` · `quote` · `estimateMarket` · `openOrders` · `account` · `balances` · `deposit` · `withdraw` · `limit` · `market` · `swap` · `cancel` · `cancelMany` · `cancelAll` · `modify` · `claimSettled` · `createPool` — see below |
235
+ | `orgs` | `get` · `batch` · `directory` · `forPlayer` · `search` · `proposals` · `seats` · `tradingAccount` · `accessibleKeyspaces` · `vaultsAtHub` |
236
+ | `org(id)` handle | `.governance` · `.members` · `.metadata` · `.types` · `.treasury` · `.orders` · `.vault` — see below |
237
+ | helpers | `aggregateLevels` · `midPrice` · `spread` · `depth` · `vwap` · `estimateMarketBuyCost` · `estimateMarketSellProceeds` · `computeBidQuoteDeposit` · `computeAskProceeds` · `computeQuoteFee` · `iterateDiscovery/Fills/Trades/OpenOrders/RecentTrades/HubLocations/ItemLocations/OrgDirectory` · `untilIndexed` · `explainMoveAbort` / `explainMoveAbortDetailed` · `toBase` / `fromBase` |
238
+
239
+ `ReadOnlyClient` exposes the same reads flat (`ro.recentTrades()`,
240
+ `ro.order()`, `ro.character()`, `ro.route()`, `ro.worldItems()`, …) with
241
+ identity always explicit. Every read's JSDoc gives its compute-unit cost —
242
+ from 20 CU (a single lookup) to 150 CU (`discover`) and 300 CU
243
+ (`routing.compare`, three route searches).
213
244
 
214
245
  Runnable examples live in [`examples/`](./examples).
215
246
 
247
+ ### Reading the market, the map and the players
248
+
249
+ ```ts
250
+ // The public tape — human-readable prices, newest first.
251
+ const { trades } = await client.market.recentTrades({ assetId: '77800' })
252
+
253
+ // What became of an order you placed (open / filled / cancelled + fills).
254
+ const order = await client.orders.get({ poolId, orderId })
255
+
256
+ // Who is behind an address, and their tribe.
257
+ const [who] = await client.characters.batch({ addresses: [wallet] })
258
+
259
+ // Static reference data — fetch once, cache.
260
+ const items = await client.world.items() // assetId strings
261
+ const { producedBy, usedIn } = await client.world.recipesFor('77753')
262
+ // producedBy: the blueprints that make it (inputs, outputs, kind, facilities)
263
+ // usedIn: the blueprints that consume it — both [] if no blueprint touches it
264
+
265
+ // Routes take system NAMES — see the note below.
266
+ const route = await client.routing.route({
267
+ origin: 'U4T-SL7', destination: 'U.L6B.HNX', maxJumpRangeLy: 500,
268
+ })
269
+ ```
270
+
271
+ > **Solar system names are player-reported (cycle 7).** The star map ships
272
+ > with ids, coordinates and stargates, but a system's *name* is known only once
273
+ > a player reports it. Until then `solarSystemName` is `null` on every read,
274
+ > a lookup **by name** fails (`SolarSystemNotFound` / `RouteNotFound`) while the
275
+ > same system resolves **by id**, and routing — which is name-only — cannot
276
+ > reach it. Key on `solarSystemId`; use `spatial.autocompleteSystems()` to find
277
+ > names that resolve, and `spatial.stats().knownSolarSystemNames` for coverage.
278
+
279
+ > **Display prices carry no fee.** `market.displayPrice(s)` is the plain
280
+ > market price; pool metadata's `feeRateScaled` is the fee class's *entry*
281
+ > tier — use `orders.fees()` for maker rates and your own tier — and the rate a fill actually charged is on the fill
282
+ > (`fee`, `makerFee`/`takerFee`, `feeRateBps`).
283
+
284
+ ## Coin markets (currency pairs)
285
+
286
+ `client.coins` trades `triex::pool::Pool<Base, Quote>` order books — one Move
287
+ coin against another, usually CRED. Name a pool by `poolId` or by
288
+ `baseCoinType` (+ `quoteCoinType`, default CRED):
289
+
290
+ ```ts
291
+ import { coinPriceToRaw } from '@trinaryex/sdk'
292
+
293
+ const pool = { baseCoinType: '0x…::wbtc::WBTC' } // vs CRED
294
+
295
+ const book = await client.coins.orderbook({ ...pool, depth: 20 })
296
+ const fees = await client.coins.tradeParams(pool) // live FeePolicy rates
297
+
298
+ // Limit buy 2 WBTC (8 dp) at 61,250 CRED (6 dp) each — price is 1e9-scaled.
299
+ await client.coins.limit({
300
+ ...pool, side: 'buy',
301
+ price: coinPriceToRaw('61250', 8, 6),
302
+ quantity: 200_000_000n,
303
+ })
304
+ await client.coins.market({ ...pool, side: 'sell', quantity: 50_000_000n })
305
+ await client.coins.swap({ ...pool, side: 'buy', amountIn: 1_000_000n }) // wallet → wallet
306
+ await client.coins.claimSettled({ pools: [pool], withdrawCoinTypes: ['0x…::wbtc::WBTC'] })
307
+ ```
308
+
309
+ - **Reads come from the fullnode.** The coin-pool indexer routes are not on the
310
+ gateway, so books, fees, open orders and account state are simulated view
311
+ calls (head-current, no API key cost). Only `coins.list()` (`GET /v1/coins`)
312
+ is an indexer read. `ReadOnlyClient` takes an optional `suiClient` for these.
313
+ - **Prices are 1e9-scaled:** `quote = base × price / 1e9`; human price is
314
+ `raw / 10^(9 + quoteDecimals − baseDecimals)` (`coinPriceToRaw` /
315
+ `formatCoinPrice`). No lot/tick size; a resting order needs
316
+ `quantity ≥ coinMinOrderQuantity(price)`.
317
+ - **Both sides pay fees, in quote.** Bids pay the taker fee on top and escrow a
318
+ maker fee for the resting part; asks pay out of their proceeds. Bid funding
319
+ is `computeCoinBidDeposit` at the highest entry-rung rate (taker or maker,
320
+ current or staged) — it never under-funds. A market buy holds the exact cost
321
+ against the live book (`estimateMarket`) unless you pass `quoteBudget`.
322
+ - `coins.swap` needs no trading account and is charged the entry-rung rate;
323
+ `coins.quote` without `tradingAccountId` is its exact dry-run.
324
+
325
+ Design notes and Move references: [DESIGN-COINS.md](./DESIGN-COINS.md).
326
+
327
+ ## Organizations & governance (Armature)
328
+
329
+ An organization is a **tree of DAOs** — a root plus its units — and every write
330
+ goes through a governance pipeline whose shape depends on who is calling. Acting
331
+ as one means binding both the organization *and* a seat within it:
332
+
333
+ ```ts
334
+ const org = await client.org(orgId) // any unit id resolves the whole tree
335
+ org.seats // boards you sit on, highest authority first
336
+ org.as(officersDaoId) // act through a different seat you hold
337
+ ```
338
+
339
+ ### The same call is not the same transaction
340
+
341
+ ```ts
342
+ const outcome = await org.members.add(['0x…'])
343
+ switch (outcome.status) {
344
+ case 'executed': break // your vote cleared quorum — done
345
+ case 'proposed': outcome.proposalId; break // the board still has to vote
346
+ case 'blocked': outcome.reason; break // no path available, and why
347
+ }
348
+ ```
349
+
350
+ `blocked` is a **returned value, not a throw** — "you are not on this board" is
351
+ an ordinary answer. Real failures still throw `TriexClientError`. Use
352
+ `org.governance.resolve(action)` to ask without signing, and
353
+ `org.governance.paths(action)` for the full trace of why.
354
+
355
+ Whether a lone vote suffices is a question about **per-type config**, not about
356
+ rank: it clears quorum only when `boardSize × quorum ≤ 10000` and the execution
357
+ delay is zero. `org.governance.read()` returns those configs.
358
+
359
+ ### The rest of the handle
360
+
361
+ | Group | Methods |
362
+ |---|---|
363
+ | `governance` | `read` · `resolve` · `paths` · `run` · `runBatch` · `runComposite` · `canComposite` · `vote` · `execute` · `tryExpire` · `proposals` |
364
+ | `members` | `add` · `remove` · `setBoard` |
365
+ | `metadata` | `update` |
366
+ | `types` | `enable` · `updateConfig` · `enableComposite` · `enableSendCoin` · `enableTrading` |
367
+ | `treasury` | `balances` · `balance` · `itemBalance` · `deposit` · `send` · `sendToOrg` |
368
+ | `orders` | `ensureAccount` · `limit` · `cancel` · `buyFromTreasury` · `sellFromDaoVault` · `sweepCoin` · `sweepItems` · `sweepAll` |
369
+ | `vault` | `atHub` · `resolve` · `info` · `balance` · `init` · `deposit` · `withdraw` · `grant` · `revoke` · `deinit` |
370
+
371
+ Four things worth knowing before you call them:
372
+
373
+ - **Funding a treasury is permissionless.** `treasury.deposit()` needs no seat
374
+ and no vote, and returns a plain `TxResult`. Paying out returns `RunOutcome`
375
+ because it is governance. The return types are the authorization model.
376
+ - **Trading never degrades into a proposal.** A limit order deferred by a week
377
+ is priced against a book that no longer exists, and a funded buy split into
378
+ two proposals loses its atomic deposit-then-place guarantee — so these
379
+ `blocked` instead.
380
+ - **Shared storage is keyed by (storage unit, organization).** There is no "the
381
+ vault at this hub": anyone can register one at any SSU. `vault.resolve()`
382
+ answers for *your* organization.
383
+ - **`types.enableTrading({ bindToBaseType })` is irreversible.** It binds the
384
+ coin-pool order types to one base coin permanently. Leave it unset.
385
+
216
386
  ## Units & money
217
387
 
218
388
  - All prices, quantities, and amounts are **`bigint` in raw base units**;
219
389
  timestamps are epoch **milliseconds**. Items are identified by `assetId`
220
390
  (numeric item-type id as a string).
221
391
  - Item pools price in CRED base units per item (no price scaling). Pool
222
- metadata carries `feeRateScaled` (× 1e9; `20_000_000` = 2%) and the
223
- base/quote `decimals` for display conversion via `toBase`/`fromBase`.
224
- - Only buyers pay fees. A limit bid deposits
225
- `quote × (1e9 + feeRateScaled) / 1e9` — computed for you.
392
+ metadata carries the base/quote `decimals` for display conversion via
393
+ `toBase`/`fromBase`, and `feeRateScaled` — the pool's entry-tier taker rate.
394
+ - Fees are quote-denominated, `floor(quote × rate / 1e9)`, and **both sides
395
+ pay**: bids on top of what they owe (taker fee when they match, maker fee
396
+ escrowed while they rest), asks out of their proceeds. Rates come from the
397
+ pool's fee class (multicoin launch ladder: 2.2% taker / 1.8% maker, falling
398
+ with your trailing 30-epoch fee turnover). `orders.fees()` reads the ladder,
399
+ your tier, and the cancel retention (the share of a bid's escrowed maker fee
400
+ kept when you cancel, modify down, or it expires) from the chain.
401
+ - A limit bid is funded for `notional + floor(notional × bidEscrowFeeRate /
402
+ 1e9)` — the pool's highest rate, so it can never be under-funded; anything
403
+ unused stays in the trading account. Sells need no CRED.
226
404
  - Order expiry defaults to good-til-cancelled (`GTC_EXPIRE`).
227
405
 
228
406
  ## Consistency model
@@ -230,7 +408,7 @@ Runnable examples live in [`examples/`](./examples).
230
408
  The indexer is eventually-consistent (seconds behind head). On-chain writes
231
409
  are authoritative and atomic — a stale read can only make a transaction abort
232
410
  and roll back, never lose funds. The SDK reads everything that funds
233
- transactions (balance-manager resolution, currency balances, receipts, hangar
411
+ transactions (trading-account resolution, currency balances, receipts, hangar
234
412
  slots) from the **fullnode**, head-current. Prefer ids returned from writes
235
413
  (`TxResult.createdObjects`) over immediate re-reads.
236
414
 
@@ -280,6 +458,32 @@ inputs to prove the gate fails when it should. A vendored copy cannot see the
280
458
  gateway moving underneath us, so a scheduled job runs the same check against
281
459
  the live document — see `.github/workflows/gateway_drift.yml`.
282
460
 
461
+ ### Regenerating the abort catalog
462
+
463
+ `src/moveAbortCatalog.generated.ts` is generated from the Move sources of all four
464
+ contract repositories: [trinary-exchange](https://github.com/loash-industries/trinary-exchange)
465
+ (triex + CRED) and the three Armature repos (`armature`, `armature-vault`,
466
+ `armature-trading`), so organization aborts are explained as well as trading ones.
467
+ It is committed, so building and testing the SDK never needs those checkouts — only
468
+ regenerating does, after an error constant is added, removed or renumbered:
469
+
470
+ ```bash
471
+ npm run generate:error-codes -- \
472
+ --contracts <trinary-exchange> \ # or $TRIEX_CONTRACTS (default ../trinary-exchange)
473
+ --armature <armature> \ # or $ARMATURE_CONTRACTS (default ../armature)
474
+ --armature-vault <armature-vault> \ # or $ARMATURE_VAULT_CONTRACTS (default ../armature-vault)
475
+ --armature-trading <armature-trading> # or $ARMATURE_TRADING_CONTRACTS (default ../armature-trading)
476
+ npm run check:error-codes -- <same flags> # fail if the catalog is stale
477
+ ```
478
+
479
+ Every repository is required; a missing checkout fails rather than shrinking the
480
+ catalog.
481
+
482
+ `check:error-codes` needs the contract checkouts, so it is a local/release step
483
+ rather than a CI one. Drift is caught in CI a different way: the curated messages in
484
+ `src/moveAbort.ts` are keyed by `MoveAbortName`, a union generated from the
485
+ contracts, so a renamed or deleted constant fails `npm run tscheck`.
486
+
283
487
  ## Links
284
488
 
285
489
  - [Trinary Exchange](https://trinary.exchange/) — the EVE Frontier
@@ -1,8 +1,12 @@
1
+ import { OrgsApi } from './armature/OrgsApi';
2
+ import { CoinsReadApi } from './coins/CoinsApi';
1
3
  import { IndexerClient } from './queries';
2
- import { AssemblyEnriched, AssemblyOwner, AutocompleteSystems, BalanceManagerOwner, BatchSystems, BatchSystemsParams, CoordinateSearch, CoordinateSearchParams, BalancesAtHubParams, DiscoveryFilters, DiscoveryResult, FillsPage, FillsParams, HistoryPageParams, HubEnriched, HubItemOrderbook, HubItemsPage, HubLocationFilters, HubLocationPage, ItemSearchPage, InventoryBalances, LocationPageParams, NearbyHub, NearbyHubsParams, NearbyHubsBySystemParams, NearbySystems, NearbySystemsParams, OpenOrdersPage, PackageIds, PoolMetadata, ReadOnlyClientConfig, SolarSystem, SolarSystemName, SpatialStats, Sweepable, TradeHubDetail, TradesPage, TradesParams } from './types';
4
+ import { AssemblyEnriched, AssemblyOwner, AutocompleteSystems, TradingAccountOwner, BatchSystems, BatchSystemsParams, CoordinateSearch, CoordinateSearchParams, BalancesAtHubParams, DiscoveryFilters, DiscoveryResult, FillsPage, FillsParams, HistoryPageParams, HubEnriched, HubItemOrderbook, HubItemsPage, HubLocationFilters, HubLocationPage, ItemSearchPage, InventoryBalances, LocationPageParams, NearbyHub, NearbyHubsParams, NearbyHubsBySystemParams, NearbySystems, NearbySystemsParams, OpenOrdersPage, PackageIds, PoolMetadata, ReadOnlyClientConfig, SolarSystem, SolarSystemName, SpatialStats, Sweepable, TradeHubDetail, TradesPage, TradesParams, Character, CharacterLookup, DisplayPrice, DisplayPriceParams, DisplayPricesParams, FillDetail, HubEconomics, ItemInfo, ItemBlueprints, Blueprint, OrderDetail, OrderLookupParams, PlatformStats, PoolFees, RecentTradesPage, RecentTradesParams, Route, RouteComparison, RouteParams, RouteShipParams, RoutingStats, Tribe, WorldItem } from './types';
3
5
  export declare class ReadOnlyClient {
4
6
  readonly ids: PackageIds;
5
7
  readonly indexer: IndexerClient;
8
+ readonly orgs: OrgsApi;
9
+ readonly coins: CoinsReadApi;
6
10
  constructor(config: ReadOnlyClientConfig);
7
11
  discover(filters?: DiscoveryFilters): Promise<DiscoveryResult>;
8
12
  hub(hubId: string): Promise<TradeHubDetail>;
@@ -36,8 +40,8 @@ export declare class ReadOnlyClient {
36
40
  solarSystemIds: number[];
37
41
  }): Promise<SolarSystemName[]>;
38
42
  accountOwners(params: {
39
- balanceManagerIds: string[];
40
- }): Promise<BalanceManagerOwner[]>;
43
+ tradingAccountIds: string[];
44
+ }): Promise<TradingAccountOwner[]>;
41
45
  spatialSystem(solarSystem: string): Promise<SolarSystem>;
42
46
  spatialSystems(params: BatchSystemsParams): Promise<BatchSystems>;
43
47
  spatialNearbySystems(params: NearbySystemsParams): Promise<NearbySystems>;
@@ -47,10 +51,40 @@ export declare class ReadOnlyClient {
47
51
  }): Promise<AutocompleteSystems>;
48
52
  spatialStats(): Promise<SpatialStats>;
49
53
  balancesAtHub(params: BalancesAtHubParams & {
50
- balanceManagerId?: string;
54
+ tradingAccountId?: string;
51
55
  }): Promise<InventoryBalances>;
52
- openOrders(balanceManagerId: string, params?: HistoryPageParams): Promise<OpenOrdersPage>;
53
- fills(balanceManagerId: string, params?: FillsParams): Promise<FillsPage>;
54
- trades(balanceManagerId: string, params?: TradesParams): Promise<TradesPage>;
55
- sweepable(balanceManagerId: string): Promise<Sweepable>;
56
+ openOrders(tradingAccountId: string, params?: HistoryPageParams): Promise<OpenOrdersPage>;
57
+ fills(tradingAccountId: string, params?: FillsParams): Promise<FillsPage>;
58
+ trades(tradingAccountId: string, params?: TradesParams): Promise<TradesPage>;
59
+ sweepable(tradingAccountId: string): Promise<Sweepable>;
60
+ order(params: OrderLookupParams): Promise<OrderDetail>;
61
+ fill(eventDigest: string): Promise<FillDetail>;
62
+ recentTrades(params?: RecentTradesParams): Promise<RecentTradesPage>;
63
+ displayPrices(params: DisplayPricesParams): Promise<DisplayPrice[]>;
64
+ displayPrice(itemId: string, opts?: DisplayPriceParams): Promise<DisplayPrice>;
65
+ hubEconomics(params: {
66
+ hubIds: string[];
67
+ }): Promise<HubEconomics[]>;
68
+ topPoolsByFees(opts?: {
69
+ limit?: number;
70
+ }): Promise<PoolFees[]>;
71
+ stats(): Promise<PlatformStats>;
72
+ character(characterId: string, opts?: {
73
+ enrich?: boolean;
74
+ }): Promise<Character>;
75
+ charactersByAddress(address: string, opts?: {
76
+ enrich?: boolean;
77
+ }): Promise<Character[]>;
78
+ charactersByName(name: string): Promise<Character[]>;
79
+ charactersBatch(params: {
80
+ addresses: string[];
81
+ }): Promise<CharacterLookup[]>;
82
+ tribe(tribeId: number): Promise<Tribe>;
83
+ worldItems(): Promise<WorldItem[]>;
84
+ worldItem(assetId: string): Promise<ItemInfo>;
85
+ recipes(): Promise<Blueprint[]>;
86
+ recipesFor(assetId: string): Promise<ItemBlueprints>;
87
+ route(params: RouteParams): Promise<Route>;
88
+ compareRoutes(params: RouteShipParams): Promise<RouteComparison>;
89
+ routingStats(): Promise<RoutingStats>;
56
90
  }
@@ -1,45 +1,64 @@
1
1
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
2
2
  import { ClientWithCoreApi } from '@mysten/sui/client';
3
+ import { OrgHandle } from './armature/OrgClient';
4
+ import { OrgsWriteApi } from './armature/OrgsApi';
5
+ import { CoinsApi } from './coins/CoinsApi';
6
+ import { TradingFees } from './onchain';
3
7
  import { IndexerClient } from './queries';
4
- import { AssemblyEnriched, AssemblyOwner, AutocompleteSystems, BalanceManagerOwner, BatchSystems, BatchSystemsParams, CoordinateSearch, CoordinateSearchParams, BalancesAtHubParams, CancelAllOrdersParams, CancelOrderParams, ClaimSettledParams, CurrencyBalances, DepositCurrencyParams, DepositItemsParams, DiscoveryFilters, DiscoveryResult, EnsureAccountResult, FillsPage, FillsParams, HistoryPageParams, HubEnriched, HubItemOrderbook, HubItemsPage, HubLocationFilters, HubLocationPage, ItemSearchPage, InventoryBalances, LimitOrderParams, LocationPageParams, MarketOrderParams, ModifyOrderParams, NearbyHub, NearbyHubsParams, NearbyHubsBySystemParams, NearbySystems, NearbySystemsParams, OpenOrdersPage, PackageIds, PoolMetadata, SolarSystem, SolarSystemName, SpatialStats, Sweepable, TradeHubDetail, TradesPage, TradesParams, TradingAccount, TransactionExecutor, TriexClientConfig, TxResult, WithdrawCurrencyParams, WithdrawItemsParams } from './types';
8
+ import { AssemblyEnriched, AssemblyOwner, AutocompleteSystems, TradingAccountOwner, BatchSystems, BatchSystemsParams, CoordinateSearch, CoordinateSearchParams, BalancesAtHubParams, CancelAllOrdersParams, CancelOrderParams, CancelOrdersParams, ClaimOperatorShareParams, ClaimSettledParams, CreatePoolParams, CreatePoolResult, MintCapParams, MintCapResult, PoolSelector, RevokeCapParams, TradingAccountCaps, TradingFeesParams, CurrencyBalances, DepositCurrencyParams, DepositItemsParams, DiscoveryFilters, DiscoveryResult, EnsureAccountResult, FillsPage, FillsParams, HistoryPageParams, HubEnriched, HubItemOrderbook, HubItemsPage, HubLocationFilters, HubLocationPage, ItemSearchPage, InventoryBalances, LimitOrderParams, LocationPageParams, MarketOrderParams, ModifyOrderParams, NearbyHub, NearbyHubsParams, NearbyHubsBySystemParams, NearbySystems, NearbySystemsParams, OpenOrdersPage, PackageIds, PoolMetadata, SolarSystem, SolarSystemName, SpatialStats, Sweepable, TradeHubDetail, TradesPage, TradesParams, TradingAccount, TransactionExecutor, TriexClientConfig, TxResult, WithdrawCurrencyParams, WithdrawItemsParams, Character, CharacterLookup, DisplayPrice, DisplayPriceParams, DisplayPricesParams, FillDetail, HubEconomics, ItemInfo, ItemBlueprints, Blueprint, OrderDetail, OrderLookupParams, PlatformStats, PoolFees, RecentTradesPage, RecentTradesParams, Route, RouteComparison, RouteParams, RouteShipParams, RoutingStats, Tribe, WorldItem } from './types';
5
9
  export declare class TriexClient {
6
10
  readonly suiClient: ClientWithCoreApi;
7
11
  readonly ids: PackageIds;
8
12
  readonly indexer: IndexerClient;
9
13
  private readonly executor?;
10
14
  private readonly address?;
11
- private cachedBalanceManagerId?;
15
+ private readonly cachedTradingAccountIds;
12
16
  readonly account: AccountApi;
13
17
  readonly balances: BalancesApi;
14
18
  readonly market: MarketApi;
15
19
  readonly orders: OrdersApi;
16
20
  readonly spatial: SpatialApi;
21
+ readonly routing: RoutingApi;
22
+ readonly characters: CharactersApi;
23
+ readonly world: WorldApi;
24
+ readonly orgs: OrgsWriteApi;
25
+ readonly coins: CoinsApi;
17
26
  constructor(config: TriexClientConfig);
27
+ org(orgIdOrUnitId: string, options?: {
28
+ seat?: string;
29
+ address?: string;
30
+ }): Promise<OrgHandle>;
18
31
  requireExecutor(): TransactionExecutor;
19
32
  requireAddress(override?: string): string;
20
- resolveBalanceManagerId(address: string): Promise<string | null>;
21
- rememberBalanceManagerId(id: string): void;
33
+ optionalAddress(override?: string): string | undefined;
34
+ resolveTradingAccountId(address: string): Promise<string | null>;
35
+ rememberTradingAccountId(owner: string, id: string): void;
36
+ resolveItemPoolId(selector: PoolSelector): Promise<string>;
22
37
  beginBmTx(owner: string): Promise<{
23
38
  tx: Transaction;
24
39
  bm: TransactionObjectArgument;
25
40
  existingBmId: string | null;
26
41
  }>;
27
42
  finishBmTx(tx: Transaction, bm: TransactionObjectArgument, existingBmId: string | null, owner: string): Promise<TxResult>;
28
- requireBalanceManagerId(owner: string): Promise<string>;
43
+ requireTradingAccountId(owner: string): Promise<string>;
29
44
  }
30
45
  declare class AccountApi {
31
46
  private readonly c;
32
47
  constructor(c: TriexClient);
33
48
  get(address?: string): Promise<TradingAccount | null>;
34
49
  ensure(address?: string): Promise<EnsureAccountResult>;
50
+ register(): Promise<TxResult>;
51
+ mintCap(params: MintCapParams): Promise<MintCapResult>;
52
+ revokeCap(params: RevokeCapParams): Promise<TxResult>;
53
+ caps(address?: string): Promise<TradingAccountCaps>;
35
54
  depositCurrency(params: DepositCurrencyParams): Promise<TxResult>;
36
55
  depositItems(params: DepositItemsParams): Promise<TxResult>;
37
56
  withdrawCurrency(params?: WithdrawCurrencyParams): Promise<TxResult>;
38
57
  withdrawItems(params: WithdrawItemsParams): Promise<TxResult>;
39
58
  sweepable(): Promise<Sweepable>;
40
59
  owners(params: {
41
- balanceManagerIds: string[];
42
- }): Promise<BalanceManagerOwner[]>;
60
+ tradingAccountIds: string[];
61
+ }): Promise<TradingAccountOwner[]>;
43
62
  claimSettled(params?: ClaimSettledParams): Promise<TxResult>;
44
63
  }
45
64
  declare class BalancesApi {
@@ -84,6 +103,18 @@ declare class MarketApi {
84
103
  solarSystemNames(params: {
85
104
  solarSystemIds: number[];
86
105
  }): Promise<SolarSystemName[]>;
106
+ createPool(params: CreatePoolParams): Promise<CreatePoolResult>;
107
+ claimOperatorShare(params: ClaimOperatorShareParams): Promise<TxResult>;
108
+ recentTrades(params?: RecentTradesParams): Promise<RecentTradesPage>;
109
+ displayPrices(params: DisplayPricesParams): Promise<DisplayPrice[]>;
110
+ displayPrice(itemId: string, opts?: DisplayPriceParams): Promise<DisplayPrice>;
111
+ hubEconomics(params: {
112
+ hubIds: string[];
113
+ }): Promise<HubEconomics[]>;
114
+ topPoolsByFees(opts?: {
115
+ limit?: number;
116
+ }): Promise<PoolFees[]>;
117
+ stats(): Promise<PlatformStats>;
87
118
  }
88
119
  declare class SpatialApi {
89
120
  private readonly c;
@@ -97,20 +128,54 @@ declare class SpatialApi {
97
128
  }): Promise<AutocompleteSystems>;
98
129
  stats(): Promise<SpatialStats>;
99
130
  }
131
+ declare class RoutingApi {
132
+ private readonly c;
133
+ constructor(c: TriexClient);
134
+ route(params: RouteParams): Promise<Route>;
135
+ compare(params: RouteShipParams): Promise<RouteComparison>;
136
+ stats(): Promise<RoutingStats>;
137
+ }
138
+ declare class CharactersApi {
139
+ private readonly c;
140
+ constructor(c: TriexClient);
141
+ get(characterId: string, opts?: {
142
+ enrich?: boolean;
143
+ }): Promise<Character>;
144
+ byAddress(address?: string, opts?: {
145
+ enrich?: boolean;
146
+ }): Promise<Character[]>;
147
+ byName(name: string): Promise<Character[]>;
148
+ batch(params: {
149
+ addresses: string[];
150
+ }): Promise<CharacterLookup[]>;
151
+ tribe(tribeId: number): Promise<Tribe>;
152
+ }
153
+ declare class WorldApi {
154
+ private readonly c;
155
+ constructor(c: TriexClient);
156
+ items(): Promise<WorldItem[]>;
157
+ item(assetId: string): Promise<ItemInfo>;
158
+ recipes(): Promise<Blueprint[]>;
159
+ recipesFor(assetId: string): Promise<ItemBlueprints>;
160
+ }
100
161
  declare class OrdersApi {
101
162
  private readonly c;
102
163
  constructor(c: TriexClient);
164
+ fees(params: TradingFeesParams): Promise<TradingFees>;
103
165
  limit(params: LimitOrderParams): Promise<TxResult>;
104
166
  market(params: MarketOrderParams): Promise<TxResult>;
105
167
  cancel(params: CancelOrderParams): Promise<TxResult>;
168
+ cancelMany(params: CancelOrdersParams): Promise<TxResult>;
106
169
  cancelAll(params: CancelAllOrdersParams): Promise<TxResult>;
107
170
  modify(params: ModifyOrderParams): Promise<TxResult>;
108
171
  openOrders(params?: HistoryPageParams): Promise<OpenOrdersPage>;
109
172
  fills(params?: FillsParams): Promise<FillsPage>;
110
173
  trades(params?: TradesParams): Promise<TradesPage>;
174
+ get(params: OrderLookupParams): Promise<OrderDetail>;
175
+ fill(eventDigest: string): Promise<FillDetail>;
111
176
  private ownBm;
112
177
  private requirePool;
113
178
  private depositQuoteDeficit;
114
179
  private beginCancelTx;
115
180
  }
116
- export type { AccountApi, BalancesApi, MarketApi, OrdersApi, SpatialApi };
181
+ export type { AccountApi, BalancesApi, CharactersApi, MarketApi, OrdersApi, RoutingApi, SpatialApi, WorldApi, };