@trinaryex/sdk 3.8.0 → 4.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.
- package/DESIGN.md +253 -71
- package/README.md +218 -16
- package/dist/ReadOnlyClient.d.ts +42 -8
- package/dist/TriexClient.d.ts +73 -8
- package/dist/armature/OrgClient.d.ts +372 -0
- package/dist/armature/OrgClientGroups.d.ts +186 -0
- package/dist/armature/OrgsApi.d.ts +69 -0
- package/dist/armature/actions.d.ts +75 -0
- package/dist/armature/create.d.ts +27 -0
- package/dist/armature/currency.d.ts +64 -0
- package/dist/armature/executors.d.ts +44 -0
- package/dist/armature/governance.d.ts +194 -0
- package/dist/armature/harness.d.ts +96 -0
- package/dist/armature/lifecycle.d.ts +84 -0
- package/dist/armature/plan.d.ts +39 -0
- package/dist/armature/proposals.d.ts +51 -0
- package/dist/armature/queries.d.ts +16 -0
- package/dist/armature/schemas.d.ts +559 -0
- package/dist/armature/trading.d.ts +114 -0
- package/dist/armature/transactions.d.ts +160 -0
- package/dist/armature/treasury.d.ts +41 -0
- package/dist/armature/tree.d.ts +13 -0
- package/dist/armature/types.d.ts +59 -0
- package/dist/armature/upgrade.d.ts +27 -0
- package/dist/armature/vault.d.ts +94 -0
- package/dist/coins/CoinsApi.d.ts +53 -0
- package/dist/coins/funding.d.ts +6 -0
- package/dist/coins/money.d.ts +36 -0
- package/dist/coins/onchain.d.ts +162 -0
- package/dist/coins/schemas.d.ts +456 -0
- package/dist/coins/transactions.d.ts +82 -0
- package/dist/coins/types.d.ts +115 -0
- package/dist/errors.d.ts +11 -1
- package/dist/funding.d.ts +2 -2
- package/dist/http.d.ts +3 -0
- package/dist/index.d.ts +63 -8
- package/dist/index.js +10587 -959
- package/dist/money.d.ts +15 -0
- package/dist/moveAbort.d.ts +28 -0
- package/dist/moveAbortCatalog.generated.d.ts +9 -0
- package/dist/onchain.d.ts +55 -3
- package/dist/paging.d.ts +9 -3
- package/dist/queries.d.ts +35 -7
- package/dist/schemas.d.ts +1911 -50
- package/dist/transactions.d.ts +63 -1
- package/dist/types.d.ts +116 -7
- 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
|
|
118
|
+
// Stream a trading account's full trade history (auto-pagination) …
|
|
119
119
|
const history = []
|
|
120
|
-
for await (const trade of iterateTrades(ro.indexer,
|
|
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
|
|
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
|
|
138
|
-
|
|
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
|
|
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` / `
|
|
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,184 @@ 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
|
-
|
|
|
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 bom = await client.world.recipesFor('77753') // [] if not craftable
|
|
262
|
+
|
|
263
|
+
// Routes take system NAMES — see the note below.
|
|
264
|
+
const route = await client.routing.route({
|
|
265
|
+
origin: 'U4T-SL7', destination: 'U.L6B.HNX', maxJumpRangeLy: 500,
|
|
266
|
+
})
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
> **Solar system names are player-reported (cycle 7).** The star map ships
|
|
270
|
+
> with ids, coordinates and stargates, but a system's *name* is known only once
|
|
271
|
+
> a player reports it. Until then `solarSystemName` is `null` on every read,
|
|
272
|
+
> a lookup **by name** fails (`SolarSystemNotFound` / `RouteNotFound`) while the
|
|
273
|
+
> same system resolves **by id**, and routing — which is name-only — cannot
|
|
274
|
+
> reach it. Key on `solarSystemId`; use `spatial.autocompleteSystems()` to find
|
|
275
|
+
> names that resolve, and `spatial.stats().knownSolarSystemNames` for coverage.
|
|
276
|
+
|
|
277
|
+
> **Display prices carry no fee.** `market.displayPrice(s)` is the plain
|
|
278
|
+
> market price; pool metadata's `feeRateScaled` is the fee class's *entry*
|
|
279
|
+
> tier — use `orders.fees()` for maker rates and your own tier — and the rate a fill actually charged is on the fill
|
|
280
|
+
> (`fee`, `makerFee`/`takerFee`, `feeRateBps`).
|
|
281
|
+
|
|
282
|
+
## Coin markets (currency pairs)
|
|
283
|
+
|
|
284
|
+
`client.coins` trades `triex::pool::Pool<Base, Quote>` order books — one Move
|
|
285
|
+
coin against another, usually CRED. Name a pool by `poolId` or by
|
|
286
|
+
`baseCoinType` (+ `quoteCoinType`, default CRED):
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
import { coinPriceToRaw } from '@trinaryex/sdk'
|
|
290
|
+
|
|
291
|
+
const pool = { baseCoinType: '0x…::wbtc::WBTC' } // vs CRED
|
|
292
|
+
|
|
293
|
+
const book = await client.coins.orderbook({ ...pool, depth: 20 })
|
|
294
|
+
const fees = await client.coins.tradeParams(pool) // live FeePolicy rates
|
|
295
|
+
|
|
296
|
+
// Limit buy 2 WBTC (8 dp) at 61,250 CRED (6 dp) each — price is 1e9-scaled.
|
|
297
|
+
await client.coins.limit({
|
|
298
|
+
...pool, side: 'buy',
|
|
299
|
+
price: coinPriceToRaw('61250', 8, 6),
|
|
300
|
+
quantity: 200_000_000n,
|
|
301
|
+
})
|
|
302
|
+
await client.coins.market({ ...pool, side: 'sell', quantity: 50_000_000n })
|
|
303
|
+
await client.coins.swap({ ...pool, side: 'buy', amountIn: 1_000_000n }) // wallet → wallet
|
|
304
|
+
await client.coins.claimSettled({ pools: [pool], withdrawCoinTypes: ['0x…::wbtc::WBTC'] })
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
- **Reads come from the fullnode.** The coin-pool indexer routes are not on the
|
|
308
|
+
gateway, so books, fees, open orders and account state are simulated view
|
|
309
|
+
calls (head-current, no API key cost). Only `coins.list()` (`GET /v1/coins`)
|
|
310
|
+
is an indexer read. `ReadOnlyClient` takes an optional `suiClient` for these.
|
|
311
|
+
- **Prices are 1e9-scaled:** `quote = base × price / 1e9`; human price is
|
|
312
|
+
`raw / 10^(9 + quoteDecimals − baseDecimals)` (`coinPriceToRaw` /
|
|
313
|
+
`formatCoinPrice`). No lot/tick size; a resting order needs
|
|
314
|
+
`quantity ≥ coinMinOrderQuantity(price)`.
|
|
315
|
+
- **Both sides pay fees, in quote.** Bids pay the taker fee on top and escrow a
|
|
316
|
+
maker fee for the resting part; asks pay out of their proceeds. Bid funding
|
|
317
|
+
is `computeCoinBidDeposit` at the highest entry-rung rate (taker or maker,
|
|
318
|
+
current or staged) — it never under-funds. A market buy holds the exact cost
|
|
319
|
+
against the live book (`estimateMarket`) unless you pass `quoteBudget`.
|
|
320
|
+
- `coins.swap` needs no trading account and is charged the entry-rung rate;
|
|
321
|
+
`coins.quote` without `tradingAccountId` is its exact dry-run.
|
|
322
|
+
|
|
323
|
+
Design notes and Move references: [DESIGN-COINS.md](./DESIGN-COINS.md).
|
|
324
|
+
|
|
325
|
+
## Organizations & governance (Armature)
|
|
326
|
+
|
|
327
|
+
An organization is a **tree of DAOs** — a root plus its units — and every write
|
|
328
|
+
goes through a governance pipeline whose shape depends on who is calling. Acting
|
|
329
|
+
as one means binding both the organization *and* a seat within it:
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
const org = await client.org(orgId) // any unit id resolves the whole tree
|
|
333
|
+
org.seats // boards you sit on, highest authority first
|
|
334
|
+
org.as(officersDaoId) // act through a different seat you hold
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### The same call is not the same transaction
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
const outcome = await org.members.add(['0x…'])
|
|
341
|
+
switch (outcome.status) {
|
|
342
|
+
case 'executed': break // your vote cleared quorum — done
|
|
343
|
+
case 'proposed': outcome.proposalId; break // the board still has to vote
|
|
344
|
+
case 'blocked': outcome.reason; break // no path available, and why
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
`blocked` is a **returned value, not a throw** — "you are not on this board" is
|
|
349
|
+
an ordinary answer. Real failures still throw `TriexClientError`. Use
|
|
350
|
+
`org.governance.resolve(action)` to ask without signing, and
|
|
351
|
+
`org.governance.paths(action)` for the full trace of why.
|
|
352
|
+
|
|
353
|
+
Whether a lone vote suffices is a question about **per-type config**, not about
|
|
354
|
+
rank: it clears quorum only when `boardSize × quorum ≤ 10000` and the execution
|
|
355
|
+
delay is zero. `org.governance.read()` returns those configs.
|
|
356
|
+
|
|
357
|
+
### The rest of the handle
|
|
358
|
+
|
|
359
|
+
| Group | Methods |
|
|
360
|
+
|---|---|
|
|
361
|
+
| `governance` | `read` · `resolve` · `paths` · `run` · `runBatch` · `runComposite` · `canComposite` · `vote` · `execute` · `tryExpire` · `proposals` |
|
|
362
|
+
| `members` | `add` · `remove` · `setBoard` |
|
|
363
|
+
| `metadata` | `update` |
|
|
364
|
+
| `types` | `enable` · `updateConfig` · `enableComposite` · `enableSendCoin` · `enableTrading` |
|
|
365
|
+
| `treasury` | `balances` · `balance` · `itemBalance` · `deposit` · `send` · `sendToOrg` |
|
|
366
|
+
| `orders` | `ensureAccount` · `limit` · `cancel` · `buyFromTreasury` · `sellFromDaoVault` · `sweepCoin` · `sweepItems` · `sweepAll` |
|
|
367
|
+
| `vault` | `atHub` · `resolve` · `info` · `balance` · `init` · `deposit` · `withdraw` · `grant` · `revoke` · `deinit` |
|
|
368
|
+
|
|
369
|
+
Four things worth knowing before you call them:
|
|
370
|
+
|
|
371
|
+
- **Funding a treasury is permissionless.** `treasury.deposit()` needs no seat
|
|
372
|
+
and no vote, and returns a plain `TxResult`. Paying out returns `RunOutcome`
|
|
373
|
+
because it is governance. The return types are the authorization model.
|
|
374
|
+
- **Trading never degrades into a proposal.** A limit order deferred by a week
|
|
375
|
+
is priced against a book that no longer exists, and a funded buy split into
|
|
376
|
+
two proposals loses its atomic deposit-then-place guarantee — so these
|
|
377
|
+
`blocked` instead.
|
|
378
|
+
- **Shared storage is keyed by (storage unit, organization).** There is no "the
|
|
379
|
+
vault at this hub": anyone can register one at any SSU. `vault.resolve()`
|
|
380
|
+
answers for *your* organization.
|
|
381
|
+
- **`types.enableTrading({ bindToBaseType })` is irreversible.** It binds the
|
|
382
|
+
coin-pool order types to one base coin permanently. Leave it unset.
|
|
383
|
+
|
|
216
384
|
## Units & money
|
|
217
385
|
|
|
218
386
|
- All prices, quantities, and amounts are **`bigint` in raw base units**;
|
|
219
387
|
timestamps are epoch **milliseconds**. Items are identified by `assetId`
|
|
220
388
|
(numeric item-type id as a string).
|
|
221
389
|
- Item pools price in CRED base units per item (no price scaling). Pool
|
|
222
|
-
metadata carries
|
|
223
|
-
|
|
224
|
-
-
|
|
225
|
-
|
|
390
|
+
metadata carries the base/quote `decimals` for display conversion via
|
|
391
|
+
`toBase`/`fromBase`, and `feeRateScaled` — the pool's entry-tier taker rate.
|
|
392
|
+
- Fees are quote-denominated, `floor(quote × rate / 1e9)`, and **both sides
|
|
393
|
+
pay**: bids on top of what they owe (taker fee when they match, maker fee
|
|
394
|
+
escrowed while they rest), asks out of their proceeds. Rates come from the
|
|
395
|
+
pool's fee class (multicoin launch ladder: 2.2% taker / 1.8% maker, falling
|
|
396
|
+
with your trailing 30-epoch fee turnover). `orders.fees()` reads the ladder,
|
|
397
|
+
your tier, and the cancel retention (the share of a bid's escrowed maker fee
|
|
398
|
+
kept when you cancel, modify down, or it expires) from the chain.
|
|
399
|
+
- A limit bid is funded for `notional + floor(notional × bidEscrowFeeRate /
|
|
400
|
+
1e9)` — the pool's highest rate, so it can never be under-funded; anything
|
|
401
|
+
unused stays in the trading account. Sells need no CRED.
|
|
226
402
|
- Order expiry defaults to good-til-cancelled (`GTC_EXPIRE`).
|
|
227
403
|
|
|
228
404
|
## Consistency model
|
|
@@ -230,7 +406,7 @@ Runnable examples live in [`examples/`](./examples).
|
|
|
230
406
|
The indexer is eventually-consistent (seconds behind head). On-chain writes
|
|
231
407
|
are authoritative and atomic — a stale read can only make a transaction abort
|
|
232
408
|
and roll back, never lose funds. The SDK reads everything that funds
|
|
233
|
-
transactions (
|
|
409
|
+
transactions (trading-account resolution, currency balances, receipts, hangar
|
|
234
410
|
slots) from the **fullnode**, head-current. Prefer ids returned from writes
|
|
235
411
|
(`TxResult.createdObjects`) over immediate re-reads.
|
|
236
412
|
|
|
@@ -280,6 +456,32 @@ inputs to prove the gate fails when it should. A vendored copy cannot see the
|
|
|
280
456
|
gateway moving underneath us, so a scheduled job runs the same check against
|
|
281
457
|
the live document — see `.github/workflows/gateway_drift.yml`.
|
|
282
458
|
|
|
459
|
+
### Regenerating the abort catalog
|
|
460
|
+
|
|
461
|
+
`src/moveAbortCatalog.generated.ts` is generated from the Move sources of all four
|
|
462
|
+
contract repositories: [trinary-exchange](https://github.com/loash-industries/trinary-exchange)
|
|
463
|
+
(triex + CRED) and the three Armature repos (`armature`, `armature-vault`,
|
|
464
|
+
`armature-trading`), so organization aborts are explained as well as trading ones.
|
|
465
|
+
It is committed, so building and testing the SDK never needs those checkouts — only
|
|
466
|
+
regenerating does, after an error constant is added, removed or renumbered:
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
npm run generate:error-codes -- \
|
|
470
|
+
--contracts <trinary-exchange> \ # or $TRIEX_CONTRACTS (default ../trinary-exchange)
|
|
471
|
+
--armature <armature> \ # or $ARMATURE_CONTRACTS (default ../armature)
|
|
472
|
+
--armature-vault <armature-vault> \ # or $ARMATURE_VAULT_CONTRACTS (default ../armature-vault)
|
|
473
|
+
--armature-trading <armature-trading> # or $ARMATURE_TRADING_CONTRACTS (default ../armature-trading)
|
|
474
|
+
npm run check:error-codes -- <same flags> # fail if the catalog is stale
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
Every repository is required; a missing checkout fails rather than shrinking the
|
|
478
|
+
catalog.
|
|
479
|
+
|
|
480
|
+
`check:error-codes` needs the contract checkouts, so it is a local/release step
|
|
481
|
+
rather than a CI one. Drift is caught in CI a different way: the curated messages in
|
|
482
|
+
`src/moveAbort.ts` are keyed by `MoveAbortName`, a union generated from the
|
|
483
|
+
contracts, so a renamed or deleted constant fails `npm run tscheck`.
|
|
484
|
+
|
|
283
485
|
## Links
|
|
284
486
|
|
|
285
487
|
- [Trinary Exchange](https://trinary.exchange/) — the EVE Frontier
|
package/dist/ReadOnlyClient.d.ts
CHANGED
|
@@ -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,
|
|
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, OrderDetail, OrderLookupParams, PlatformStats, PoolFees, RecentTradesPage, RecentTradesParams, Recipe, 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
|
-
|
|
40
|
-
}): Promise<
|
|
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
|
-
|
|
54
|
+
tradingAccountId?: string;
|
|
51
55
|
}): Promise<InventoryBalances>;
|
|
52
|
-
openOrders(
|
|
53
|
-
fills(
|
|
54
|
-
trades(
|
|
55
|
-
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<Recipe[]>;
|
|
86
|
+
recipesFor(productAssetId: string): Promise<Recipe[]>;
|
|
87
|
+
route(params: RouteParams): Promise<Route>;
|
|
88
|
+
compareRoutes(params: RouteShipParams): Promise<RouteComparison>;
|
|
89
|
+
routingStats(): Promise<RoutingStats>;
|
|
56
90
|
}
|
package/dist/TriexClient.d.ts
CHANGED
|
@@ -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,
|
|
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, OrderDetail, OrderLookupParams, PlatformStats, PoolFees, RecentTradesPage, RecentTradesParams, Recipe, 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
|
|
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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
}): Promise<
|
|
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<Recipe[]>;
|
|
159
|
+
recipesFor(productAssetId: string): Promise<Recipe[]>;
|
|
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, };
|