@t2000/sdk 0.2.7 → 0.4.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,393 @@
1
+ import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
2
+ import { SuiClient } from '@mysten/sui/client';
3
+
4
+ type AdapterCapability = 'save' | 'withdraw' | 'borrow' | 'repay' | 'swap';
5
+ interface AdapterTxResult {
6
+ tx: Transaction;
7
+ feeCoin?: TransactionObjectArgument;
8
+ meta?: Record<string, unknown>;
9
+ }
10
+ interface LendingRates {
11
+ asset: string;
12
+ saveApy: number;
13
+ borrowApy: number;
14
+ }
15
+ interface AdapterPositions {
16
+ supplies: Array<{
17
+ asset: string;
18
+ amount: number;
19
+ apy: number;
20
+ }>;
21
+ borrows: Array<{
22
+ asset: string;
23
+ amount: number;
24
+ apy: number;
25
+ }>;
26
+ }
27
+ interface HealthInfo {
28
+ healthFactor: number;
29
+ supplied: number;
30
+ borrowed: number;
31
+ maxBorrow: number;
32
+ liquidationThreshold: number;
33
+ }
34
+ interface SwapQuote {
35
+ expectedOutput: number;
36
+ priceImpact: number;
37
+ poolPrice: number;
38
+ }
39
+ interface LendingAdapter {
40
+ readonly id: string;
41
+ readonly name: string;
42
+ readonly version: string;
43
+ readonly capabilities: readonly AdapterCapability[];
44
+ readonly supportedAssets: readonly string[];
45
+ readonly supportsSameAssetBorrow: boolean;
46
+ init(client: SuiClient): Promise<void>;
47
+ getRates(asset: string): Promise<LendingRates>;
48
+ getPositions(address: string): Promise<AdapterPositions>;
49
+ getHealth(address: string): Promise<HealthInfo>;
50
+ buildSaveTx(address: string, amount: number, asset: string, options?: {
51
+ collectFee?: boolean;
52
+ }): Promise<AdapterTxResult>;
53
+ buildWithdrawTx(address: string, amount: number, asset: string): Promise<AdapterTxResult & {
54
+ effectiveAmount: number;
55
+ }>;
56
+ buildBorrowTx(address: string, amount: number, asset: string, options?: {
57
+ collectFee?: boolean;
58
+ }): Promise<AdapterTxResult>;
59
+ buildRepayTx(address: string, amount: number, asset: string): Promise<AdapterTxResult>;
60
+ maxWithdraw(address: string, asset: string): Promise<{
61
+ maxAmount: number;
62
+ healthFactorAfter: number;
63
+ currentHF: number;
64
+ }>;
65
+ maxBorrow(address: string, asset: string): Promise<{
66
+ maxAmount: number;
67
+ healthFactorAfter: number;
68
+ currentHF: number;
69
+ }>;
70
+ }
71
+ interface SwapAdapter {
72
+ readonly id: string;
73
+ readonly name: string;
74
+ readonly version: string;
75
+ readonly capabilities: readonly AdapterCapability[];
76
+ init(client: SuiClient): Promise<void>;
77
+ getQuote(from: string, to: string, amount: number): Promise<SwapQuote>;
78
+ buildSwapTx(address: string, from: string, to: string, amount: number, maxSlippageBps?: number): Promise<AdapterTxResult & {
79
+ estimatedOut: number;
80
+ toDecimals: number;
81
+ }>;
82
+ getSupportedPairs(): Array<{
83
+ from: string;
84
+ to: string;
85
+ }>;
86
+ getPoolPrice(): Promise<number>;
87
+ }
88
+
89
+ interface T2000Options {
90
+ keyPath?: string;
91
+ /** PIN to decrypt the key file. Accepts any string (4+ chars). */
92
+ pin?: string;
93
+ /** @deprecated Use `pin` instead. */
94
+ passphrase?: string;
95
+ network?: 'mainnet' | 'testnet';
96
+ rpcUrl?: string;
97
+ sponsored?: boolean;
98
+ name?: string;
99
+ }
100
+ interface GasReserve {
101
+ sui: number;
102
+ usdEquiv: number;
103
+ }
104
+ interface BalanceResponse {
105
+ available: number;
106
+ savings: number;
107
+ gasReserve: GasReserve;
108
+ total: number;
109
+ assets: Record<string, number>;
110
+ }
111
+ type GasMethod = 'self-funded' | 'sponsored' | 'auto-topup';
112
+ interface SendResult {
113
+ success: boolean;
114
+ tx: string;
115
+ amount: number;
116
+ to: string;
117
+ gasCost: number;
118
+ gasCostUnit: string;
119
+ gasMethod: GasMethod;
120
+ balance: BalanceResponse;
121
+ }
122
+ interface SaveResult {
123
+ success: boolean;
124
+ tx: string;
125
+ amount: number;
126
+ apy: number;
127
+ fee: number;
128
+ gasCost: number;
129
+ gasMethod: GasMethod;
130
+ savingsBalance: number;
131
+ }
132
+ interface WithdrawResult {
133
+ success: boolean;
134
+ tx: string;
135
+ amount: number;
136
+ gasCost: number;
137
+ gasMethod: GasMethod;
138
+ }
139
+ interface BorrowResult {
140
+ success: boolean;
141
+ tx: string;
142
+ amount: number;
143
+ fee: number;
144
+ healthFactor: number;
145
+ gasCost: number;
146
+ gasMethod: GasMethod;
147
+ }
148
+ interface RepayResult {
149
+ success: boolean;
150
+ tx: string;
151
+ amount: number;
152
+ remainingDebt: number;
153
+ gasCost: number;
154
+ gasMethod: GasMethod;
155
+ }
156
+ interface SwapResult {
157
+ success: boolean;
158
+ tx: string;
159
+ fromAmount: number;
160
+ fromAsset: string;
161
+ toAmount: number;
162
+ toAsset: string;
163
+ priceImpact: number;
164
+ fee: number;
165
+ gasCost: number;
166
+ gasMethod: GasMethod;
167
+ }
168
+ interface HealthFactorResult {
169
+ healthFactor: number;
170
+ supplied: number;
171
+ borrowed: number;
172
+ maxBorrow: number;
173
+ liquidationThreshold: number;
174
+ }
175
+ interface MaxWithdrawResult {
176
+ maxAmount: number;
177
+ healthFactorAfter: number;
178
+ currentHF: number;
179
+ }
180
+ interface MaxBorrowResult {
181
+ maxAmount: number;
182
+ healthFactorAfter: number;
183
+ currentHF: number;
184
+ }
185
+ interface RatesResult {
186
+ USDC: {
187
+ saveApy: number;
188
+ borrowApy: number;
189
+ };
190
+ }
191
+ interface PositionEntry {
192
+ protocol: string;
193
+ asset: string;
194
+ type: 'save' | 'borrow';
195
+ amount: number;
196
+ apy: number;
197
+ }
198
+ interface PositionsResult {
199
+ positions: PositionEntry[];
200
+ }
201
+ interface EarningsResult {
202
+ totalYieldEarned: number;
203
+ currentApy: number;
204
+ dailyEarning: number;
205
+ supplied: number;
206
+ }
207
+ interface FundStatusResult {
208
+ supplied: number;
209
+ apy: number;
210
+ earnedToday: number;
211
+ earnedAllTime: number;
212
+ projectedMonthly: number;
213
+ }
214
+ interface DepositInfo {
215
+ address: string;
216
+ network: string;
217
+ supportedAssets: string[];
218
+ instructions: string;
219
+ }
220
+ interface TransactionRecord {
221
+ digest: string;
222
+ action: string;
223
+ amount?: number;
224
+ asset?: string;
225
+ timestamp: number;
226
+ gasMethod?: GasMethod;
227
+ }
228
+ interface SentinelAgent {
229
+ id: string;
230
+ objectId: string;
231
+ name: string;
232
+ model: string;
233
+ systemPrompt: string;
234
+ attackFee: bigint;
235
+ prizePool: bigint;
236
+ totalAttacks: number;
237
+ successfulBreaches: number;
238
+ state: string;
239
+ }
240
+ interface SentinelVerdict {
241
+ success: boolean;
242
+ score: number;
243
+ agentResponse: string;
244
+ juryResponse: string;
245
+ funResponse: string;
246
+ signature: string;
247
+ timestampMs: number;
248
+ }
249
+ interface SentinelAttackResult {
250
+ attackObjectId: string;
251
+ sentinelId: string;
252
+ prompt: string;
253
+ verdict: SentinelVerdict;
254
+ requestTx: string;
255
+ settleTx: string;
256
+ won: boolean;
257
+ feePaid: number;
258
+ }
259
+
260
+ declare class ProtocolRegistry {
261
+ private lending;
262
+ private swap;
263
+ registerLending(adapter: LendingAdapter): void;
264
+ registerSwap(adapter: SwapAdapter): void;
265
+ bestSaveRate(asset: string): Promise<{
266
+ adapter: LendingAdapter;
267
+ rate: LendingRates;
268
+ }>;
269
+ bestBorrowRate(asset: string, opts?: {
270
+ requireSameAssetBorrow?: boolean;
271
+ }): Promise<{
272
+ adapter: LendingAdapter;
273
+ rate: LendingRates;
274
+ }>;
275
+ bestSwapQuote(from: string, to: string, amount: number): Promise<{
276
+ adapter: SwapAdapter;
277
+ quote: SwapQuote;
278
+ }>;
279
+ allRates(asset: string): Promise<Array<{
280
+ protocol: string;
281
+ protocolId: string;
282
+ rates: LendingRates;
283
+ }>>;
284
+ allPositions(address: string): Promise<Array<{
285
+ protocol: string;
286
+ protocolId: string;
287
+ positions: AdapterPositions;
288
+ }>>;
289
+ getLending(id: string): LendingAdapter | undefined;
290
+ getSwap(id: string): SwapAdapter | undefined;
291
+ listLending(): LendingAdapter[];
292
+ listSwap(): SwapAdapter[];
293
+ }
294
+
295
+ declare class NaviAdapter implements LendingAdapter {
296
+ readonly id = "navi";
297
+ readonly name = "NAVI Protocol";
298
+ readonly version = "1.0.0";
299
+ readonly capabilities: readonly AdapterCapability[];
300
+ readonly supportedAssets: readonly string[];
301
+ readonly supportsSameAssetBorrow = true;
302
+ private client;
303
+ init(client: SuiClient): Promise<void>;
304
+ initSync(client: SuiClient): void;
305
+ getRates(asset: string): Promise<LendingRates>;
306
+ getPositions(address: string): Promise<AdapterPositions>;
307
+ getHealth(address: string): Promise<HealthInfo>;
308
+ buildSaveTx(address: string, amount: number, _asset: string, options?: {
309
+ collectFee?: boolean;
310
+ }): Promise<AdapterTxResult>;
311
+ buildWithdrawTx(address: string, amount: number, _asset: string): Promise<AdapterTxResult & {
312
+ effectiveAmount: number;
313
+ }>;
314
+ buildBorrowTx(address: string, amount: number, _asset: string, options?: {
315
+ collectFee?: boolean;
316
+ }): Promise<AdapterTxResult>;
317
+ buildRepayTx(address: string, amount: number, _asset: string): Promise<AdapterTxResult>;
318
+ maxWithdraw(address: string, _asset: string): Promise<MaxWithdrawResult>;
319
+ maxBorrow(address: string, _asset: string): Promise<MaxBorrowResult>;
320
+ }
321
+
322
+ declare class CetusAdapter implements SwapAdapter {
323
+ readonly id = "cetus";
324
+ readonly name = "Cetus";
325
+ readonly version = "1.0.0";
326
+ readonly capabilities: readonly AdapterCapability[];
327
+ private client;
328
+ init(client: SuiClient): Promise<void>;
329
+ initSync(client: SuiClient): void;
330
+ getQuote(from: string, to: string, amount: number): Promise<SwapQuote>;
331
+ buildSwapTx(address: string, from: string, to: string, amount: number, maxSlippageBps?: number): Promise<AdapterTxResult & {
332
+ estimatedOut: number;
333
+ toDecimals: number;
334
+ }>;
335
+ getSupportedPairs(): Array<{
336
+ from: string;
337
+ to: string;
338
+ }>;
339
+ getPoolPrice(): Promise<number>;
340
+ }
341
+
342
+ /**
343
+ * Suilend adapter — save + withdraw for USDC.
344
+ * Borrow/repay deferred to Phase 10 (requires multi-stable support).
345
+ *
346
+ * Uses the @suilend/sdk package (optional peer dependency). Users must
347
+ * install it separately: `npm install @suilend/sdk@^1`
348
+ *
349
+ * @see https://docs.suilend.fi/ecosystem/suilend-sdk-guide
350
+ */
351
+ declare class SuilendAdapter implements LendingAdapter {
352
+ readonly id = "suilend";
353
+ readonly name = "Suilend";
354
+ readonly version = "1.0.0";
355
+ readonly capabilities: readonly AdapterCapability[];
356
+ readonly supportedAssets: readonly string[];
357
+ readonly supportsSameAssetBorrow = false;
358
+ private client;
359
+ private suilend;
360
+ private lendingMarketType;
361
+ private initialized;
362
+ init(client: SuiClient): Promise<void>;
363
+ private ensureInit;
364
+ private findReserve;
365
+ private getObligationCaps;
366
+ private resolveSymbol;
367
+ getRates(asset: string): Promise<LendingRates>;
368
+ getPositions(address: string): Promise<AdapterPositions>;
369
+ getHealth(address: string): Promise<HealthInfo>;
370
+ buildSaveTx(address: string, amount: number, _asset: string, options?: {
371
+ collectFee?: boolean;
372
+ }): Promise<AdapterTxResult>;
373
+ buildWithdrawTx(address: string, amount: number, _asset: string): Promise<AdapterTxResult & {
374
+ effectiveAmount: number;
375
+ }>;
376
+ buildBorrowTx(_address: string, _amount: number, _asset: string, _options?: {
377
+ collectFee?: boolean;
378
+ }): Promise<AdapterTxResult>;
379
+ buildRepayTx(_address: string, _amount: number, _asset: string): Promise<AdapterTxResult>;
380
+ maxWithdraw(address: string, _asset: string): Promise<{
381
+ maxAmount: number;
382
+ healthFactorAfter: number;
383
+ currentHF: number;
384
+ }>;
385
+ maxBorrow(_address: string, _asset: string): Promise<{
386
+ maxAmount: number;
387
+ healthFactorAfter: number;
388
+ currentHF: number;
389
+ }>;
390
+ private fetchAllCoins;
391
+ }
392
+
393
+ export { type AdapterCapability as A, type BalanceResponse as B, CetusAdapter as C, type DepositInfo as D, type EarningsResult as E, type FundStatusResult as F, type GasMethod as G, type HealthFactorResult as H, type LendingAdapter as L, type MaxWithdrawResult as M, NaviAdapter as N, type PositionsResult as P, type RepayResult as R, type SendResult as S, type T2000Options as T, type WithdrawResult as W, type TransactionRecord as a, type SwapAdapter as b, type SaveResult as c, type BorrowResult as d, type MaxBorrowResult as e, type SwapResult as f, type RatesResult as g, type LendingRates as h, type SentinelAgent as i, type SentinelAttackResult as j, type SentinelVerdict as k, type AdapterPositions as l, type AdapterTxResult as m, type GasReserve as n, type HealthInfo as o, type PositionEntry as p, ProtocolRegistry as q, SuilendAdapter as r, type SwapQuote as s };