@t2000/sdk 0.15.3 → 0.16.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.
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/{index-BykavuDO.d.cts → index-BOkO4S7r.d.cts} +87 -1
- package/dist/{index-BykavuDO.d.ts → index-BOkO4S7r.d.ts} +87 -1
- package/dist/index.cjs +602 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -5
- package/dist/index.d.ts +113 -5
- package/dist/index.js +601 -11
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/LICENSE +0 -21
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { I as InvestmentTrade, T as T2000Options,
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse, c as TransactionRecord, D as DepositInfo, L as LendingAdapter, d as SwapAdapter, e as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, f as BorrowResult, R as RepayResult, g as MaxBorrowResult, H as HealthFactorResult, h as SwapResult, i as InvestResult, j as InvestEarnResult, k as StrategyBuyResult, l as StrategySellResult, m as StrategyRebalanceResult, n as StrategyStatusResult, o as AutoInvestRunResult, P as PortfolioResult, p as InvestmentPosition, q as PositionsResult, r as RatesResult, s as LendingRates, t as RebalanceResult, E as EarningsResult, F as FundStatusResult, u as SentinelAgent, v as SentinelAttackResult, G as GasMethod } from './index-BOkO4S7r.cjs';
|
|
2
|
+
export { w as AdapterCapability, x as AdapterPositions, y as AdapterTxResult, z as AssetRates, C as CetusAdapter, J as GasReserve, K as HealthInfo, N as NaviAdapter, O as PerpsAdapter, Q as PerpsPosition, U as PositionEntry, V as PositionSide, X as ProtocolDescriptor, Y as ProtocolRegistry, Z as RebalanceStep, _ as SentinelVerdict, $ as SuilendAdapter, a0 as SwapQuote, a1 as TradePositionsResult, a2 as TradeResult, a3 as allDescriptors, a4 as cetusDescriptor, a5 as getSentinelInfo, a6 as listSentinels, a7 as naviDescriptor, a8 as requestAttack, a9 as sentinelAttack, aa as sentinelDescriptor, ab as settleAttack, ac as submitPrompt, ad as suilendDescriptor } from './index-BOkO4S7r.cjs';
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
5
5
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
6
6
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
7
7
|
|
|
8
|
-
type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SPONSOR_FAILED' | 'SPONSOR_RATE_LIMITED' | 'GAS_STATION_UNAVAILABLE' | 'GAS_FEE_EXCEEDED' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'SWAP_FAILED' | 'SLIPPAGE_EXCEEDED' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | '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' | 'SENTINEL_API_ERROR' | 'SENTINEL_NOT_FOUND' | 'SENTINEL_TX_FAILED' | 'SENTINEL_TEE_ERROR' | 'SAFEGUARD_BLOCKED' | 'INSUFFICIENT_INVESTMENT' | 'INVESTMENT_LOCKED' | 'INVEST_ALREADY_EARNING' | 'INVEST_NOT_EARNING' | 'BORROW_GUARD_INVESTMENT' | 'MARKET_NOT_SUPPORTED' | 'LEVERAGE_EXCEEDED' | 'POSITION_SIZE_EXCEEDED' | 'BLUEFIN_AUTH_FAILED' | 'BLUEFIN_API_ERROR' | 'POSITION_NOT_FOUND' | 'UNKNOWN';
|
|
8
|
+
type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SPONSOR_FAILED' | 'SPONSOR_RATE_LIMITED' | 'GAS_STATION_UNAVAILABLE' | 'GAS_FEE_EXCEEDED' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'SWAP_FAILED' | 'SLIPPAGE_EXCEEDED' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | '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' | 'SENTINEL_API_ERROR' | 'SENTINEL_NOT_FOUND' | 'SENTINEL_TX_FAILED' | 'SENTINEL_TEE_ERROR' | 'SAFEGUARD_BLOCKED' | 'INSUFFICIENT_INVESTMENT' | 'INVESTMENT_LOCKED' | 'INVEST_ALREADY_EARNING' | 'INVEST_NOT_EARNING' | 'BORROW_GUARD_INVESTMENT' | 'STRATEGY_NOT_FOUND' | 'STRATEGY_INVALID_ALLOCATIONS' | 'STRATEGY_HAS_POSITIONS' | 'STRATEGY_BUILTIN' | 'STRATEGY_MIN_AMOUNT' | 'AUTO_INVEST_NOT_FOUND' | 'AUTO_INVEST_INSUFFICIENT' | 'MARKET_NOT_SUPPORTED' | 'LEVERAGE_EXCEEDED' | 'POSITION_SIZE_EXCEEDED' | 'BLUEFIN_AUTH_FAILED' | 'BLUEFIN_API_ERROR' | 'POSITION_NOT_FOUND' | 'UNKNOWN';
|
|
9
9
|
interface T2000ErrorData {
|
|
10
10
|
reason?: string;
|
|
11
11
|
[key: string]: unknown;
|
|
@@ -97,6 +97,37 @@ declare const INVESTMENT_ASSETS: {
|
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
type InvestmentAsset = keyof typeof INVESTMENT_ASSETS;
|
|
100
|
+
declare const DEFAULT_STRATEGIES: {
|
|
101
|
+
readonly bluechip: {
|
|
102
|
+
readonly name: "Bluechip / Large-Cap";
|
|
103
|
+
readonly allocations: {
|
|
104
|
+
readonly BTC: 50;
|
|
105
|
+
readonly ETH: 30;
|
|
106
|
+
readonly SUI: 20;
|
|
107
|
+
};
|
|
108
|
+
readonly description: "Large-cap crypto index";
|
|
109
|
+
readonly custom: false;
|
|
110
|
+
};
|
|
111
|
+
readonly layer1: {
|
|
112
|
+
readonly name: "Smart Contract Platforms";
|
|
113
|
+
readonly allocations: {
|
|
114
|
+
readonly ETH: 50;
|
|
115
|
+
readonly SUI: 50;
|
|
116
|
+
};
|
|
117
|
+
readonly description: "Smart contract platforms";
|
|
118
|
+
readonly custom: false;
|
|
119
|
+
};
|
|
120
|
+
readonly 'sui-heavy': {
|
|
121
|
+
readonly name: "Sui-Weighted Portfolio";
|
|
122
|
+
readonly allocations: {
|
|
123
|
+
readonly BTC: 20;
|
|
124
|
+
readonly ETH: 20;
|
|
125
|
+
readonly SUI: 60;
|
|
126
|
+
};
|
|
127
|
+
readonly description: "Sui-weighted portfolio";
|
|
128
|
+
readonly custom: false;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
100
131
|
declare const PERPS_MARKETS: readonly ["SUI-PERP"];
|
|
101
132
|
type PerpsMarket = (typeof PERPS_MARKETS)[number];
|
|
102
133
|
declare const DEFAULT_MAX_LEVERAGE = 5;
|
|
@@ -198,6 +229,56 @@ declare class PortfolioManager {
|
|
|
198
229
|
recordUnearn(asset: string): void;
|
|
199
230
|
isEarning(asset: string): boolean;
|
|
200
231
|
getRealizedPnL(): number;
|
|
232
|
+
recordStrategyBuy(strategyKey: string, trade: InvestmentTrade): void;
|
|
233
|
+
recordStrategySell(strategyKey: string, trade: InvestmentTrade): number;
|
|
234
|
+
getStrategyPositions(strategyKey: string): Array<{
|
|
235
|
+
asset: string;
|
|
236
|
+
} & StoredPosition>;
|
|
237
|
+
getAllStrategyKeys(): string[];
|
|
238
|
+
hasStrategyPositions(strategyKey: string): boolean;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
declare class StrategyManager {
|
|
242
|
+
private data;
|
|
243
|
+
private readonly filePath;
|
|
244
|
+
private readonly dir;
|
|
245
|
+
private seeded;
|
|
246
|
+
constructor(configDir?: string);
|
|
247
|
+
private load;
|
|
248
|
+
private save;
|
|
249
|
+
private seedDefaults;
|
|
250
|
+
getAll(): Record<string, StrategyDefinition>;
|
|
251
|
+
get(name: string): StrategyDefinition;
|
|
252
|
+
create(params: {
|
|
253
|
+
name: string;
|
|
254
|
+
allocations: Record<string, number>;
|
|
255
|
+
description?: string;
|
|
256
|
+
}): StrategyDefinition;
|
|
257
|
+
delete(name: string): void;
|
|
258
|
+
validateAllocations(allocations: Record<string, number>): void;
|
|
259
|
+
validateMinAmount(allocations: Record<string, number>, totalUsd: number): void;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
declare class AutoInvestManager {
|
|
263
|
+
private data;
|
|
264
|
+
private readonly filePath;
|
|
265
|
+
private readonly dir;
|
|
266
|
+
constructor(configDir?: string);
|
|
267
|
+
private load;
|
|
268
|
+
private save;
|
|
269
|
+
setup(params: {
|
|
270
|
+
amount: number;
|
|
271
|
+
frequency: 'daily' | 'weekly' | 'monthly';
|
|
272
|
+
strategy?: string;
|
|
273
|
+
asset?: string;
|
|
274
|
+
dayOfWeek?: number;
|
|
275
|
+
dayOfMonth?: number;
|
|
276
|
+
}): AutoInvestSchedule;
|
|
277
|
+
getStatus(): AutoInvestStatus;
|
|
278
|
+
getSchedule(id: string): AutoInvestSchedule;
|
|
279
|
+
recordRun(id: string, amountInvested: number): void;
|
|
280
|
+
stop(id: string): void;
|
|
281
|
+
remove(id: string): void;
|
|
201
282
|
}
|
|
202
283
|
|
|
203
284
|
interface T2000Events {
|
|
@@ -243,6 +324,8 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
243
324
|
readonly enforcer: SafeguardEnforcer;
|
|
244
325
|
readonly contacts: ContactManager;
|
|
245
326
|
readonly portfolio: PortfolioManager;
|
|
327
|
+
readonly strategies: StrategyManager;
|
|
328
|
+
readonly autoInvest: AutoInvestManager;
|
|
246
329
|
private constructor();
|
|
247
330
|
private static createDefaultRegistry;
|
|
248
331
|
static create(options?: T2000Options): Promise<T2000>;
|
|
@@ -341,7 +424,32 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
341
424
|
investUnearn(params: {
|
|
342
425
|
asset: InvestmentAsset;
|
|
343
426
|
}): Promise<InvestEarnResult>;
|
|
344
|
-
|
|
427
|
+
investStrategy(params: {
|
|
428
|
+
strategy: string;
|
|
429
|
+
usdAmount: number;
|
|
430
|
+
dryRun?: boolean;
|
|
431
|
+
}): Promise<StrategyBuyResult>;
|
|
432
|
+
sellStrategy(params: {
|
|
433
|
+
strategy: string;
|
|
434
|
+
}): Promise<StrategySellResult>;
|
|
435
|
+
rebalanceStrategy(params: {
|
|
436
|
+
strategy: string;
|
|
437
|
+
}): Promise<StrategyRebalanceResult>;
|
|
438
|
+
getStrategyStatus(name: string): Promise<StrategyStatusResult>;
|
|
439
|
+
setupAutoInvest(params: {
|
|
440
|
+
amount: number;
|
|
441
|
+
frequency: 'daily' | 'weekly' | 'monthly';
|
|
442
|
+
strategy?: string;
|
|
443
|
+
asset?: string;
|
|
444
|
+
dayOfWeek?: number;
|
|
445
|
+
dayOfMonth?: number;
|
|
446
|
+
}): AutoInvestSchedule;
|
|
447
|
+
getAutoInvestStatus(): AutoInvestStatus;
|
|
448
|
+
runAutoInvest(): Promise<AutoInvestRunResult>;
|
|
449
|
+
stopAutoInvest(id: string): void;
|
|
450
|
+
getPortfolio(): Promise<PortfolioResult & {
|
|
451
|
+
strategyPositions?: Record<string, InvestmentPosition[]>;
|
|
452
|
+
}>;
|
|
345
453
|
positions(): Promise<PositionsResult>;
|
|
346
454
|
rates(): Promise<RatesResult>;
|
|
347
455
|
allRates(asset?: string): Promise<{
|
|
@@ -491,4 +599,4 @@ interface GasStatusResponse {
|
|
|
491
599
|
}
|
|
492
600
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
493
601
|
|
|
494
|
-
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestResult, type InvestmentAsset, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
602
|
+
export { AutoInvestManager, AutoInvestRunResult, AutoInvestSchedule, AutoInvestStatus, type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestResult, type InvestmentAsset, InvestmentPosition, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, StrategyBuyResult, StrategyDefinition, StrategyManager, StrategyRebalanceResult, StrategySellResult, StrategyStatusResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { I as InvestmentTrade, T as T2000Options,
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvestmentTrade, S as StrategyDefinition, A as AutoInvestSchedule, a as AutoInvestStatus, T as T2000Options, b as SendResult, B as BalanceResponse, c as TransactionRecord, D as DepositInfo, L as LendingAdapter, d as SwapAdapter, e as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, f as BorrowResult, R as RepayResult, g as MaxBorrowResult, H as HealthFactorResult, h as SwapResult, i as InvestResult, j as InvestEarnResult, k as StrategyBuyResult, l as StrategySellResult, m as StrategyRebalanceResult, n as StrategyStatusResult, o as AutoInvestRunResult, P as PortfolioResult, p as InvestmentPosition, q as PositionsResult, r as RatesResult, s as LendingRates, t as RebalanceResult, E as EarningsResult, F as FundStatusResult, u as SentinelAgent, v as SentinelAttackResult, G as GasMethod } from './index-BOkO4S7r.js';
|
|
2
|
+
export { w as AdapterCapability, x as AdapterPositions, y as AdapterTxResult, z as AssetRates, C as CetusAdapter, J as GasReserve, K as HealthInfo, N as NaviAdapter, O as PerpsAdapter, Q as PerpsPosition, U as PositionEntry, V as PositionSide, X as ProtocolDescriptor, Y as ProtocolRegistry, Z as RebalanceStep, _ as SentinelVerdict, $ as SuilendAdapter, a0 as SwapQuote, a1 as TradePositionsResult, a2 as TradeResult, a3 as allDescriptors, a4 as cetusDescriptor, a5 as getSentinelInfo, a6 as listSentinels, a7 as naviDescriptor, a8 as requestAttack, a9 as sentinelAttack, aa as sentinelDescriptor, ab as settleAttack, ac as submitPrompt, ad as suilendDescriptor } from './index-BOkO4S7r.js';
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
5
5
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
6
6
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
7
7
|
|
|
8
|
-
type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SPONSOR_FAILED' | 'SPONSOR_RATE_LIMITED' | 'GAS_STATION_UNAVAILABLE' | 'GAS_FEE_EXCEEDED' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'SWAP_FAILED' | 'SLIPPAGE_EXCEEDED' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | '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' | 'SENTINEL_API_ERROR' | 'SENTINEL_NOT_FOUND' | 'SENTINEL_TX_FAILED' | 'SENTINEL_TEE_ERROR' | 'SAFEGUARD_BLOCKED' | 'INSUFFICIENT_INVESTMENT' | 'INVESTMENT_LOCKED' | 'INVEST_ALREADY_EARNING' | 'INVEST_NOT_EARNING' | 'BORROW_GUARD_INVESTMENT' | 'MARKET_NOT_SUPPORTED' | 'LEVERAGE_EXCEEDED' | 'POSITION_SIZE_EXCEEDED' | 'BLUEFIN_AUTH_FAILED' | 'BLUEFIN_API_ERROR' | 'POSITION_NOT_FOUND' | 'UNKNOWN';
|
|
8
|
+
type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'SPONSOR_FAILED' | 'SPONSOR_RATE_LIMITED' | 'GAS_STATION_UNAVAILABLE' | 'GAS_FEE_EXCEEDED' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'SWAP_FAILED' | 'SLIPPAGE_EXCEEDED' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | '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' | 'SENTINEL_API_ERROR' | 'SENTINEL_NOT_FOUND' | 'SENTINEL_TX_FAILED' | 'SENTINEL_TEE_ERROR' | 'SAFEGUARD_BLOCKED' | 'INSUFFICIENT_INVESTMENT' | 'INVESTMENT_LOCKED' | 'INVEST_ALREADY_EARNING' | 'INVEST_NOT_EARNING' | 'BORROW_GUARD_INVESTMENT' | 'STRATEGY_NOT_FOUND' | 'STRATEGY_INVALID_ALLOCATIONS' | 'STRATEGY_HAS_POSITIONS' | 'STRATEGY_BUILTIN' | 'STRATEGY_MIN_AMOUNT' | 'AUTO_INVEST_NOT_FOUND' | 'AUTO_INVEST_INSUFFICIENT' | 'MARKET_NOT_SUPPORTED' | 'LEVERAGE_EXCEEDED' | 'POSITION_SIZE_EXCEEDED' | 'BLUEFIN_AUTH_FAILED' | 'BLUEFIN_API_ERROR' | 'POSITION_NOT_FOUND' | 'UNKNOWN';
|
|
9
9
|
interface T2000ErrorData {
|
|
10
10
|
reason?: string;
|
|
11
11
|
[key: string]: unknown;
|
|
@@ -97,6 +97,37 @@ declare const INVESTMENT_ASSETS: {
|
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
type InvestmentAsset = keyof typeof INVESTMENT_ASSETS;
|
|
100
|
+
declare const DEFAULT_STRATEGIES: {
|
|
101
|
+
readonly bluechip: {
|
|
102
|
+
readonly name: "Bluechip / Large-Cap";
|
|
103
|
+
readonly allocations: {
|
|
104
|
+
readonly BTC: 50;
|
|
105
|
+
readonly ETH: 30;
|
|
106
|
+
readonly SUI: 20;
|
|
107
|
+
};
|
|
108
|
+
readonly description: "Large-cap crypto index";
|
|
109
|
+
readonly custom: false;
|
|
110
|
+
};
|
|
111
|
+
readonly layer1: {
|
|
112
|
+
readonly name: "Smart Contract Platforms";
|
|
113
|
+
readonly allocations: {
|
|
114
|
+
readonly ETH: 50;
|
|
115
|
+
readonly SUI: 50;
|
|
116
|
+
};
|
|
117
|
+
readonly description: "Smart contract platforms";
|
|
118
|
+
readonly custom: false;
|
|
119
|
+
};
|
|
120
|
+
readonly 'sui-heavy': {
|
|
121
|
+
readonly name: "Sui-Weighted Portfolio";
|
|
122
|
+
readonly allocations: {
|
|
123
|
+
readonly BTC: 20;
|
|
124
|
+
readonly ETH: 20;
|
|
125
|
+
readonly SUI: 60;
|
|
126
|
+
};
|
|
127
|
+
readonly description: "Sui-weighted portfolio";
|
|
128
|
+
readonly custom: false;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
100
131
|
declare const PERPS_MARKETS: readonly ["SUI-PERP"];
|
|
101
132
|
type PerpsMarket = (typeof PERPS_MARKETS)[number];
|
|
102
133
|
declare const DEFAULT_MAX_LEVERAGE = 5;
|
|
@@ -198,6 +229,56 @@ declare class PortfolioManager {
|
|
|
198
229
|
recordUnearn(asset: string): void;
|
|
199
230
|
isEarning(asset: string): boolean;
|
|
200
231
|
getRealizedPnL(): number;
|
|
232
|
+
recordStrategyBuy(strategyKey: string, trade: InvestmentTrade): void;
|
|
233
|
+
recordStrategySell(strategyKey: string, trade: InvestmentTrade): number;
|
|
234
|
+
getStrategyPositions(strategyKey: string): Array<{
|
|
235
|
+
asset: string;
|
|
236
|
+
} & StoredPosition>;
|
|
237
|
+
getAllStrategyKeys(): string[];
|
|
238
|
+
hasStrategyPositions(strategyKey: string): boolean;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
declare class StrategyManager {
|
|
242
|
+
private data;
|
|
243
|
+
private readonly filePath;
|
|
244
|
+
private readonly dir;
|
|
245
|
+
private seeded;
|
|
246
|
+
constructor(configDir?: string);
|
|
247
|
+
private load;
|
|
248
|
+
private save;
|
|
249
|
+
private seedDefaults;
|
|
250
|
+
getAll(): Record<string, StrategyDefinition>;
|
|
251
|
+
get(name: string): StrategyDefinition;
|
|
252
|
+
create(params: {
|
|
253
|
+
name: string;
|
|
254
|
+
allocations: Record<string, number>;
|
|
255
|
+
description?: string;
|
|
256
|
+
}): StrategyDefinition;
|
|
257
|
+
delete(name: string): void;
|
|
258
|
+
validateAllocations(allocations: Record<string, number>): void;
|
|
259
|
+
validateMinAmount(allocations: Record<string, number>, totalUsd: number): void;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
declare class AutoInvestManager {
|
|
263
|
+
private data;
|
|
264
|
+
private readonly filePath;
|
|
265
|
+
private readonly dir;
|
|
266
|
+
constructor(configDir?: string);
|
|
267
|
+
private load;
|
|
268
|
+
private save;
|
|
269
|
+
setup(params: {
|
|
270
|
+
amount: number;
|
|
271
|
+
frequency: 'daily' | 'weekly' | 'monthly';
|
|
272
|
+
strategy?: string;
|
|
273
|
+
asset?: string;
|
|
274
|
+
dayOfWeek?: number;
|
|
275
|
+
dayOfMonth?: number;
|
|
276
|
+
}): AutoInvestSchedule;
|
|
277
|
+
getStatus(): AutoInvestStatus;
|
|
278
|
+
getSchedule(id: string): AutoInvestSchedule;
|
|
279
|
+
recordRun(id: string, amountInvested: number): void;
|
|
280
|
+
stop(id: string): void;
|
|
281
|
+
remove(id: string): void;
|
|
201
282
|
}
|
|
202
283
|
|
|
203
284
|
interface T2000Events {
|
|
@@ -243,6 +324,8 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
243
324
|
readonly enforcer: SafeguardEnforcer;
|
|
244
325
|
readonly contacts: ContactManager;
|
|
245
326
|
readonly portfolio: PortfolioManager;
|
|
327
|
+
readonly strategies: StrategyManager;
|
|
328
|
+
readonly autoInvest: AutoInvestManager;
|
|
246
329
|
private constructor();
|
|
247
330
|
private static createDefaultRegistry;
|
|
248
331
|
static create(options?: T2000Options): Promise<T2000>;
|
|
@@ -341,7 +424,32 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
341
424
|
investUnearn(params: {
|
|
342
425
|
asset: InvestmentAsset;
|
|
343
426
|
}): Promise<InvestEarnResult>;
|
|
344
|
-
|
|
427
|
+
investStrategy(params: {
|
|
428
|
+
strategy: string;
|
|
429
|
+
usdAmount: number;
|
|
430
|
+
dryRun?: boolean;
|
|
431
|
+
}): Promise<StrategyBuyResult>;
|
|
432
|
+
sellStrategy(params: {
|
|
433
|
+
strategy: string;
|
|
434
|
+
}): Promise<StrategySellResult>;
|
|
435
|
+
rebalanceStrategy(params: {
|
|
436
|
+
strategy: string;
|
|
437
|
+
}): Promise<StrategyRebalanceResult>;
|
|
438
|
+
getStrategyStatus(name: string): Promise<StrategyStatusResult>;
|
|
439
|
+
setupAutoInvest(params: {
|
|
440
|
+
amount: number;
|
|
441
|
+
frequency: 'daily' | 'weekly' | 'monthly';
|
|
442
|
+
strategy?: string;
|
|
443
|
+
asset?: string;
|
|
444
|
+
dayOfWeek?: number;
|
|
445
|
+
dayOfMonth?: number;
|
|
446
|
+
}): AutoInvestSchedule;
|
|
447
|
+
getAutoInvestStatus(): AutoInvestStatus;
|
|
448
|
+
runAutoInvest(): Promise<AutoInvestRunResult>;
|
|
449
|
+
stopAutoInvest(id: string): void;
|
|
450
|
+
getPortfolio(): Promise<PortfolioResult & {
|
|
451
|
+
strategyPositions?: Record<string, InvestmentPosition[]>;
|
|
452
|
+
}>;
|
|
345
453
|
positions(): Promise<PositionsResult>;
|
|
346
454
|
rates(): Promise<RatesResult>;
|
|
347
455
|
allRates(asset?: string): Promise<{
|
|
@@ -491,4 +599,4 @@ interface GasStatusResponse {
|
|
|
491
599
|
}
|
|
492
600
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
493
601
|
|
|
494
|
-
export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestResult, type InvestmentAsset, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|
|
602
|
+
export { AutoInvestManager, AutoInvestRunResult, AutoInvestSchedule, AutoInvestStatus, type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, type Contact, ContactManager, type ContactMap, DEFAULT_MAX_LEVERAGE, DEFAULT_MAX_POSITION_SIZE, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, DEFAULT_STRATEGIES, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, GAS_RESERVE_MIN, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, INVESTMENT_ASSETS, InvestEarnResult, InvestResult, type InvestmentAsset, InvestmentPosition, InvestmentTrade, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, OUTBOUND_OPS, PERPS_MARKETS, type PerpsMarket, PortfolioManager, PortfolioResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, type SafeguardConfig, SafeguardEnforcer, SafeguardError, type SafeguardErrorDetails, type SafeguardRule, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, StrategyBuyResult, StrategyDefinition, StrategyManager, StrategyRebalanceResult, StrategySellResult, StrategyStatusResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, type TxMetadata, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatAssetAmount, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
|