@t2000/sdk 0.7.2 → 0.8.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/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { T as T2000Options, S as SendResult, B as BalanceResponse, a as TransactionRecord, D as DepositInfo, L as LendingAdapter, b as SwapAdapter, c as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, d as BorrowResult, R as RepayResult, e as MaxBorrowResult, H as HealthFactorResult, f as SwapResult, P as PositionsResult, g as RatesResult, h as LendingRates, E as EarningsResult, F as FundStatusResult, i as SentinelAgent, j as SentinelAttackResult, G as GasMethod } from './index-rT0oHn8M.cjs';
5
- export { A as AdapterCapability, k as AdapterPositions, l as AdapterTxResult, C as CetusAdapter, m as GasReserve, n as HealthInfo, N as NaviAdapter, o as PositionEntry, p as ProtocolDescriptor, q as ProtocolRegistry, r as SentinelVerdict, s as SuilendAdapter, t as SwapQuote, u as allDescriptors, v as cetusDescriptor, w as getSentinelInfo, x as listSentinels, y as naviDescriptor, z as requestAttack, I as sentinelAttack, J as sentinelDescriptor, K as settleAttack, O as submitPrompt, Q as suilendDescriptor } from './index-rT0oHn8M.cjs';
4
+ import { T as T2000Options, S as SendResult, B as BalanceResponse, a as TransactionRecord, D as DepositInfo, L as LendingAdapter, b as SwapAdapter, c as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, d as BorrowResult, R as RepayResult, e as MaxBorrowResult, H as HealthFactorResult, f as SwapResult, P as PositionsResult, g as RatesResult, h as LendingRates, i as RebalanceResult, E as EarningsResult, F as FundStatusResult, j as SentinelAgent, k as SentinelAttackResult, G as GasMethod } from './index-DNjooNFy.cjs';
5
+ export { A as AdapterCapability, l as AdapterPositions, m as AdapterTxResult, n as AssetRates, C as CetusAdapter, o as GasReserve, p as HealthInfo, N as NaviAdapter, q as PositionEntry, r as ProtocolDescriptor, s as ProtocolRegistry, t as RebalanceStep, u as SentinelVerdict, v as SuilendAdapter, w as SwapQuote, x as allDescriptors, y as cetusDescriptor, z as getSentinelInfo, I as listSentinels, J as naviDescriptor, K as requestAttack, O as sentinelAttack, Q as sentinelDescriptor, U as settleAttack, V as submitPrompt, X as suilendDescriptor } from './index-DNjooNFy.cjs';
6
6
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
7
7
 
8
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' | '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' | 'FACILITATOR_TIMEOUT' | 'SENTINEL_API_ERROR' | 'SENTINEL_NOT_FOUND' | 'SENTINEL_TX_FAILED' | 'SENTINEL_TEE_ERROR' | 'UNKNOWN';
@@ -151,6 +151,17 @@ declare class T2000 extends EventEmitter<T2000Events> {
151
151
  protocolId: string;
152
152
  rates: LendingRates;
153
153
  }[]>;
154
+ allRatesAcrossAssets(): Promise<{
155
+ protocol: string;
156
+ protocolId: string;
157
+ asset: string;
158
+ rates: LendingRates;
159
+ }[]>;
160
+ rebalance(opts?: {
161
+ dryRun?: boolean;
162
+ minYieldDiff?: number;
163
+ maxBreakEven?: number;
164
+ }): Promise<RebalanceResult>;
154
165
  earnings(): Promise<EarningsResult>;
155
166
  fundStatus(): Promise<FundStatusResult>;
156
167
  sentinelList(): Promise<SentinelAgent[]>;
@@ -170,14 +181,36 @@ declare const SUPPORTED_ASSETS: {
170
181
  readonly type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
171
182
  readonly decimals: 6;
172
183
  readonly symbol: "USDC";
184
+ readonly displayName: "USDC";
185
+ };
186
+ readonly USDT: {
187
+ readonly type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT";
188
+ readonly decimals: 6;
189
+ readonly symbol: "USDT";
190
+ readonly displayName: "suiUSDT";
191
+ };
192
+ readonly USDe: {
193
+ readonly type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
194
+ readonly decimals: 6;
195
+ readonly symbol: "USDe";
196
+ readonly displayName: "suiUSDe";
197
+ };
198
+ readonly USDsui: {
199
+ readonly type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
200
+ readonly decimals: 6;
201
+ readonly symbol: "USDsui";
202
+ readonly displayName: "USDsui";
173
203
  };
174
204
  readonly SUI: {
175
205
  readonly type: "0x2::sui::SUI";
176
206
  readonly decimals: 9;
177
207
  readonly symbol: "SUI";
208
+ readonly displayName: "SUI";
178
209
  };
179
210
  };
180
211
  type SupportedAsset = keyof typeof SUPPORTED_ASSETS;
212
+ type StableAsset = Exclude<SupportedAsset, 'SUI'>;
213
+ declare const STABLE_ASSETS: readonly StableAsset[];
181
214
  declare const DEFAULT_NETWORK: "mainnet";
