@trinaryex/sdk 2.0.0 → 3.1.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 CHANGED
@@ -10,8 +10,9 @@ swagger. Remaining: npm publish (CI release workflow ready; needs NPM_TOKEN + pu
10
10
  first module, with room to grow into a higher-level, full-featured client.
11
11
  **Audience:** players and bots trading on Trinary Exchange via an API key.
12
12
  **Target (MVP):** **testnet only**, the **`stillness`** tenant; **only the most-recent (v1)
13
- `triexbook` contracts** are supported. Item↔currency (CRED) markets via `multicoin_pool`
14
- ("pools"); coin-pools are out of scope for now.
13
+ [CLOB contracts](https://github.com/loash-industries/trinary-exchange)** are supported.
14
+ Item↔currency (CRED) markets via `multicoin_pool` ("pools"); coin-pools are out of scope
15
+ for now.
15
16
  **Models after:** [`@trinaryex/keyspace`](https://www.npmjs.com/package/@trinaryex/keyspace)
16
17
  (client + `executor` pattern, `queries`/`transactions` split, zod validation, vite build,
17
18
  semantic-release).
@@ -20,11 +21,11 @@ semantic-release).
20
21
 
21
22
  ## 1. What this SDK is (and isn't)
22
23
 
23
- Trinary Exchange is a Sui-based, DeepBook-style market for an EVE-Frontier game economy.
24
+ Trinary Exchange is a Sui-based order-book market for an EVE-Frontier game economy.
24
25
  Players trade **items** (multicoin balances, priced in the **CRED** trade currency) and
25
26
  **currency** at **trade hubs** (Smart Storage Units / SSUs) through on-chain order books
26
- (the `triexbook` DeepBook fork), settling through a per-player **balance manager** (the
27
- on-chain trading account).
27
+ (the [Trinary Exchange CLOB Move contracts](https://github.com/loash-industries/trinary-exchange)),
28
+ settling through a per-player **balance manager** (the on-chain trading account).
28
29
 
29
30
  The SDK gives a player/bot one object to:
30
31
 
@@ -110,7 +111,7 @@ on the free/standard tier).
110
111
  │ (fetch + x-api-key + zod validate) │ (Postgres read models)
111
112
  │ │
112
113
  │ transactions.ts ──build PTB──► executor() │───► player's wallet / keypair
113
- │ (pure @mysten/sui Transaction builders) │ └─► Sui network (triexbook)
114
+ │ (pure @mysten/sui Transaction builders) │ └─► Sui network (CLOB contracts)
114
115
  └────────────────────────────────────────────┘
115
116
  ```
116
117
 
@@ -139,7 +140,7 @@ executor: (tx) => signAndExecuteTransaction({ transaction: tx })
139
140
 
140
141
  Executor results are **normalized** (`execute.ts`): both the v2 core-client
141
142
  `TransactionResult` and the legacy `{ digest, objectChanges }` shape work, and on-chain
142
- aborts are rethrown as typed `TransactionFailed` errors with the triexbook abort code
143
+ aborts are rethrown as typed `TransactionFailed` errors with the CLOB abort code
143
144
  translated (§11 of TRIEX_SYSTEM_DESIGN). Include `effects` + `objectTypes` (v2) or
144
145
  `objectChanges` (legacy) so created objects — e.g. a freshly-created `BalanceManager` —
145
146
  are captured for read-your-writes.
@@ -216,7 +217,7 @@ const client = new TriexClient({
216
217
  network: 'testnet', // selects package-id bundle
217
218
  executor: (tx) => signAndExecuteTransaction({ transaction: tx, options: { showObjectChanges: true } }),
218
219
  // packageIds optional — resolved from `network` defaults, overridable:
219
- // packageIds: { triexbook, multicoin, warehouseReceipts, credCoinType, clock: '0x6', ... }
220
+ // packageIds: { triex, multicoin, warehouseReceipts, credCoinType, clock: '0x6', ... }
220
221
  })
221
222
  ```
222
223
 
@@ -279,18 +280,18 @@ pure functions `(args) => Transaction`; the facade fills object IDs from indexer
279
280
 
280
281
  | Builder | Move target | Notes |
281
282
  |---|---|---|
282
- | `newBalanceManager` | `${triexbook}::balance_manager::new()` | returns BM; `transferObjects([bm], self)` when freshly created |
283
- | `depositCoin` | `${triexbook}::balance_manager::deposit<T>(bm, coin)` | coin prepared via list/merge/split of wallet coins |
284
- | `depositMulticoinObject` | `${triexbook}::balance_manager::deposit_multicoin(bm, object)` | deposit an owned multicoin `Balance` object (wallet receipts) into BM |
285
- | `withdrawAllCoin` | `${triexbook}::balance_manager::withdraw_all<T>(bm)` → `transferObjects` | #13 |
286
- | `withdrawAllMulticoin` | `${triexbook}::balance_manager::withdraw_all_multicoin(bm, collectionId, assetId)` | #12 step 1 |
283
+ | `newBalanceManager` | `${triex}::balance_manager::new()` | returns BM; `transferObjects([bm], self)` when freshly created |
284
+ | `depositCoin` | `${triex}::balance_manager::deposit<T>(bm, coin)` | coin prepared via list/merge/split of wallet coins |
285
+ | `depositMulticoinObject` | `${triex}::balance_manager::deposit_multicoin(bm, object)` | deposit an owned multicoin `Balance` object (wallet receipts) into BM |
286
+ | `withdrawAllCoin` | `${triex}::balance_manager::withdraw_all<T>(bm)` → `transferObjects` | #13 |
287
+ | `withdrawAllMulticoin` | `${triex}::balance_manager::withdraw_all_multicoin(bm, collectionId, assetId)` | #12 step 1 |
287
288
  | `redeemReceipt` | `${warehouseReceipts}::receipt::redeem_receipt(balance, ssu, character, vaultConfig, collection, isOwner)` | #12 step 2 (BM item → hangar) |
288
- | `ownerProof` | `${triexbook}::balance_manager::generate_proof_as_owner(bm)` | required before placing/withdrawing |
289
- | `placeLimitOrderItem` | `${triexbook}::multicoin_pool::place_limit_order<Quote>(pool, bm, proof, orderType, selfMatch, price, qty, isBid, expireTs, clock)` | items (multicoin) |
290
- | `placeMarketOrderItem` | `${triexbook}::multicoin_pool::place_market_order<Quote>(pool, bm, proof, selfMatch, qty, isBid, clock)` | items (multicoin) |
291
- | `cancelOrderItem` | `${triexbook}::multicoin_pool::cancel_order<Quote>(pool, bm, proof, orderId u64, clock)` | implemented (+ `cancel_all_orders`, `modify_order`) |
292
- | `withdrawCoin` | `${triexbook}::balance_manager::withdraw<T>(bm, amount)` | partial currency withdraw |
293
- | `withdrawSettledAmounts` | `${triexbook}::multicoin_pool::withdraw_settled_amounts<Quote>(pool, bm, proof)` | claim post-fill proceeds into the BM |
289
+ | `ownerProof` | `${triex}::balance_manager::generate_proof_as_owner(bm)` | required before placing/withdrawing |
290
+ | `placeLimitOrderItem` | `${triex}::multicoin_pool::place_limit_order<Quote>(pool, bm, proof, orderType, selfMatch, price, qty, isBid, expireTs, clock)` | items (multicoin) |
291
+ | `placeMarketOrderItem` | `${triex}::multicoin_pool::place_market_order<Quote>(pool, bm, proof, selfMatch, qty, isBid, clock)` | items (multicoin) |
292
+ | `cancelOrderItem` | `${triex}::multicoin_pool::cancel_order<Quote>(pool, bm, proof, orderId u64, clock)` | implemented (+ `cancel_all_orders`, `modify_order`) |
293
+ | `withdrawCoin` | `${triex}::balance_manager::withdraw<T>(bm, amount)` | partial currency withdraw |
294
+ | `withdrawSettledAmounts` | `${triex}::multicoin_pool::withdraw_settled_amounts<Quote>(pool, bm, proof)` | claim post-fill proceeds into the BM |
294
295
 
295
296
  > `<Quote>` is the CRED coin type (`credCoinType`). Item markets are `multicoin_pool`; the
296
297
  > item is identified by `collectionId` + `assetId` (u64), not a Move type parameter.
@@ -351,8 +352,8 @@ back into the SSU/hangar (needs `ssu`, `character`, `vaultConfig`, `collection`,
351
352
 
352
353
  ## 7. Money math (`money.ts`)
353
354
 
354
- - **Coin (currency-pair) pools:** `quote = base * price / TRIEXBOOK_PRICE_SCALING`
355
- where `TRIEXBOOK_PRICE_SCALING = 1_000_000_000` (1e9).
355
+ - **Coin (currency-pair) pools:** `quote = base * price / TRIEX_PRICE_SCALING`
356
+ where `TRIEX_PRICE_SCALING = 1_000_000_000` (1e9).
356
357
  - **Multicoin (item) pools:** scaling factor `1` → `quote = price * quantity` (confirmed
357
358
  against the production app, which passes the unscaled price straight to
358
359
  `place_limit_order`; TRIEX_SYSTEM_DESIGN §7's blanket "all prices ×1e9" describes coin
package/README.md CHANGED
@@ -5,9 +5,10 @@
5
5
 
6
6
  The official TypeScript trading SDK for
7
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
8
+ **EVE Frontier marketplace** — a Sui-based order-book market for trading
9
+ items and currency across EVE Frontier trade hubs, built on the
10
+ [Trinary Exchange CLOB Move contracts](https://github.com/loash-industries/trinary-exchange).
11
+ Players and bots read live **EVE Frontier market data** through the
11
12
  [Trinary Exchange API](https://docs.trinary.exchange/) and trade by signing
12
13
  on-chain transactions with their own wallet or keypair.
13
14
 
@@ -251,6 +252,8 @@ node --env-file=.env scripts/integration.mjs # write paths on testnet (uses gas
251
252
  - [API documentation](https://docs.trinary.exchange/) — REST reference,
252
253
  guides, and [API keys](https://docs.trinary.exchange/docs/api-keys) for the
253
254
  Trinary Exchange trading API
255
+ - [Trinary Exchange CLOB contracts](https://github.com/loash-industries/trinary-exchange)
256
+ — the Sui Move order-book contracts this SDK talks to
254
257
  - [`@trinaryex/sdk` on npm](https://www.npmjs.com/package/@trinaryex/sdk)
255
258
  - [Design notes](./DESIGN.md) — architecture, scope, and verification history
256
259
 
@@ -1,5 +1,5 @@
1
1
  import { IndexerClient } from './queries';
2
- import { BalancesAtHubParams, DiscoveryFilters, DiscoveryResult, FillsPage, FillsParams, HistoryPageParams, HubItemsPage, InventoryBalances, OpenOrdersPage, Orderbook, PackageIds, PoolMetadata, ReadOnlyClientConfig, Sweepable, TradeHubDetail, TradesPage, TradesParams } from './types';
2
+ import { BalancesAtHubParams, DiscoveryFilters, DiscoveryResult, FillsPage, FillsParams, HistoryPageParams, HubItemOrderbook, HubItemsPage, 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;
@@ -14,7 +14,7 @@ export declare class ReadOnlyClient {
14
14
  orderbook(params: {
15
15
  storageUnitId: string;
16
16
  assetId: string;
17
- }): Promise<Orderbook>;
17
+ }): Promise<HubItemOrderbook>;
18
18
  poolMetadata(poolId: string): Promise<PoolMetadata>;
19
19
  balancesAtHub(params: BalancesAtHubParams & {
20
20
  balanceManagerId?: 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, HubItemsPage, InventoryBalances, LimitOrderParams, MarketOrderParams, ModifyOrderParams, OpenOrdersPage, Orderbook, 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, 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;
@@ -59,7 +59,7 @@ declare class MarketApi {
59
59
  orderbook(params: {
60
60
  storageUnitId: string;
61
61
  assetId: string;
62
- }): Promise<Orderbook>;
62
+ }): Promise<HubItemOrderbook>;
63
63
  poolMetadata(poolId: string): Promise<PoolMetadata>;
64
64
  }
65
65
  declare class OrdersApi {
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export type { AccountApi, BalancesApi, MarketApi, OrdersApi, } from './TriexClie
3
3
  export { ReadOnlyClient } from './ReadOnlyClient';
4
4
  export { TriexError, TriexClientError, explainMoveAbort } from './errors';
5
5
  export { DEFAULT_INDEXER_URL, CLOCK_ID, STILLNESS_PACKAGE_IDS, NETWORK_PRESETS, resolvePackageIds, } from './config';
6
- export { toBase, fromBase, computeItemQuote, computeBidQuoteDeposit, estimateMarketBuyCost, marketBuyRoundingBuffer, TRIEXBOOK_PRICE_SCALING, MULTICOIN_PRICE_SCALING, FEE_RATE_SCALING, GTC_EXPIRE, } from './money';
6
+ export { toBase, fromBase, computeItemQuote, computeBidQuoteDeposit, estimateMarketBuyCost, marketBuyRoundingBuffer, TRIEX_PRICE_SCALING, MULTICOIN_PRICE_SCALING, FEE_RATE_SCALING, GTC_EXPIRE, } from './money';
7
7
  export { IndexerClient } from './queries';
8
8
  export * as transactions from './transactions';
9
9
  export { getWalletCurrencyBalance, getBalanceManagerCurrencyBalance, getBalanceManagerItemBalance, getRegistryMulticoinCollectionId, findOwnedItemReceipts, fetchCharacterInfo, fetchSsuOwnerInfo, fetchInventorySlotQuantity, toSsuObjectId, getObjectRef, } from './onchain';
@@ -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, 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, 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';