@t2000/sdk 0.7.1 → 0.8.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 +19 -6
- package/dist/adapters/index.cjs +338 -128
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +338 -128
- package/dist/adapters/index.js.map +1 -1
- package/dist/{index-rT0oHn8M.d.cts → index-DNjooNFy.d.cts} +54 -14
- package/dist/{index-rT0oHn8M.d.ts → index-DNjooNFy.d.ts} +54 -14
- package/dist/index.cjs +641 -161
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -3
- package/dist/index.d.ts +45 -3
- package/dist/index.js +637 -162
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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, swap on Cetus DEX, borrow against collateral — all from a single class.
|
|
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.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@t2000/sdk)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -40,6 +40,14 @@ await agent.send({ to: '0x...', amount: 10 });
|
|
|
40
40
|
// Save (earn yield — auto-selects best rate across NAVI + Suilend)
|
|
41
41
|
await agent.save({ amount: 50, asset: 'USDC' });
|
|
42
42
|
|
|
43
|
+
// Borrow a different stablecoin against your collateral
|
|
44
|
+
await agent.borrow({ amount: 25, asset: 'USDT', protocol: 'suilend' });
|
|
45
|
+
|
|
46
|
+
// Rebalance — move savings to the best rate (dry-run first)
|
|
47
|
+
const plan = await agent.rebalance({ dryRun: true });
|
|
48
|
+
console.log(`+${plan.annualGain.toFixed(2)}/year, break-even: ${plan.breakEvenDays} days`);
|
|
49
|
+
await agent.rebalance(); // execute
|
|
50
|
+
|
|
43
51
|
// Swap USDC → SUI (via Cetus DEX)
|
|
44
52
|
await agent.swap({ from: 'USDC', to: 'SUI', amount: 5 });
|
|
45
53
|
|
|
@@ -89,12 +97,13 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
|
|
|
89
97
|
| `agent.address()` | Wallet Sui address | `string` |
|
|
90
98
|
| `agent.balance()` | Available USDC + savings + gas reserve | `BalanceResponse` |
|
|
91
99
|
| `agent.send({ to, amount, asset? })` | Transfer USDC to any Sui address | `SendResult` |
|
|
92
|
-
| `agent.save({ amount, asset, protocol? })` | Deposit
|
|
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` |
|
|
93
101
|
| `agent.withdraw({ amount, asset })` | Withdraw USDC from savings. `amount` can be `'all'`. | `WithdrawResult` |
|
|
94
102
|
| `agent.swap({ from, to, amount, maxSlippage? })` | Swap via Cetus CLMM DEX. `maxSlippage` in % (default: 3). | `SwapResult` |
|
|
95
103
|
| `agent.swapQuote({ from, to, amount })` | Get swap quote without executing | `SwapQuote` |
|
|
96
104
|
| `agent.borrow({ amount, asset })` | Borrow USDC against collateral | `BorrowResult` |
|
|
97
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` |
|
|
98
107
|
| `agent.exportKey()` | Export private key (bech32 format) | `string` |
|
|
99
108
|
|
|
100
109
|
### Query Methods
|
|
@@ -104,6 +113,7 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
|
|
|
104
113
|
| `agent.healthFactor()` | Lending health factor | `HealthFactorResult` |
|
|
105
114
|
| `agent.earnings()` | Yield earned to date | `EarningsResult` |
|
|
106
115
|
| `agent.rates()` | Best save/borrow APYs across protocols | `RatesResult` |
|
|
116
|
+
| `agent.allRatesAcrossAssets()` | All rates for all stablecoins across all protocols | `Array<{ protocol, asset, rates }>` |
|
|
107
117
|
| `agent.positions()` | All open DeFi positions | `PositionsResult` |
|
|
108
118
|
| `agent.fundStatus()` | Complete savings summary | `FundStatusResult` |
|
|
109
119
|
| `agent.maxWithdraw()` | Max safe withdrawal amount | `MaxWithdrawResult` |
|
|
@@ -239,10 +249,13 @@ Options like `pin`, `keyPath`, and `rpcUrl` are passed directly to `T2000.create
|
|
|
239
249
|
|
|
240
250
|
## Supported Assets
|
|
241
251
|
|
|
242
|
-
| Asset | Type | Decimals |
|
|
243
|
-
|
|
244
|
-
| USDC | `0xdba3...::usdc::USDC` | 6 |
|
|
245
|
-
|
|
|
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 | — | — | ✅ | — |
|
|
246
259
|
|
|
247
260
|
## Error Handling
|
|
248
261
|
|