@trinaryex/sdk 3.9.0 → 5.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.
Files changed (47) hide show
  1. package/DESIGN.md +253 -71
  2. package/README.md +220 -16
  3. package/dist/ReadOnlyClient.d.ts +42 -8
  4. package/dist/TriexClient.d.ts +73 -8
  5. package/dist/armature/OrgClient.d.ts +372 -0
  6. package/dist/armature/OrgClientGroups.d.ts +186 -0
  7. package/dist/armature/OrgsApi.d.ts +69 -0
  8. package/dist/armature/actions.d.ts +75 -0
  9. package/dist/armature/create.d.ts +27 -0
  10. package/dist/armature/currency.d.ts +64 -0
  11. package/dist/armature/executors.d.ts +44 -0
  12. package/dist/armature/governance.d.ts +194 -0
  13. package/dist/armature/harness.d.ts +96 -0
  14. package/dist/armature/lifecycle.d.ts +84 -0
  15. package/dist/armature/plan.d.ts +39 -0
  16. package/dist/armature/proposals.d.ts +51 -0
  17. package/dist/armature/queries.d.ts +16 -0
  18. package/dist/armature/schemas.d.ts +559 -0
  19. package/dist/armature/trading.d.ts +114 -0
  20. package/dist/armature/transactions.d.ts +160 -0
  21. package/dist/armature/treasury.d.ts +41 -0
  22. package/dist/armature/tree.d.ts +13 -0
  23. package/dist/armature/types.d.ts +59 -0
  24. package/dist/armature/upgrade.d.ts +27 -0
  25. package/dist/armature/vault.d.ts +94 -0
  26. package/dist/coins/CoinsApi.d.ts +53 -0
  27. package/dist/coins/funding.d.ts +6 -0
  28. package/dist/coins/money.d.ts +36 -0
  29. package/dist/coins/onchain.d.ts +162 -0
  30. package/dist/coins/schemas.d.ts +456 -0
  31. package/dist/coins/transactions.d.ts +82 -0
  32. package/dist/coins/types.d.ts +115 -0
  33. package/dist/errors.d.ts +11 -1
  34. package/dist/funding.d.ts +2 -2
  35. package/dist/http.d.ts +3 -0
  36. package/dist/index.d.ts +63 -8
  37. package/dist/index.js +10620 -959
  38. package/dist/money.d.ts +15 -0
  39. package/dist/moveAbort.d.ts +28 -0
  40. package/dist/moveAbortCatalog.generated.d.ts +9 -0
  41. package/dist/onchain.d.ts +55 -3
  42. package/dist/paging.d.ts +9 -3
  43. package/dist/queries.d.ts +35 -7
  44. package/dist/schemas.d.ts +2257 -50
  45. package/dist/transactions.d.ts +63 -1
  46. package/dist/types.d.ts +118 -7
  47. package/package.json +3 -1
