@t2000/sdk 0.19.24 → 0.20.1

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,127 @@
1
+ import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
2
+ import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
+
4
+ type AdapterCapability = 'save' | 'withdraw' | 'borrow' | 'repay';
5
+ /**
6
+ * Describes a protocol for indexer event classification.
7
+ * Each adapter exports one of these so the server can auto-build
8
+ * detection rules without manual sync.
9
+ *
10
+ * To add a new protocol: export a `descriptor` from your adapter file.
11
+ */
12
+ interface ProtocolDescriptor {
13
+ /** Unique protocol ID — must match the adapter's `id` field */
14
+ id: string;
15
+ /** Human-readable name */
16
+ name: string;
17
+ /**
18
+ * On-chain package IDs that identify this protocol's transactions.
19
+ * For protocols with upgradeable packages, list the original/base package.
20
+ */
21
+ packages: string[];
22
+ /**
23
+ * Maps `module::function` patterns to action types.
24
+ * The indexer matches Move call targets against these patterns.
25
+ * For dynamic package IDs (e.g. NAVI), matching is done on module::function only.
26
+ */
27
+ actionMap: Record<string, string>;
28
+ /**
29
+ * If true, the indexer matches by module::function suffix only,
30
+ * ignoring the package ID prefix. Use for protocols with frequently
31
+ * upgraded (dynamic) package IDs.
32
+ */
33
+ dynamicPackageId?: boolean;
34
+ }
35
+ interface AdapterTxResult {
36
+ tx: Transaction;
37
+ feeCoin?: TransactionObjectArgument;
38
+ meta?: Record<string, unknown>;
39
+ }
40
+ interface LendingRates {
41
+ asset: string;
42
+ saveApy: number;
43
+ borrowApy: number;
44
+ }
45
+ interface AdapterPositions {
46
+ supplies: Array<{
47
+ asset: string;
48
+ amount: number;
49
+ amountUsd?: number;
50
+ apy: number;
51
+ }>;
52
+ borrows: Array<{
53
+ asset: string;
54
+ amount: number;
55
+ amountUsd?: number;
56
+ apy: number;
57
+ }>;
58
+ }
59
+ interface HealthInfo {
60
+ healthFactor: number;
61
+ supplied: number;
62
+ borrowed: number;
63
+ maxBorrow: number;
64
+ liquidationThreshold: number;
65
+ }
66
+ interface LendingAdapter {
67
+ readonly id: string;
68
+ readonly name: string;
69
+ readonly version: string;
70
+ readonly capabilities: readonly AdapterCapability[];
71
+ readonly supportedAssets: readonly string[];
72
+ readonly supportsSameAssetBorrow: boolean;
73
+ init(client: SuiJsonRpcClient): Promise<void>;
74
+ getRates(asset: string): Promise<LendingRates>;
75
+ getPositions(address: string): Promise<AdapterPositions>;
76
+ getHealth(address: string): Promise<HealthInfo>;
77
+ buildSaveTx(address: string, amount: number, asset: string, options?: {
78
+ collectFee?: boolean;
79
+ sponsored?: boolean;
80
+ }): Promise<AdapterTxResult>;
81
+ buildWithdrawTx(address: string, amount: number, asset: string, options?: {
82
+ sponsored?: boolean;
83
+ }): Promise<AdapterTxResult & {
84
+ effectiveAmount: number;
85
+ }>;
86
+ buildBorrowTx(address: string, amount: number, asset: string, options?: {
87
+ collectFee?: boolean;
88
+ sponsored?: boolean;
89
+ }): Promise<AdapterTxResult>;
90
+ buildRepayTx(address: string, amount: number, asset: string, options?: {
91
+ sponsored?: boolean;
92
+ skipOracle?: boolean;
93
+ }): Promise<AdapterTxResult>;
94
+ maxWithdraw(address: string, asset: string): Promise<{
95
+ maxAmount: number;
96
+ healthFactorAfter: number;
97
+ currentHF: number;
98
+ }>;
99
+ maxBorrow(address: string, asset: string): Promise<{
100
+ maxAmount: number;
101
+ healthFactorAfter: number;
102
+ currentHF: number;
103
+ }>;
104
+ addWithdrawToTx?(tx: Transaction, address: string, amount: number, asset: string): Promise<{
105
+ coin: TransactionObjectArgument;
106
+ effectiveAmount: number;
107
+ }>;
108
+ addSaveToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
109
+ collectFee?: boolean;
110
+ }): Promise<void>;
111
+ addRepayToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
112
+ getPendingRewards?(address: string): Promise<PendingReward[]>;
113
+ addClaimRewardsToTx?(tx: Transaction, address: string): Promise<PendingReward[]>;
114
+ }
115
+ interface PendingReward {
116
+ protocol: string;
117
+ asset: string;
118
+ coinType: string;
119
+ symbol: string;
120
+ amount: number;
121
+ estimatedValueUsd: number;
122
+ }
123
+
124
+ declare const naviDescriptor: ProtocolDescriptor;
125
+ declare const allDescriptors: ProtocolDescriptor[];
126
+
127
+ export { type AdapterCapability as A, type HealthInfo as H, type LendingAdapter as L, type ProtocolDescriptor as P, type LendingRates as a, type AdapterPositions as b, type AdapterTxResult as c, allDescriptors as d, type PendingReward as e, naviDescriptor as n };
@@ -0,0 +1,127 @@
1
+ import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
2
+ import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
+
4
+ type AdapterCapability = 'save' | 'withdraw' | 'borrow' | 'repay';
5
+ /**
6
+ * Describes a protocol for indexer event classification.
7
+ * Each adapter exports one of these so the server can auto-build
8
+ * detection rules without manual sync.
9
+ *
10
+ * To add a new protocol: export a `descriptor` from your adapter file.
11
+ */
12
+ interface ProtocolDescriptor {
13
+ /** Unique protocol ID — must match the adapter's `id` field */
14
+ id: string;
15
+ /** Human-readable name */
16
+ name: string;
17
+ /**
18
+ * On-chain package IDs that identify this protocol's transactions.
19
+ * For protocols with upgradeable packages, list the original/base package.
20
+ */
21
+ packages: string[];
22
+ /**
23
+ * Maps `module::function` patterns to action types.
24
+ * The indexer matches Move call targets against these patterns.
25
+ * For dynamic package IDs (e.g. NAVI), matching is done on module::function only.
26
+ */
27
+ actionMap: Record<string, string>;
28
+ /**
29
+ * If true, the indexer matches by module::function suffix only,
30
+ * ignoring the package ID prefix. Use for protocols with frequently
31
+ * upgraded (dynamic) package IDs.
32
+ */
33
+ dynamicPackageId?: boolean;
34
+ }
35
+ interface AdapterTxResult {
36
+ tx: Transaction;
37
+ feeCoin?: TransactionObjectArgument;
38
+ meta?: Record<string, unknown>;
39
+ }
40
+ interface LendingRates {
41
+ asset: string;
42
+ saveApy: number;
43
+ borrowApy: number;
44
+ }
45
+ interface AdapterPositions {
46
+ supplies: Array<{
47
+ asset: string;
48
+ amount: number;
49
+ amountUsd?: number;
50
+ apy: number;
51
+ }>;
52
+ borrows: Array<{
53
+ asset: string;
54
+ amount: number;
55
+ amountUsd?: number;
56
+ apy: number;
57
+ }>;
58
+ }
59
+ interface HealthInfo {
60
+ healthFactor: number;
61
+ supplied: number;
62
+ borrowed: number;
63
+ maxBorrow: number;
64
+ liquidationThreshold: number;
65
+ }
66
+ interface LendingAdapter {
67
+ readonly id: string;
68
+ readonly name: string;
69
+ readonly version: string;
70
+ readonly capabilities: readonly AdapterCapability[];
71
+ readonly supportedAssets: readonly string[];
72
+ readonly supportsSameAssetBorrow: boolean;
73
+ init(client: SuiJsonRpcClient): Promise<void>;
74
+ getRates(asset: string): Promise<LendingRates>;
75
+ getPositions(address: string): Promise<AdapterPositions>;
76
+ getHealth(address: string): Promise<HealthInfo>;
77
+ buildSaveTx(address: string, amount: number, asset: string, options?: {
78
+ collectFee?: boolean;
79
+ sponsored?: boolean;
80
+ }): Promise<AdapterTxResult>;
81
+ buildWithdrawTx(address: string, amount: number, asset: string, options?: {
82
+ sponsored?: boolean;
83
+ }): Promise<AdapterTxResult & {
84
+ effectiveAmount: number;
85
+ }>;
86
+ buildBorrowTx(address: string, amount: number, asset: string, options?: {
87
+ collectFee?: boolean;
88
+ sponsored?: boolean;
89
+ }): Promise<AdapterTxResult>;
90
+ buildRepayTx(address: string, amount: number, asset: string, options?: {
91
+ sponsored?: boolean;
92
+ skipOracle?: boolean;
93
+ }): Promise<AdapterTxResult>;
94
+ maxWithdraw(address: string, asset: string): Promise<{
95
+ maxAmount: number;
96
+ healthFactorAfter: number;
97
+ currentHF: number;
98
+ }>;
99
+ maxBorrow(address: string, asset: string): Promise<{
100
+ maxAmount: number;
101
+ healthFactorAfter: number;
102
+ currentHF: number;
103
+ }>;
104
+ addWithdrawToTx?(tx: Transaction, address: string, amount: number, asset: string): Promise<{
105
+ coin: TransactionObjectArgument;
106
+ effectiveAmount: number;
107
+ }>;
108
+ addSaveToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
109
+ collectFee?: boolean;
110
+ }): Promise<void>;
111
+ addRepayToTx?(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
112
+ getPendingRewards?(address: string): Promise<PendingReward[]>;
113
+ addClaimRewardsToTx?(tx: Transaction, address: string): Promise<PendingReward[]>;
114
+ }
115
+ interface PendingReward {
116
+ protocol: string;
117
+ asset: string;
118
+ coinType: string;
119
+ symbol: string;
120
+ amount: number;
121
+ estimatedValueUsd: number;
122
+ }
123
+
124
+ declare const naviDescriptor: ProtocolDescriptor;
125
+ declare const allDescriptors: ProtocolDescriptor[];
126
+
127
+ export { type AdapterCapability as A, type HealthInfo as H, type LendingAdapter as L, type ProtocolDescriptor as P, type LendingRates as a, type AdapterPositions as b, type AdapterTxResult as c, allDescriptors as d, type PendingReward as e, naviDescriptor as n };
@@ -0,0 +1,292 @@
1
+ import { L as LendingAdapter, a as LendingRates, b as AdapterPositions, A as AdapterCapability, H as HealthInfo, c as AdapterTxResult, e as PendingReward$1 } from './descriptors-Be4FAgN5.js';
2
+ import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
+ import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
4
+
5
+ interface T2000Options {
6
+ keyPath?: string;
7
+ /** PIN to decrypt the key file. Accepts any string (4+ chars). */
8
+ pin?: string;
9
+ /** @deprecated Use `pin` instead. */
10
+ passphrase?: string;
11
+ network?: 'mainnet' | 'testnet';
12
+ rpcUrl?: string;
13
+ sponsored?: boolean;
14
+ name?: string;
15
+ }
16
+ interface GasReserve {
17
+ sui: number;
18
+ usdEquiv: number;
19
+ }
20
+ interface BalanceResponse {
21
+ available: number;
22
+ savings: number;
23
+ debt: number;
24
+ pendingRewards: number;
25
+ gasReserve: GasReserve;
26
+ total: number;
27
+ stables: Record<string, number>;
28
+ }
29
+ type GasMethod = 'self-funded' | 'sponsored' | 'auto-topup' | 'none';
30
+ interface SendResult {
31
+ success: boolean;
32
+ tx: string;
33
+ amount: number;
34
+ to: string;
35
+ contactName?: string;
36
+ gasCost: number;
37
+ gasCostUnit: string;
38
+ gasMethod: GasMethod;
39
+ balance: BalanceResponse;
40
+ }
41
+ interface SaveResult {
42
+ success: boolean;
43
+ tx: string;
44
+ amount: number;
45
+ apy: number;
46
+ fee: number;
47
+ gasCost: number;
48
+ gasMethod: GasMethod;
49
+ savingsBalance: number;
50
+ }
51
+ interface WithdrawResult {
52
+ success: boolean;
53
+ tx: string;
54
+ amount: number;
55
+ gasCost: number;
56
+ gasMethod: GasMethod;
57
+ }
58
+ interface BorrowResult {
59
+ success: boolean;
60
+ tx: string;
61
+ amount: number;
62
+ fee: number;
63
+ healthFactor: number;
64
+ gasCost: number;
65
+ gasMethod: GasMethod;
66
+ }
67
+ interface RepayResult {
68
+ success: boolean;
69
+ tx: string;
70
+ amount: number;
71
+ remainingDebt: number;
72
+ gasCost: number;
73
+ gasMethod: GasMethod;
74
+ }
75
+ interface HealthFactorResult {
76
+ healthFactor: number;
77
+ supplied: number;
78
+ borrowed: number;
79
+ maxBorrow: number;
80
+ liquidationThreshold: number;
81
+ }
82
+ interface MaxWithdrawResult {
83
+ maxAmount: number;
84
+ healthFactorAfter: number;
85
+ currentHF: number;
86
+ }
87
+ interface MaxBorrowResult {
88
+ maxAmount: number;
89
+ healthFactorAfter: number;
90
+ currentHF: number;
91
+ }
92
+ interface AssetRates {
93
+ saveApy: number;
94
+ borrowApy: number;
95
+ }
96
+ interface RatesResult {
97
+ [asset: string]: AssetRates;
98
+ }
99
+ interface PositionEntry {
100
+ protocol: string;
101
+ asset: string;
102
+ type: 'save' | 'borrow';
103
+ amount: number;
104
+ amountUsd?: number;
105
+ apy: number;
106
+ }
107
+ interface PositionsResult {
108
+ positions: PositionEntry[];
109
+ }
110
+ interface EarningsResult {
111
+ totalYieldEarned: number;
112
+ currentApy: number;
113
+ dailyEarning: number;
114
+ supplied: number;
115
+ }
116
+ interface FundStatusResult {
117
+ supplied: number;
118
+ apy: number;
119
+ earnedToday: number;
120
+ earnedAllTime: number;
121
+ projectedMonthly: number;
122
+ }
123
+ interface DepositInfo {
124
+ address: string;
125
+ network: string;
126
+ supportedAssets: string[];
127
+ instructions: string;
128
+ }
129
+ interface TransactionRecord {
130
+ digest: string;
131
+ action: string;
132
+ amount?: number;
133
+ asset?: string;
134
+ recipient?: string;
135
+ timestamp: number;
136
+ gasCost?: number;
137
+ gasMethod?: GasMethod;
138
+ }
139
+ interface PendingReward {
140
+ protocol: string;
141
+ asset: string;
142
+ coinType: string;
143
+ symbol: string;
144
+ amount: number;
145
+ estimatedValueUsd: number;
146
+ }
147
+ interface ClaimRewardsResult {
148
+ success: boolean;
149
+ tx: string;
150
+ rewards: PendingReward[];
151
+ totalValueUsd: number;
152
+ gasCost: number;
153
+ gasMethod: GasMethod;
154
+ }
155
+ interface StakeVSuiResult {
156
+ success: boolean;
157
+ tx: string;
158
+ amountSui: number;
159
+ vSuiReceived: number;
160
+ apy: number;
161
+ gasCost: number;
162
+ gasMethod: GasMethod;
163
+ }
164
+ interface UnstakeVSuiResult {
165
+ success: boolean;
166
+ tx: string;
167
+ vSuiAmount: number;
168
+ suiReceived: number;
169
+ gasCost: number;
170
+ gasMethod: GasMethod;
171
+ }
172
+ interface SwapResult {
173
+ success: boolean;
174
+ tx: string;
175
+ fromToken: string;
176
+ toToken: string;
177
+ fromAmount: number;
178
+ toAmount: number;
179
+ priceImpact: number;
180
+ route: string;
181
+ gasCost: number;
182
+ gasMethod: GasMethod;
183
+ }
184
+ interface SwapQuoteResult {
185
+ fromToken: string;
186
+ toToken: string;
187
+ fromAmount: number;
188
+ toAmount: number;
189
+ priceImpact: number;
190
+ route: string;
191
+ }
192
+ interface PayOptions {
193
+ url: string;
194
+ method?: string;
195
+ body?: string;
196
+ headers?: Record<string, string>;
197
+ maxPrice?: number;
198
+ }
199
+ interface PayResult {
200
+ status: number;
201
+ body: unknown;
202
+ paid: boolean;
203
+ cost?: number;
204
+ receipt?: {
205
+ reference: string;
206
+ timestamp: string;
207
+ };
208
+ }
209
+
210
+ declare class ProtocolRegistry {
211
+ private lending;
212
+ registerLending(adapter: LendingAdapter): void;
213
+ bestSaveRate(asset: string): Promise<{
214
+ adapter: LendingAdapter;
215
+ rate: LendingRates;
216
+ }>;
217
+ bestBorrowRate(asset: string, opts?: {
218
+ requireSameAssetBorrow?: boolean;
219
+ }): Promise<{
220
+ adapter: LendingAdapter;
221
+ rate: LendingRates;
222
+ }>;
223
+ bestSaveRateAcrossAssets(): Promise<{
224
+ adapter: LendingAdapter;
225
+ rate: LendingRates;
226
+ asset: string;
227
+ }>;
228
+ allRatesAcrossAssets(): Promise<Array<{
229
+ protocol: string;
230
+ protocolId: string;
231
+ asset: string;
232
+ rates: LendingRates;
233
+ }>>;
234
+ allRates(asset: string): Promise<Array<{
235
+ protocol: string;
236
+ protocolId: string;
237
+ rates: LendingRates;
238
+ }>>;
239
+ allPositions(address: string): Promise<Array<{
240
+ protocol: string;
241
+ protocolId: string;
242
+ positions: AdapterPositions;
243
+ }>>;
244
+ getLending(id: string): LendingAdapter | undefined;
245
+ listLending(): LendingAdapter[];
246
+ }
247
+
248
+ declare class NaviAdapter implements LendingAdapter {
249
+ readonly id = "navi";
250
+ readonly name = "NAVI Protocol";
251
+ readonly version = "1.0.0";
252
+ readonly capabilities: readonly AdapterCapability[];
253
+ readonly supportedAssets: readonly string[];
254
+ readonly supportsSameAssetBorrow = true;
255
+ private client;
256
+ init(client: SuiJsonRpcClient): Promise<void>;
257
+ initSync(client: SuiJsonRpcClient): void;
258
+ getRates(asset: string): Promise<LendingRates>;
259
+ getPositions(address: string): Promise<AdapterPositions>;
260
+ getHealth(address: string): Promise<HealthInfo>;
261
+ buildSaveTx(address: string, amount: number, asset: string, options?: {
262
+ collectFee?: boolean;
263
+ sponsored?: boolean;
264
+ }): Promise<AdapterTxResult>;
265
+ buildWithdrawTx(address: string, amount: number, asset: string, options?: {
266
+ sponsored?: boolean;
267
+ }): Promise<AdapterTxResult & {
268
+ effectiveAmount: number;
269
+ }>;
270
+ buildBorrowTx(address: string, amount: number, asset: string, options?: {
271
+ collectFee?: boolean;
272
+ sponsored?: boolean;
273
+ }): Promise<AdapterTxResult>;
274
+ buildRepayTx(address: string, amount: number, asset: string, options?: {
275
+ sponsored?: boolean;
276
+ skipOracle?: boolean;
277
+ }): Promise<AdapterTxResult>;
278
+ maxWithdraw(address: string, _asset: string): Promise<MaxWithdrawResult>;
279
+ maxBorrow(address: string, _asset: string): Promise<MaxBorrowResult>;
280
+ addWithdrawToTx(tx: Transaction, address: string, amount: number, asset: string): Promise<{
281
+ coin: TransactionObjectArgument;
282
+ effectiveAmount: number;
283
+ }>;
284
+ addSaveToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string, options?: {
285
+ collectFee?: boolean;
286
+ }): Promise<void>;
287
+ addRepayToTx(tx: Transaction, address: string, coin: TransactionObjectArgument, asset: string): Promise<void>;
288
+ getPendingRewards(address: string): Promise<PendingReward$1[]>;
289
+ addClaimRewardsToTx(tx: Transaction, address: string): Promise<PendingReward$1[]>;
290
+ }
291
+
292
+ export { type AssetRates as A, type BalanceResponse as B, type ClaimRewardsResult as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, type MaxWithdrawResult as M, NaviAdapter as N, type PayOptions as P, type RepayResult as R, type StakeVSuiResult as S, type T2000Options as T, type UnstakeVSuiResult as U, type WithdrawResult as W, type PayResult as a, type SwapResult as b, type SwapQuoteResult as c, type SendResult as d, type TransactionRecord as e, type SaveResult as f, type BorrowResult as g, type MaxBorrowResult as h, type PendingReward as i, type PositionsResult as j, type RatesResult as k, type GasReserve as l, type PositionEntry as m, ProtocolRegistry as n };