@trinaryex/sdk 1.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.
@@ -0,0 +1,76 @@
1
+ import { Transaction, TransactionResult, TransactionObjectArgument } from '@mysten/sui/transactions';
2
+ import { PackageIds } from './types';
3
+ export declare function newBalanceManager(tx: Transaction, ids: PackageIds): TransactionResult;
4
+ export declare function generateProofAsOwner(tx: Transaction, ids: PackageIds, bm: TransactionObjectArgument): TransactionResult;
5
+ export declare function depositCoin(tx: Transaction, ids: PackageIds, bm: TransactionObjectArgument, coin: TransactionObjectArgument, coinType?: string): void;
6
+ export declare function depositMulticoinObject(tx: Transaction, ids: PackageIds, bm: TransactionObjectArgument, itemObjectId: string): void;
7
+ export declare function withdrawCoin(tx: Transaction, ids: PackageIds, bm: TransactionObjectArgument, amount: bigint, coinType?: string): TransactionResult;
8
+ export declare function withdrawAllCoin(tx: Transaction, ids: PackageIds, bm: TransactionObjectArgument, coinType?: string): TransactionResult;
9
+ export declare function withdrawAllMulticoin(tx: Transaction, ids: PackageIds, bm: TransactionObjectArgument, collectionId: string, assetId: bigint): TransactionResult;
10
+ export declare function redeemReceipt(tx: Transaction, ids: PackageIds, balance: TransactionObjectArgument, args: {
11
+ ssuObjectId: string;
12
+ characterId: string;
13
+ vaultConfigId: string;
14
+ collectionId: string;
15
+ isOwner: boolean;
16
+ }): void;
17
+ export interface HangarSourceArgs {
18
+ ssuObjectId: string;
19
+ characterId: string;
20
+ capRef: {
21
+ objectId: string;
22
+ version: string;
23
+ digest: string;
24
+ };
25
+ capTypeArg: string;
26
+ vaultConfigId: string;
27
+ vaultCollectionId: string;
28
+ assetId: bigint;
29
+ amount: number;
30
+ }
31
+ export declare function sourceItemsFromHangar(tx: Transaction, ids: PackageIds, bm: TransactionObjectArgument, args: HangarSourceArgs): void;
32
+ export interface PlaceLimitOrderArgs {
33
+ poolId: string;
34
+ bm: TransactionObjectArgument;
35
+ proof: TransactionObjectArgument;
36
+ price: bigint;
37
+ quantity: bigint;
38
+ isBid: boolean;
39
+ orderType?: number;
40
+ selfMatchingOption?: number;
41
+ expireTimestamp: bigint;
42
+ }
43
+ export declare function placeLimitOrderItem(tx: Transaction, ids: PackageIds, args: PlaceLimitOrderArgs): void;
44
+ export interface PlaceMarketOrderArgs {
45
+ poolId: string;
46
+ bm: TransactionObjectArgument;
47
+ proof: TransactionObjectArgument;
48
+ quantity: bigint;
49
+ isBid: boolean;
50
+ selfMatchingOption?: number;
51
+ }
52
+ export declare function placeMarketOrderItem(tx: Transaction, ids: PackageIds, args: PlaceMarketOrderArgs): void;
53
+ export declare function cancelOrderItem(tx: Transaction, ids: PackageIds, args: {
54
+ poolId: string;
55
+ bm: TransactionObjectArgument;
56
+ proof: TransactionObjectArgument;
57
+ orderId: bigint;
58
+ }): void;
59
+ export declare function cancelAllOrdersItem(tx: Transaction, ids: PackageIds, args: {
60
+ poolId: string;
61
+ bm: TransactionObjectArgument;
62
+ proof: TransactionObjectArgument;
63
+ }): void;
64
+ export declare function modifyOrderItem(tx: Transaction, ids: PackageIds, args: {
65
+ poolId: string;
66
+ bm: TransactionObjectArgument;
67
+ proof: TransactionObjectArgument;
68
+ orderId: bigint;
69
+ newQuantity: bigint;
70
+ }): void;
71
+ export declare function withdrawSettledAmounts(tx: Transaction, ids: PackageIds, args: {
72
+ poolId: string;
73
+ bm: TransactionObjectArgument;
74
+ proof: TransactionObjectArgument;
75
+ quoteCoinType?: string;
76
+ }): void;
@@ -0,0 +1,172 @@
1
+ import { Transaction } from '@mysten/sui/transactions';
2
+ import { ClientWithCoreApi } from '@mysten/sui/client';
3
+ import { z } from 'zod';
4
+ import { AssetBalanceSchema, CollectionHubSchema, DiscoveryOrderSchema, DiscoveryResultSchema, FillSchema, FillsPageSchema, HubItemSchema, HubItemsPageSchema, HubLocationSchema, HubVaultSchema, InventoryBalancesSchema, OpenOrderSchema, OpenOrdersPageSchema, OrderbookOrderSchema, PoolMetadataSchema, SweepableItemSchema, SweepablePoolSchema, SweepableSchema, TradeSchema, TradesPageSchema } from './schemas';
5
+ export interface ObjectChange {
6
+ type: string;
7
+ objectId?: string;
8
+ objectType?: string;
9
+ [key: string]: unknown;
10
+ }
11
+ export type TransactionExecutor = (tx: Transaction) => Promise<unknown>;
12
+ export interface TxResult {
13
+ digest: string;
14
+ createdObjects: {
15
+ objectId: string;
16
+ objectType: string;
17
+ }[];
18
+ raw: unknown;
19
+ }
20
+ export type TriexNetwork = 'testnet';
21
+ export interface PackageIds {
22
+ triexbook: string;
23
+ triexRegistry: string;
24
+ multicoin: string;
25
+ warehouseReceipts: string;
26
+ credCoinType: string;
27
+ world: string;
28
+ worldOriginal: string;
29
+ clock: string;
30
+ }
31
+ export interface TriexClientConfig {
32
+ suiClient: ClientWithCoreApi;
33
+ apiKey: string;
34
+ executor?: TransactionExecutor;
35
+ address?: string;
36
+ indexerUrl?: string;
37
+ network?: TriexNetwork;
38
+ packageIds?: Partial<PackageIds>;
39
+ }
40
+ export interface ReadOnlyClientConfig {
41
+ apiKey: string;
42
+ indexerUrl?: string;
43
+ network?: TriexNetwork;
44
+ packageIds?: Partial<PackageIds>;
45
+ }
46
+ export type OrderSide = 'buy' | 'sell';
47
+ export type DiscoveryOrder = z.output<typeof DiscoveryOrderSchema>;
48
+ export type DiscoveryResult = z.output<typeof DiscoveryResultSchema>;
49
+ export type OrderbookOrder = z.output<typeof OrderbookOrderSchema>;
50
+ export type PoolMetadata = z.output<typeof PoolMetadataSchema>;
51
+ export type HubVaultInfo = z.output<typeof HubVaultSchema>;
52
+ export type HubLocation = z.output<typeof HubLocationSchema>;
53
+ export type HubItem = z.output<typeof HubItemSchema>;
54
+ export type HubItemsPage = z.output<typeof HubItemsPageSchema>;
55
+ export type CollectionHub = z.output<typeof CollectionHubSchema>;
56
+ export type AssetBalance = z.output<typeof AssetBalanceSchema>;
57
+ export type InventoryBalances = z.output<typeof InventoryBalancesSchema>;
58
+ export type OpenOrder = z.output<typeof OpenOrderSchema>;
59
+ export type OpenOrdersPage = z.output<typeof OpenOrdersPageSchema>;
60
+ export type Fill = z.output<typeof FillSchema>;
61
+ export type FillsPage = z.output<typeof FillsPageSchema>;
62
+ export type Trade = z.output<typeof TradeSchema>;
63
+ export type TradesPage = z.output<typeof TradesPageSchema>;
64
+ export type SweepablePool = z.output<typeof SweepablePoolSchema>;
65
+ export type SweepableItem = z.output<typeof SweepableItemSchema>;
66
+ export type Sweepable = z.output<typeof SweepableSchema>;
67
+ export interface Orderbook {
68
+ poolId: string;
69
+ bids: OrderbookOrder[];
70
+ asks: OrderbookOrder[];
71
+ }
72
+ export interface TradeHubDetail {
73
+ hubId: string;
74
+ collectionId: string;
75
+ vaultConfigId: string;
76
+ location: HubLocation | null;
77
+ }
78
+ export interface TradingAccount {
79
+ balanceManagerId: string;
80
+ owner: string;
81
+ }
82
+ export interface CurrencyBalances {
83
+ wallet: bigint;
84
+ balanceManager: bigint;
85
+ balanceManagerId: string | null;
86
+ }
87
+ export interface EnsureAccountResult {
88
+ balanceManagerId: string;
89
+ created: boolean;
90
+ }
91
+ export interface DiscoveryFilters {
92
+ storageUnitIds?: string[];
93
+ assetId?: string;
94
+ balanceManagerId?: string;
95
+ side?: 'buy' | 'sell' | 'both';
96
+ publicOnly?: boolean;
97
+ cursor?: string;
98
+ limit?: number;
99
+ }
100
+ export interface BalancesAtHubParams {
101
+ storageUnitId: string;
102
+ address?: string;
103
+ inventoryKey?: string;
104
+ vaultIds?: string[];
105
+ }
106
+ export interface HistoryPageParams {
107
+ before?: number;
108
+ after?: number;
109
+ limit?: number;
110
+ }
111
+ export interface FillsParams extends HistoryPageParams {
112
+ poolId?: string;
113
+ side?: 'maker' | 'taker' | 'all';
114
+ }
115
+ export interface TradesParams extends HistoryPageParams {
116
+ side?: 'maker' | 'taker' | 'all';
117
+ assetId?: string;
118
+ }
119
+ export interface DepositCurrencyParams {
120
+ amount: bigint;
121
+ }
122
+ export interface DepositItemsParams {
123
+ storageUnitId: string;
124
+ items: {
125
+ assetId: string;
126
+ amount: bigint;
127
+ }[];
128
+ }
129
+ export interface WithdrawCurrencyParams {
130
+ amount?: bigint;
131
+ }
132
+ export interface WithdrawItemsParams {
133
+ storageUnitId: string;
134
+ items: {
135
+ assetId: string;
136
+ }[];
137
+ characterId?: string;
138
+ }
139
+ export interface LimitOrderParams {
140
+ storageUnitId: string;
141
+ assetId: string;
142
+ side: OrderSide;
143
+ price: bigint;
144
+ quantity: bigint;
145
+ expireAt?: bigint;
146
+ orderType?: number;
147
+ selfMatchingOption?: number;
148
+ quoteDeposit?: bigint;
149
+ }
150
+ export interface MarketOrderParams {
151
+ storageUnitId: string;
152
+ assetId: string;
153
+ side: OrderSide;
154
+ quantity: bigint;
155
+ quoteBudget?: bigint;
156
+ selfMatchingOption?: number;
157
+ }
158
+ export interface CancelOrderParams {
159
+ storageUnitId: string;
160
+ assetId: string;
161
+ orderId: bigint | string;
162
+ }
163
+ export interface CancelAllOrdersParams {
164
+ storageUnitId: string;
165
+ assetId: string;
166
+ }
167
+ export interface ModifyOrderParams extends CancelOrderParams {
168
+ newQuantity: bigint;
169
+ }
170
+ export interface ClaimSettledParams {
171
+ poolIds?: string[];
172
+ }
package/dist/wait.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare function untilIndexed<T>(probe: () => Promise<T | null | undefined | false>, options?: {
2
+ timeoutMs?: number;
3
+ intervalMs?: number;
4
+ label?: string;
5
+ }): Promise<T>;
package/package.json ADDED
@@ -0,0 +1,108 @@
1
+ {
2
+ "name": "@trinaryex/sdk",
3
+ "version": "1.0.0",
4
+ "description": "Trading SDK for Trinary Exchange — market data, order books, and on-chain trading (Sui) for bots, analytics tools, and CLIs.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "DESIGN.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "vite build",
21
+ "test": "node --experimental-vm-modules node_modules/.bin/jest",
22
+ "test:cov": "node --experimental-vm-modules node_modules/.bin/jest --ci --coverage",
23
+ "prettier": "prettier --write '{src,test}/**/*.ts'",
24
+ "prettier:check": "prettier --check '{src,test}/**/*.ts'",
25
+ "lint": "eslint --cache '{src,test}/**/*.ts'",
26
+ "lint:check": "eslint --cache '{src,test}/**/*.ts'",
27
+ "lint:fix": "eslint --cache --fix '{src,test}/**/*.ts'",
28
+ "tscheck": "tsc --noEmit",
29
+ "release": "semantic-release"
30
+ },
31
+ "author": "@blurpesec",
32
+ "license": "MIT",
33
+ "publishConfig": {
34
+ "registry": "https://registry.npmjs.org",
35
+ "access": "public"
36
+ },
37
+ "peerDependencies": {
38
+ "@mysten/sui": "^2.16.0",
39
+ "zod": "^4.0.0"
40
+ },
41
+ "devDependencies": {
42
+ "@commitlint/cli": "^18.0.0",
43
+ "@commitlint/config-conventional": "^18.0.0",
44
+ "@mysten/sui": "^2.16.0",
45
+ "@semantic-release/changelog": "^6.0.0",
46
+ "@semantic-release/commit-analyzer": "^13.0.0",
47
+ "@semantic-release/git": "^10.0.0",
48
+ "@semantic-release/github": "^10.0.0",
49
+ "@semantic-release/npm": "^12.0.0",
50
+ "@semantic-release/release-notes-generator": "^14.0.0",
51
+ "@types/jest": "^29.0.0",
52
+ "@types/node": "^22.0.0",
53
+ "@typescript-eslint/eslint-plugin": "^7.0.0",
54
+ "@typescript-eslint/parser": "^7.0.0",
55
+ "eslint": "^8.57.0",
56
+ "eslint-config-prettier": "^9.0.0",
57
+ "eslint-plugin-prettier": "^5.0.0",
58
+ "jest": "^29.7.0",
59
+ "prettier": "^3.3.0",
60
+ "semantic-release": "^24.0.0",
61
+ "ts-jest": "^29.1.2",
62
+ "typescript": "^5.4.2",
63
+ "vite": "^8.0.10",
64
+ "vite-plugin-dts": "^5.0.0",
65
+ "zod": "^4.4.3"
66
+ },
67
+ "jest": {
68
+ "preset": "ts-jest/presets/default-esm",
69
+ "moduleFileExtensions": [
70
+ "js",
71
+ "mjs",
72
+ "json",
73
+ "ts"
74
+ ],
75
+ "testRegex": ".test.ts$",
76
+ "transform": {
77
+ "^.+\\.ts$": [
78
+ "ts-jest",
79
+ {
80
+ "useESM": true,
81
+ "diagnostics": false
82
+ }
83
+ ]
84
+ },
85
+ "extensionsToTreatAsEsm": [
86
+ ".ts"
87
+ ],
88
+ "collectCoverageFrom": [
89
+ "src/**/*.{ts,js}"
90
+ ],
91
+ "testEnvironment": "node",
92
+ "coverageDirectory": "./coverage"
93
+ },
94
+ "keywords": [
95
+ "trinary-exchange",
96
+ "trading",
97
+ "sdk",
98
+ "sui",
99
+ "orderbook",
100
+ "eve-frontier",
101
+ "deepbook"
102
+ ],
103
+ "sideEffects": false,
104
+ "repository": {
105
+ "type": "git",
106
+ "url": "git+https://github.com/loash-industries/sdk.git"
107
+ }
108
+ }