@@ -0,0 +1,160 @@
1
+ import { Argument, Transaction } from '@mysten/sui/transactions';
2
+ type TxArg = ReturnType<Transaction['moveCall']>;
3
+ export interface ProposalConfigInput {
4
+ quorum: number;
5
+ approvalThreshold: number;
6
+ proposeThreshold: number;
7
+ expiryMs: number;
8
+ executionDelayMs: number;
9
+ cooldownMs: number;
10
+ composableAllowed?: boolean;
11
+ permissions?: number;
12
+ borrowScope?: string[];
13
+ }
14
+ export declare function typeNameOf(tx: Transaction, armature: string, moveType: string): TxArg;
15
+ export declare function typeNameVec(tx: Transaction, armature: string, moveTypes: string[]): TxArg;
16
+ export declare function newConfig(tx: Transaction, armature: string, c: ProposalConfigInput): TxArg;
17
+ export declare function withComposableAllowed(tx: Transaction, armature: string, config: TxArg, allowed?: boolean): TxArg;
18
+ export declare function newTypeInit(tx: Transaction, armature: string, init: {
19
+ moveType: string;
20
+ displayKey: string;
21
+ config: ProposalConfigInput;
22
+ }): TxArg;
23
+ export declare function typeInitVec(tx: Transaction, armature: string, inits: {
24
+ moveType: string;
25
+ displayKey: string;
26
+ config: ProposalConfigInput;
27
+ }[]): TxArg;
28
+ export declare function initBoard(tx: Transaction, armature: string, members: string[]): TxArg;
29
+ export declare function submitVoteExecute(tx: Transaction, args: {
30
+ armature: string;
31
+ daoId: string;
32
+ payloadMoveType: string;
33
+ payload: TxArg;
34
+ emergencyFreezeId: string;
35
+ readonly?: boolean;
36
+ metadataIpfs?: string | null;
37
+ }): TxArg;
38
+ export declare function submitProposal(tx: Transaction, args: {
39
+ armature: string;
40
+ daoId: string;
41
+ payloadMoveType: string;
42
+ payload: TxArg;
43
+ metadataIpfs?: string | null;
44
+ }): void;
45
+ export declare function ticketFromVote(tx: Transaction, args: {
46
+ armature: string;
47
+ daoId: string;
48
+ proposalId: string;
49
+ payloadMoveType: string;
50
+ emergencyFreezeId: string;
51
+ readonly?: boolean;
52
+ }): TxArg;
53
+ export declare function voteTx(args: {
54
+ armature: string;
55
+ proposalId: string;
56
+ ouId: string;
57
+ payloadMoveType: string;
58
+ approve: boolean;
59
+ }): Transaction;
60
+ export declare function appendDeleteExpiredProposal(tx: Transaction, args: {
61
+ armature: string;
62
+ proposalId: string;
63
+ payloadMoveType: string;
64
+ }): void;
65
+ export declare function deleteExpiredProposalTx(args: {
66
+ armature: string;
67
+ proposals: {
68
+ proposalId: string;
69
+ payloadMoveType: string;
70
+ }[];
71
+ }): Transaction;
72
+ export declare function newFrame(tx: Transaction, armature: string, daoId: string): TxArg;
73
+ export declare function typedStepFunction(payloadMoveType: string): string | null;
74
+ export declare function addStep(tx: Transaction, args: {
75
+ armature: string;
76
+ frame: TxArg;
77
+ daoId: string;
78
+ payloadMoveType: string;
79
+ payload: TxArg;
80
+ }): void;
81
+ export declare function submitComposite(tx: Transaction, args: {
82
+ armature: string;
83
+ daoId: string;
84
+ frame: TxArg;
85
+ metadataIpfs?: string | null;
86
+ }): void;
87
+ export declare function beginPipeline(tx: Transaction, args: {
88
+ armature: string;
89
+ daoId: string;
90
+ frameId: string;
91
+ ticket: TxArg;
92
+ }): Argument;
93
+ export declare function advanceStep(tx: Transaction, args: {
94
+ armature: string;
95
+ daoId: string;
96
+ frameId: string;
97
+ pipeline: Argument;
98
+ emergencyFreezeId: string;
99
+ payloadMoveType: string;
100
+ }): [TxArg, Argument];
101
+ export declare function finalizePipeline(tx: Transaction, armature: string, pipeline: Argument): void;
102
+ export declare function appendDeleteExhaustedFrame(tx: Transaction, armature: string, frameId: string): void;
103
+ export declare function deleteExhaustedFrameTx(args: {
104
+ armature: string;
105
+ frameId: string;
106
+ }): Transaction;
107
+ export declare function freezeTypeTx(args: {
108
+ armature: string;
109
+ emergencyFreezeId: string;
110
+ freezeAdminCapId: string;
111
+ moveType: string;
112
+ }): Transaction;
113
+ export declare function unfreezeTypeTx(args: {
114
+ armature: string;
115
+ emergencyFreezeId: string;
116
+ freezeAdminCapId: string;
117
+ moveType: string;
118
+ }): Transaction;
119
+ export declare function publishEntryTx(args: {
120
+ armature: string;
121
+ ouId: string;
122
+ location: string;
123
+ description: string;
124
+ }): Transaction;
125
+ export declare function updateEntryTx(args: {
126
+ armature: string;
127
+ ouId: string;
128
+ entryId: string;
129
+ location: string;
130
+ }): Transaction;
131
+ export declare function editEntryTx(args: {
132
+ armature: string;
133
+ ouId: string;
134
+ entryId: string;
135
+ location: string;
136
+ }): Transaction;
137
+ export declare function rotateEncryptionEpochTx(args: {
138
+ armature: string;
139
+ ouId: string;
140
+ }): Transaction;
141
+ export declare function removeEntryTx(args: {
142
+ armature: string;
143
+ ouId: string;
144
+ entryId: string;
145
+ }): Transaction;
146
+ export declare function createOuTx(args: {
147
+ armature: string;
148
+ board: string[];
149
+ name: string;
150
+ metadataUri: string;
151
+ }): Transaction;
152
+ export declare function destroyOuTx(args: {
153
+ armature: string;
154
+ ouId: string;
155
+ treasuryId: string;
156
+ capabilityVaultId: string;
157
+ charterId: string;
158
+ emergencyFreezeId: string;
159
+ }): Transaction;
160
+ export {};
@@ -0,0 +1,41 @@
1
+ import { ClientWithCoreApi } from '@mysten/sui/client';
2
+ import { Transaction } from '@mysten/sui/transactions';
3
+ import { ArmaturePkgs } from './actions';
4
+ import { OuProposalAction } from './harness';
5
+ export interface TreasuryCoinBalance {
6
+ coinType: string;
7
+ amount: bigint;
8
+ }
9
+ export declare function toTypeNameKey(coinType: string): string;
10
+ export declare function fetchTreasuryCoinBalances(suiClient: ClientWithCoreApi, treasuryVaultId: string): Promise<TreasuryCoinBalance[]>;
11
+ export declare function fetchTreasuryCoinBalance(suiClient: ClientWithCoreApi, treasuryVaultId: string, coinType: string): Promise<bigint>;
12
+ export declare function depositToTreasuryTx(args: {
13
+ armature: string;
14
+ treasuryVaultId: string;
15
+ coinType: string;
16
+ amount: bigint;
17
+ }): Transaction;
18
+ export declare function claimTreasuryCoinsTx(args: {
19
+ armature: string;
20
+ treasuryVaultId: string;
21
+ coinType: string;
22
+ coinObjectIds: string[];
23
+ }): Transaction;
24
+ export declare function sendCoinAction(pkgs: ArmaturePkgs, params: {
25
+ coinType: string;
26
+ recipient: string;
27
+ amount: bigint;
28
+ treasuryVaultId: string;
29
+ }): OuProposalAction;
30
+ export declare function sendCoinToOuAction(pkgs: ArmaturePkgs, params: {
31
+ coinType: string;
32
+ recipientTreasuryId: string;
33
+ amount: bigint;
34
+ treasuryVaultId: string;
35
+ }): OuProposalAction;
36
+ export declare function sendSmallPaymentAction(pkgs: ArmaturePkgs, params: {
37
+ coinType: string;
38
+ recipient: string;
39
+ amount: bigint;
40
+ treasuryVaultId: string;
41
+ }): OuProposalAction;
@@ -0,0 +1,13 @@
1
+ import { Org, OrgNode, OrgSeat, OuExecContext } from './types';
2
+ export declare function roleForDepth(depth: number): {
3
+ key: string;
4
+ label: string;
5
+ };
6
+ export declare function flattenOrg(org: Org): OrgNode[];
7
+ export declare function nodeById(nodes: readonly OrgNode[], daoId: string | null | undefined): OrgNode | null;
8
+ export declare function rootNode(nodes: readonly OrgNode[]): OrgNode | null;
9
+ export declare function tradingNode(nodes: readonly OrgNode[]): OrgNode | null;
10
+ export declare function seatsFor(nodes: readonly OrgNode[], address: string): OrgSeat[];
11
+ export declare function resolveSeat(nodes: readonly OrgNode[], address: string, preferredDaoId?: string | null): OrgSeat | null;
12
+ export declare function execContextFor(nodes: readonly OrgNode[], daoId: string): OuExecContext | null;
13
+ export declare function findNodeAcross(orgs: readonly Org[], daoId: string | null | undefined): OrgNode | null;
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod';
2
+ import { AccessibleKeyspaceSchema, HubDaoVaultSchema, OrgDirectoryPageSchema, ProposalCompositeStepSchema, ProposalSummarySchema, VaultAclEntrySchema } from './schemas';
3
+ export type { Org, OrgActor, OrgDirectoryEntry, OrgMetadata, OrgSearchResult, } from './schemas';
4
+ export type OrgDirectoryPage = z.output<typeof OrgDirectoryPageSchema>;
5
+ export type ProposalSummary = z.output<typeof ProposalSummarySchema>;
6
+ export type ProposalCompositeStep = z.output<typeof ProposalCompositeStepSchema>;
7
+ export type ProposalStatus = ProposalSummary['status'];
8
+ export type AccessibleKeyspace = z.output<typeof AccessibleKeyspaceSchema>;
9
+ export type KeyspaceRole = AccessibleKeyspace['roles'][number];
10
+ export type KeyspaceMatchVia = AccessibleKeyspace['matchVia'];
11
+ export type HubDaoVault = z.output<typeof HubDaoVaultSchema>;
12
+ export type VaultAclEntry = z.output<typeof VaultAclEntrySchema>;
13
+ export type VaultRole = VaultAclEntry['role'];
14
+ export interface VaultPrincipal {
15
+ kind: 'player' | 'machine' | 'ou';
16
+ value: string;
17
+ }
18
+ export interface OrgDirectoryParams {
19
+ limit?: number;
20
+ cursor?: string;
21
+ sort?: 'members' | 'name';
22
+ }
23
+ export interface OrgSearchParams {
24
+ limit?: number;
25
+ enrich?: boolean;
26
+ }
27
+ export interface OrgNode {
28
+ daoId: string;
29
+ parentDaoId: string | null;
30
+ depth: number;
31
+ childDaoIds: string[];
32
+ name: string | null;
33
+ charterId: string | null;
34
+ treasuryId: string | null;
35
+ capabilityVaultId: string | null;
36
+ emergencyFreezeId: string | null;
37
+ members: string[];
38
+ tradingAccountId: string | null;
39
+ subdaoControlCapId: string | null;
40
+ roleKey: string;
41
+ roleLabel: string;
42
+ rank: number;
43
+ }
44
+ export interface OrgSeat extends OrgNode {
45
+ address: string;
46
+ }
47
+ export interface OuParent {
48
+ daoId: string;
49
+ board: string[];
50
+ emergencyFreezeId: string;
51
+ capVaultId: string;
52
+ controlCapId: string;
53
+ }
54
+ export interface OuExecContext {
55
+ daoId: string;
56
+ board: string[];
57
+ emergencyFreezeId: string;
58
+ parent?: OuParent;
59
+ }
@@ -0,0 +1,27 @@
1
+ import { Transaction } from '@mysten/sui/transactions';
2
+ import { ArmaturePkgs } from './actions';
3
+ import { OuProposalAction } from './harness';
4
+ export interface UpgradeBuild {
5
+ modules: (string | number[] | Uint8Array)[];
6
+ dependencies: string[];
7
+ }
8
+ export declare const UPGRADE_POLICY: {
9
+ readonly COMPATIBLE: 0;
10
+ readonly ADDITIVE: 128;
11
+ readonly DEP_ONLY: 192;
12
+ };
13
+ export declare function appendUpgradeExecution(tx: Transaction, args: {
14
+ armatureProposals: string;
15
+ capabilityVaultId: string;
16
+ packageId: string;
17
+ ticket: ReturnType<Transaction['moveCall']>;
18
+ build: UpgradeBuild;
19
+ }): void;
20
+ export declare function proposeUpgradeAction(pkgs: ArmaturePkgs, params: {
21
+ capId: string;
22
+ packageId: string;
23
+ digest: number[] | Uint8Array;
24
+ policy?: number;
25
+ capabilityVaultId: string;
26
+ build?: UpgradeBuild;
27
+ }): OuProposalAction;
@@ -0,0 +1,94 @@
1
+ import { ClientWithCoreApi } from '@mysten/sui/client';
2
+ import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
3
+ import { PackageIds } from '../types';
4
+ import { VaultPrincipal, VaultRole } from './types';
5
+ export declare const VaultKeyBcs: import('@mysten/bcs').BcsStruct<{
6
+ storage_unit_id: import('@mysten/bcs').BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
7
+ registrant_ou_id: import('@mysten/bcs').BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
8
+ }, string>;
9
+ export declare function toStorageUnitId(value: string): string;
10
+ export declare function resolveOuVaultId(suiClient: ClientWithCoreApi, ids: PackageIds, params: {
11
+ storageUnitId: string;
12
+ registrantOrgId: string;
13
+ }): Promise<string | null>;
14
+ export interface OuVaultInfo {
15
+ vaultId: string;
16
+ storageUnitId: string;
17
+ collectionId: string;
18
+ registrantOrgId: string;
19
+ nonEmptyAssets: number;
20
+ acl: {
21
+ role: VaultRole;
22
+ principal: VaultPrincipal;
23
+ }[];
24
+ }
25
+ export declare function fetchOuVaultInfo(suiClient: ClientWithCoreApi, vaultId: string): Promise<OuVaultInfo | null>;
26
+ export declare function fetchVaultBalance(suiClient: ClientWithCoreApi, vaultId: string, assetId: bigint): Promise<bigint>;
27
+ export declare function principalVec(tx: Transaction, armatureVault: string, principals: VaultPrincipal[]): TransactionObjectArgument;
28
+ export declare function roleVec(tx: Transaction, armatureVault: string, roles: VaultRole[]): TransactionObjectArgument;
29
+ export declare function initializeOuVaultTx(tx: Transaction, args: {
30
+ armatureVault: string;
31
+ registryId: string;
32
+ storageUnitId: string;
33
+ registrantOrgId: string;
34
+ vaultConfigId: string;
35
+ depositPrincipals: VaultPrincipal[];
36
+ withdrawPrincipals: VaultPrincipal[];
37
+ editPrincipals: VaultPrincipal[];
38
+ }): void;
39
+ export declare function depositReceiptTx(tx: Transaction, args: {
40
+ armatureVault: string;
41
+ vaultId: string;
42
+ ouId: string;
43
+ balance: TransactionObjectArgument;
44
+ }): void;
45
+ export declare function withdrawReceiptTx(tx: Transaction, args: {
46
+ armatureVault: string;
47
+ vaultId: string;
48
+ ouId: string;
49
+ assetId: bigint;
50
+ amount: bigint;
51
+ }): TransactionObjectArgument;
52
+ export declare function grantTx(tx: Transaction, args: {
53
+ armatureVault: string;
54
+ vaultId: string;
55
+ editorOuId: string;
56
+ grants: {
57
+ role: VaultRole;
58
+ principal: VaultPrincipal;
59
+ }[];
60
+ }): void;
61
+ export declare function grantEditOuTx(tx: Transaction, args: {
62
+ armatureVault: string;
63
+ vaultId: string;
64
+ editorOuId: string;
65
+ targetOuId: string;
66
+ }): void;
67
+ export declare function revokeTx(tx: Transaction, args: {
68
+ armatureVault: string;
69
+ vaultId: string;
70
+ editorOuId: string;
71
+ revocations: {
72
+ role: VaultRole;
73
+ principal: VaultPrincipal;
74
+ }[];
75
+ }): void;
76
+ export declare function updateRegistryKeyTx(tx: Transaction, args: {
77
+ armatureVault: string;
78
+ registryId: string;
79
+ vaultId: string;
80
+ editorOuId: string;
81
+ newRegistrantOrgId: string;
82
+ }): void;
83
+ export declare function deinitializeOuVaultTx(tx: Transaction, args: {
84
+ armatureVault: string;
85
+ registryId: string;
86
+ vaultId: string;
87
+ editorOuId: string;
88
+ }): void;
89
+ export declare function sourceWalletReceipts(suiClient: ClientWithCoreApi, tx: Transaction, ids: PackageIds, params: {
90
+ owner: string;
91
+ assetId: bigint;
92
+ amount: bigint;
93
+ collectionId: string;
94
+ }): Promise<TransactionObjectArgument>;
@@ -0,0 +1,53 @@
1
+ import { ClientWithCoreApi } from '@mysten/sui/client';
2
+ import { IndexerClient } from '../queries';
3
+ import { TriexClient } from '../TriexClient';
4
+ import { PackageIds, TxResult } from '../types';
5
+ import { CoinMarketEstimate } from './money';
6
+ import { CoinBookOrder, CoinPoolAccount, CoinTradeParams } from './onchain';
7
+ import { CoinAccountParams, CoinBalances, CoinBalancesParams, CoinCancelOrderParams, CoinCancelOrdersParams, CoinClaimSettledParams, CoinDepositParams, CoinInfo, CoinLimitOrderParams, CoinMarketEstimateParams, CoinMarketOrderParams, CoinModifyOrderParams, CoinOrderbook, CoinOrderbookParams, CoinPool, CoinPoolSelector, CoinSwapParams, CoinSwapQuote, CoinSwapQuoteParams, CoinSwapResult, CoinTradeParamsParams, CoinWithdrawParams, CreateCoinPoolParams, CreateCoinPoolResult } from './types';
8
+ export declare const DEFAULT_SWAP_SLIPPAGE_BPS = 50;
9
+ export interface CoinsReadDeps {
10
+ indexer: IndexerClient;
11
+ ids: PackageIds;
12
+ suiClient?: ClientWithCoreApi;
13
+ requireAddress: (override?: string) => string;
14
+ resolveTradingAccountId?: (address: string) => Promise<string | null>;
15
+ defaultSender?: () => string | undefined;
16
+ }
17
+ export declare class CoinsReadApi {
18
+ protected readonly deps: CoinsReadDeps;
19
+ private readonly poolCache;
20
+ constructor(deps: CoinsReadDeps);
21
+ protected get ids(): PackageIds;
22
+ protected requireSui(): ClientWithCoreApi;
23
+ list(params?: {
24
+ coinTypes?: string[];
25
+ }): Promise<CoinInfo[]>;
26
+ resolvePool(selector: CoinPoolSelector): Promise<CoinPool>;
27
+ orderbook(params: CoinOrderbookParams): Promise<CoinOrderbook>;
28
+ tradeParams(params: CoinTradeParamsParams): Promise<CoinTradeParams>;
29
+ quote(params: CoinSwapQuoteParams): Promise<CoinSwapQuote>;
30
+ estimateMarket(params: CoinMarketEstimateParams): Promise<CoinMarketEstimate>;
31
+ openOrders(params: CoinAccountParams): Promise<CoinBookOrder[]>;
32
+ account(params: CoinAccountParams): Promise<CoinPoolAccount | null>;
33
+ balances(params: CoinBalancesParams): Promise<CoinBalances>;
34
+ protected lookupAccount(address: string): Promise<string | null>;
35
+ protected accountIdFor(explicit?: string): Promise<string | null>;
36
+ private remember;
37
+ }
38
+ export declare class CoinsApi extends CoinsReadApi {
39
+ private readonly c;
40
+ constructor(c: TriexClient);
41
+ deposit(params: CoinDepositParams): Promise<TxResult>;
42
+ withdraw(params: CoinWithdrawParams): Promise<TxResult>;
43
+ limit(params: CoinLimitOrderParams): Promise<TxResult>;
44
+ market(params: CoinMarketOrderParams): Promise<TxResult>;
45
+ swap(params: CoinSwapParams): Promise<CoinSwapResult>;
46
+ cancel(params: CoinCancelOrderParams): Promise<TxResult>;
47
+ cancelMany(params: CoinCancelOrdersParams): Promise<TxResult>;
48
+ cancelAll(params: CoinPoolSelector): Promise<TxResult>;
49
+ modify(params: CoinModifyOrderParams): Promise<TxResult>;
50
+ claimSettled(params: CoinClaimSettledParams): Promise<TxResult>;
51
+ createPool(params: CreateCoinPoolParams): Promise<CreateCoinPoolResult>;
52
+ private withAccountTx;
53
+ }
@@ -0,0 +1,6 @@
1
+ import { ClientWithCoreApi } from '@mysten/sui/client';
2
+ import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
3
+ import { PackageIds } from '../types';
4
+ export declare function isSuiCoinType(coinType: string): boolean;
5
+ export declare function prepareCoinInput(suiClient: ClientWithCoreApi, tx: Transaction, owner: string, coinType: string, amount: bigint, insufficientMessage?: string): Promise<TransactionObjectArgument>;
6
+ export declare function depositCoinDeficit(suiClient: ClientWithCoreApi, tx: Transaction, ids: PackageIds, account: TransactionObjectArgument, existingAccountId: string | null, owner: string, coinType: string, target: bigint): Promise<bigint>;
@@ -0,0 +1,36 @@
1
+ export declare const COIN_PRICE_SCALING = 1000000000n;
2
+ export declare const COIN_MIN_PRICE = 1n;
3
+ export declare const COIN_MAX_PRICE: bigint;
4
+ export declare const COIN_POOL_CREATION_FEE = 500000000n;
5
+ export declare const COIN_MAX_FILLS = 100;
6
+ export declare function coinQuoteForBase(price: bigint, quantity: bigint): bigint;
7
+ export declare function coinQuoteFee(quote: bigint, feeRateScaled: bigint): bigint;
8
+ export declare function coinMinOrderQuantity(price: bigint): bigint;
9
+ export declare function computeCoinBidDeposit(price: bigint, quantity: bigint, feeRateScaled: bigint): bigint;
10
+ export interface CoinFeeRates {
11
+ takerFee: bigint;
12
+ makerFee: bigint;
13
+ }
14
+ export declare function conservativeBidFeeRate(entry: CoinFeeRates, next?: CoinFeeRates | null, opts?: {
15
+ marketOrder?: boolean;
16
+ }): bigint;
17
+ export declare function coinSellNet(grossQuote: bigint, feeRateScaled: bigint): bigint;
18
+ export interface CoinMakerOrder {
19
+ price: bigint;
20
+ remainingQuantity: bigint;
21
+ }
22
+ export interface CoinMarketEstimate {
23
+ side: 'buy' | 'sell';
24
+ requestedQuantity: bigint;
25
+ filledQuantity: bigint;
26
+ fillable: boolean;
27
+ grossQuote: bigint;
28
+ fee: bigint;
29
+ totalQuote: bigint;
30
+ avgPrice: bigint | null;
31
+ makersVisited: number;
32
+ }
33
+ export declare function estimateCoinMarketOrder(makers: ReadonlyArray<CoinMakerOrder>, side: 'buy' | 'sell', quantity: bigint, takerFeeRateScaled: bigint): CoinMarketEstimate;
34
+ export declare function coinPriceDecimals(baseDecimals: number, quoteDecimals: number): number;
35
+ export declare function coinPriceToRaw(human: string | number, baseDecimals: number, quoteDecimals: number): bigint;
36
+ export declare function formatCoinPrice(raw: bigint, baseDecimals: number, quoteDecimals: number): string;
@@ -0,0 +1,162 @@
1
+ import { ClientWithCoreApi } from '@mysten/sui/client';
2
+ import { Transaction } from '@mysten/sui/transactions';
3
+ import { PackageIds } from '../types';
4
+ import { CoinPoolTypes } from './transactions';
5
+ import { CoinFeeRates } from './money';
6
+ export declare const CoinOrderBcs: import('@mysten/bcs').BcsStruct<{
7
+ trading_account_id: import('@mysten/bcs').BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
8
+ order_id: import('@mysten/bcs').BcsType<string, string | number | bigint, "u128">;
9
+ price: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
10
+ is_bid: import('@mysten/bcs').BcsType<boolean, boolean, "bool">;
11
+ quantity: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
12
+ filled_quantity: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
13
+ epoch: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
14
+ maker_fee_rate: import('@mysten/bcs').BcsType<number, number, "u16">;
15
+ cancel_retention_bps: import('@mysten/bcs').BcsType<number, number, "u16">;
16
+ status: import('@mysten/bcs').BcsType<number, number, "u8">;
17
+ expire_timestamp: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
18
+ }, string>;
19
+ export declare const CoinOrderPageBcs: import('@mysten/bcs').BcsStruct<{
20
+ orders: import('@mysten/bcs').BcsType<{
21
+ trading_account_id: string;
22
+ order_id: string;
23
+ price: string;
24
+ is_bid: boolean;
25
+ quantity: string;
26
+ filled_quantity: string;
27
+ epoch: string;
28
+ maker_fee_rate: number;
29
+ cancel_retention_bps: number;
30
+ status: number;
31
+ expire_timestamp: string;
32
+ }[], Iterable<{
33
+ trading_account_id: string | Uint8Array<ArrayBufferLike>;
34
+ order_id: string | number | bigint;
35
+ price: string | number | bigint;
36
+ is_bid: boolean;
37
+ quantity: string | number | bigint;
38
+ filled_quantity: string | number | bigint;
39
+ epoch: string | number | bigint;
40
+ maker_fee_rate: number;
41
+ cancel_retention_bps: number;
42
+ status: number;
43
+ expire_timestamp: string | number | bigint;
44
+ }> & {
45
+ length: number;
46
+ }, string>;
47
+ has_next_page: import('@mysten/bcs').BcsType<boolean, boolean, "bool">;
48
+ }, string>;
49
+ export declare const CoinBalancesBcs: import('@mysten/bcs').BcsStruct<{
50
+ base: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
51
+ quote: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
52
+ cred: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
53
+ }, string>;
54
+ export declare const CoinPoolAccountBcs: import('@mysten/bcs').BcsStruct<{
55
+ open_orders: import('@mysten/bcs').BcsStruct<{
56
+ contents: import('@mysten/bcs').BcsType<string[], Iterable<string | number | bigint> & {
57
+ length: number;
58
+ }, string>;
59
+ }, string>;
60
+ taker_volume: import('@mysten/bcs').BcsType<string, string | number | bigint, "u128">;
61
+ maker_volume: import('@mysten/bcs').BcsType<string, string | number | bigint, "u128">;
62
+ settled_balances: import('@mysten/bcs').BcsStruct<{
63
+ base: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
64
+ quote: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
65
+ cred: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
66
+ }, string>;
67
+ owed_balances: import('@mysten/bcs').BcsStruct<{
68
+ base: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
69
+ quote: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
70
+ cred: import('@mysten/bcs').BcsType<string, string | number | bigint, "u64">;
71
+ }, string>;
72
+ pending_turnover: import('@mysten/bcs').BcsType<{
73
+ epoch: string;
74
+ amount: string;
75
+ }[], Iterable<{
76
+ epoch: string | number | bigint;
77
+ amount: string | number | bigint;
78
+ }> & {
79
+ length: number;
80
+ }, string>;
81
+ }, string>;
82
+ export declare const CoinFeeScheduleBcs: import('@mysten/bcs').BcsStruct<{
83
+ tiers: import('@mysten/bcs').BcsType<{
84
+ min_turnover: string;
85
+ taker_fee: string;
86
+ maker_fee: string;
87
+ }[], Iterable<{
88
+ min_turnover: string | number | bigint;
89
+ taker_fee: string | number | bigint;
90
+ maker_fee: string | number | bigint;
91
+ }> & {
92
+ length: number;
93
+ }, string>;
94
+ }, string>;
95
+ export declare const COIN_ORDER_STATUS: readonly ["live", "partially_filled", "filled", "canceled", "expired"];
96
+ export interface CoinBookOrder {
97
+ orderId: string;
98
+ tradingAccountId: string;
99
+ isBid: boolean;
100
+ price: bigint;
101
+ quantity: bigint;
102
+ filledQuantity: bigint;
103
+ remainingQuantity: bigint;
104
+ expireTimestamp: bigint;
105
+ makerFeeBps: number;
106
+ cancelRetentionBps: number;
107
+ status: (typeof COIN_ORDER_STATUS)[number] | 'unknown';
108
+ epoch: bigint;
109
+ }
110
+ export declare function toCoinBookOrder(o: ReturnType<typeof CoinOrderBcs.parse>): CoinBookOrder;
111
+ export declare function simulateReturnValues(suiClient: ClientWithCoreApi, tx: Transaction, sender?: string): Promise<Uint8Array[][] | null>;
112
+ export declare function resolveCoinPoolId(suiClient: ClientWithCoreApi, ids: PackageIds, pair: {
113
+ baseCoinType: string;
114
+ quoteCoinType: string;
115
+ }): Promise<string | null>;
116
+ export declare function fetchCoinPoolTypes(suiClient: ClientWithCoreApi, poolId: string): Promise<CoinPoolTypes>;
117
+ export declare function getTradingAccountCoinBalance(suiClient: ClientWithCoreApi, ids: PackageIds, tradingAccountId: string, coinType: string): Promise<bigint>;
118
+ export interface CoinBookSide {
119
+ orders: CoinBookOrder[];
120
+ hasMore: boolean;
121
+ }
122
+ export declare function fetchCoinBookSide(suiClient: ClientWithCoreApi, ids: PackageIds, pool: CoinPoolTypes, bids: boolean, opts?: {
123
+ depth?: number;
124
+ pageSize?: number;
125
+ now?: number;
126
+ }): Promise<CoinBookSide>;
127
+ export interface CoinPoolBalances {
128
+ base: bigint;
129
+ quote: bigint;
130
+ cred: bigint;
131
+ }
132
+ export interface CoinPoolAccount {
133
+ poolId: string;
134
+ tradingAccountId: string;
135
+ openOrderIds: string[];
136
+ takerVolume: bigint;
137
+ makerVolume: bigint;
138
+ settled: CoinPoolBalances;
139
+ owed: CoinPoolBalances;
140
+ lockedInOrders: CoinPoolBalances;
141
+ }
142
+ export declare function fetchCoinPoolAccount(suiClient: ClientWithCoreApi, ids: PackageIds, pool: CoinPoolTypes, tradingAccountId: string, sender?: string): Promise<CoinPoolAccount | null>;
143
+ export declare function fetchCoinAccountOrders(suiClient: ClientWithCoreApi, ids: PackageIds, pool: CoinPoolTypes, tradingAccountId: string, sender?: string): Promise<CoinBookOrder[]>;
144
+ export interface CoinTradeParams {
145
+ poolId: string;
146
+ feeClass: number;
147
+ entry: CoinFeeRates;
148
+ next: CoinFeeRates & {
149
+ effectiveEpoch: bigint;
150
+ };
151
+ cancelRetentionBps: bigint;
152
+ account: (CoinFeeRates & {
153
+ tier: bigint;
154
+ turnover: bigint;
155
+ }) | null;
156
+ }
157
+ export declare function fetchCoinTradeParams(suiClient: ClientWithCoreApi, ids: PackageIds, pool: CoinPoolTypes, tradingAccountId?: string | null, sender?: string): Promise<CoinTradeParams>;
158
+ export declare function dryRunCoinQuantityOut(suiClient: ClientWithCoreApi, ids: PackageIds, pool: CoinPoolTypes, args: {
159
+ baseIn: bigint;
160
+ quoteIn: bigint;
161
+ tradingAccountId?: string | null;
162
+ }, sender?: string): Promise<[bigint, bigint]>;