@t2000/sdk 0.19.24 → 0.20.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 +34 -150
- package/dist/adapters/descriptors.cjs +1 -42
- package/dist/adapters/descriptors.cjs.map +1 -1
- package/dist/adapters/descriptors.d.cts +1 -1
- package/dist/adapters/descriptors.d.ts +1 -1
- package/dist/adapters/descriptors.js +2 -41
- package/dist/adapters/descriptors.js.map +1 -1
- package/dist/adapters/index.cjs +3 -745
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +4 -171
- package/dist/adapters/index.d.ts +4 -171
- package/dist/adapters/index.js +4 -742
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.js +20 -178
- package/dist/browser.js.map +1 -1
- package/dist/descriptors-Be4FAgN5.d.cts +127 -0
- package/dist/descriptors-Be4FAgN5.d.ts +127 -0
- package/dist/index-D1DxZ1DK.d.ts +292 -0
- package/dist/index-MP_J_nSO.d.cts +292 -0
- package/dist/index.cjs +680 -3461
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -313
- package/dist/index.d.ts +34 -313
- package/dist/index.js +592 -3360
- package/dist/index.js.map +1 -1
- package/package.json +5 -8
- package/dist/descriptors-B6qt_mwi.d.cts +0 -584
- package/dist/descriptors-B6qt_mwi.d.ts +0 -584
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { I as InvestmentRecord, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, P as PayOptions, b as PayResult, c as SendResult, B as BalanceResponse, d as TransactionRecord, D as DepositInfo, L as LendingAdapter, e as SwapAdapter, f as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, g as BorrowResult, R as RepayResult, h as MaxBorrowResult, H as HealthFactorResult, i as SwapResult, j as InvestResult, k as InvestEarnResult, l as InvestRebalanceResult, m as PendingReward, C as ClaimRewardsResult, n as StrategyBuyResult, o as StrategySellResult, p as StrategyRebalanceResult, q as StrategyStatusResult, r as AutoInvestRunResult, s as PortfolioResult, t as InvestmentPosition, u as PositionsResult, v as RatesResult, w as LendingRates, x as RebalanceResult, E as EarningsResult, F as FundStatusResult, G as GasMethod } from './descriptors-B6qt_mwi.js';
|
|
2
|
-
export { y as AdapterCapability, z as AdapterPositions, J as AdapterTxResult, K as AssetRates, N as GasReserve, O as HealthInfo, Q as InvestRebalanceMove, U as PerpsAdapter, V as PerpsPosition, X as PerpsPositionsResult, Y as PerpsTradeResult, Z as PositionEntry, _ as PositionSide, $ as ProtocolDescriptor, a0 as RebalanceStep, a1 as SwapQuote, a2 as allDescriptors, a3 as cetusDescriptor, a4 as naviDescriptor, a5 as suilendDescriptor } from './descriptors-B6qt_mwi.js';
|
|
3
1
|
import { EventEmitter } from 'eventemitter3';
|
|
4
2
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
5
3
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
+
import { L as LendingAdapter, a as LendingRates } from './descriptors-Be4FAgN5.js';
|
|
5
|
+
export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H as HealthInfo, P as ProtocolDescriptor, d as allDescriptors, n as naviDescriptor } from './descriptors-Be4FAgN5.js';
|
|
6
|
+
import { T as T2000Options, P as PayOptions, a as PayResult, S as StakeVSuiResult, U as UnstakeVSuiResult, b as SwapResult, c as SwapQuoteResult, d as SendResult, B as BalanceResponse, e as TransactionRecord, D as DepositInfo, f as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, g as BorrowResult, R as RepayResult, h as MaxBorrowResult, H as HealthFactorResult, i as PendingReward, C as ClaimRewardsResult, j as PositionsResult, k as RatesResult, E as EarningsResult, F as FundStatusResult, G as GasMethod } from './index-D1DxZ1DK.js';
|
|
7
|
+
export { A as AssetRates, l as GasReserve, N as NaviAdapter, m as PositionEntry, n as ProtocolRegistry } from './index-D1DxZ1DK.js';
|
|
6
8
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
7
|
-
export { CetusAdapter, NaviAdapter, ProtocolRegistry, SuilendAdapter } from './adapters/index.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Abstract signing interface that decouples the SDK from any specific
|
|
@@ -43,7 +44,7 @@ declare class ZkLoginSigner implements TransactionSigner {
|
|
|
43
44
|
isExpired(currentEpoch: number): boolean;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SPONSOR_FAILED' | 'SPONSOR_RATE_LIMITED' | 'USDC_SPONSOR_FAILED' | 'USDC_SPONSOR_RATE_LIMITED' | 'GAS_STATION_UNAVAILABLE' | 'GAS_FEE_EXCEEDED' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | '
|
|
47
|
+
type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SPONSOR_FAILED' | 'SPONSOR_RATE_LIMITED' | 'USDC_SPONSOR_FAILED' | 'USDC_SPONSOR_RATE_LIMITED' | 'GAS_STATION_UNAVAILABLE' | 'GAS_FEE_EXCEEDED' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'WITHDRAW_FAILED' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'SPONSOR_UNAVAILABLE' | 'AUTO_TOPUP_FAILED' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'CONTACT_NOT_FOUND' | 'INVALID_CONTACT_NAME' | 'FACILITATOR_TIMEOUT' | 'SAFEGUARD_BLOCKED' | 'SWAP_NO_ROUTE' | 'SWAP_FAILED' | 'UNKNOWN';
|
|
47
48
|
interface T2000ErrorData {
|
|
48
49
|
reason?: string;
|
|
49
50
|
[key: string]: unknown;
|
|
@@ -99,111 +100,12 @@ declare const SUPPORTED_ASSETS: {
|
|
|
99
100
|
readonly symbol: "SUI";
|
|
100
101
|
readonly displayName: "SUI";
|
|
101
102
|
};
|
|
102
|
-
readonly BTC: {
|
|
103
|
-
readonly type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC";
|
|
104
|
-
readonly decimals: 8;
|
|
105
|
-
readonly symbol: "BTC";
|
|
106
|
-
readonly displayName: "Bitcoin";
|
|
107
|
-
};
|
|
108
|
-
readonly ETH: {
|
|
109
|
-
readonly type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH";
|
|
110
|
-
readonly decimals: 8;
|
|
111
|
-
readonly symbol: "ETH";
|
|
112
|
-
readonly displayName: "Ethereum";
|
|
113
|
-
};
|
|
114
|
-
readonly GOLD: {
|
|
115
|
-
readonly type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM";
|
|
116
|
-
readonly decimals: 9;
|
|
117
|
-
readonly symbol: "GOLD";
|
|
118
|
-
readonly displayName: "Gold";
|
|
119
|
-
};
|
|
120
103
|
};
|
|
121
104
|
type SupportedAsset = keyof typeof SUPPORTED_ASSETS;
|
|
122
|
-
type StableAsset = Exclude<SupportedAsset, 'SUI'
|
|
105
|
+
type StableAsset = Exclude<SupportedAsset, 'SUI'>;
|
|
123
106
|
declare const STABLE_ASSETS: readonly StableAsset[];
|
|
124
107
|
declare const DEFAULT_NETWORK: "mainnet";
|
|
125
|
-
declare const
|
|
126
|
-
readonly SUI: {
|
|
127
|
-
readonly type: "0x2::sui::SUI";
|
|
128
|
-
readonly decimals: 9;
|
|
129
|
-
readonly symbol: "SUI";
|
|
130
|
-
readonly displayName: "SUI";
|
|
131
|
-
};
|
|
132
|
-
readonly BTC: {
|
|
133
|
-
readonly type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC";
|
|
134
|
-
readonly decimals: 8;
|
|
135
|
-
readonly symbol: "BTC";
|
|
136
|
-
readonly displayName: "Bitcoin";
|
|
137
|
-
};
|
|
138
|
-
readonly ETH: {
|
|
139
|
-
readonly type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH";
|
|
140
|
-
readonly decimals: 8;
|
|
141
|
-
readonly symbol: "ETH";
|
|
142
|
-
readonly displayName: "Ethereum";
|
|
143
|
-
};
|
|
144
|
-
readonly GOLD: {
|
|
145
|
-
readonly type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM";
|
|
146
|
-
readonly decimals: 9;
|
|
147
|
-
readonly symbol: "GOLD";
|
|
148
|
-
readonly displayName: "Gold";
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
type InvestmentAsset = keyof typeof INVESTMENT_ASSETS;
|
|
152
|
-
declare const DEFAULT_STRATEGIES: {
|
|
153
|
-
readonly bluechip: {
|
|
154
|
-
readonly name: "Bluechip / Large-Cap";
|
|
155
|
-
readonly allocations: {
|
|
156
|
-
readonly BTC: 50;
|
|
157
|
-
readonly ETH: 30;
|
|
158
|
-
readonly SUI: 20;
|
|
159
|
-
};
|
|
160
|
-
readonly description: "Large-cap crypto index";
|
|
161
|
-
readonly custom: false;
|
|
162
|
-
};
|
|
163
|
-
readonly layer1: {
|
|
164
|
-
readonly name: "Smart Contract Platforms";
|
|
165
|
-
readonly allocations: {
|
|
166
|
-
readonly ETH: 50;
|
|
167
|
-
readonly SUI: 50;
|
|
168
|
-
};
|
|
169
|
-
readonly description: "Smart contract platforms";
|
|
170
|
-
readonly custom: false;
|
|
171
|
-
};
|
|
172
|
-
readonly 'sui-heavy': {
|
|
173
|
-
readonly name: "Sui-Weighted Portfolio";
|
|
174
|
-
readonly allocations: {
|
|
175
|
-
readonly BTC: 20;
|
|
176
|
-
readonly ETH: 20;
|
|
177
|
-
readonly SUI: 60;
|
|
178
|
-
};
|
|
179
|
-
readonly description: "Sui-weighted portfolio";
|
|
180
|
-
readonly custom: false;
|
|
181
|
-
};
|
|
182
|
-
readonly 'all-weather': {
|
|
183
|
-
readonly name: "All-Weather Portfolio";
|
|
184
|
-
readonly allocations: {
|
|
185
|
-
readonly BTC: 30;
|
|
186
|
-
readonly ETH: 20;
|
|
187
|
-
readonly SUI: 20;
|
|
188
|
-
readonly GOLD: 30;
|
|
189
|
-
};
|
|
190
|
-
readonly description: "Crypto and commodities";
|
|
191
|
-
readonly custom: false;
|
|
192
|
-
};
|
|
193
|
-
readonly 'safe-haven': {
|
|
194
|
-
readonly name: "Safe Haven";
|
|
195
|
-
readonly allocations: {
|
|
196
|
-
readonly BTC: 50;
|
|
197
|
-
readonly GOLD: 50;
|
|
198
|
-
};
|
|
199
|
-
readonly description: "Store-of-value assets";
|
|
200
|
-
readonly custom: false;
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
declare const PERPS_MARKETS: readonly ["SUI-PERP"];
|
|
204
|
-
type PerpsMarket = (typeof PERPS_MARKETS)[number];
|
|
205
|
-
declare const DEFAULT_MAX_LEVERAGE = 5;
|
|
206
|
-
declare const DEFAULT_MAX_POSITION_SIZE = 1000;
|
|
108
|
+
declare const CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
|
|
207
109
|
declare const GAS_RESERVE_MIN = 0.05;
|
|
208
110
|
|
|
209
111
|
interface SafeguardConfig {
|
|
@@ -216,10 +118,10 @@ interface SafeguardConfig {
|
|
|
216
118
|
maxPositionSize?: number;
|
|
217
119
|
}
|
|
218
120
|
interface TxMetadata {
|
|
219
|
-
operation: 'send' | 'save' | 'withdraw' | 'borrow' | 'repay' | '
|
|
121
|
+
operation: 'send' | 'save' | 'withdraw' | 'borrow' | 'repay' | 'pay';
|
|
220
122
|
amount?: number;
|
|
221
123
|
}
|
|
222
|
-
declare const OUTBOUND_OPS: Set<"save" | "borrow" | "
|
|
124
|
+
declare const OUTBOUND_OPS: Set<"save" | "borrow" | "send" | "withdraw" | "repay" | "pay">;
|
|
223
125
|
declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
|
|
224
126
|
|
|
225
127
|
declare class SafeguardEnforcer {
|
|
@@ -243,7 +145,6 @@ interface Contact {
|
|
|
243
145
|
name: string;
|
|
244
146
|
address: string;
|
|
245
147
|
}
|
|
246
|
-
type ContactMap = Record<string, Contact>;
|
|
247
148
|
declare class ContactManager {
|
|
248
149
|
private contacts;
|
|
249
150
|
private readonly filePath;
|
|
@@ -264,90 +165,6 @@ declare class ContactManager {
|
|
|
264
165
|
private validateName;
|
|
265
166
|
}
|
|
266
167
|
|
|
267
|
-
interface StoredPosition {
|
|
268
|
-
totalAmount: number;
|
|
269
|
-
costBasis: number;
|
|
270
|
-
avgPrice: number;
|
|
271
|
-
trades: InvestmentRecord[];
|
|
272
|
-
earning?: boolean;
|
|
273
|
-
earningProtocol?: string;
|
|
274
|
-
earningApy?: number;
|
|
275
|
-
}
|
|
276
|
-
declare class PortfolioManager {
|
|
277
|
-
private data;
|
|
278
|
-
private readonly filePath;
|
|
279
|
-
private readonly dir;
|
|
280
|
-
constructor(configDir?: string);
|
|
281
|
-
private load;
|
|
282
|
-
private save;
|
|
283
|
-
recordBuy(trade: InvestmentRecord): void;
|
|
284
|
-
recordSell(trade: InvestmentRecord): number;
|
|
285
|
-
getPosition(asset: string): StoredPosition | undefined;
|
|
286
|
-
getPositions(): Array<{
|
|
287
|
-
asset: string;
|
|
288
|
-
} & StoredPosition>;
|
|
289
|
-
recordEarn(asset: string, protocol: string, apy: number): void;
|
|
290
|
-
recordUnearn(asset: string): void;
|
|
291
|
-
getStrategyAmountForAsset(asset: string): number;
|
|
292
|
-
getDirectAmount(asset: string): number;
|
|
293
|
-
deductFromStrategies(asset: string, amount: number): void;
|
|
294
|
-
closePosition(asset: string): void;
|
|
295
|
-
isEarning(asset: string): boolean;
|
|
296
|
-
getRealizedPnL(): number;
|
|
297
|
-
recordStrategyBuy(strategyKey: string, trade: InvestmentRecord): void;
|
|
298
|
-
recordStrategySell(strategyKey: string, trade: InvestmentRecord): number;
|
|
299
|
-
getStrategyPositions(strategyKey: string): Array<{
|
|
300
|
-
asset: string;
|
|
301
|
-
} & StoredPosition>;
|
|
302
|
-
getAllStrategyKeys(): string[];
|
|
303
|
-
clearStrategy(strategyKey: string): void;
|
|
304
|
-
hasStrategyPositions(strategyKey: string): boolean;
|
|
305
|
-
closeStrategyPosition(strategyKey: string, asset: string): void;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
declare class StrategyManager {
|
|
309
|
-
private data;
|
|
310
|
-
private readonly filePath;
|
|
311
|
-
private readonly dir;
|
|
312
|
-
private seeded;
|
|
313
|
-
constructor(configDir?: string);
|
|
314
|
-
private load;
|
|
315
|
-
private save;
|
|
316
|
-
private seedDefaults;
|
|
317
|
-
getAll(): Record<string, StrategyDefinition>;
|
|
318
|
-
get(name: string): StrategyDefinition;
|
|
319
|
-
create(params: {
|
|
320
|
-
name: string;
|
|
321
|
-
allocations: Record<string, number>;
|
|
322
|
-
description?: string;
|
|
323
|
-
}): StrategyDefinition;
|
|
324
|
-
delete(name: string): void;
|
|
325
|
-
validateAllocations(allocations: Record<string, number>): void;
|
|
326
|
-
validateMinAmount(allocations: Record<string, number>, totalUsd: number): void;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
declare class AutoInvestManager {
|
|
330
|
-
private data;
|
|
331
|
-
private readonly filePath;
|
|
332
|
-
private readonly dir;
|
|
333
|
-
constructor(configDir?: string);
|
|
334
|
-
private load;
|
|
335
|
-
private save;
|
|
336
|
-
setup(params: {
|
|
337
|
-
amount: number;
|
|
338
|
-
frequency: 'daily' | 'weekly' | 'monthly';
|
|
339
|
-
strategy?: string;
|
|
340
|
-
asset?: string;
|
|
341
|
-
dayOfWeek?: number;
|
|
342
|
-
dayOfMonth?: number;
|
|
343
|
-
}): AutoInvestSchedule;
|
|
344
|
-
getStatus(): AutoInvestStatus;
|
|
345
|
-
getSchedule(id: string): AutoInvestSchedule;
|
|
346
|
-
recordRun(id: string, amountInvested: number): void;
|
|
347
|
-
stop(id: string): void;
|
|
348
|
-
remove(id: string): void;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
168
|
interface T2000Events {
|
|
352
169
|
balanceChange: (event: {
|
|
353
170
|
asset: string;
|
|
@@ -391,9 +208,6 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
391
208
|
private readonly registry;
|
|
392
209
|
readonly enforcer: SafeguardEnforcer;
|
|
393
210
|
readonly contacts: ContactManager;
|
|
394
|
-
readonly portfolio: PortfolioManager;
|
|
395
|
-
readonly strategies: StrategyManager;
|
|
396
|
-
readonly autoInvest: AutoInvestManager;
|
|
397
211
|
private constructor();
|
|
398
212
|
private constructor();
|
|
399
213
|
private static createDefaultRegistry;
|
|
@@ -421,6 +235,25 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
421
235
|
/** Transaction signer (works for both keypair and zkLogin). */
|
|
422
236
|
get signer(): TransactionSigner;
|
|
423
237
|
pay(options: PayOptions): Promise<PayResult>;
|
|
238
|
+
stakeVSui(params: {
|
|
239
|
+
amount: number;
|
|
240
|
+
}): Promise<StakeVSuiResult>;
|
|
241
|
+
unstakeVSui(params: {
|
|
242
|
+
amount: number | 'all';
|
|
243
|
+
}): Promise<UnstakeVSuiResult>;
|
|
244
|
+
swap(params: {
|
|
245
|
+
from: string;
|
|
246
|
+
to: string;
|
|
247
|
+
amount: number;
|
|
248
|
+
byAmountIn?: boolean;
|
|
249
|
+
slippage?: number;
|
|
250
|
+
}): Promise<SwapResult>;
|
|
251
|
+
swapQuote(params: {
|
|
252
|
+
from: string;
|
|
253
|
+
to: string;
|
|
254
|
+
amount: number;
|
|
255
|
+
byAmountIn?: boolean;
|
|
256
|
+
}): Promise<SwapQuoteResult>;
|
|
424
257
|
address(): string;
|
|
425
258
|
send(params: {
|
|
426
259
|
to: string;
|
|
@@ -434,7 +267,6 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
434
267
|
transactionDetail(digest: string): Promise<TransactionRecord | null>;
|
|
435
268
|
deposit(): Promise<DepositInfo>;
|
|
436
269
|
exportKey(): string;
|
|
437
|
-
/** Create a T2000 instance from zkLogin credentials (for web app). */
|
|
438
270
|
static fromZkLogin(opts: {
|
|
439
271
|
ephemeralKeypair: Ed25519Keypair;
|
|
440
272
|
zkProof: ZkLoginProof;
|
|
@@ -442,30 +274,23 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
442
274
|
maxEpoch: number;
|
|
443
275
|
rpcUrl?: string;
|
|
444
276
|
}): T2000;
|
|
445
|
-
registerAdapter(adapter: LendingAdapter
|
|
277
|
+
registerAdapter(adapter: LendingAdapter): Promise<void>;
|
|
446
278
|
save(params: {
|
|
447
279
|
amount: number | 'all';
|
|
280
|
+
asset?: SupportedAsset;
|
|
448
281
|
protocol?: string;
|
|
449
282
|
}): Promise<SaveResult>;
|
|
450
283
|
withdraw(params: {
|
|
451
284
|
amount: number | 'all';
|
|
285
|
+
asset?: string;
|
|
452
286
|
protocol?: string;
|
|
453
287
|
}): Promise<WithdrawResult>;
|
|
454
288
|
private withdrawAllProtocols;
|
|
455
289
|
private _fetchCoins;
|
|
456
290
|
private _mergeCoinsInTx;
|
|
457
|
-
private _swapToUsdc;
|
|
458
|
-
private _swapFromUsdc;
|
|
459
|
-
/**
|
|
460
|
-
* Auto-withdraw from savings when checking balance is insufficient for an
|
|
461
|
-
* operation. Handles non-USDC savings (e.g. USDe) via the standard withdraw
|
|
462
|
-
* path which swaps back to USDC. Throws if savings are also insufficient.
|
|
463
|
-
*/
|
|
464
291
|
private _lastFundDigest;
|
|
465
292
|
private _autoFundFromSavings;
|
|
466
|
-
private _convertWalletStablesToUsdc;
|
|
467
293
|
maxWithdraw(): Promise<MaxWithdrawResult>;
|
|
468
|
-
private adjustMaxBorrowForInvestments;
|
|
469
294
|
borrow(params: {
|
|
470
295
|
amount: number;
|
|
471
296
|
protocol?: string;
|
|
@@ -477,99 +302,8 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
477
302
|
private _repayAllBorrows;
|
|
478
303
|
maxBorrow(): Promise<MaxBorrowResult>;
|
|
479
304
|
healthFactor(): Promise<HealthFactorResult>;
|
|
480
|
-
swap(params: {
|
|
481
|
-
from: string;
|
|
482
|
-
to: string;
|
|
483
|
-
amount: number;
|
|
484
|
-
maxSlippage?: number;
|
|
485
|
-
_skipPortfolioRecord?: boolean;
|
|
486
|
-
}): Promise<SwapResult>;
|
|
487
|
-
swapQuote(params: {
|
|
488
|
-
from: string;
|
|
489
|
-
to: string;
|
|
490
|
-
amount: number;
|
|
491
|
-
}): Promise<{
|
|
492
|
-
expectedOutput: number;
|
|
493
|
-
priceImpact: number;
|
|
494
|
-
poolPrice: number;
|
|
495
|
-
fee: {
|
|
496
|
-
amount: number;
|
|
497
|
-
rate: number;
|
|
498
|
-
};
|
|
499
|
-
}>;
|
|
500
|
-
/** @deprecated Use swap() instead */
|
|
501
|
-
exchange(params: {
|
|
502
|
-
from: string;
|
|
503
|
-
to: string;
|
|
504
|
-
amount: number;
|
|
505
|
-
maxSlippage?: number;
|
|
506
|
-
_bypassInvestmentGuard?: boolean;
|
|
507
|
-
}): Promise<SwapResult>;
|
|
508
|
-
/** @deprecated Use swapQuote() instead */
|
|
509
|
-
exchangeQuote(params: {
|
|
510
|
-
from: string;
|
|
511
|
-
to: string;
|
|
512
|
-
amount: number;
|
|
513
|
-
}): Promise<{
|
|
514
|
-
expectedOutput: number;
|
|
515
|
-
priceImpact: number;
|
|
516
|
-
poolPrice: number;
|
|
517
|
-
fee: {
|
|
518
|
-
amount: number;
|
|
519
|
-
rate: number;
|
|
520
|
-
};
|
|
521
|
-
}>;
|
|
522
|
-
investBuy(params: {
|
|
523
|
-
asset: InvestmentAsset;
|
|
524
|
-
usdAmount: number;
|
|
525
|
-
maxSlippage?: number;
|
|
526
|
-
}): Promise<InvestResult>;
|
|
527
|
-
investSell(params: {
|
|
528
|
-
asset: InvestmentAsset;
|
|
529
|
-
usdAmount: number | 'all';
|
|
530
|
-
maxSlippage?: number;
|
|
531
|
-
_strategyOnly?: boolean;
|
|
532
|
-
}): Promise<InvestResult>;
|
|
533
|
-
investEarn(params: {
|
|
534
|
-
asset: InvestmentAsset;
|
|
535
|
-
protocol?: string;
|
|
536
|
-
}): Promise<InvestEarnResult>;
|
|
537
|
-
investUnearn(params: {
|
|
538
|
-
asset: InvestmentAsset;
|
|
539
|
-
}): Promise<InvestEarnResult>;
|
|
540
|
-
investRebalance(opts?: {
|
|
541
|
-
dryRun?: boolean;
|
|
542
|
-
minYieldDiff?: number;
|
|
543
|
-
}): Promise<InvestRebalanceResult>;
|
|
544
305
|
getPendingRewards(): Promise<PendingReward[]>;
|
|
545
306
|
claimRewards(): Promise<ClaimRewardsResult>;
|
|
546
|
-
private swapRewardTokensToUsdc;
|
|
547
|
-
investStrategy(params: {
|
|
548
|
-
strategy: string;
|
|
549
|
-
usdAmount: number;
|
|
550
|
-
dryRun?: boolean;
|
|
551
|
-
}): Promise<StrategyBuyResult>;
|
|
552
|
-
sellStrategy(params: {
|
|
553
|
-
strategy: string;
|
|
554
|
-
}): Promise<StrategySellResult>;
|
|
555
|
-
rebalanceStrategy(params: {
|
|
556
|
-
strategy: string;
|
|
557
|
-
}): Promise<StrategyRebalanceResult>;
|
|
558
|
-
getStrategyStatus(name: string): Promise<StrategyStatusResult>;
|
|
559
|
-
setupAutoInvest(params: {
|
|
560
|
-
amount: number;
|
|
561
|
-
frequency: 'daily' | 'weekly' | 'monthly';
|
|
562
|
-
strategy?: string;
|
|
563
|
-
asset?: string;
|
|
564
|
-
dayOfWeek?: number;
|
|
565
|
-
dayOfMonth?: number;
|
|
566
|
-
}): AutoInvestSchedule;
|
|
567
|
-
getAutoInvestStatus(): AutoInvestStatus;
|
|
568
|
-
runAutoInvest(): Promise<AutoInvestRunResult>;
|
|
569
|
-
stopAutoInvest(id: string): void;
|
|
570
|
-
getPortfolio(): Promise<PortfolioResult & {
|
|
571
|
-
strategyPositions?: Record<string, InvestmentPosition[]>;
|
|
572
|
-
}>;
|
|
573
307
|
positions(): Promise<PositionsResult>;
|
|
574
308
|
rates(): Promise<RatesResult>;
|
|
575
309
|
allRates(asset?: string): Promise<{
|
|
@@ -583,14 +317,8 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
583
317
|
asset: string;
|
|
584
318
|
rates: LendingRates;
|
|
585
319
|
}[]>;
|
|
586
|
-
rebalance(opts?: {
|
|
587
|
-
dryRun?: boolean;
|
|
588
|
-
minYieldDiff?: number;
|
|
589
|
-
maxBreakEven?: number;
|
|
590
|
-
}): Promise<RebalanceResult>;
|
|
591
320
|
earnings(): Promise<EarningsResult>;
|
|
592
321
|
fundStatus(): Promise<FundStatusResult>;
|
|
593
|
-
private getFreeBalance;
|
|
594
322
|
private resolveLending;
|
|
595
323
|
private emitBalanceChange;
|
|
596
324
|
}
|
|
@@ -630,7 +358,7 @@ declare function getAddress(keypair: Ed25519Keypair): string;
|
|
|
630
358
|
|
|
631
359
|
declare function solveHashcash(challenge: string): string;
|
|
632
360
|
|
|
633
|
-
type FeeOperation = 'save' | '
|
|
361
|
+
type FeeOperation = 'save' | 'borrow';
|
|
634
362
|
interface ProtocolFeeInfo {
|
|
635
363
|
amount: number;
|
|
636
364
|
asset: string;
|
|
@@ -658,8 +386,6 @@ interface SimulationResult {
|
|
|
658
386
|
declare function simulateTransaction(client: SuiJsonRpcClient, tx: Transaction, sender: string): Promise<SimulationResult>;
|
|
659
387
|
declare function throwIfSimulationFailed(sim: SimulationResult): void;
|
|
660
388
|
|
|
661
|
-
declare function getPoolPrice(client: SuiJsonRpcClient): Promise<number>;
|
|
662
|
-
|
|
663
389
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
664
390
|
|
|
665
391
|
type SafeguardRule = 'locked' | 'maxPerTx' | 'maxDailySend';
|
|
@@ -715,12 +441,7 @@ interface AutoTopUpResult {
|
|
|
715
441
|
suiReceived: number;
|
|
716
442
|
}
|
|
717
443
|
declare function shouldAutoTopUp(client: SuiJsonRpcClient, address: string): Promise<boolean>;
|
|
718
|
-
|
|
719
|
-
* Swap USDC→SUI to replenish gas. Tries self-funding first; if the agent
|
|
720
|
-
* doesn't have enough SUI to pay for the swap itself, falls back to
|
|
721
|
-
* gas station sponsorship — eliminating the chicken-and-egg problem.
|
|
722
|
-
*/
|
|
723
|
-
declare function executeAutoTopUp(client: SuiJsonRpcClient, signer: TransactionSigner): Promise<AutoTopUpResult>;
|
|
444
|
+
declare function executeAutoTopUp(_client: SuiJsonRpcClient, _signer: TransactionSigner): Promise<AutoTopUpResult>;
|
|
724
445
|
|
|
725
446
|
type GasRequestType = 'bootstrap' | 'auto-topup' | 'fallback';
|
|
726
447
|
interface GasSponsorResponse {
|
|
@@ -737,4 +458,4 @@ interface GasStatusResponse {
|
|
|
737
458
|
}
|
|
738
459
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
739
460
|
|
|
740
|
-
export {
|
|
461
|
+
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CETUS_USDC_SUI_POOL, CLOCK_ID, ClaimRewardsResult, ContactManager, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, KeypairSigner, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PayOptions, PayResult, PendingReward, PositionsResult, type ProtocolFeeInfo, RatesResult, RepayResult, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, type SimulationResult, type StableAsset, StakeVSuiResult, type SupportedAsset, SwapQuoteResult, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TransactionSigner, type TxMetadata, USDC_DECIMALS, UnstakeVSuiResult, WithdrawResult, type ZkLoginProof, ZkLoginSigner, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|