@t2000/sdk 0.8.7 → 0.9.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @t2000/sdk
2
2
 
3
- The complete TypeScript SDK for AI agent bank accounts on Sui. Send USDC, earn yield via NAVI + Suilend across 4 stablecoins (USDC, USDT, USDe, USDsui), swap on Cetus DEX, borrow against collateral, and auto-rebalance for optimal yield — all from a single class.
3
+ The complete TypeScript SDK for AI agent bank accounts on Sui. Send USDC, earn yield via NAVI + Suilend, borrow against collateral, and auto-rebalance for optimal yield — all from a single class. USDC in, USDC out — multi-stablecoin optimization is handled internally by rebalance.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@t2000/sdk)](https://www.npmjs.com/package/@t2000/sdk)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
@@ -38,21 +38,18 @@ console.log(`$${balance.available} USDC available`);
38
38
  await agent.send({ to: '0x...', amount: 10 });
39
39
 
40
40
  // Save (earn yield — auto-selects best rate across NAVI + Suilend)
41
- await agent.save({ amount: 50, asset: 'USDC' });
41
+ await agent.save({ amount: 50 });
42
42
 
43
- // Borrow a different stablecoin against your collateral
44
- await agent.borrow({ amount: 25, asset: 'USDT', protocol: 'suilend' });
43
+ // Borrow USDC against your collateral
44
+ await agent.borrow({ amount: 25 });
45
45
 
46
46
  // Rebalance — move savings to the best rate (dry-run first)
47
47
  const plan = await agent.rebalance({ dryRun: true });
48
48
  console.log(`+${plan.annualGain.toFixed(2)}/year, break-even: ${plan.breakEvenDays} days`);
49
49
  await agent.rebalance(); // execute
50
50
 
51
- // Swap USDC SUI (via Cetus DEX)
52
- await agent.swap({ from: 'USDC', to: 'SUI', amount: 5 });
53
-
54
- // Borrow against savings
55
- await agent.borrow({ amount: 20, asset: 'USDC' });
51
+ // Withdraw always returns USDC (auto-swaps non-USDC positions)
52
+ await agent.withdraw({ amount: 25 });
56
53
  ```
57
54
 
58
55
  ## API Reference
@@ -97,13 +94,11 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
97
94
  | `agent.address()` | Wallet Sui address | `string` |
98
95
  | `agent.balance()` | Available USDC + savings + gas reserve | `BalanceResponse` |
99
96
  | `agent.send({ to, amount, asset? })` | Transfer USDC to any Sui address | `SendResult` |
100
- | `agent.save({ amount, asset, protocol? })` | Deposit stablecoins to savings (earn APY). Supports USDC, USDT, USDe, USDsui. Auto-selects best rate or specify `protocol`. `amount` can be `'all'`. | `SaveResult` |
101
- | `agent.withdraw({ amount, asset })` | Withdraw USDC from savings. `amount` can be `'all'`. | `WithdrawResult` |
102
- | `agent.swap({ from, to, amount, maxSlippage? })` | Swap via Cetus CLMM DEX. `maxSlippage` in % (default: 3). | `SwapResult` |
103
- | `agent.swapQuote({ from, to, amount })` | Get swap quote without executing | `SwapQuote` |
104
- | `agent.borrow({ amount, asset })` | Borrow USDC against collateral | `BorrowResult` |
105
- | `agent.repay({ amount, asset })` | Repay outstanding borrows. `amount` can be `'all'`. | `RepayResult` |
106
- | `agent.rebalance({ dryRun?, minYieldDiff?, maxBreakEven? })` | Optimize yield — move savings to best rate across protocols/stablecoins. Dry-run for preview. | `RebalanceResult` |
97
+ | `agent.save({ amount, protocol? })` | Deposit USDC to savings (earn APY). Auto-selects best rate or specify `protocol`. `amount` can be `'all'`. | `SaveResult` |
98
+ | `agent.withdraw({ amount })` | Withdraw from savings. Always returns USDC (auto-swaps non-USDC positions). `amount` can be `'all'`. | `WithdrawResult` |
99
+ | `agent.borrow({ amount })` | Borrow USDC against collateral | `BorrowResult` |
100
+ | `agent.repay({ amount })` | Repay outstanding USDC borrows. `amount` can be `'all'`. | `RepayResult` |
101
+ | `agent.rebalance({ dryRun?, minYieldDiff?, maxBreakEven? })` | Optimize yield move savings to best rate across protocols/stablecoins internally. Dry-run for preview. | `RebalanceResult` |
107
102
  | `agent.exportKey()` | Export private key (bech32 format) | `string` |
108
103
 
109
104
  ### Query Methods
@@ -226,7 +221,7 @@ agent.signer; // Ed25519Keypair
226
221
 
227
222
  ## Gas Abstraction
228
223
 
229
- Every operation (send, save, borrow, repay, withdraw, swap) routes through a 3-step gas resolution chain via `executeWithGas()`. The agent never fails due to low gas if it has USDC or the Gas Station is reachable:
224
+ Every operation (send, save, borrow, repay, withdraw) routes through a 3-step gas resolution chain via `executeWithGas()`. The agent never fails due to low gas if it has USDC or the Gas Station is reachable:
230
225
 
231
226
  | Step | Strategy | Condition | How it works |
232
227
  |------|----------|-----------|--------------|
@@ -249,13 +244,16 @@ Options like `pin`, `keyPath`, and `rpcUrl` are passed directly to `T2000.create
249
244
 
250
245
  ## Supported Assets
251
246
 
252
- | Asset | Display | Type | Decimals | Save | Borrow | Swap | Rebalance |
253
- |-------|---------|------|----------|------|--------|------|-----------|
254
- | USDC | USDC | `0xdba3...::usdc::USDC` | 6 | ✅ | ✅ | ✅ | ✅ |
255
- | USDT | suiUSDT | `0x375f...::usdt::USDT` | 6 | | | | |
256
- | USDe | suiUSDe | `0x41d5...::sui_usde::SUI_USDE` | 6 | ✅ | ✅ | ✅ | ✅ |
257
- | USDsui | USDsui | `0x44f8...::usdsui::USDSUI` | 6 | ✅ | ✅ | ✅ | ✅ |
258
- | SUI | SUI | `0x2::sui::SUI` | 9 | — | — | | |
247
+ User-facing operations (save, borrow, repay, withdraw) accept USDC only.
248
+ Rebalance optimizes across all stablecoins internally.
249
+
250
+ | Asset | Display | Type | Decimals | Save | Borrow | Withdraw | Rebalance (internal) |
251
+ |-------|---------|------|----------|------|--------|----------|---------------------|
252
+ | USDC | USDC | `0xdba3...::usdc::USDC` | 6 | ✅ | ✅ | ✅ (always returns USDC) | ✅ |
253
+ | USDT | suiUSDT | `0x375f...::usdt::USDT` | 6 | — (via rebalance) | — | | |
254
+ | USDe | suiUSDe | `0x41d5...::sui_usde::SUI_USDE` | 6 | — (via rebalance) | — | — | ✅ |
255
+ | USDsui | USDsui | `0x44f8...::usdsui::USDSUI` | 6 | — (via rebalance) | — | — | ✅ |
256
+ | SUI | SUI | `0x2::sui::SUI` | 9 | — | — | — | — |
259
257
 
260
258
  ## Error Handling
261
259
 
@@ -207,24 +207,6 @@ var ProtocolRegistry = class {
207
207
  listSwap() {
208
208
  return [...this.swap.values()];
209
209
  }
210
- isSupportedAsset(asset, capability) {
211
- for (const adapter of this.lending.values()) {
212
- if (!adapter.supportedAssets.includes(asset)) continue;
213
- if (capability && !adapter.capabilities.includes(capability)) continue;
214
- return true;
215
- }
216
- return false;
217
- }
218
- getSupportedAssets(capability) {
219
- const assets = /* @__PURE__ */ new Set();
220
- for (const adapter of this.lending.values()) {
221
- if (capability && !adapter.capabilities.includes(capability)) continue;
222
- for (const a of adapter.supportedAssets) {
223
- assets.add(a);
224
- }
225
- }
226
- return [...assets];
227
- }
228
210
  };
229
211
 
230
212
  // src/utils/format.ts