@tbookdev/vault-sdk-sui 0.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/README.md +39 -0
- package/dist/index.cjs +501 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +226 -0
- package/dist/index.d.ts +226 -0
- package/dist/index.js +478 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { SuiClient } from '@mysten/sui/client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sui vault registry — contract object ids per network.
|
|
5
|
+
*
|
|
6
|
+
* Source of truth: tokenized-asset-claim-portal deployments (mirrored in
|
|
7
|
+
* tbook-vault-fe/lib/contracts.ts and verified against the Kotlin backend's
|
|
8
|
+
* authoritative list). Object ids are stable across package upgrades on Sui;
|
|
9
|
+
* PACKAGE_ID changes on upgrade — keep in sync with DEPLOYMENTS notes.
|
|
10
|
+
*/
|
|
11
|
+
type SuiNetwork = "mainnet" | "testnet";
|
|
12
|
+
interface SuiVaultConfig {
|
|
13
|
+
/** Catalog vault id (matches the API catalog). */
|
|
14
|
+
id: string;
|
|
15
|
+
network: SuiNetwork;
|
|
16
|
+
packageId: string;
|
|
17
|
+
usdcType: string;
|
|
18
|
+
rcusdpType: string;
|
|
19
|
+
vaultObjectId: string;
|
|
20
|
+
pendingDepositsId: string;
|
|
21
|
+
pendingRedeemsId: string;
|
|
22
|
+
balancesId: string;
|
|
23
|
+
claimsId: string;
|
|
24
|
+
userRecordsId: string;
|
|
25
|
+
vaultTypeConfigId: string;
|
|
26
|
+
depositSettlementStateId: string;
|
|
27
|
+
}
|
|
28
|
+
declare const USDC_DECIMALS = 6;
|
|
29
|
+
declare const SHARE_DECIMALS = 6;
|
|
30
|
+
declare function getSuiVaultConfig(vaultId: string, network: SuiNetwork): SuiVaultConfig;
|
|
31
|
+
declare function listSuiVaults(network: SuiNetwork): SuiVaultConfig[];
|
|
32
|
+
type SuiVaultErrorCode = "UNKNOWN_VAULT" | "INSUFFICIENT_BALANCE" | "NOTHING_CLAIMABLE" | "RPC_ERROR";
|
|
33
|
+
declare class SuiVaultError extends Error {
|
|
34
|
+
readonly code: SuiVaultErrorCode;
|
|
35
|
+
constructor(code: SuiVaultErrorCode, message: string);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Unsigned PTB builders for the rcUSDP Sui vault (vault_api module).
|
|
40
|
+
*
|
|
41
|
+
* Ported from tbook-vault-fe/hooks/use-vault-actions.ts, stripped of React
|
|
42
|
+
* and signing — every builder returns base64 tx bytes for the caller's
|
|
43
|
+
* wallet infrastructure (WaaS, multisig, CLI) to sign and submit.
|
|
44
|
+
*
|
|
45
|
+
* Gas: `tx.build()` selects gas coins owned by `sender`; the sender needs
|
|
46
|
+
* SUI for gas. Sponsored transactions are a later iteration.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
interface SuiBuildResult {
|
|
50
|
+
/** Unsigned transaction bytes, base64 — contract format `sui:tx-bytes-base64`. */
|
|
51
|
+
txBytesBase64: string;
|
|
52
|
+
/** Human-readable description of what the transaction does. */
|
|
53
|
+
message: string;
|
|
54
|
+
}
|
|
55
|
+
/** Deposit USDC into the vault (T+1 settlement). `amount` in raw units (1e6). */
|
|
56
|
+
declare function buildDepositTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
57
|
+
sender: string;
|
|
58
|
+
amount: bigint;
|
|
59
|
+
}): Promise<SuiBuildResult>;
|
|
60
|
+
/** Queue a redemption for USDC (settles with the next cycle). `shares` raw (1e6). */
|
|
61
|
+
declare function buildQueueRedeemTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
62
|
+
sender: string;
|
|
63
|
+
shares: bigint;
|
|
64
|
+
}): Promise<SuiBuildResult>;
|
|
65
|
+
/** Instant redemption to USDC (immediate, higher fee). `shares` raw (1e6). */
|
|
66
|
+
declare function buildInstantRedeemTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
67
|
+
sender: string;
|
|
68
|
+
shares: bigint;
|
|
69
|
+
}): Promise<SuiBuildResult>;
|
|
70
|
+
/** Cancel a pending deposit by record id (only while its cycle is accepting). */
|
|
71
|
+
declare function buildCancelDepositTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
72
|
+
sender: string;
|
|
73
|
+
recordId: string | bigint;
|
|
74
|
+
}): Promise<SuiBuildResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Plain USDC transfer (treasury withdrawals to allowlisted addresses).
|
|
77
|
+
* `amount` in raw units (1e6).
|
|
78
|
+
*/
|
|
79
|
+
declare function buildTransferUsdcTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
80
|
+
sender: string;
|
|
81
|
+
recipient: string;
|
|
82
|
+
amount: bigint;
|
|
83
|
+
}): Promise<SuiBuildResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Claim settled redemption proceeds. Claims the full claimable balance by
|
|
86
|
+
* default (contract semantics: claim pays the account's own wallet).
|
|
87
|
+
* Throws NOTHING_CLAIMABLE when the claimable balance is zero.
|
|
88
|
+
*/
|
|
89
|
+
declare function buildClaimTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
90
|
+
sender: string;
|
|
91
|
+
amount?: bigint;
|
|
92
|
+
}): Promise<SuiBuildResult>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Read queries for the rcUSDP Sui vault.
|
|
96
|
+
*
|
|
97
|
+
* Position reads use a single devInspect batch over the vault module's view
|
|
98
|
+
* functions (ported from tbook-vault-fe/hooks/use-vault-user.ts); vault
|
|
99
|
+
* state reads the shared Vault object's fields.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
interface SuiVaultPosition {
|
|
103
|
+
/** Settled shares (1e6). */
|
|
104
|
+
shares: bigint;
|
|
105
|
+
/** USDC pending in the current deposit cycle (1e6). */
|
|
106
|
+
pendingDeposit: bigint;
|
|
107
|
+
/** Shares queued for redemption (1e6). */
|
|
108
|
+
pendingRedeem: bigint;
|
|
109
|
+
/** Settled USDC awaiting claim (1e6). */
|
|
110
|
+
claimable: bigint;
|
|
111
|
+
}
|
|
112
|
+
interface SuiVaultState {
|
|
113
|
+
paused: boolean;
|
|
114
|
+
totalShares: bigint;
|
|
115
|
+
sharePrice1e18: bigint;
|
|
116
|
+
depositFeeBps: number;
|
|
117
|
+
redeemFeeBps: number;
|
|
118
|
+
raw: Record<string, unknown>;
|
|
119
|
+
}
|
|
120
|
+
/** Fetch a user's full position in one devInspect round-trip. */
|
|
121
|
+
declare function getUserPosition(client: SuiClient, cfg: SuiVaultConfig, address: string): Promise<SuiVaultPosition>;
|
|
122
|
+
/** Read the shared Vault object's state fields. */
|
|
123
|
+
declare function getVaultState(client: SuiClient, cfg: SuiVaultConfig): Promise<SuiVaultState>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Per-user record reads (UserRecords table) — devInspect over
|
|
127
|
+
* vault::get_all_user_records, BCS layout ported from
|
|
128
|
+
* tbook-vault-fe/hooks/use-transaction-history.ts.
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
/** Action codes from vault.move. */
|
|
132
|
+
declare const SUI_ACTION: {
|
|
133
|
+
readonly DEPOSIT: 0;
|
|
134
|
+
readonly REDEEM: 1;
|
|
135
|
+
readonly CLAIM: 2;
|
|
136
|
+
readonly INSTANT_REDEEM: 3;
|
|
137
|
+
readonly WITHDRAW_RCUSDP: 4;
|
|
138
|
+
readonly CANCEL_DEPOSIT: 5;
|
|
139
|
+
};
|
|
140
|
+
/** Record status codes from vault.move. */
|
|
141
|
+
declare const SUI_RECORD_STATUS: {
|
|
142
|
+
readonly PENDING: 0;
|
|
143
|
+
readonly COMPLETED: 1;
|
|
144
|
+
readonly CANCELLED: 2;
|
|
145
|
+
};
|
|
146
|
+
interface SuiUserRecord {
|
|
147
|
+
recordId: string;
|
|
148
|
+
action: number;
|
|
149
|
+
/** Raw units (1e6). */
|
|
150
|
+
amount: bigint;
|
|
151
|
+
fee: bigint;
|
|
152
|
+
shares: bigint;
|
|
153
|
+
status: number;
|
|
154
|
+
/** Unix ms. */
|
|
155
|
+
createdAt: number;
|
|
156
|
+
/** Unix ms; 0 while pending. */
|
|
157
|
+
settledAt: number;
|
|
158
|
+
relatedRecordId: string;
|
|
159
|
+
}
|
|
160
|
+
/** Fetch all of a user's vault records, newest first. */
|
|
161
|
+
declare function getUserRecords(client: SuiClient, cfg: SuiVaultConfig, address: string): Promise<SuiUserRecord[]>;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* AlphaVault (XAUa tokenized gold) — Sui direct rail builders and reads.
|
|
165
|
+
*
|
|
166
|
+
* Contract: rwa-alpha-token `alpha_vault` module. Subscription/redemption
|
|
167
|
+
* are request-based with T+3 issuer settlement; all user entries take the
|
|
168
|
+
* single shared AlphaVault object + Clock. Wallets must be whitelisted by
|
|
169
|
+
* the issuer before subscribing (contract `not_whitelisted` semantics).
|
|
170
|
+
*
|
|
171
|
+
* XAUA has 6 decimals (shares are u128 in the same scale); USDC is 1e6.
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
interface AlphaVaultConfig {
|
|
175
|
+
/** Catalog vault id ("xaua-sui"). */
|
|
176
|
+
id: string;
|
|
177
|
+
network: "mainnet" | "testnet";
|
|
178
|
+
packageId: string;
|
|
179
|
+
vaultObjectId: string;
|
|
180
|
+
usdcType: string;
|
|
181
|
+
xauaType: string;
|
|
182
|
+
}
|
|
183
|
+
declare function getAlphaVaultConfig(vaultId: string, network: "mainnet" | "testnet"): AlphaVaultConfig;
|
|
184
|
+
interface AlphaPosition {
|
|
185
|
+
/** XAUA shares free to redeem (1e6 scale, u128 on-chain). */
|
|
186
|
+
availableShares: bigint;
|
|
187
|
+
/** Shares locked in pending redemption requests. */
|
|
188
|
+
lockedShares: bigint;
|
|
189
|
+
/** Settled USDC awaiting claim (1e6). */
|
|
190
|
+
claimableUsdc: bigint;
|
|
191
|
+
totalSubscribedUsdc: bigint;
|
|
192
|
+
totalRedeemedShares: bigint;
|
|
193
|
+
totalClaimedUsdc: bigint;
|
|
194
|
+
}
|
|
195
|
+
interface BuildResult {
|
|
196
|
+
txBytesBase64: string;
|
|
197
|
+
message: string;
|
|
198
|
+
}
|
|
199
|
+
/** Subscribe USDC for XAUa at the settlement cycle's NAV (T+3). */
|
|
200
|
+
declare function buildSubscribeTx(client: SuiClient, cfg: AlphaVaultConfig, params: {
|
|
201
|
+
sender: string;
|
|
202
|
+
amount: bigint;
|
|
203
|
+
}): Promise<BuildResult>;
|
|
204
|
+
/** Queue a redemption of XAUa shares (T+3 issuer settlement). */
|
|
205
|
+
declare function buildRequestRedemptionTx(client: SuiClient, cfg: AlphaVaultConfig, params: {
|
|
206
|
+
sender: string;
|
|
207
|
+
shares: bigint;
|
|
208
|
+
}): Promise<BuildResult>;
|
|
209
|
+
/** Cancel a pending subscription or redemption request by id. */
|
|
210
|
+
declare function buildCancelRequestTx(client: SuiClient, cfg: AlphaVaultConfig, params: {
|
|
211
|
+
sender: string;
|
|
212
|
+
requestId: string | bigint;
|
|
213
|
+
kind: "subscription" | "redemption";
|
|
214
|
+
}): Promise<BuildResult>;
|
|
215
|
+
/**
|
|
216
|
+
* Claim settled redemption proceeds. Claims the full claimable balance by
|
|
217
|
+
* default; throws NOTHING_CLAIMABLE when it is zero.
|
|
218
|
+
*/
|
|
219
|
+
declare function buildClaimUsdcTx(client: SuiClient, cfg: AlphaVaultConfig, params: {
|
|
220
|
+
sender: string;
|
|
221
|
+
amount?: bigint;
|
|
222
|
+
}): Promise<BuildResult>;
|
|
223
|
+
/** Read a user's AlphaVault position in one devInspect round-trip. */
|
|
224
|
+
declare function getAlphaPosition(client: SuiClient, cfg: AlphaVaultConfig, address: string): Promise<AlphaPosition>;
|
|
225
|
+
|
|
226
|
+
export { type AlphaPosition, type AlphaVaultConfig, SHARE_DECIMALS, SUI_ACTION, SUI_RECORD_STATUS, type SuiBuildResult, type SuiNetwork, type SuiUserRecord, type SuiVaultConfig, SuiVaultError, type SuiVaultErrorCode, type SuiVaultPosition, type SuiVaultState, USDC_DECIMALS, buildCancelDepositTx, buildCancelRequestTx, buildClaimTx, buildClaimUsdcTx, buildDepositTx, buildInstantRedeemTx, buildQueueRedeemTx, buildRequestRedemptionTx, buildSubscribeTx, buildTransferUsdcTx, getAlphaPosition, getAlphaVaultConfig, getSuiVaultConfig, getUserPosition, getUserRecords, getVaultState, listSuiVaults };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { SuiClient } from '@mysten/sui/client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sui vault registry — contract object ids per network.
|
|
5
|
+
*
|
|
6
|
+
* Source of truth: tokenized-asset-claim-portal deployments (mirrored in
|
|
7
|
+
* tbook-vault-fe/lib/contracts.ts and verified against the Kotlin backend's
|
|
8
|
+
* authoritative list). Object ids are stable across package upgrades on Sui;
|
|
9
|
+
* PACKAGE_ID changes on upgrade — keep in sync with DEPLOYMENTS notes.
|
|
10
|
+
*/
|
|
11
|
+
type SuiNetwork = "mainnet" | "testnet";
|
|
12
|
+
interface SuiVaultConfig {
|
|
13
|
+
/** Catalog vault id (matches the API catalog). */
|
|
14
|
+
id: string;
|
|
15
|
+
network: SuiNetwork;
|
|
16
|
+
packageId: string;
|
|
17
|
+
usdcType: string;
|
|
18
|
+
rcusdpType: string;
|
|
19
|
+
vaultObjectId: string;
|
|
20
|
+
pendingDepositsId: string;
|
|
21
|
+
pendingRedeemsId: string;
|
|
22
|
+
balancesId: string;
|
|
23
|
+
claimsId: string;
|
|
24
|
+
userRecordsId: string;
|
|
25
|
+
vaultTypeConfigId: string;
|
|
26
|
+
depositSettlementStateId: string;
|
|
27
|
+
}
|
|
28
|
+
declare const USDC_DECIMALS = 6;
|
|
29
|
+
declare const SHARE_DECIMALS = 6;
|
|
30
|
+
declare function getSuiVaultConfig(vaultId: string, network: SuiNetwork): SuiVaultConfig;
|
|
31
|
+
declare function listSuiVaults(network: SuiNetwork): SuiVaultConfig[];
|
|
32
|
+
type SuiVaultErrorCode = "UNKNOWN_VAULT" | "INSUFFICIENT_BALANCE" | "NOTHING_CLAIMABLE" | "RPC_ERROR";
|
|
33
|
+
declare class SuiVaultError extends Error {
|
|
34
|
+
readonly code: SuiVaultErrorCode;
|
|
35
|
+
constructor(code: SuiVaultErrorCode, message: string);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Unsigned PTB builders for the rcUSDP Sui vault (vault_api module).
|
|
40
|
+
*
|
|
41
|
+
* Ported from tbook-vault-fe/hooks/use-vault-actions.ts, stripped of React
|
|
42
|
+
* and signing — every builder returns base64 tx bytes for the caller's
|
|
43
|
+
* wallet infrastructure (WaaS, multisig, CLI) to sign and submit.
|
|
44
|
+
*
|
|
45
|
+
* Gas: `tx.build()` selects gas coins owned by `sender`; the sender needs
|
|
46
|
+
* SUI for gas. Sponsored transactions are a later iteration.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
interface SuiBuildResult {
|
|
50
|
+
/** Unsigned transaction bytes, base64 — contract format `sui:tx-bytes-base64`. */
|
|
51
|
+
txBytesBase64: string;
|
|
52
|
+
/** Human-readable description of what the transaction does. */
|
|
53
|
+
message: string;
|
|
54
|
+
}
|
|
55
|
+
/** Deposit USDC into the vault (T+1 settlement). `amount` in raw units (1e6). */
|
|
56
|
+
declare function buildDepositTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
57
|
+
sender: string;
|
|
58
|
+
amount: bigint;
|
|
59
|
+
}): Promise<SuiBuildResult>;
|
|
60
|
+
/** Queue a redemption for USDC (settles with the next cycle). `shares` raw (1e6). */
|
|
61
|
+
declare function buildQueueRedeemTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
62
|
+
sender: string;
|
|
63
|
+
shares: bigint;
|
|
64
|
+
}): Promise<SuiBuildResult>;
|
|
65
|
+
/** Instant redemption to USDC (immediate, higher fee). `shares` raw (1e6). */
|
|
66
|
+
declare function buildInstantRedeemTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
67
|
+
sender: string;
|
|
68
|
+
shares: bigint;
|
|
69
|
+
}): Promise<SuiBuildResult>;
|
|
70
|
+
/** Cancel a pending deposit by record id (only while its cycle is accepting). */
|
|
71
|
+
declare function buildCancelDepositTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
72
|
+
sender: string;
|
|
73
|
+
recordId: string | bigint;
|
|
74
|
+
}): Promise<SuiBuildResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Plain USDC transfer (treasury withdrawals to allowlisted addresses).
|
|
77
|
+
* `amount` in raw units (1e6).
|
|
78
|
+
*/
|
|
79
|
+
declare function buildTransferUsdcTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
80
|
+
sender: string;
|
|
81
|
+
recipient: string;
|
|
82
|
+
amount: bigint;
|
|
83
|
+
}): Promise<SuiBuildResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Claim settled redemption proceeds. Claims the full claimable balance by
|
|
86
|
+
* default (contract semantics: claim pays the account's own wallet).
|
|
87
|
+
* Throws NOTHING_CLAIMABLE when the claimable balance is zero.
|
|
88
|
+
*/
|
|
89
|
+
declare function buildClaimTx(client: SuiClient, cfg: SuiVaultConfig, params: {
|
|
90
|
+
sender: string;
|
|
91
|
+
amount?: bigint;
|
|
92
|
+
}): Promise<SuiBuildResult>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Read queries for the rcUSDP Sui vault.
|
|
96
|
+
*
|
|
97
|
+
* Position reads use a single devInspect batch over the vault module's view
|
|
98
|
+
* functions (ported from tbook-vault-fe/hooks/use-vault-user.ts); vault
|
|
99
|
+
* state reads the shared Vault object's fields.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
interface SuiVaultPosition {
|
|
103
|
+
/** Settled shares (1e6). */
|
|
104
|
+
shares: bigint;
|
|
105
|
+
/** USDC pending in the current deposit cycle (1e6). */
|
|
106
|
+
pendingDeposit: bigint;
|
|
107
|
+
/** Shares queued for redemption (1e6). */
|
|
108
|
+
pendingRedeem: bigint;
|
|
109
|
+
/** Settled USDC awaiting claim (1e6). */
|
|
110
|
+
claimable: bigint;
|
|
111
|
+
}
|
|
112
|
+
interface SuiVaultState {
|
|
113
|
+
paused: boolean;
|
|
114
|
+
totalShares: bigint;
|
|
115
|
+
sharePrice1e18: bigint;
|
|
116
|
+
depositFeeBps: number;
|
|
117
|
+
redeemFeeBps: number;
|
|
118
|
+
raw: Record<string, unknown>;
|
|
119
|
+
}
|
|
120
|
+
/** Fetch a user's full position in one devInspect round-trip. */
|
|
121
|
+
declare function getUserPosition(client: SuiClient, cfg: SuiVaultConfig, address: string): Promise<SuiVaultPosition>;
|
|
122
|
+
/** Read the shared Vault object's state fields. */
|
|
123
|
+
declare function getVaultState(client: SuiClient, cfg: SuiVaultConfig): Promise<SuiVaultState>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Per-user record reads (UserRecords table) — devInspect over
|
|
127
|
+
* vault::get_all_user_records, BCS layout ported from
|
|
128
|
+
* tbook-vault-fe/hooks/use-transaction-history.ts.
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
/** Action codes from vault.move. */
|
|
132
|
+
declare const SUI_ACTION: {
|
|
133
|
+
readonly DEPOSIT: 0;
|
|
134
|
+
readonly REDEEM: 1;
|
|
135
|
+
readonly CLAIM: 2;
|
|
136
|
+
readonly INSTANT_REDEEM: 3;
|
|
137
|
+
readonly WITHDRAW_RCUSDP: 4;
|
|
138
|
+
readonly CANCEL_DEPOSIT: 5;
|
|
139
|
+
};
|
|
140
|
+
/** Record status codes from vault.move. */
|
|
141
|
+
declare const SUI_RECORD_STATUS: {
|
|
142
|
+
readonly PENDING: 0;
|
|
143
|
+
readonly COMPLETED: 1;
|
|
144
|
+
readonly CANCELLED: 2;
|
|
145
|
+
};
|
|
146
|
+
interface SuiUserRecord {
|
|
147
|
+
recordId: string;
|
|
148
|
+
action: number;
|
|
149
|
+
/** Raw units (1e6). */
|
|
150
|
+
amount: bigint;
|
|
151
|
+
fee: bigint;
|
|
152
|
+
shares: bigint;
|
|
153
|
+
status: number;
|
|
154
|
+
/** Unix ms. */
|
|
155
|
+
createdAt: number;
|
|
156
|
+
/** Unix ms; 0 while pending. */
|
|
157
|
+
settledAt: number;
|
|
158
|
+
relatedRecordId: string;
|
|
159
|
+
}
|
|
160
|
+
/** Fetch all of a user's vault records, newest first. */
|
|
161
|
+
declare function getUserRecords(client: SuiClient, cfg: SuiVaultConfig, address: string): Promise<SuiUserRecord[]>;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* AlphaVault (XAUa tokenized gold) — Sui direct rail builders and reads.
|
|
165
|
+
*
|
|
166
|
+
* Contract: rwa-alpha-token `alpha_vault` module. Subscription/redemption
|
|
167
|
+
* are request-based with T+3 issuer settlement; all user entries take the
|
|
168
|
+
* single shared AlphaVault object + Clock. Wallets must be whitelisted by
|
|
169
|
+
* the issuer before subscribing (contract `not_whitelisted` semantics).
|
|
170
|
+
*
|
|
171
|
+
* XAUA has 6 decimals (shares are u128 in the same scale); USDC is 1e6.
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
interface AlphaVaultConfig {
|
|
175
|
+
/** Catalog vault id ("xaua-sui"). */
|
|
176
|
+
id: string;
|
|
177
|
+
network: "mainnet" | "testnet";
|
|
178
|
+
packageId: string;
|
|
179
|
+
vaultObjectId: string;
|
|
180
|
+
usdcType: string;
|
|
181
|
+
xauaType: string;
|
|
182
|
+
}
|
|
183
|
+
declare function getAlphaVaultConfig(vaultId: string, network: "mainnet" | "testnet"): AlphaVaultConfig;
|
|
184
|
+
interface AlphaPosition {
|
|
185
|
+
/** XAUA shares free to redeem (1e6 scale, u128 on-chain). */
|
|
186
|
+
availableShares: bigint;
|
|
187
|
+
/** Shares locked in pending redemption requests. */
|
|
188
|
+
lockedShares: bigint;
|
|
189
|
+
/** Settled USDC awaiting claim (1e6). */
|
|
190
|
+
claimableUsdc: bigint;
|
|
191
|
+
totalSubscribedUsdc: bigint;
|
|
192
|
+
totalRedeemedShares: bigint;
|
|
193
|
+
totalClaimedUsdc: bigint;
|
|
194
|
+
}
|
|
195
|
+
interface BuildResult {
|
|
196
|
+
txBytesBase64: string;
|
|
197
|
+
message: string;
|
|
198
|
+
}
|
|
199
|
+
/** Subscribe USDC for XAUa at the settlement cycle's NAV (T+3). */
|
|
200
|
+
declare function buildSubscribeTx(client: SuiClient, cfg: AlphaVaultConfig, params: {
|
|
201
|
+
sender: string;
|
|
202
|
+
amount: bigint;
|
|
203
|
+
}): Promise<BuildResult>;
|
|
204
|
+
/** Queue a redemption of XAUa shares (T+3 issuer settlement). */
|
|
205
|
+
declare function buildRequestRedemptionTx(client: SuiClient, cfg: AlphaVaultConfig, params: {
|
|
206
|
+
sender: string;
|
|
207
|
+
shares: bigint;
|
|
208
|
+
}): Promise<BuildResult>;
|
|
209
|
+
/** Cancel a pending subscription or redemption request by id. */
|
|
210
|
+
declare function buildCancelRequestTx(client: SuiClient, cfg: AlphaVaultConfig, params: {
|
|
211
|
+
sender: string;
|
|
212
|
+
requestId: string | bigint;
|
|
213
|
+
kind: "subscription" | "redemption";
|
|
214
|
+
}): Promise<BuildResult>;
|
|
215
|
+
/**
|
|
216
|
+
* Claim settled redemption proceeds. Claims the full claimable balance by
|
|
217
|
+
* default; throws NOTHING_CLAIMABLE when it is zero.
|
|
218
|
+
*/
|
|
219
|
+
declare function buildClaimUsdcTx(client: SuiClient, cfg: AlphaVaultConfig, params: {
|
|
220
|
+
sender: string;
|
|
221
|
+
amount?: bigint;
|
|
222
|
+
}): Promise<BuildResult>;
|
|
223
|
+
/** Read a user's AlphaVault position in one devInspect round-trip. */
|
|
224
|
+
declare function getAlphaPosition(client: SuiClient, cfg: AlphaVaultConfig, address: string): Promise<AlphaPosition>;
|
|
225
|
+
|
|
226
|
+
export { type AlphaPosition, type AlphaVaultConfig, SHARE_DECIMALS, SUI_ACTION, SUI_RECORD_STATUS, type SuiBuildResult, type SuiNetwork, type SuiUserRecord, type SuiVaultConfig, SuiVaultError, type SuiVaultErrorCode, type SuiVaultPosition, type SuiVaultState, USDC_DECIMALS, buildCancelDepositTx, buildCancelRequestTx, buildClaimTx, buildClaimUsdcTx, buildDepositTx, buildInstantRedeemTx, buildQueueRedeemTx, buildRequestRedemptionTx, buildSubscribeTx, buildTransferUsdcTx, getAlphaPosition, getAlphaVaultConfig, getSuiVaultConfig, getUserPosition, getUserRecords, getVaultState, listSuiVaults };
|