@t2000/sdk 0.19.24 → 0.20.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 +34 -150
- package/dist/adapters/descriptors.cjs +1 -42
- package/dist/adapters/descriptors.cjs.map +1 -1
- package/dist/adapters/descriptors.d.cts +1 -1
- package/dist/adapters/descriptors.d.ts +1 -1
- package/dist/adapters/descriptors.js +2 -41
- package/dist/adapters/descriptors.js.map +1 -1
- package/dist/adapters/index.cjs +3 -745
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +4 -171
- package/dist/adapters/index.d.ts +4 -171
- package/dist/adapters/index.js +4 -742
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.js +20 -178
- package/dist/browser.js.map +1 -1
- package/dist/descriptors-Be4FAgN5.d.cts +127 -0
- package/dist/descriptors-Be4FAgN5.d.ts +127 -0
- package/dist/index-D1DxZ1DK.d.ts +292 -0
- package/dist/index-MP_J_nSO.d.cts +292 -0
- package/dist/index.cjs +711 -3456
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -313
- package/dist/index.d.ts +42 -313
- package/dist/index.js +642 -3375
- package/dist/index.js.map +1 -1
- package/package.json +5 -8
- package/dist/descriptors-B6qt_mwi.d.cts +0 -584
- package/dist/descriptors-B6qt_mwi.d.ts +0 -584
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# @t2000/sdk
|
|
2
2
|
|
|
3
|
-
The complete TypeScript SDK for AI agent bank accounts on Sui. Send USDC, earn yield via NAVI
|
|
3
|
+
The complete TypeScript SDK for AI agent bank accounts on Sui. Send USDC, earn yield via NAVI, and borrow against collateral — all from a single class. USDC in, USDC out.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@t2000/sdk)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
**[Website](https://t2000.ai)** · **[GitHub](https://github.com/mission69b/t2000)** · **[CLI](https://www.npmjs.com/package/@t2000/cli)** · **[MPP](https://www.npmjs.com/package/@
|
|
8
|
+
**[Website](https://t2000.ai)** · **[GitHub](https://github.com/mission69b/t2000)** · **[CLI](https://www.npmjs.com/package/@t2000/cli)** · **[MPP](https://www.npmjs.com/package/@suimpp/mpp)** · **[MCP](https://www.npmjs.com/package/@t2000/mcp)**
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -37,62 +37,14 @@ console.log(`$${balance.available} USDC available`);
|
|
|
37
37
|
// Send USDC
|
|
38
38
|
await agent.send({ to: '0x...', amount: 10 });
|
|
39
39
|
|
|
40
|
-
// Save (earn yield — auto-selects best rate
|
|
40
|
+
// Save (earn yield — auto-selects best rate via NAVI)
|
|
41
41
|
await agent.save({ amount: 50 });
|
|
42
42
|
|
|
43
43
|
// Borrow USDC against your collateral
|
|
44
44
|
await agent.borrow({ amount: 25 });
|
|
45
45
|
|
|
46
|
-
//
|
|
47
|
-
await agent.swap({ from: 'USDC', to: 'SUI', amount: 5 });
|
|
48
|
-
|
|
49
|
-
// Rebalance — move savings to the best rate (dry-run first)
|
|
50
|
-
const plan = await agent.rebalance({ dryRun: true });
|
|
51
|
-
console.log(`+${plan.annualGain.toFixed(2)}/year, break-even: ${plan.breakEvenDays} days`);
|
|
52
|
-
await agent.rebalance(); // execute
|
|
53
|
-
|
|
54
|
-
// Withdraw — always returns USDC (auto-swaps non-USDC positions)
|
|
46
|
+
// Withdraw from savings (USDC)
|
|
55
47
|
await agent.withdraw({ amount: 25 });
|
|
56
|
-
|
|
57
|
-
// Buy crypto assets
|
|
58
|
-
await agent.buy({ asset: 'SUI', usdAmount: 100 });
|
|
59
|
-
await agent.buy({ asset: 'BTC', usdAmount: 500 });
|
|
60
|
-
await agent.buy({ asset: 'ETH', usdAmount: 200 });
|
|
61
|
-
await agent.buy({ asset: 'GOLD', usdAmount: 100 });
|
|
62
|
-
|
|
63
|
-
// Check portfolio
|
|
64
|
-
const portfolio = await agent.getPortfolio();
|
|
65
|
-
console.log(`P&L: ${portfolio.unrealizedPnL}`);
|
|
66
|
-
|
|
67
|
-
// Earn yield on investment (deposit into best-rate lending)
|
|
68
|
-
await agent.investEarn({ asset: 'SUI' });
|
|
69
|
-
|
|
70
|
-
// Stop earning (withdraw from lending, keep in portfolio)
|
|
71
|
-
await agent.investUnearn({ asset: 'SUI' });
|
|
72
|
-
|
|
73
|
-
// Rebalance earning positions to better-rate protocols
|
|
74
|
-
await agent.investRebalance(); // execute
|
|
75
|
-
await agent.investRebalance({ dryRun: true }); // preview only
|
|
76
|
-
|
|
77
|
-
// Sell position (auto-withdraws if earning first)
|
|
78
|
-
await agent.sell({ asset: 'SUI', usdAmount: 'all' });
|
|
79
|
-
|
|
80
|
-
// Buy into a strategy (single atomic PTB)
|
|
81
|
-
// bluechip: BTC 50%, ETH 30%, SUI 20%; all-weather: BTC 30%, ETH 20%, SUI 20%, GOLD 30%; safe-haven: BTC 50%, GOLD 50%
|
|
82
|
-
await agent.investStrategy({ strategy: 'bluechip', usdAmount: 200 });
|
|
83
|
-
|
|
84
|
-
// Check strategy status
|
|
85
|
-
const status = await agent.getStrategyStatus({ strategy: 'bluechip' });
|
|
86
|
-
console.log(`Total value: $${status.totalValue}`);
|
|
87
|
-
|
|
88
|
-
// Rebalance strategy to target weights
|
|
89
|
-
await agent.rebalanceStrategy({ strategy: 'bluechip' });
|
|
90
|
-
|
|
91
|
-
// Set up dollar-cost averaging
|
|
92
|
-
await agent.setupAutoInvest({ amount: 50, frequency: 'weekly', strategy: 'bluechip' });
|
|
93
|
-
|
|
94
|
-
// Run pending DCA purchases
|
|
95
|
-
await agent.runAutoInvest();
|
|
96
48
|
```
|
|
97
49
|
|
|
98
50
|
## API Reference
|
|
@@ -137,15 +89,13 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
|
|
|
137
89
|
| `agent.address()` | Wallet Sui address | `string` |
|
|
138
90
|
| `agent.balance()` | Available USDC + savings + gas reserve | `BalanceResponse` |
|
|
139
91
|
| `agent.send({ to, amount, asset? })` | Transfer USDC to any Sui address | `SendResult` |
|
|
140
|
-
| `agent.save({ amount, protocol? })` | Deposit to savings (earn APY). Auto-
|
|
141
|
-
| `agent.withdraw({ amount })` | Withdraw from savings.
|
|
92
|
+
| `agent.save({ amount, asset?, protocol? })` | Deposit to savings (earn APY). Auto-selects best rate or specify `protocol`. `amount` can be `'all'`. Optional `asset` for multi-asset NAVI deposits (default: USDC). | `SaveResult` |
|
|
93
|
+
| `agent.withdraw({ amount, asset? })` | Withdraw from savings. `amount` can be `'all'`. Optional `asset` for multi-asset withdrawals (default: USDC). | `WithdrawResult` |
|
|
142
94
|
| `agent.borrow({ amount })` | Borrow USDC against collateral | `BorrowResult` |
|
|
143
|
-
| `agent.repay({ amount })` | Repay outstanding debt
|
|
144
|
-
| `agent.
|
|
145
|
-
| `agent.
|
|
146
|
-
| `agent.
|
|
147
|
-
| `agent.buy({ asset, usdAmount, maxSlippage? })` | Buy crypto asset with USD | `InvestResult` |
|
|
148
|
-
| `agent.sell({ asset, usdAmount \| 'all', maxSlippage? })` | Sell crypto back to USDC (auto-withdraws if earning) | `InvestResult` |
|
|
95
|
+
| `agent.repay({ amount })` | Repay outstanding debt in USDC. `amount` can be `'all'`. | `RepayResult` |
|
|
96
|
+
| `agent.swap({ from, to, amount, slippage? })` | Swap tokens via Cetus Aggregator (20+ DEXs). User-friendly names or full coin types. | `SwapResult` |
|
|
97
|
+
| `agent.stakeVSui({ amount })` | Stake SUI for vSUI via VOLO liquid staking (min 1 SUI) | `StakeVSuiResult` |
|
|
98
|
+
| `agent.unstakeVSui({ amount })` | Unstake vSUI back to SUI. `amount` can be `'all'`. | `UnstakeVSuiResult` |
|
|
149
99
|
| `agent.exportKey()` | Export private key (bech32 format) | `string` |
|
|
150
100
|
|
|
151
101
|
### Query Methods
|
|
@@ -155,13 +105,14 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
|
|
|
155
105
|
| `agent.healthFactor()` | Lending health factor | `HealthFactorResult` |
|
|
156
106
|
| `agent.earnings()` | Yield earned to date | `EarningsResult` |
|
|
157
107
|
| `agent.rates()` | Best save/borrow APYs across protocols | `RatesResult` |
|
|
158
|
-
| `agent.allRatesAcrossAssets()` |
|
|
108
|
+
| `agent.allRatesAcrossAssets()` | Per-protocol rate data across assets | `Array<{ protocol, asset, rates }>` |
|
|
159
109
|
| `agent.positions()` | All open DeFi positions | `PositionsResult` |
|
|
160
110
|
| `agent.fundStatus()` | Complete savings summary | `FundStatusResult` |
|
|
161
111
|
| `agent.maxWithdraw()` | Max safe withdrawal amount | `MaxWithdrawResult` |
|
|
162
112
|
| `agent.maxBorrow()` | Max safe borrow amount | `MaxBorrowResult` |
|
|
163
113
|
| `agent.deposit()` | Wallet address + funding instructions | `DepositInfo` |
|
|
164
114
|
| `agent.history({ limit? })` | Transaction history (default: all) | `TransactionRecord[]` |
|
|
115
|
+
| `agent.swapQuote({ from, to, amount })` | Preview swap route, output amount, and price impact (no execution) | `SwapQuoteResult` |
|
|
165
116
|
|
|
166
117
|
### Contacts Methods
|
|
167
118
|
|
|
@@ -187,38 +138,6 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
|
|
|
187
138
|
|
|
188
139
|
**Types:** `SafeguardConfig` — `{ maxPerTx?, maxDailySend?, locked? }` · `SafeguardError` — thrown when limits exceeded or agent locked
|
|
189
140
|
|
|
190
|
-
### Investment Yield Methods
|
|
191
|
-
|
|
192
|
-
| Method | Description | Returns |
|
|
193
|
-
|--------|-------------|---------|
|
|
194
|
-
| `agent.investEarn({ asset })` | Deposit held asset into best-rate lending for yield | `InvestEarnResult` |
|
|
195
|
-
| `agent.investUnearn({ asset })` | Withdraw from lending, keep in portfolio | `InvestUnearnResult` |
|
|
196
|
-
| `agent.investRebalance({ dryRun?, minYieldDiff? })` | Move earning positions to better-rate protocols | `InvestRebalanceResult` |
|
|
197
|
-
| `agent.getPortfolio()` | Investment positions + P&L (grouped by strategy) | `PortfolioResult` |
|
|
198
|
-
|
|
199
|
-
> **Deprecated aliases:** `agent.exchange()` and `agent.exchangeQuote()` still work but are deprecated — use `agent.swap()` and `agent.swapQuote()`. Similarly, `agent.investBuy()` and `agent.investSell()` are deprecated — use `agent.buy()` and `agent.sell()`.
|
|
200
|
-
|
|
201
|
-
### Strategy Methods
|
|
202
|
-
|
|
203
|
-
| Method | Description | Returns |
|
|
204
|
-
|--------|-------------|---------|
|
|
205
|
-
| `agent.investStrategy({ strategy, usdAmount, maxSlippage?, dryRun? })` | Buy into a strategy (single atomic PTB) | `StrategyBuyResult` |
|
|
206
|
-
| `agent.sellStrategy({ strategy, maxSlippage? })` | Sell all positions in a strategy | `StrategySellResult` |
|
|
207
|
-
| `agent.rebalanceStrategy({ strategy, maxSlippage?, driftThreshold? })` | Rebalance to target weights | `StrategyRebalanceResult` |
|
|
208
|
-
| `agent.getStrategyStatus({ strategy })` | Positions, weights, drift for a strategy | `StrategyStatusResult` |
|
|
209
|
-
| `agent.getStrategies()` | List all available strategies | `StrategyDefinition[]` |
|
|
210
|
-
| `agent.createStrategy({ name, allocations, description? })` | Create a custom strategy | `StrategyDefinition` |
|
|
211
|
-
| `agent.deleteStrategy({ name })` | Delete a custom strategy (no active positions) | `void` |
|
|
212
|
-
|
|
213
|
-
### Auto-Invest (DCA) Methods
|
|
214
|
-
|
|
215
|
-
| Method | Description | Returns |
|
|
216
|
-
|--------|-------------|---------|
|
|
217
|
-
| `agent.setupAutoInvest({ amount, frequency, strategy?, asset? })` | Schedule recurring purchases | `AutoInvestSchedule` |
|
|
218
|
-
| `agent.getAutoInvestStatus()` | View schedules and pending runs | `AutoInvestStatus` |
|
|
219
|
-
| `agent.runAutoInvest()` | Execute all pending DCA purchases | `AutoInvestRunResult` |
|
|
220
|
-
| `agent.stopAutoInvest({ id? })` | Stop one or all schedules | `void` |
|
|
221
|
-
|
|
222
141
|
### Key Management
|
|
223
142
|
|
|
224
143
|
```typescript
|
|
@@ -294,7 +213,6 @@ import {
|
|
|
294
213
|
rawToUsdc,
|
|
295
214
|
formatUsd,
|
|
296
215
|
formatSui,
|
|
297
|
-
formatAssetAmount,
|
|
298
216
|
validateAddress,
|
|
299
217
|
truncateAddress,
|
|
300
218
|
} from '@t2000/sdk';
|
|
@@ -304,16 +222,11 @@ usdcToRaw(10.50); // 10_500_000n
|
|
|
304
222
|
formatUsd(1234.5); // "$1234.50"
|
|
305
223
|
truncateAddress('0xabcdef...1234'); // "0xabcd...1234"
|
|
306
224
|
validateAddress('0x...'); // throws if invalid
|
|
307
|
-
|
|
308
|
-
// Asset-aware decimal formatting
|
|
309
|
-
formatAssetAmount('BTC', 0.00123456); // "0.00123456" (8 decimals)
|
|
310
|
-
formatAssetAmount('ETH', 1.5); // "1.50000000" (8 decimals)
|
|
311
|
-
formatAssetAmount('SUI', 105.26); // "105.260000000" (9 decimals)
|
|
312
225
|
```
|
|
313
226
|
|
|
314
227
|
### Advanced: Exposed Internals
|
|
315
228
|
|
|
316
|
-
For integrations (like `@
|
|
229
|
+
For integrations (like `@suimpp/mpp`), the agent exposes:
|
|
317
230
|
|
|
318
231
|
```typescript
|
|
319
232
|
agent.suiClient; // SuiJsonRpcClient instance
|
|
@@ -327,13 +240,13 @@ Every operation (send, save, borrow, repay, withdraw) routes through a 3-step ga
|
|
|
327
240
|
| Step | Strategy | Condition | How it works |
|
|
328
241
|
|------|----------|-----------|--------------|
|
|
329
242
|
| 1 | **Self-funded** | SUI ≥ 0.05 | Uses the agent's own SUI for gas |
|
|
330
|
-
| 2 | **Auto-topup** | SUI < 0.05, USDC ≥ $2 |
|
|
243
|
+
| 2 | **Auto-topup** | SUI < 0.05, USDC ≥ $2 | Converts $1 USDC → SUI (currently disabled, falls back to step 3) |
|
|
331
244
|
| 3 | **Sponsored** | Steps 1 & 2 fail | Gas Station sponsors the full transaction |
|
|
332
245
|
| 4 | **Error** | All fail | Throws `INSUFFICIENT_GAS` |
|
|
333
246
|
|
|
334
247
|
Every transaction result includes a `gasMethod` field (`'self-funded'` | `'auto-topup'` | `'sponsored'`) indicating which strategy was used.
|
|
335
248
|
|
|
336
|
-
**Architecture:** Each protocol operation (NAVI,
|
|
249
|
+
**Architecture:** Each protocol operation (NAVI, send) exposes both `buildXxxTx()` (standalone transaction) and `addXxxToTx()` (composable PTB) functions. Multi-step flows compose multiple protocol calls into a single atomic PTB. `executeWithGas()` handles execution with the gas fallback chain. If any step within a PTB fails, the entire transaction reverts — no funds left in intermediate states.
|
|
337
250
|
|
|
338
251
|
## Configuration
|
|
339
252
|
|
|
@@ -345,21 +258,12 @@ Options like `pin`, `keyPath`, and `rpcUrl` are passed directly to `T2000.create
|
|
|
345
258
|
|
|
346
259
|
## Supported Assets
|
|
347
260
|
|
|
348
|
-
User-facing
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
|
354
|
-
|-------|---------|------|----------|------|--------|----------|---------------------|--------|
|
|
355
|
-
| USDC | USDC | `0xdba3...::usdc::USDC` | 6 | ✅ | ✅ | ✅ (always returns USDC) | ✅ | — |
|
|
356
|
-
| USDT | suiUSDT | `0x375f...::usdt::USDT` | 6 | — (via rebalance) | — | — | ✅ | — |
|
|
357
|
-
| USDe | suiUSDe | `0x41d5...::sui_usde::SUI_USDE` | 6 | — (via rebalance) | — | — | ✅ | — |
|
|
358
|
-
| USDsui | USDsui | `0x44f8...::usdsui::USDSUI` | 6 | — (via rebalance) | — | — | ✅ | — |
|
|
359
|
-
| SUI | SUI | `0x2::sui::SUI` | 9 | — | — | — | — | ✅ |
|
|
360
|
-
| BTC | Bitcoin | `0xaafb...::btc::BTC` | 8 | — | — | — | — | ✅ |
|
|
361
|
-
| ETH | Ethereum | `0xd0e8...::eth::ETH` | 8 | — | — | — | — | ✅ |
|
|
362
|
-
| GOLD | Gold (XAUm) | `0x9d29...::xaum::XAUM` | 9 | — | — | — | — | ✅ |
|
|
261
|
+
User-facing savings, credit, and transfers are denominated in **USDC**.
|
|
262
|
+
|
|
263
|
+
| Asset | Display | Type | Decimals | Save | Borrow | Withdraw |
|
|
264
|
+
|-------|---------|------|----------|------|--------|----------|
|
|
265
|
+
| USDC | USDC | `0xdba3...::usdc::USDC` | 6 | ✅ | ✅ | ✅ |
|
|
266
|
+
| SUI | SUI | `0x2::sui::SUI` | 9 | — | — | — |
|
|
363
267
|
|
|
364
268
|
## Error Handling
|
|
365
269
|
|
|
@@ -376,67 +280,47 @@ try {
|
|
|
376
280
|
}
|
|
377
281
|
```
|
|
378
282
|
|
|
379
|
-
Common error codes: `INSUFFICIENT_BALANCE` · `INVALID_ADDRESS` · `INVALID_AMOUNT` · `HEALTH_FACTOR_TOO_LOW` · `NO_COLLATERAL` · `WALLET_NOT_FOUND` · `WALLET_LOCKED` · `WALLET_EXISTS` · `SIMULATION_FAILED` · `TRANSACTION_FAILED` · `PROTOCOL_PAUSED` · `INSUFFICIENT_GAS` · `
|
|
380
|
-
|
|
381
|
-
## Protocol SDKs
|
|
283
|
+
Common error codes: `INSUFFICIENT_BALANCE` · `INVALID_ADDRESS` · `INVALID_AMOUNT` · `HEALTH_FACTOR_TOO_LOW` · `NO_COLLATERAL` · `WALLET_NOT_FOUND` · `WALLET_LOCKED` · `WALLET_EXISTS` · `SIMULATION_FAILED` · `TRANSACTION_FAILED` · `PROTOCOL_PAUSED` · `INSUFFICIENT_GAS` · `WITHDRAW_WOULD_LIQUIDATE` · `AUTO_TOPUP_FAILED` · `GAS_STATION_UNAVAILABLE` · `SWAP_NO_ROUTE` · `SWAP_FAILED`
|
|
382
284
|
|
|
383
|
-
|
|
285
|
+
## Protocol Integration
|
|
384
286
|
|
|
385
|
-
|
|
386
|
-
|----------|-----|----------|
|
|
387
|
-
| NAVI | `@naviprotocol/lending` | Lending positions, deposits, withdrawals, borrows, rewards |
|
|
388
|
-
| Suilend | `@suilend/sdk` | Lending positions, obligation management, rewards |
|
|
389
|
-
| Cetus | `@cetusprotocol/aggregator-sdk` (V3) | DEX aggregation, token swaps |
|
|
287
|
+
t2000 uses an MCP-first integration model: NAVI MCP for reads, thin transaction builders for writes. No protocol SDK dependencies needed.
|
|
390
288
|
|
|
391
|
-
|
|
289
|
+
| Protocol | Integration | Used for |
|
|
290
|
+
|----------|------------|----------|
|
|
291
|
+
| NAVI | MCP (reads) + thin tx builders (writes) | Lending positions, deposits, withdrawals, borrows, rewards |
|
|
292
|
+
| Cetus Aggregator V3 | `@cetusprotocol/aggregator-sdk` (isolated) | Multi-DEX swap routing — any token pair with liquidity |
|
|
293
|
+
| VOLO | Thin tx builders (direct Move calls) | Stake SUI → vSUI, unstake vSUI → SUI |
|
|
392
294
|
|
|
393
295
|
## Testing
|
|
394
296
|
|
|
395
297
|
```bash
|
|
396
|
-
# Run all SDK unit tests
|
|
298
|
+
# Run all SDK unit tests
|
|
397
299
|
pnpm --filter @t2000/sdk test
|
|
398
300
|
|
|
399
301
|
# Run smoke tests against mainnet RPC (read-only, no transactions)
|
|
400
302
|
SMOKE=1 pnpm --filter @t2000/sdk test -- src/__smoke__
|
|
401
303
|
```
|
|
402
304
|
|
|
403
|
-
| Test File | Coverage |
|
|
404
|
-
|-----------|----------|
|
|
405
|
-
| `format.test.ts` | `mistToSui`, `suiToMist`, `usdcToRaw`, `rawToUsdc`, `rawToDisplay`, `displayToRaw`, `bpsToPercent`, `formatUsd`, `formatSui`, `formatLargeNumber` |
|
|
406
|
-
| `sui.test.ts` | `validateAddress`, `truncateAddress` |
|
|
407
|
-
| `simulate.test.ts` | `throwIfSimulationFailed` (success, failure, missing error, metadata) |
|
|
408
|
-
| `hashcash.test.ts` | PoW generation and verification |
|
|
409
|
-
| `keyManager.test.ts` | Key generation, encryption, decryption, import/export |
|
|
410
|
-
| `errors.test.ts` | `T2000Error` construction, serialization, `mapWalletError`, `mapMoveAbortCode` |
|
|
411
|
-
| `navi.test.ts` | NAVI math utilities (health factor, APY, position calculations) |
|
|
412
|
-
| `send.test.ts` | Send transaction building and validation |
|
|
413
|
-
| `manager.test.ts` | Gas resolution chain (self-fund, auto-topup, sponsored fallback) |
|
|
414
|
-
| `autoTopUp.test.ts` | Auto-topup threshold logic and swap execution |
|
|
415
|
-
| `compliance.test.ts` | Adapter contract compliance (49 checks across all adapters) |
|
|
416
|
-
| `registry.test.ts` | Best rates, multi-protocol routing, quote aggregation |
|
|
417
|
-
| `cetus.test.ts` | Cetus swap adapter (metadata, quotes, transaction building) |
|
|
418
|
-
| `suilend.test.ts` | Suilend adapter (rates, positions, health, SDK mocks) |
|
|
419
|
-
| `t2000.integration.test.ts` | End-to-end flows (save, withdraw, borrow, repay, rebalance, auto-swap) |
|
|
420
|
-
| `protocolFee.test.ts` | Protocol fee calculation and collection |
|
|
421
|
-
| `serialization.test.ts` | Transaction JSON serialization roundtrip |
|
|
422
|
-
|
|
423
305
|
## Protocol Fees
|
|
424
306
|
|
|
425
307
|
| Operation | Fee | Notes |
|
|
426
308
|
|-----------|-----|-------|
|
|
427
309
|
| Save (deposit) | 0.10% | Protocol fee on deposit |
|
|
428
310
|
| Borrow | 0.05% | Protocol fee on loan |
|
|
429
|
-
| Swap | **Free** | Cetus pool fees only; used internally by rebalance/auto-convert |
|
|
430
311
|
| Withdraw | Free | |
|
|
431
312
|
| Repay | Free | |
|
|
432
313
|
| Send | Free | |
|
|
314
|
+
| Swap | Free | Cetus Aggregator network fees only |
|
|
315
|
+
| Stake (vSUI) | Free | VOLO protocol fees only |
|
|
316
|
+
| Unstake (vSUI) | Free | |
|
|
433
317
|
| Pay (MPP) | Free | Agent pays the API price, no t2000 surcharge |
|
|
434
318
|
|
|
435
319
|
Fees are collected by the t2000 protocol treasury on-chain.
|
|
436
320
|
|
|
437
321
|
## MCP Server
|
|
438
322
|
|
|
439
|
-
The SDK powers the [`@t2000/mcp`](https://www.npmjs.com/package/@t2000/mcp) server
|
|
323
|
+
The SDK powers the [`@t2000/mcp`](https://www.npmjs.com/package/@t2000/mcp) server for Claude Desktop, Cursor, and any MCP-compatible AI platform. Run `t2000 mcp` to start.
|
|
440
324
|
|
|
441
325
|
## License
|
|
442
326
|
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/constants.ts
|
|
4
|
-
process.env.T2000_PACKAGE_ID ?? "0xab92e9f1fe549ad3d6a52924a73181b45791e76120b975138fac9ec9b75db9f3";
|
|
5
|
-
process.env.T2000_CONFIG_ID ?? "0x408add9aa9322f93cfd87523d8f603006eb8713894f4c460283c58a6888dae8a";
|
|
6
|
-
process.env.T2000_TREASURY_ID ?? "0x3bb501b8300125dca59019247941a42af6b292a150ce3cfcce9449456be2ec91";
|
|
7
|
-
process.env.T2000_API_URL ?? "https://api.t2000.ai";
|
|
8
|
-
var CETUS_PACKAGE = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb";
|
|
9
|
-
|
|
10
3
|
// src/adapters/descriptors.ts
|
|
11
|
-
var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
|
|
12
4
|
var naviDescriptor = {
|
|
13
5
|
id: "navi",
|
|
14
6
|
name: "NAVI Protocol",
|
|
@@ -25,44 +17,11 @@ var naviDescriptor = {
|
|
|
25
17
|
"incentive_v3::repay": "repay"
|
|
26
18
|
}
|
|
27
19
|
};
|
|
28
|
-
var suilendDescriptor = {
|
|
29
|
-
id: "suilend",
|
|
30
|
-
name: "Suilend",
|
|
31
|
-
packages: [SUILEND_PACKAGE],
|
|
32
|
-
actionMap: {
|
|
33
|
-
"lending_market::deposit_liquidity_and_mint_ctokens": "save",
|
|
34
|
-
"lending_market::deposit_ctokens_into_obligation": "save",
|
|
35
|
-
"lending_market::create_obligation": "save",
|
|
36
|
-
"lending_market::withdraw_ctokens": "withdraw",
|
|
37
|
-
"lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
|
|
38
|
-
"lending_market::redeem_ctokens_and_withdraw_liquidity_request": "withdraw",
|
|
39
|
-
"lending_market::fulfill_liquidity_request": "withdraw",
|
|
40
|
-
"lending_market::unstake_sui_from_staker": "withdraw",
|
|
41
|
-
"lending_market::borrow": "borrow",
|
|
42
|
-
"lending_market::repay": "repay"
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var cetusDescriptor = {
|
|
46
|
-
id: "cetus",
|
|
47
|
-
name: "Cetus DEX",
|
|
48
|
-
packages: [CETUS_PACKAGE],
|
|
49
|
-
actionMap: {
|
|
50
|
-
"router::swap": "swap",
|
|
51
|
-
"router::swap_ab_bc": "swap",
|
|
52
|
-
"router::swap_ab_cb": "swap",
|
|
53
|
-
"router::swap_ba_bc": "swap",
|
|
54
|
-
"router::swap_ba_cb": "swap"
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
20
|
var allDescriptors = [
|
|
58
|
-
naviDescriptor
|
|
59
|
-
suilendDescriptor,
|
|
60
|
-
cetusDescriptor
|
|
21
|
+
naviDescriptor
|
|
61
22
|
];
|
|
62
23
|
|
|
63
24
|
exports.allDescriptors = allDescriptors;
|
|
64
|
-
exports.cetusDescriptor = cetusDescriptor;
|
|
65
25
|
exports.naviDescriptor = naviDescriptor;
|
|
66
|
-
exports.suilendDescriptor = suilendDescriptor;
|
|
67
26
|
//# sourceMappingURL=descriptors.cjs.map
|
|
68
27
|
//# sourceMappingURL=descriptors.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/descriptors.ts"],"names":[],"mappings":";;;AAIO,IAAM,cAAA,GAAqC;AAAA,EAChD,EAAA,EAAI,MAAA;AAAA,EACJ,IAAA,EAAM,eAAA;AAAA,EACN,UAAU,EAAC;AAAA,EACX,gBAAA,EAAkB,IAAA;AAAA,EAClB,SAAA,EAAW;AAAA,IACT,6BAAA,EAA+B,MAAA;AAAA,IAC/B,uBAAA,EAAyB,MAAA;AAAA,IACzB,2BAAA,EAA6B,UAAA;AAAA,IAC7B,8BAAA,EAAgC,UAAA;AAAA,IAChC,yBAAA,EAA2B,QAAA;AAAA,IAC3B,4BAAA,EAA8B,QAAA;AAAA,IAC9B,2BAAA,EAA6B,OAAA;AAAA,IAC7B,qBAAA,EAAuB;AAAA;AAE3B;AAEO,IAAM,cAAA,GAAuC;AAAA,EAClD;AACF","file":"descriptors.cjs","sourcesContent":["import type { ProtocolDescriptor } from './types.js';\n\nexport type { ProtocolDescriptor } from './types.js';\n\nexport const naviDescriptor: ProtocolDescriptor = {\n id: 'navi',\n name: 'NAVI Protocol',\n packages: [],\n dynamicPackageId: true,\n actionMap: {\n 'incentive_v3::entry_deposit': 'save',\n 'incentive_v3::deposit': 'save',\n 'incentive_v3::withdraw_v2': 'withdraw',\n 'incentive_v3::entry_withdraw': 'withdraw',\n 'incentive_v3::borrow_v2': 'borrow',\n 'incentive_v3::entry_borrow': 'borrow',\n 'incentive_v3::entry_repay': 'repay',\n 'incentive_v3::repay': 'repay',\n },\n};\n\nexport const allDescriptors: ProtocolDescriptor[] = [\n naviDescriptor,\n];\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { P as ProtocolDescriptor, d as allDescriptors, n as naviDescriptor } from '../descriptors-Be4FAgN5.cjs';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { P as ProtocolDescriptor, d as allDescriptors, n as naviDescriptor } from '../descriptors-Be4FAgN5.js';
|
|
2
2
|
import '@mysten/sui/transactions';
|
|
3
3
|
import '@mysten/sui/jsonRpc';
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
// src/constants.ts
|
|
2
|
-
process.env.T2000_PACKAGE_ID ?? "0xab92e9f1fe549ad3d6a52924a73181b45791e76120b975138fac9ec9b75db9f3";
|
|
3
|
-
process.env.T2000_CONFIG_ID ?? "0x408add9aa9322f93cfd87523d8f603006eb8713894f4c460283c58a6888dae8a";
|
|
4
|
-
process.env.T2000_TREASURY_ID ?? "0x3bb501b8300125dca59019247941a42af6b292a150ce3cfcce9449456be2ec91";
|
|
5
|
-
process.env.T2000_API_URL ?? "https://api.t2000.ai";
|
|
6
|
-
var CETUS_PACKAGE = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb";
|
|
7
|
-
|
|
8
1
|
// src/adapters/descriptors.ts
|
|
9
|
-
var SUILEND_PACKAGE = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf";
|
|
10
2
|
var naviDescriptor = {
|
|
11
3
|
id: "navi",
|
|
12
4
|
name: "NAVI Protocol",
|
|
@@ -23,41 +15,10 @@ var naviDescriptor = {
|
|
|
23
15
|
"incentive_v3::repay": "repay"
|
|
24
16
|
}
|
|
25
17
|
};
|
|
26
|
-
var suilendDescriptor = {
|
|
27
|
-
id: "suilend",
|
|
28
|
-
name: "Suilend",
|
|
29
|
-
packages: [SUILEND_PACKAGE],
|
|
30
|
-
actionMap: {
|
|
31
|
-
"lending_market::deposit_liquidity_and_mint_ctokens": "save",
|
|
32
|
-
"lending_market::deposit_ctokens_into_obligation": "save",
|
|
33
|
-
"lending_market::create_obligation": "save",
|
|
34
|
-
"lending_market::withdraw_ctokens": "withdraw",
|
|
35
|
-
"lending_market::redeem_ctokens_and_withdraw_liquidity": "withdraw",
|
|
36
|
-
"lending_market::redeem_ctokens_and_withdraw_liquidity_request": "withdraw",
|
|
37
|
-
"lending_market::fulfill_liquidity_request": "withdraw",
|
|
38
|
-
"lending_market::unstake_sui_from_staker": "withdraw",
|
|
39
|
-
"lending_market::borrow": "borrow",
|
|
40
|
-
"lending_market::repay": "repay"
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var cetusDescriptor = {
|
|
44
|
-
id: "cetus",
|
|
45
|
-
name: "Cetus DEX",
|
|
46
|
-
packages: [CETUS_PACKAGE],
|
|
47
|
-
actionMap: {
|
|
48
|
-
"router::swap": "swap",
|
|
49
|
-
"router::swap_ab_bc": "swap",
|
|
50
|
-
"router::swap_ab_cb": "swap",
|
|
51
|
-
"router::swap_ba_bc": "swap",
|
|
52
|
-
"router::swap_ba_cb": "swap"
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
18
|
var allDescriptors = [
|
|
56
|
-
naviDescriptor
|
|
57
|
-
suilendDescriptor,
|
|
58
|
-
cetusDescriptor
|
|
19
|
+
naviDescriptor
|
|
59
20
|
];
|
|
60
21
|
|
|
61
|
-
export { allDescriptors,
|
|
22
|
+
export { allDescriptors, naviDescriptor };
|
|
62
23
|
//# sourceMappingURL=descriptors.js.map
|
|
63
24
|
//# sourceMappingURL=descriptors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/descriptors.ts"],"names":[],"mappings":";AAIO,IAAM,cAAA,GAAqC;AAAA,EAChD,EAAA,EAAI,MAAA;AAAA,EACJ,IAAA,EAAM,eAAA;AAAA,EACN,UAAU,EAAC;AAAA,EACX,gBAAA,EAAkB,IAAA;AAAA,EAClB,SAAA,EAAW;AAAA,IACT,6BAAA,EAA+B,MAAA;AAAA,IAC/B,uBAAA,EAAyB,MAAA;AAAA,IACzB,2BAAA,EAA6B,UAAA;AAAA,IAC7B,8BAAA,EAAgC,UAAA;AAAA,IAChC,yBAAA,EAA2B,QAAA;AAAA,IAC3B,4BAAA,EAA8B,QAAA;AAAA,IAC9B,2BAAA,EAA6B,OAAA;AAAA,IAC7B,qBAAA,EAAuB;AAAA;AAE3B;AAEO,IAAM,cAAA,GAAuC;AAAA,EAClD;AACF","file":"descriptors.js","sourcesContent":["import type { ProtocolDescriptor } from './types.js';\n\nexport type { ProtocolDescriptor } from './types.js';\n\nexport const naviDescriptor: ProtocolDescriptor = {\n id: 'navi',\n name: 'NAVI Protocol',\n packages: [],\n dynamicPackageId: true,\n actionMap: {\n 'incentive_v3::entry_deposit': 'save',\n 'incentive_v3::deposit': 'save',\n 'incentive_v3::withdraw_v2': 'withdraw',\n 'incentive_v3::entry_withdraw': 'withdraw',\n 'incentive_v3::borrow_v2': 'borrow',\n 'incentive_v3::entry_borrow': 'borrow',\n 'incentive_v3::entry_repay': 'repay',\n 'incentive_v3::repay': 'repay',\n },\n};\n\nexport const allDescriptors: ProtocolDescriptor[] = [\n naviDescriptor,\n];\n"]}
|