@t2000/sdk 0.13.0 → 0.14.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 CHANGED
@@ -53,6 +53,16 @@ await agent.rebalance(); // execute
53
53
 
54
54
  // Withdraw — always returns USDC (auto-swaps non-USDC positions)
55
55
  await agent.withdraw({ amount: 25 });
56
+
57
+ // Invest in crypto assets
58
+ await agent.investBuy({ asset: 'SUI', usdAmount: 100 });
59
+
60
+ // Check portfolio
61
+ const portfolio = await agent.getPortfolio();
62
+ console.log(`P&L: ${portfolio.unrealizedPnL}`);
63
+
64
+ // Sell position
65
+ await agent.investSell({ asset: 'SUI', usdAmount: 'all' });
56
66
  ```
57
67
 
58
68
  ## API Reference
@@ -153,6 +163,14 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
153
163
 
154
164
  **Types:** `SafeguardConfig` — `{ maxPerTx?, maxDailySend?, locked? }` · `SafeguardError` — thrown when limits exceeded or agent locked
155
165
 
166
+ ### Investment Methods
167
+
168
+ | Method | Description | Returns |
169
+ |--------|-------------|---------|
170
+ | `agent.investBuy({ asset, usdAmount, maxSlippage? })` | Buy crypto asset with USD | `InvestResult` |
171
+ | `agent.investSell({ asset, usdAmount \| 'all', maxSlippage? })` | Sell crypto back to USDC | `InvestResult` |
172
+ | `agent.getPortfolio()` | Investment positions + P&L | `PortfolioResult` |
173
+
156
174
  ### Key Management
157
175
 
158
176
  ```typescript
@@ -278,13 +296,15 @@ Save auto-converts non-USDC wallet stablecoins, withdraw auto-swaps non-USDC
278
296
  positions back to USDC, and repay auto-swaps USDC to the borrowed asset if
279
297
  debt is non-USDC (from rebalance). Rebalance optimizes across all stablecoins internally.
280
298
 
281
- | Asset | Display | Type | Decimals | Save | Borrow | Withdraw | Rebalance (internal) |
282
- |-------|---------|------|----------|------|--------|----------|---------------------|
283
- | USDC | USDC | `0xdba3...::usdc::USDC` | 6 | ✅ | ✅ | ✅ (always returns USDC) | ✅ |
284
- | USDT | suiUSDT | `0x375f...::usdt::USDT` | 6 | — (via rebalance) | — | — | ✅ |
285
- | USDe | suiUSDe | `0x41d5...::sui_usde::SUI_USDE` | 6 | — (via rebalance) | — | — | ✅ |
286
- | USDsui | USDsui | `0x44f8...::usdsui::USDSUI` | 6 | — (via rebalance) | — | — | ✅ |
287
- | SUI | SUI | `0x2::sui::SUI` | 9 | — | — | — | — |
299
+ | Asset | Display | Type | Decimals | Save | Borrow | Withdraw | Rebalance (internal) | Invest |
300
+ |-------|---------|------|----------|------|--------|----------|---------------------|--------|
301
+ | USDC | USDC | `0xdba3...::usdc::USDC` | 6 | ✅ | ✅ | ✅ (always returns USDC) | ✅ | — |
302
+ | USDT | suiUSDT | `0x375f...::usdt::USDT` | 6 | — (via rebalance) | — | — | ✅ | — |
303
+ | USDe | suiUSDe | `0x41d5...::sui_usde::SUI_USDE` | 6 | — (via rebalance) | — | — | ✅ | — |
304
+ | USDsui | USDsui | `0x44f8...::usdsui::USDSUI` | 6 | — (via rebalance) | — | — | ✅ | — |
305
+ | SUI | SUI | `0x2::sui::SUI` | 9 | — | — | — | — | ✅ |
306
+ | BTC | Bitcoin | `0xaafb...::btc::BTC` | 8 | — | — | — | — | ✅ |
307
+ | ETH | Ethereum | `0xd0e8...::eth::ETH` | 8 | — | — | — | — | ✅ |
288
308
 
289
309
  ## Error Handling
290
310
 
@@ -306,7 +326,7 @@ Common error codes: `INSUFFICIENT_BALANCE` · `INVALID_ADDRESS` · `INVALID_AMOU
306
326
  ## Testing
307
327
 
308
328
  ```bash
309
- # Run all SDK unit tests (367 tests)
329
+ # Run all SDK unit tests (469 tests)
310
330
  pnpm --filter @t2000/sdk test
311
331
  ```
312
332
 
@@ -347,7 +367,7 @@ Fees are collected by the t2000 protocol treasury on-chain.
347
367
 
348
368
  ## MCP Server
349
369
 
350
- The SDK powers the [`@t2000/mcp`](https://www.npmjs.com/package/@t2000/mcp) server — 17 tools and 5 prompts for Claude Desktop, Cursor, and any MCP-compatible AI platform. Run `t2000 mcp` to start.
370
+ The SDK powers the [`@t2000/mcp`](https://www.npmjs.com/package/@t2000/mcp) server — 19 tools and 6 prompts for Claude Desktop, Cursor, and any MCP-compatible AI platform. Run `t2000 mcp` to start.
351
371
 
352
372
  ## License
353
373
 
@@ -39,6 +39,18 @@ var SUPPORTED_ASSETS = {
39
39
  decimals: 9,
40
40
  symbol: "SUI",
41
41
  displayName: "SUI"
42
+ },
43
+ BTC: {
44
+ type: "0xaafb102dd0902f5055cadecd687fb5b71ca82ef0e0285d90afde828ec58ca96b::btc::BTC",
45
+ decimals: 8,
46
+ symbol: "BTC",
47
+ displayName: "Bitcoin"
48
+ },
49
+ ETH: {
50
+ type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH",
51
+ decimals: 8,
52
+ symbol: "ETH",
53
+ displayName: "Ethereum"
42
54
  }
43
55
  };
44
56
  var STABLE_ASSETS = ["USDC", "USDT", "USDe", "USDsui"];
@@ -48,6 +60,11 @@ var T2000_TREASURY_ID = process.env.T2000_TREASURY_ID ?? "0x3bb501b8300125dca590
48
60
  process.env.T2000_API_URL ?? "https://api.t2000.ai";
49
61
  var CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
50
62
  var CETUS_PACKAGE = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb";
63
+ var INVESTMENT_ASSETS = {
64
+ SUI: SUPPORTED_ASSETS.SUI,
65
+ BTC: SUPPORTED_ASSETS.BTC,
66
+ ETH: SUPPORTED_ASSETS.ETH
67
+ };
51
68
  var SENTINEL = {
52
69
  PACKAGE: "0x88b83f36dafcd5f6dcdcf1d2cb5889b03f61264ab3cee9cae35db7aa940a21b7"};
53
70
 
@@ -1075,10 +1092,10 @@ var CetusAdapter = class {
1075
1092
  };
1076
1093
  }
1077
1094
  getSupportedPairs() {
1078
- const pairs = [
1079
- { from: "USDC", to: "SUI" },
1080
- { from: "SUI", to: "USDC" }
1081
- ];
1095
+ const pairs = [];
1096
+ for (const asset of Object.keys(INVESTMENT_ASSETS)) {
1097
+ pairs.push({ from: "USDC", to: asset }, { from: asset, to: "USDC" });
1098
+ }
1082
1099
  for (const a of STABLE_ASSETS) {
1083
1100
  for (const b of STABLE_ASSETS) {
1084
1101
  if (a !== b) pairs.push({ from: a, to: b });