@trinaryex/sdk 1.0.0 → 2.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/README.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # @trinaryex/sdk
2
2
 
3
- The trading SDK for **Trinary Exchange** — a Sui-based, DeepBook-style market
4
- for the EVE Frontier game economy. Players and bots read market + account data
5
- through the [Trinary Exchange API](https://api.trinary.exchange) and trade by
6
- signing on-chain transactions with their own wallet or keypair.
3
+ [![npm version](https://img.shields.io/npm/v/%40trinaryex%2Fsdk)](https://www.npmjs.com/package/@trinaryex/sdk)
4
+ [![license: MIT](https://img.shields.io/npm/l/%40trinaryex%2Fsdk)](#license)
5
+
6
+ The official TypeScript trading SDK for
7
+ [**Trinary Exchange**](https://trinary.exchange/), the player-built
8
+ **EVE Frontier marketplace** — a Sui-based, DeepBook-style order-book market
9
+ for trading items and currency across EVE Frontier trade hubs. Players and
10
+ bots read live **EVE Frontier market data** through the
11
+ [Trinary Exchange API](https://docs.trinary.exchange/) and trade by signing
12
+ on-chain transactions with their own wallet or keypair.
13
+
14
+ - 🛰️ Browse the markets: **<https://trinary.exchange/>**
15
+ - 📚 Full API documentation: **<https://docs.trinary.exchange/>**
7
16
 
8
17
  Built for exactly the things you'd want to build on an exchange:
9
18
 
@@ -12,9 +21,10 @@ Built for exactly the things you'd want to build on an exchange:
12
21
  - **CLI tools** — everything is plain async TypeScript with typed errors
13
22
  - **agentic trading** — stable error codes plus human-readable on-chain abort translation
14
23
 
15
- > **Status: pre-release.** Reads and the full write surface (deposits,
16
- > withdrawals, orders, cancels, claims) are implemented and unit-tested
17
- > against the production app's transaction composition. Targets **testnet**
24
+ > **Status: v1.0.0 — released.** The full read and write surface (deposits,
25
+ > withdrawals, orders, cancels, claims) is verified end-to-end against the
26
+ > live gateway and chain: a scripted trading lifecycle with real fills, fees,
27
+ > and settled-proceeds claims, on top of 93 unit tests. Targets **testnet**
18
28
  > (the `stillness` world). See [DESIGN.md](./DESIGN.md).
19
29
 
20
30
  ## Two planes, two auth models
@@ -98,7 +108,7 @@ const feed = await ro.discover({ assetId: '70810', side: 'sell' })
98
108
  ### Market analytics
99
109
 
100
110
  ```ts
101
- import { aggregateLevels, midPrice, spread, vwap, bucketTrades, iterateTrades } from '@trinaryex/sdk'
111
+ import { aggregateLevels, midPrice, spread, vwap, iterateTrades } from '@trinaryex/sdk'
102
112
 
103
113
  const book = await ro.orderbook({ storageUnitId, assetId })
104
114
  console.log('mid', midPrice(book), 'spread', spread(book)?.bps, 'bps')
@@ -109,9 +119,8 @@ const history = []
109
119
  for await (const trade of iterateTrades(ro.indexer, balanceManagerId)) {
110
120
  history.push(trade) // { price, baseQuantity, quoteQuantity, fee, side, tradedAt, … }
111
121
  }
112
- // … and chart it: the API has no price-history endpoint, so build candles
113
- // client-side.
114
- const hourly = bucketTrades(history, 60 * 60 * 1000) // OHLCV Candle[]
122
+ // … and summarize it.
123
+ console.log('lifetime VWAP', vwap(history))
115
124
  ```
116
125
 
117
126
  ### Trading bot loop
@@ -197,7 +206,7 @@ explainMoveAbort(rawError) // "No liquidity available (EEmptyOrderbook)" | null
197
206
  | `balances` | `atHub` (items: warehouse/marketplace/hangar) · `currency` (CRED wallet + BM, fullnode) |
198
207
  | `market` | `discover` · `hub` · `itemsAtHub` · `resolvePool` · `orderbook` · `poolMetadata` |
199
208
  | `orders` | `limit` · `market` · `cancel` · `cancelAll` · `modify` · `openOrders` · `fills` · `trades` |
200
- | helpers | `aggregateLevels` · `midPrice` · `spread` · `depth` · `vwap` · `bucketTrades` (OHLCV) · `estimateMarketBuyCost` · `iterateDiscovery/Fills/Trades` · `untilIndexed` · `explainMoveAbort` · `toBase` / `fromBase` |
209
+ | helpers | `aggregateLevels` · `midPrice` · `spread` · `depth` · `vwap` · `estimateMarketBuyCost` · `iterateDiscovery/Fills/Trades` · `untilIndexed` · `explainMoveAbort` · `toBase` / `fromBase` |
201
210
 
202
211
  Runnable examples live in [`examples/`](./examples).
203
212
 
@@ -226,7 +235,7 @@ slots) from the **fullnode**, head-current. Prefer ids returned from writes
226
235
 
227
236
  ```bash
228
237
  npm install
229
- npm run tscheck && npm test # 70 unit tests
238
+ npm run tscheck && npm test # 93 unit tests
230
239
  npm run build
231
240
 
232
241
  # Live verification (needs .env — see .env.sample):
@@ -234,6 +243,17 @@ node --env-file=.env scripts/smoke.mjs # read surface vs the live gateway
234
243
  node --env-file=.env scripts/integration.mjs # write paths on testnet (uses gas)
235
244
  ```
236
245
 
246
+ ## Links
247
+
248
+ - [Trinary Exchange](https://trinary.exchange/) — the EVE Frontier
249
+ marketplace: live order books, trade hubs, and market data for the EVE
250
+ Frontier economy
251
+ - [API documentation](https://docs.trinary.exchange/) — REST reference,
252
+ guides, and [API keys](https://docs.trinary.exchange/docs/api-keys) for the
253
+ Trinary Exchange trading API
254
+ - [`@trinaryex/sdk` on npm](https://www.npmjs.com/package/@trinaryex/sdk)
255
+ - [Design notes](./DESIGN.md) — architecture, scope, and verification history
256
+
237
257
  ## License
238
258
 
239
259
  MIT
package/dist/book.d.ts CHANGED
@@ -14,14 +14,3 @@ export declare function spread(book: Orderbook): {
14
14
  } | null;
15
15
  export declare function depth(orders: OrderbookOrder[]): bigint;
16
16
  export declare function vwap(executions: ReadonlyArray<Pick<Fill | Trade, 'baseQuantity' | 'quoteQuantity'>>): bigint | null;
17
- export interface Candle {
18
- openTime: number;
19
- open: bigint;
20
- high: bigint;
21
- low: bigint;
22
- close: bigint;
23
- baseVolume: bigint;
24
- quoteVolume: bigint;
25
- tradeCount: number;
26
- }
27
- export declare function bucketTrades(trades: ReadonlyArray<Pick<Trade, 'price' | 'baseQuantity' | 'quoteQuantity' | 'tradedAt'>>, intervalMs: number): Candle[];
package/dist/index.d.ts CHANGED
@@ -10,8 +10,8 @@ export { getWalletCurrencyBalance, getBalanceManagerCurrencyBalance, getBalanceM
10
10
  export { prepareWalletCoinInput, sourceItemsIntoBalanceManager, } from './funding';
11
11
  export { normalizeExecuteResult, executeAndNormalize, findCreatedObject, } from './execute';
12
12
  export type { NormalizedExecution, CreatedObject } from './execute';
13
- export { aggregateLevels, bestBid, bestAsk, midPrice, spread, depth, vwap, bucketTrades, } from './book';
14
- export type { BookLevel, Candle } from './book';
13
+ export { aggregateLevels, bestBid, bestAsk, midPrice, spread, depth, vwap, } from './book';
14
+ 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';
package/dist/index.js CHANGED
@@ -1537,27 +1537,9 @@ function Xe(e) {
1537
1537
  for (let r of e) t += r.baseQuantity, n += r.quoteQuantity;
1538
1538
  return t === 0n ? null : n / t;
1539
1539
  }
1540
- function Ze(e, t) {
1541
- if (t <= 0) throw Error("intervalMs must be positive");
1542
- let n = [...e].sort((e, t) => e.tradedAt - t.tradedAt), r = [];
1543
- for (let e of n) {
1544
- let n = Math.floor(e.tradedAt / t) * t, i = r[r.length - 1];
1545
- i && i.openTime === n ? (e.price > i.high && (i.high = e.price), e.price < i.low && (i.low = e.price), i.close = e.price, i.baseVolume += e.baseQuantity, i.quoteVolume += e.quoteQuantity, i.tradeCount++) : r.push({
1546
- openTime: n,
1547
- open: e.price,
1548
- high: e.price,
1549
- low: e.price,
1550
- close: e.price,
1551
- baseVolume: e.baseQuantity,
1552
- quoteVolume: e.quoteQuantity,
1553
- tradeCount: 1
1554
- });
1555
- }
1556
- return r;
1557
- }
1558
1540
  //#endregion
1559
1541
  //#region src/paging.ts
1560
- async function* Qe(e, t, n) {
1542
+ async function* Ze(e, t, n) {
1561
1543
  let r = n?.maxItems ?? 1e4, i = t?.cursor, a = 0;
1562
1544
  for (;;) {
1563
1545
  let n = await e.discovery({
@@ -1569,7 +1551,7 @@ async function* Qe(e, t, n) {
1569
1551
  i = n.nextCursor;
1570
1552
  }
1571
1553
  }
1572
- async function* $e(e, t, n, r) {
1554
+ async function* Qe(e, t, n, r) {
1573
1555
  let i = r?.maxItems ?? 1e4, a = n?.before, o = 0;
1574
1556
  for (;;) {
1575
1557
  let r = await e.fills(t, {
@@ -1581,7 +1563,7 @@ async function* $e(e, t, n, r) {
1581
1563
  a = r.fills[r.fills.length - 1].filledAt;
1582
1564
  }
1583
1565
  }
1584
- async function* et(e, t, n, r) {
1566
+ async function* $e(e, t, n, r) {
1585
1567
  let i = r?.maxItems ?? 1e4, a = n?.before, o = 0;
1586
1568
  for (;;) {
1587
1569
  let r = await e.trades(t, {
@@ -1595,7 +1577,7 @@ async function* et(e, t, n, r) {
1595
1577
  }
1596
1578
  //#endregion
1597
1579
  //#region src/wait.ts
1598
- async function tt(e, t) {
1580
+ async function et(e, t) {
1599
1581
  let n = t?.timeoutMs ?? 3e4, r = t?.intervalMs ?? 2e3, i = Date.now() + n;
1600
1582
  for (;;) {
1601
1583
  let a = await e();
@@ -1605,4 +1587,4 @@ async function tt(e, t) {
1605
1587
  }
1606
1588
  }
1607
1589
  //#endregion
1608
- export { o as CLOCK_ID, a as DEFAULT_INDEXER_URL, W as FEE_RATE_SCALING, fe as GTC_EXPIRE, X as IndexerClient, U as MULTICOIN_PRICE_SCALING, c as NETWORK_PRESETS, Ge as ReadOnlyClient, s as STILLNESS_PACKAGE_IDS, de as TRIEXBOOK_PRICE_SCALING, ze as TriexClient, d as TriexClientError, u as TriexError, Ke as aggregateLevels, $ as bestAsk, Q as bestBid, Ze as bucketTrades, K as computeBidQuoteDeposit, G as computeItemQuote, Ye as depth, ge as estimateMarketBuyCost, m as executeAndNormalize, p as explainMoveAbort, O as fetchCharacterInfo, A as fetchInventorySlotQuantity, k as fetchSsuOwnerInfo, g as findCreatedObject, D as findOwnedItemReceipts, me as fromBase, T as getBalanceManagerCurrencyBalance, ie as getBalanceManagerItemBalance, ne as getObjectRef, E as getRegistryMulticoinCollectionId, re as getWalletCurrencyBalance, Qe as iterateDiscovery, $e as iterateFills, et as iterateTrades, he as marketBuyRoundingBuffer, qe as midPrice, h as normalizeExecuteResult, V as prepareWalletCoinInput, l as resolvePackageIds, H as sourceItemsIntoBalanceManager, Je as spread, pe as toBase, w as toSsuObjectId, ae as transactions, tt as untilIndexed, Xe as vwap };
1590
+ export { o as CLOCK_ID, a as DEFAULT_INDEXER_URL, W as FEE_RATE_SCALING, fe as GTC_EXPIRE, X as IndexerClient, U as MULTICOIN_PRICE_SCALING, c as NETWORK_PRESETS, Ge as ReadOnlyClient, s as STILLNESS_PACKAGE_IDS, de as TRIEXBOOK_PRICE_SCALING, ze as TriexClient, d as TriexClientError, u as TriexError, Ke as aggregateLevels, $ as bestAsk, Q as bestBid, K as computeBidQuoteDeposit, G as computeItemQuote, Ye as depth, ge as estimateMarketBuyCost, m as executeAndNormalize, p as explainMoveAbort, O as fetchCharacterInfo, A as fetchInventorySlotQuantity, k as fetchSsuOwnerInfo, g as findCreatedObject, D as findOwnedItemReceipts, me as fromBase, T as getBalanceManagerCurrencyBalance, ie as getBalanceManagerItemBalance, ne as getObjectRef, E as getRegistryMulticoinCollectionId, re as getWalletCurrencyBalance, Ze as iterateDiscovery, Qe as iterateFills, $e as iterateTrades, he as marketBuyRoundingBuffer, qe as midPrice, h as normalizeExecuteResult, V as prepareWalletCoinInput, l as resolvePackageIds, H as sourceItemsIntoBalanceManager, Je as spread, pe as toBase, w as toSsuObjectId, ae as transactions, et as untilIndexed, Xe as vwap };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trinaryex/sdk",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
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",
@@ -98,6 +98,12 @@
98
98
  "sui",
99
99
  "orderbook",
100
100
  "eve-frontier",
101
+ "eve-frontier-trading",
102
+ "eve-frontier-market",
103
+ "eve-frontier-marketplace",
104
+ "marketplace",
105
+ "market-data",
106
+ "trading-bot",
101
107
  "deepbook"
102
108
  ],
103
109
  "sideEffects": false,