@t2000/sdk 0.11.2 → 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
@@ -121,6 +131,16 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
121
131
  | `agent.deposit()` | Wallet address + funding instructions | `DepositInfo` |
122
132
  | `agent.history({ limit? })` | Transaction history (default: all) | `TransactionRecord[]` |
123
133
 
134
+ ### Contacts Methods
135
+
136
+ | Method | Description | Returns |
137
+ |--------|-------------|---------|
138
+ | `agent.contacts.add(name, address)` | Save a named contact | `void` |
139
+ | `agent.contacts.remove(name)` | Remove a contact | `void` |
140
+ | `agent.contacts.list()` | List all saved contacts | `Contact[]` |
141
+ | `agent.contacts.get(name)` | Get a contact by name | `Contact` |
142
+ | `agent.contacts.resolve(nameOrAddress)` | Resolve name to address (passthrough if already an address) | `string` |
143
+
124
144
  ### Sentinel Methods
125
145
 
126
146
  | Method | Description | Returns |
@@ -143,6 +163,14 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
143
163
 
144
164
  **Types:** `SafeguardConfig` — `{ maxPerTx?, maxDailySend?, locked? }` · `SafeguardError` — thrown when limits exceeded or agent locked
145
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
+
146
174
  ### Key Management
147
175
 
148
176
  ```typescript
@@ -268,13 +296,15 @@ Save auto-converts non-USDC wallet stablecoins, withdraw auto-swaps non-USDC
268
296
  positions back to USDC, and repay auto-swaps USDC to the borrowed asset if
269
297
  debt is non-USDC (from rebalance). Rebalance optimizes across all stablecoins internally.
270
298
 
271
- | Asset | Display | Type | Decimals | Save | Borrow | Withdraw | Rebalance (internal) |
272
- |-------|---------|------|----------|------|--------|----------|---------------------|
273
- | USDC | USDC | `0xdba3...::usdc::USDC` | 6 | ✅ | ✅ | ✅ (always returns USDC) | ✅ |
274
- | USDT | suiUSDT | `0x375f...::usdt::USDT` | 6 | — (via rebalance) | — | — | ✅ |
275
- | USDe | suiUSDe | `0x41d5...::sui_usde::SUI_USDE` | 6 | — (via rebalance) | — | — | ✅ |
276
- | USDsui | USDsui | `0x44f8...::usdsui::USDSUI` | 6 | — (via rebalance) | — | — | ✅ |
277
- | 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 | — | — | — | — | ✅ |
278
308
 
279
309
  ## Error Handling
280
310
 
@@ -296,7 +326,7 @@ Common error codes: `INSUFFICIENT_BALANCE` · `INVALID_ADDRESS` · `INVALID_AMOU
296
326
  ## Testing
297
327
 
298
328
  ```bash
299
- # Run all SDK unit tests (367 tests)
329
+ # Run all SDK unit tests (469 tests)
300
330
  pnpm --filter @t2000/sdk test
301
331
  ```
302
332
 
@@ -337,7 +367,7 @@ Fees are collected by the t2000 protocol treasury on-chain.
337
367
 
338
368
  ## MCP Server
339
369
 
340
- The SDK powers the [`@t2000/mcp`](https://www.npmjs.com/package/@t2000/mcp) server — 16 tools and 3 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.
341
371
 
342
372
  ## License
343
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 });