@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 +22 -21
- package/README.md +6 -3
- package/dist/ReadOnlyClient.d.ts +2 -2
- package/dist/TriexClient.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +225 -192
- package/dist/money.d.ts +1 -1
- package/dist/queries.d.ts +6 -1
- package/dist/schemas.d.ts +181 -0
- package/dist/types.d.ts +9 -2
- package/package.json +2 -2
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
|
-
|
|
14
|
-
("pools"); coin-pools are out of scope
|
|
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
|
|
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
|
|
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 (
|
|
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
|
|
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: {
|
|
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` | `${
|
|
283
|
-
| `depositCoin` | `${
|
|
284
|
-
| `depositMulticoinObject` | `${
|
|
285
|
-
| `withdrawAllCoin` | `${
|
|
286
|
-
| `withdrawAllMulticoin` | `${
|
|
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` | `${
|
|
289
|
-
| `placeLimitOrderItem` | `${
|
|
290
|
-
| `placeMarketOrderItem` | `${
|
|
291
|
-
| `cancelOrderItem` | `${
|
|
292
|
-
| `withdrawCoin` | `${
|
|
293
|
-
| `withdrawSettledAmounts` | `${
|
|
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 /
|
|
355
|
-
where `
|
|
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
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
package/dist/ReadOnlyClient.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IndexerClient } from './queries';
|
|
2
|
-
import { BalancesAtHubParams, DiscoveryFilters, DiscoveryResult, FillsPage, FillsParams, HistoryPageParams, HubItemsPage, InventoryBalances, OpenOrdersPage,
|
|
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<
|
|
17
|
+
}): Promise<HubItemOrderbook>;
|
|
18
18
|
poolMetadata(poolId: string): Promise<PoolMetadata>;
|
|
19
19
|
balancesAtHub(params: BalancesAtHubParams & {
|
|
20
20
|
balanceManagerId?: string;
|
package/dist/TriexClient.d.ts
CHANGED
|
@@ -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,
|
|
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<
|
|
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,
|
|
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';
|