@t2000/sdk 0.14.1 → 0.15.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 +10 -2
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/{index-B14ZyQZt.d.cts → index-BykavuDO.d.cts} +14 -1
- package/dist/{index-B14ZyQZt.d.ts → index-BykavuDO.d.ts} +14 -1
- package/dist/index.d.cts +19 -6
- package/dist/index.d.ts +19 -6
- package/package.json +1 -1
- package/dist/adapters/index.cjs +0 -1742
- package/dist/adapters/index.cjs.map +0 -1
- package/dist/adapters/index.js +0 -1732
- package/dist/adapters/index.js.map +0 -1
- package/dist/index.cjs +0 -4463
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -4394
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -63,7 +63,13 @@ await agent.investBuy({ asset: 'ETH', usdAmount: 200 });
|
|
|
63
63
|
const portfolio = await agent.getPortfolio();
|
|
64
64
|
console.log(`P&L: ${portfolio.unrealizedPnL}`);
|
|
65
65
|
|
|
66
|
-
//
|
|
66
|
+
// Earn yield on investment (deposit into best-rate lending)
|
|
67
|
+
await agent.investEarn({ asset: 'SUI' });
|
|
68
|
+
|
|
69
|
+
// Stop earning (withdraw from lending, keep in portfolio)
|
|
70
|
+
await agent.investUnearn({ asset: 'SUI' });
|
|
71
|
+
|
|
72
|
+
// Sell position (auto-withdraws if earning first)
|
|
67
73
|
await agent.investSell({ asset: 'SUI', usdAmount: 'all' });
|
|
68
74
|
```
|
|
69
75
|
|
|
@@ -170,7 +176,9 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
|
|
|
170
176
|
| Method | Description | Returns |
|
|
171
177
|
|--------|-------------|---------|
|
|
172
178
|
| `agent.investBuy({ asset, usdAmount, maxSlippage? })` | Buy crypto asset with USD | `InvestResult` |
|
|
173
|
-
| `agent.investSell({ asset, usdAmount \| 'all', maxSlippage? })` | Sell crypto back to USDC | `InvestResult` |
|
|
179
|
+
| `agent.investSell({ asset, usdAmount \| 'all', maxSlippage? })` | Sell crypto back to USDC (auto-withdraws if earning) | `InvestResult` |
|
|
180
|
+
| `agent.investEarn({ asset })` | Deposit invested asset into best-rate lending for yield | `InvestEarnResult` |
|
|
181
|
+
| `agent.investUnearn({ asset })` | Withdraw from lending, keep in portfolio | `InvestUnearnResult` |
|
|
174
182
|
| `agent.getPortfolio()` | Investment positions + P&L | `PortfolioResult` |
|
|
175
183
|
|
|
176
184
|
### Key Management
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AdapterCapability,
|
|
1
|
+
export { A as AdapterCapability, o as AdapterPositions, p as AdapterTxResult, C as CetusAdapter, s as HealthInfo, L as LendingAdapter, k as LendingRates, N as NaviAdapter, u as PerpsAdapter, y as ProtocolDescriptor, z as ProtocolRegistry, O as SuilendAdapter, b as SwapAdapter, Q as SwapQuote, X as allDescriptors, Y as cetusDescriptor, $ as naviDescriptor, a2 as sentinelDescriptor, a5 as suilendDescriptor } from '../index-BykavuDO.cjs';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
|
4
4
|
import '@mysten/sui/keypairs/ed25519';
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AdapterCapability,
|
|
1
|
+
export { A as AdapterCapability, o as AdapterPositions, p as AdapterTxResult, C as CetusAdapter, s as HealthInfo, L as LendingAdapter, k as LendingRates, N as NaviAdapter, u as PerpsAdapter, y as ProtocolDescriptor, z as ProtocolRegistry, O as SuilendAdapter, b as SwapAdapter, Q as SwapQuote, X as allDescriptors, Y as cetusDescriptor, $ as naviDescriptor, a2 as sentinelDescriptor, a5 as suilendDescriptor } from '../index-BykavuDO.js';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
|
4
4
|
import '@mysten/sui/keypairs/ed25519';
|
|
@@ -223,6 +223,9 @@ interface InvestmentPosition {
|
|
|
223
223
|
unrealizedPnL: number;
|
|
224
224
|
unrealizedPnLPct: number;
|
|
225
225
|
trades: InvestmentTrade[];
|
|
226
|
+
earning?: boolean;
|
|
227
|
+
earningProtocol?: string;
|
|
228
|
+
earningApy?: number;
|
|
226
229
|
}
|
|
227
230
|
interface PortfolioResult {
|
|
228
231
|
positions: InvestmentPosition[];
|
|
@@ -246,6 +249,16 @@ interface InvestResult {
|
|
|
246
249
|
realizedPnL?: number;
|
|
247
250
|
position: InvestmentPosition;
|
|
248
251
|
}
|
|
252
|
+
interface InvestEarnResult {
|
|
253
|
+
success: boolean;
|
|
254
|
+
tx: string;
|
|
255
|
+
asset: string;
|
|
256
|
+
amount: number;
|
|
257
|
+
protocol: string;
|
|
258
|
+
apy: number;
|
|
259
|
+
gasCost: number;
|
|
260
|
+
gasMethod: GasMethod;
|
|
261
|
+
}
|
|
249
262
|
type PositionSide = 'long' | 'short';
|
|
250
263
|
interface PerpsPosition {
|
|
251
264
|
market: string;
|
|
@@ -608,4 +621,4 @@ declare function attack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentin
|
|
|
608
621
|
/** All registered protocol descriptors — used by the indexer for event classification */
|
|
609
622
|
declare const allDescriptors: ProtocolDescriptor[];
|
|
610
623
|
|
|
611
|
-
export {
|
|
624
|
+
export { descriptor$3 as $, 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 InvestmentTrade as I, type RebalanceStep as J, type SentinelVerdict as K, type LendingAdapter as L, type MaxWithdrawResult as M, NaviAdapter as N, SuilendAdapter as O, type PortfolioResult as P, type SwapQuote as Q, type RepayResult as R, type SendResult as S, type T2000Options as T, type TradePositionsResult as U, type TradeResult as V, type WithdrawResult as W, allDescriptors as X, descriptor$2 as Y, getSentinelInfo as Z, listSentinels as _, type TransactionRecord as a, requestAttack as a0, attack as a1, descriptor as a2, settleAttack as a3, submitPrompt as a4, descriptor$1 as a5, type SwapAdapter as b, type SaveResult as c, type BorrowResult as d, type MaxBorrowResult as e, type SwapResult as f, type InvestResult as g, type InvestEarnResult as h, type PositionsResult as i, type RatesResult as j, type LendingRates as k, type RebalanceResult as l, type SentinelAgent as m, type SentinelAttackResult as n, type AdapterPositions as o, type AdapterTxResult as p, type AssetRates as q, type GasReserve as r, type HealthInfo as s, type InvestmentPosition as t, type PerpsAdapter as u, type PerpsPosition as v, type PositionEntry as w, type PositionSide as x, type ProtocolDescriptor as y, ProtocolRegistry as z };
|
|
@@ -223,6 +223,9 @@ interface InvestmentPosition {
|
|
|
223
223
|
unrealizedPnL: number;
|
|
224
224
|
unrealizedPnLPct: number;
|
|
225
225
|
trades: InvestmentTrade[];
|
|
226
|
+
earning?: boolean;
|
|
227
|
+
earningProtocol?: string;
|
|
228
|
+
earningApy?: number;
|
|
226
229
|
}
|
|
227
230
|
interface PortfolioResult {
|
|
228
231
|
positions: InvestmentPosition[];
|
|
@@ -246,6 +249,16 @@ interface InvestResult {
|
|
|
246
249
|
realizedPnL?: number;
|
|
247
250
|
position: InvestmentPosition;
|
|
248
251
|
}
|
|
252
|
+
interface InvestEarnResult {
|
|
253
|
+
success: boolean;
|
|
254
|
+
tx: string;
|
|
255
|
+
asset: string;
|
|
256
|
+
amount: number;
|
|
257
|
+
protocol: string;
|
|
258
|
+
apy: number;
|
|
259
|
+
gasCost: number;
|
|
260
|
+
gasMethod: GasMethod;
|
|
261
|
+
}
|
|
249
262
|
type PositionSide = 'long' | 'short';
|
|
250
263
|
interface PerpsPosition {
|
|
251
264
|
market: string;
|
|
@@ -608,4 +621,4 @@ declare function attack(client: SuiJsonRpcClient, signer: Ed25519Keypair, sentin
|
|
|
608
621
|
/** All registered protocol descriptors — used by the indexer for event classification */
|
|
609
622
|
declare const allDescriptors: ProtocolDescriptor[];
|
|
610
623
|
|
|
611
|
-
export {
|
|
624
|
+
export { descriptor$3 as $, 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 InvestmentTrade as I, type RebalanceStep as J, type SentinelVerdict as K, type LendingAdapter as L, type MaxWithdrawResult as M, NaviAdapter as N, SuilendAdapter as O, type PortfolioResult as P, type SwapQuote as Q, type RepayResult as R, type SendResult as S, type T2000Options as T, type TradePositionsResult as U, type TradeResult as V, type WithdrawResult as W, allDescriptors as X, descriptor$2 as Y, getSentinelInfo as Z, listSentinels as _, type TransactionRecord as a, requestAttack as a0, attack as a1, descriptor as a2, settleAttack as a3, submitPrompt as a4, descriptor$1 as a5, type SwapAdapter as b, type SaveResult as c, type BorrowResult as d, type MaxBorrowResult as e, type SwapResult as f, type InvestResult as g, type InvestEarnResult as h, type PositionsResult as i, type RatesResult as j, type LendingRates as k, type RebalanceResult as l, type SentinelAgent as m, type SentinelAttackResult as n, type AdapterPositions as o, type AdapterTxResult as p, type AssetRates as q, type GasReserve as r, type HealthInfo as s, type InvestmentPosition as t, type PerpsAdapter as u, type PerpsPosition as v, type PositionEntry as w, type PositionSide as x, type ProtocolDescriptor as y, ProtocolRegistry as z };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { I as InvestmentTrade, 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, g as InvestResult, h as InvestEarnResult, P as PortfolioResult, i as PositionsResult, j as RatesResult, k as LendingRates, l as RebalanceResult, E as EarningsResult, F as FundStatusResult, m as SentinelAgent, n as SentinelAttackResult, G as GasMethod } from './index-BykavuDO.cjs';
|
|
2
|
+
export { A as AdapterCapability, o as AdapterPositions, p as AdapterTxResult, q as AssetRates, C as CetusAdapter, r as GasReserve, s as HealthInfo, t as InvestmentPosition, N as NaviAdapter, u as PerpsAdapter, v as PerpsPosition, w as PositionEntry, x as PositionSide, y as ProtocolDescriptor, z as ProtocolRegistry, J as RebalanceStep, K as SentinelVerdict, O as SuilendAdapter, Q as SwapQuote, U as TradePositionsResult, V as TradeResult, X as allDescriptors, Y as cetusDescriptor, Z as getSentinelInfo, _ as listSentinels, $ as naviDescriptor, a0 as requestAttack, a1 as sentinelAttack, a2 as sentinelDescriptor, a3 as settleAttack, a4 as submitPrompt, a5 as suilendDescriptor } from './index-BykavuDO.cjs';
|
|
1
3
|
import { EventEmitter } from 'eventemitter3';
|
|
2
4
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
5
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import { I as InvestmentTrade, 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, g as InvestResult, P as PortfolioResult, h as PositionsResult, i as RatesResult, j as LendingRates, k as RebalanceResult, E as EarningsResult, F as FundStatusResult, l as SentinelAgent, m as SentinelAttackResult, G as GasMethod } from './index-B14ZyQZt.cjs';
|
|
5
|
-
export { A as AdapterCapability, n as AdapterPositions, o as AdapterTxResult, p as AssetRates, C as CetusAdapter, q as GasReserve, r as HealthInfo, s as InvestmentPosition, N as NaviAdapter, t as PerpsAdapter, u as PerpsPosition, v as PositionEntry, w as PositionSide, x as ProtocolDescriptor, y as ProtocolRegistry, z as RebalanceStep, J as SentinelVerdict, K as SuilendAdapter, O as SwapQuote, Q as TradePositionsResult, U as TradeResult, V as allDescriptors, X as cetusDescriptor, Y as getSentinelInfo, Z as listSentinels, _ as naviDescriptor, $ as requestAttack, a0 as sentinelAttack, a1 as sentinelDescriptor, a2 as settleAttack, a3 as submitPrompt, a4 as suilendDescriptor } from './index-B14ZyQZt.cjs';
|
|
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' | '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' | '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;
|
|
@@ -62,7 +62,7 @@ declare const SUPPORTED_ASSETS: {
|
|
|
62
62
|
readonly displayName: "SUI";
|
|
63
63
|
};
|
|
64
64
|
readonly BTC: {
|
|
65
|
-
readonly type: "
|
|
65
|
+
readonly type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC";
|
|
66
66
|
readonly decimals: 8;
|
|
67
67
|
readonly symbol: "BTC";
|
|
68
68
|
readonly displayName: "Bitcoin";
|
|
@@ -84,7 +84,7 @@ declare const INVESTMENT_ASSETS: {
|
|
|
84
84
|
readonly displayName: "SUI";
|
|
85
85
|
};
|
|
86
86
|
readonly BTC: {
|
|
87
|
-
readonly type: "
|
|
87
|
+
readonly type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC";
|
|
88
88
|
readonly decimals: 8;
|
|
89
89
|
readonly symbol: "BTC";
|
|
90
90
|
readonly displayName: "Bitcoin";
|
|
@@ -177,6 +177,9 @@ interface StoredPosition {
|
|
|
177
177
|
costBasis: number;
|
|
178
178
|
avgPrice: number;
|
|
179
179
|
trades: InvestmentTrade[];
|
|
180
|
+
earning?: boolean;
|
|
181
|
+
earningProtocol?: string;
|
|
182
|
+
earningApy?: number;
|
|
180
183
|
}
|
|
181
184
|
declare class PortfolioManager {
|
|
182
185
|
private data;
|
|
@@ -191,6 +194,9 @@ declare class PortfolioManager {
|
|
|
191
194
|
getPositions(): Array<{
|
|
192
195
|
asset: string;
|
|
193
196
|
} & StoredPosition>;
|
|
197
|
+
recordEarn(asset: string, protocol: string, apy: number): void;
|
|
198
|
+
recordUnearn(asset: string): void;
|
|
199
|
+
isEarning(asset: string): boolean;
|
|
194
200
|
getRealizedPnL(): number;
|
|
195
201
|
}
|
|
196
202
|
|
|
@@ -287,6 +293,7 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
287
293
|
private _swapFromUsdc;
|
|
288
294
|
private _convertWalletStablesToUsdc;
|
|
289
295
|
maxWithdraw(): Promise<MaxWithdrawResult>;
|
|
296
|
+
private adjustMaxBorrowForInvestments;
|
|
290
297
|
borrow(params: {
|
|
291
298
|
amount: number;
|
|
292
299
|
protocol?: string;
|
|
@@ -328,6 +335,12 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
328
335
|
usdAmount: number | 'all';
|
|
329
336
|
maxSlippage?: number;
|
|
330
337
|
}): Promise<InvestResult>;
|
|
338
|
+
investEarn(params: {
|
|
339
|
+
asset: InvestmentAsset;
|
|
340
|
+
}): Promise<InvestEarnResult>;
|
|
341
|
+
investUnearn(params: {
|
|
342
|
+
asset: InvestmentAsset;
|
|
343
|
+
}): Promise<InvestEarnResult>;
|
|
331
344
|
getPortfolio(): Promise<PortfolioResult>;
|
|
332
345
|
positions(): Promise<PositionsResult>;
|
|
333
346
|
rates(): Promise<RatesResult>;
|
|
@@ -478,4 +491,4 @@ interface GasStatusResponse {
|
|
|
478
491
|
}
|
|
479
492
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
480
493
|
|
|
481
|
-
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, 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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { I as InvestmentTrade, 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, g as InvestResult, h as InvestEarnResult, P as PortfolioResult, i as PositionsResult, j as RatesResult, k as LendingRates, l as RebalanceResult, E as EarningsResult, F as FundStatusResult, m as SentinelAgent, n as SentinelAttackResult, G as GasMethod } from './index-BykavuDO.js';
|
|
2
|
+
export { A as AdapterCapability, o as AdapterPositions, p as AdapterTxResult, q as AssetRates, C as CetusAdapter, r as GasReserve, s as HealthInfo, t as InvestmentPosition, N as NaviAdapter, u as PerpsAdapter, v as PerpsPosition, w as PositionEntry, x as PositionSide, y as ProtocolDescriptor, z as ProtocolRegistry, J as RebalanceStep, K as SentinelVerdict, O as SuilendAdapter, Q as SwapQuote, U as TradePositionsResult, V as TradeResult, X as allDescriptors, Y as cetusDescriptor, Z as getSentinelInfo, _ as listSentinels, $ as naviDescriptor, a0 as requestAttack, a1 as sentinelAttack, a2 as sentinelDescriptor, a3 as settleAttack, a4 as submitPrompt, a5 as suilendDescriptor } from './index-BykavuDO.js';
|
|
1
3
|
import { EventEmitter } from 'eventemitter3';
|
|
2
4
|
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
3
5
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import { I as InvestmentTrade, 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, g as InvestResult, P as PortfolioResult, h as PositionsResult, i as RatesResult, j as LendingRates, k as RebalanceResult, E as EarningsResult, F as FundStatusResult, l as SentinelAgent, m as SentinelAttackResult, G as GasMethod } from './index-B14ZyQZt.js';
|
|
5
|
-
export { A as AdapterCapability, n as AdapterPositions, o as AdapterTxResult, p as AssetRates, C as CetusAdapter, q as GasReserve, r as HealthInfo, s as InvestmentPosition, N as NaviAdapter, t as PerpsAdapter, u as PerpsPosition, v as PositionEntry, w as PositionSide, x as ProtocolDescriptor, y as ProtocolRegistry, z as RebalanceStep, J as SentinelVerdict, K as SuilendAdapter, O as SwapQuote, Q as TradePositionsResult, U as TradeResult, V as allDescriptors, X as cetusDescriptor, Y as getSentinelInfo, Z as listSentinels, _ as naviDescriptor, $ as requestAttack, a0 as sentinelAttack, a1 as sentinelDescriptor, a2 as settleAttack, a3 as submitPrompt, a4 as suilendDescriptor } from './index-B14ZyQZt.js';
|
|
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' | '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' | '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;
|
|
@@ -62,7 +62,7 @@ declare const SUPPORTED_ASSETS: {
|
|
|
62
62
|
readonly displayName: "SUI";
|
|
63
63
|
};
|
|
64
64
|
readonly BTC: {
|
|
65
|
-
readonly type: "
|
|
65
|
+
readonly type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC";
|
|
66
66
|
readonly decimals: 8;
|
|
67
67
|
readonly symbol: "BTC";
|
|
68
68
|
readonly displayName: "Bitcoin";
|
|
@@ -84,7 +84,7 @@ declare const INVESTMENT_ASSETS: {
|
|
|
84
84
|
readonly displayName: "SUI";
|
|
85
85
|
};
|
|
86
86
|
readonly BTC: {
|
|
87
|
-
readonly type: "
|
|
87
|
+
readonly type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC";
|
|
88
88
|
readonly decimals: 8;
|
|
89
89
|
readonly symbol: "BTC";
|
|
90
90
|
readonly displayName: "Bitcoin";
|
|
@@ -177,6 +177,9 @@ interface StoredPosition {
|
|
|
177
177
|
costBasis: number;
|
|
178
178
|
avgPrice: number;
|
|
179
179
|
trades: InvestmentTrade[];
|
|
180
|
+
earning?: boolean;
|
|
181
|
+
earningProtocol?: string;
|
|
182
|
+
earningApy?: number;
|
|
180
183
|
}
|
|
181
184
|
declare class PortfolioManager {
|
|
182
185
|
private data;
|
|
@@ -191,6 +194,9 @@ declare class PortfolioManager {
|
|
|
191
194
|
getPositions(): Array<{
|
|
192
195
|
asset: string;
|
|
193
196
|
} & StoredPosition>;
|
|
197
|
+
recordEarn(asset: string, protocol: string, apy: number): void;
|
|
198
|
+
recordUnearn(asset: string): void;
|
|
199
|
+
isEarning(asset: string): boolean;
|
|
194
200
|
getRealizedPnL(): number;
|
|
195
201
|
}
|
|
196
202
|
|
|
@@ -287,6 +293,7 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
287
293
|
private _swapFromUsdc;
|
|
288
294
|
private _convertWalletStablesToUsdc;
|
|
289
295
|
maxWithdraw(): Promise<MaxWithdrawResult>;
|
|
296
|
+
private adjustMaxBorrowForInvestments;
|
|
290
297
|
borrow(params: {
|
|
291
298
|
amount: number;
|
|
292
299
|
protocol?: string;
|
|
@@ -328,6 +335,12 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
328
335
|
usdAmount: number | 'all';
|
|
329
336
|
maxSlippage?: number;
|
|
330
337
|
}): Promise<InvestResult>;
|
|
338
|
+
investEarn(params: {
|
|
339
|
+
asset: InvestmentAsset;
|
|
340
|
+
}): Promise<InvestEarnResult>;
|
|
341
|
+
investUnearn(params: {
|
|
342
|
+
asset: InvestmentAsset;
|
|
343
|
+
}): Promise<InvestEarnResult>;
|
|
331
344
|
getPortfolio(): Promise<PortfolioResult>;
|
|
332
345
|
positions(): Promise<PositionsResult>;
|
|
333
346
|
rates(): Promise<RatesResult>;
|
|
@@ -478,4 +491,4 @@ interface GasStatusResponse {
|
|
|
478
491
|
}
|
|
479
492
|
declare function getGasStatus(address?: string): Promise<GasStatusResponse>;
|
|
480
493
|
|
|
481
|
-
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, 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 };
|
|
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 };
|