182
215
  declare const SENTINEL: {
183
216
  readonly PACKAGE: "0x88b83f36dafcd5f6dcdcf1d2cb5889b03f61264ab3cee9cae35db7aa940a21b7";
@@ -198,8 +231,17 @@ declare function mistToSui(mist: bigint): number;
198
231
  declare function suiToMist(sui: number): bigint;
199
232
  declare function usdcToRaw(amount: number): bigint;
200
233
  declare function rawToUsdc(raw: bigint): number;
234
+ declare function stableToRaw(amount: number, decimals: number): bigint;
235
+ declare function rawToStable(raw: bigint, decimals: number): number;
236
+ declare function getDecimals(asset: SupportedAsset): number;
201
237
  declare function formatUsd(amount: number): string;
202
238
  declare function formatSui(amount: number): string;
239
+ /**
240
+ * Case-insensitive lookup against SUPPORTED_ASSETS keys.
241
+ * 'usde' → 'USDe', 'usdsui' → 'USDsui', 'usdc' → 'USDC'.
242
+ * Returns the original input if not found so downstream validation can reject it.
243
+ */
244
+ declare function normalizeAsset(input: string): string;
203
245
 
204
246
  declare function generateKeypair(): Ed25519Keypair;
205
247
  declare function keypairFromPrivateKey(privateKey: string): Ed25519Keypair;
@@ -287,4 +329,4 @@ interface GasStatusResponse {
287
329
  }
288
330
  declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
289
331
 
290
- export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, DEFAULT_NETWORK, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RepayResult, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatSui, formatUsd, generateKeypair, getAddress, getGasStatus, getPoolPrice, getRates, getSwapQuote, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
332
+ export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, DEFAULT_NETWORK, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type StableAsset, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, getSwapQuote, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAsset, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { T as T2000Options, S as SendResult, B as BalanceResponse, a as TransactionRecord, D as DepositInfo, L as LendingAdapter, b as SwapAdapter, c as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, d as BorrowResult, R as RepayResult, e as MaxBorrowResult, H as HealthFactorResult, f as SwapResult, P as PositionsResult, g as RatesResult, h as LendingRates, E as EarningsResult, F as FundStatusResult, i as SentinelAgent, j as SentinelAttackResult, G as GasMethod } from './index-rT0oHn8M.js';
5
- export { A as AdapterCapability, k as AdapterPositions, l as AdapterTxResult, C as CetusAdapter, m as GasReserve, n as HealthInfo, N as NaviAdapter, o as PositionEntry, p as ProtocolDescriptor, q as ProtocolRegistry, r as SentinelVerdict, s as SuilendAdapter, t as SwapQuote, u as allDescriptors, v as cetusDescriptor, w as getSentinelInfo, x as listSentinels, y as naviDescriptor, z as requestAttack, I as sentinelAttack, J as sentinelDescriptor, K as settleAttack, O as submitPrompt, Q as suilendDescriptor } from './index-rT0oHn8M.js';
4
+ import { T as T2000Options, S as SendResult, B as BalanceResponse, a as TransactionRecord, D as DepositInfo, L as LendingAdapter, b as SwapAdapter, c as SaveResult, W as WithdrawResult, M as MaxWithdrawResult, d as BorrowResult, R as RepayResult, e as MaxBorrowResult, H as HealthFactorResult, f as SwapResult, P as PositionsResult, g as RatesResult, h as LendingRates, i as RebalanceResult, E as EarningsResult, F as FundStatusResult, j as SentinelAgent, k as SentinelAttackResult, G as GasMethod } from './index-DNjooNFy.js';
5
+ export { A as AdapterCapability, l as AdapterPositions, m as AdapterTxResult, n as AssetRates, C as CetusAdapter, o as GasReserve, p as HealthInfo, N as NaviAdapter, q as PositionEntry, r as ProtocolDescriptor, s as ProtocolRegistry, t as RebalanceStep, u as SentinelVerdict, v as SuilendAdapter, w as SwapQuote, x as allDescriptors, y as cetusDescriptor, z as getSentinelInfo, I as listSentinels, J as naviDescriptor, K as requestAttack, O as sentinelAttack, Q as sentinelDescriptor, U as settleAttack, V as submitPrompt, X as suilendDescriptor } from './index-DNjooNFy.js';
6
6
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
7
7
 
8
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' | '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' | 'FACILITATOR_TIMEOUT' | 'SENTINEL_API_ERROR' | 'SENTINEL_NOT_FOUND' | 'SENTINEL_TX_FAILED' | 'SENTINEL_TEE_ERROR' | 'UNKNOWN';
@@ -151,6 +151,17 @@ declare class T2000 extends EventEmitter<T2000Events> {
151
151
  protocolId: string;
152
152
  rates: LendingRates;
153
153
  }[]>;
154
+ allRatesAcrossAssets(): Promise<{
155
+ protocol: string;
156
+ protocolId: string;
157
+ asset: string;
158
+ rates: LendingRates;
159
+ }[]>;
160
+ rebalance(opts?: {
161
+ dryRun?: boolean;
162
+ minYieldDiff?: number;
163
+ maxBreakEven?: number;
164
+ }): Promise<RebalanceResult>;
154
165
  earnings(): Promise<EarningsResult>;
155
166
  fundStatus(): Promise<FundStatusResult>;
156
167
  sentinelList(): Promise<SentinelAgent[]>;
@@ -170,14 +181,36 @@ declare const SUPPORTED_ASSETS: {
170
181
  readonly type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
171
182
  readonly decimals: 6;
172
183
  readonly symbol: "USDC";
184
+ readonly displayName: "USDC";
185
+ };
186
+ readonly USDT: {
187
+ readonly type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT";
188
+ readonly decimals: 6;
189
+ readonly symbol: "USDT";
190
+ readonly displayName: "suiUSDT";
191
+ };
192
+ readonly USDe: {
193
+ readonly type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE";
194
+ readonly decimals: 6;
195
+ readonly symbol: "USDe";
196
+ readonly displayName: "suiUSDe";
197
+ };
198
+ readonly USDsui: {
199
+ readonly type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
200
+ readonly decimals: 6;
201
+ readonly symbol: "USDsui";
202
+ readonly displayName: "USDsui";
173
203
  };
174
204
  readonly SUI: {
175
205
  readonly type: "0x2::sui::SUI";
176
206
  readonly decimals: 9;
177
207
  readonly symbol: "SUI";
208
+ readonly displayName: "SUI";
178
209
  };
179
210
  };
