@t2000/sdk 0.8.6 → 0.9.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 +22 -24
- package/dist/adapters/index.cjs +0 -18
- 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 +0 -18
- package/dist/adapters/index.js.map +1 -1
- package/dist/{index-DNjooNFy.d.cts → index-C7W686z2.d.cts} +1 -4
- package/dist/{index-DNjooNFy.d.ts → index-C7W686z2.d.ts} +1 -4
- package/dist/index.cjs +115 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -41
- package/dist/index.d.ts +7 -41
- package/dist/index.js +116 -80
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
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
|
[](https://www.npmjs.com/package/@t2000/sdk)
|
|
6
6
|
[](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
|
|
41
|
+
await agent.save({ amount: 50 });
|
|
42
42
|
|
|
43
|
-
// Borrow
|
|
44
|
-
await agent.borrow({ amount: 25
|
|
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
|
-
//
|
|
52
|
-
await agent.
|
|
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,
|
|
101
|
-
| `agent.withdraw({ amount
|
|
102
|
-
| `agent.
|
|
103
|
-
| `agent.
|
|
104
|
-
| `agent.
|
|
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
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
|
256
|
-
|
|
257
|
-
|
|
|
258
|
-
|
|
|
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
|
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -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
|