180
211
  type SupportedAsset = keyof typeof SUPPORTED_ASSETS;
212
+ type StableAsset = Exclude<SupportedAsset, 'SUI'>;
213
+ declare const STABLE_ASSETS: readonly StableAsset[];
181
214
  declare const DEFAULT_NETWORK: "mainnet";
182
215
  declare const SENTINEL: {
183
216
  readonly PACKAGE: "0x88b83f36dafcd5f6dcdcf1d2cb5889b03f61264ab3cee9cae35db7aa940a21b7";
@@ -198,8 +231,17 @@ declare function mistToSui(mist: bigint): number;
198
231
  declare function suiToMist(sui: number): bigint;
199
232
  declare function usdcToRaw(amount: number): bigint;
200
233
  declare function rawToUsdc(raw: bigint): number;
234
+ declare function stableToRaw(amount: number, decimals: number): bigint;
235
+ declare function rawToStable(raw: bigint, decimals: number): number;
236
+ declare function getDecimals(asset: SupportedAsset): number;
201
237
  declare function formatUsd(amount: number): string;
202
238
  declare function formatSui(amount: number): string;
239
+ /**
240
+ * Case-insensitive lookup against SUPPORTED_ASSETS keys.
241
+ * 'usde' → 'USDe', 'usdsui' → 'USDsui', 'usdc' → 'USDC'.
242
+ * Returns the original input if not found so downstream validation can reject it.
243
+ */
244
+ declare function normalizeAsset(input: string): string;
203
245
 
204
246
  declare function generateKeypair(): Ed25519Keypair;
205
247
  declare function keypairFromPrivateKey(privateKey: string): Ed25519Keypair;
@@ -287,4 +329,4 @@ interface GasStatusResponse {
287
329
  }
288
330
  declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
289
331
 
290
- export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, DEFAULT_NETWORK, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RepayResult, SENTINEL, SUI_DECIMALS, SUPPORTED_ASSETS, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatSui, formatUsd, generateKeypair, getAddress, getGasStatus, getPoolPrice, getRates, getSwapQuote, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };
332
+ export { type AutoTopUpResult, BPS_DENOMINATOR, BalanceResponse, BorrowResult, CLOCK_ID, DEFAULT_NETWORK, DepositInfo, EarningsResult, type FeeOperation, FundStatusResult, type GasExecutionResult, GasMethod, type GasRequestType, type GasSponsorResponse, type GasStatusResponse, HealthFactorResult, LendingAdapter, LendingRates, MIST_PER_SUI, MaxBorrowResult, MaxWithdrawResult, PositionsResult, type ProtocolFeeInfo, RatesResult, RebalanceResult, RepayResult, SENTINEL, STABLE_ASSETS, SUI_DECIMALS, SUPPORTED_ASSETS, SaveResult, SendResult, SentinelAgent, SentinelAttackResult, type SimulationResult, type StableAsset, type SupportedAsset, SwapAdapter, SwapResult, T2000, T2000Error, type T2000ErrorCode, type T2000ErrorData, T2000Options, TransactionRecord, USDC_DECIMALS, WithdrawResult, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, exportPrivateKey, formatSui, formatUsd, generateKeypair, getAddress, getDecimals, getGasStatus, getPoolPrice, getRates, getSwapQuote, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAsset, rawToStable, rawToUsdc, saveKey, shouldAutoTopUp, simulateTransaction, solveHashcash, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, walletExists };