@t2000/cli 0.13.1 → 0.14.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
|
@@ -30,7 +30,7 @@ t2000 init
|
|
|
30
30
|
✓ Gas sponsorship enabled
|
|
31
31
|
|
|
32
32
|
Setting up accounts...
|
|
33
|
-
✓ Checking ✓ Savings ✓ Credit ✓ Exchange ✓ 402 Pay
|
|
33
|
+
✓ Checking ✓ Savings ✓ Credit ✓ Investment ✓ Exchange ✓ 402 Pay
|
|
34
34
|
|
|
35
35
|
🎉 Bank account created
|
|
36
36
|
Address: 0x8b3e4f2a...
|
|
@@ -84,6 +84,34 @@ t2000 init
|
|
|
84
84
|
Gas: 0.31 SUI (~$0.28)
|
|
85
85
|
──────────────────────────────────────
|
|
86
86
|
Total: $85.28
|
|
87
|
+
❯ t2000 invest buy 100 SUI
|
|
88
|
+
✓ Bought 105.26 SUI at $0.95
|
|
89
|
+
Invested: $100.00
|
|
90
|
+
Portfolio: 105.26 SUI (avg $0.95)
|
|
91
|
+
Tx: https://suiscan.xyz/mainnet/tx/...
|
|
92
|
+
|
|
93
|
+
❯ t2000 invest buy 500 BTC
|
|
94
|
+
✓ Bought 0.00512820 BTC at $97,500.00
|
|
95
|
+
Invested: $500.00
|
|
96
|
+
Portfolio: 0.00512820 BTC (avg $97,500.00)
|
|
97
|
+
Tx: https://suiscan.xyz/mainnet/tx/...
|
|
98
|
+
|
|
99
|
+
❯ t2000 invest buy 200 ETH
|
|
100
|
+
✓ Bought 0.10526316 ETH at $1,900.00
|
|
101
|
+
Invested: $200.00
|
|
102
|
+
Portfolio: 0.10526316 ETH (avg $1,900.00)
|
|
103
|
+
Tx: https://suiscan.xyz/mainnet/tx/...
|
|
104
|
+
|
|
105
|
+
❯ t2000 portfolio
|
|
106
|
+
Investment Portfolio
|
|
107
|
+
─────────────────────────────────────────────────────
|
|
108
|
+
SUI 105.26000000 Avg: $0.95 Now: $0.97 +$2.10 (+2.1%)
|
|
109
|
+
BTC 0.00512820 Avg: $97,500 Now: $98,200 +$3.59 (+0.7%)
|
|
110
|
+
ETH 0.10526316 Avg: $1,900 Now: $1,920 +$2.11 (+1.1%)
|
|
111
|
+
─────────────────────────────────────────────────────
|
|
112
|
+
Total invested: $800.00
|
|
113
|
+
Current value: $807.80
|
|
114
|
+
Unrealized P&L: +$7.80 (+1.0%)
|
|
87
115
|
```
|
|
88
116
|
|
|
89
117
|
30 seconds. Send → save → borrow → pay → repay → withdraw.
|
|
@@ -162,6 +190,16 @@ t2000 init
|
|
|
162
190
|
| `t2000 contacts add <name> <address>` | Save a named contact |
|
|
163
191
|
| `t2000 contacts remove <name>` | Remove a contact |
|
|
164
192
|
|
|
193
|
+
### Investment
|
|
194
|
+
|
|
195
|
+
| Command | Description |
|
|
196
|
+
|---------|-------------|
|
|
197
|
+
| `t2000 invest buy <amount> <asset>` | Buy crypto with USDC (e.g. `t2000 invest buy 500 BTC`, `t2000 invest buy 200 ETH`) |
|
|
198
|
+
| `t2000 invest sell <amount\|all> <asset>` | Sell crypto back to USDC |
|
|
199
|
+
| `t2000 portfolio` | View investment portfolio with cost-basis P&L |
|
|
200
|
+
|
|
201
|
+
Supported assets: SUI, BTC, ETH. Dollar-denominated — `amount` is in USD.
|
|
202
|
+
|
|
165
203
|
### Safeguards
|
|
166
204
|
|
|
167
205
|
| Command | Description |
|
|
@@ -192,7 +230,7 @@ t2000 mcp uninstall
|
|
|
192
230
|
t2000 mcp
|
|
193
231
|
```
|
|
194
232
|
|
|
195
|
-
|
|
233
|
+
19 tools, 6 prompts, safeguard enforced. See [MCP setup guide](../../docs/mcp-setup.md) for details.
|
|
196
234
|
|
|
197
235
|
### HTTP API Server
|
|
198
236
|
|
|
@@ -20965,7 +20965,7 @@ var StdioServerTransport = class {
|
|
|
20965
20965
|
import { readFile } from "fs/promises";
|
|
20966
20966
|
import { resolve } from "path";
|
|
20967
20967
|
import { homedir } from "os";
|
|
20968
|
-
import { T2000, SafeguardError, T2000Error } from "@t2000/sdk";
|
|
20968
|
+
import { T2000, INVESTMENT_ASSETS, SafeguardError, T2000Error } from "@t2000/sdk";
|
|
20969
20969
|
var SESSION_PATH = resolve(homedir(), ".t2000", ".session");
|
|
20970
20970
|
async function resolvePin() {
|
|
20971
20971
|
const envPin = process.env.T2000_PIN ?? process.env.T2000_PASSPHRASE;
|
|
@@ -21117,6 +21117,26 @@ function registerReadTools(server, agent) {
|
|
|
21117
21117
|
}
|
|
21118
21118
|
}
|
|
21119
21119
|
);
|
|
21120
|
+
server.tool(
|
|
21121
|
+
"t2000_portfolio",
|
|
21122
|
+
"Show investment portfolio \u2014 positions, cost basis, current value, unrealized/realized P&L.",
|
|
21123
|
+
{},
|
|
21124
|
+
async () => {
|
|
21125
|
+
try {
|
|
21126
|
+
const result = await agent.getPortfolio();
|
|
21127
|
+
const enriched = {
|
|
21128
|
+
...result,
|
|
21129
|
+
positions: result.positions.map((p) => ({
|
|
21130
|
+
...p,
|
|
21131
|
+
...p.currentPrice === 0 && p.totalAmount > 0 ? { note: "price unavailable" } : {}
|
|
21132
|
+
}))
|
|
21133
|
+
};
|
|
21134
|
+
return { content: [{ type: "text", text: JSON.stringify(enriched) }] };
|
|
21135
|
+
} catch (err) {
|
|
21136
|
+
return errorResult(err);
|
|
21137
|
+
}
|
|
21138
|
+
}
|
|
21139
|
+
);
|
|
21120
21140
|
}
|
|
21121
21141
|
var TxMutex = class {
|
|
21122
21142
|
queue = Promise.resolve();
|
|
@@ -21351,6 +21371,58 @@ function registerWriteTools(server, agent) {
|
|
|
21351
21371
|
}
|
|
21352
21372
|
}
|
|
21353
21373
|
);
|
|
21374
|
+
const investAssets = Object.keys(INVESTMENT_ASSETS);
|
|
21375
|
+
server.tool(
|
|
21376
|
+
"t2000_invest",
|
|
21377
|
+
"Buy or sell investment assets (spot). Amount is in USD. Asset is the crypto to buy/sell (e.g. SUI, BTC, ETH). Set dryRun: true to preview.",
|
|
21378
|
+
{
|
|
21379
|
+
action: external_exports.enum(["buy", "sell"]).describe("'buy' to invest USD into asset, 'sell' to convert asset back to USDC"),
|
|
21380
|
+
asset: external_exports.enum(investAssets).describe("Asset to invest in"),
|
|
21381
|
+
amount: external_exports.union([external_exports.number(), external_exports.literal("all")]).describe('USD amount, or "all" to sell entire position'),
|
|
21382
|
+
slippage: external_exports.number().optional().describe("Max slippage percent (default: 3)"),
|
|
21383
|
+
dryRun: external_exports.boolean().optional().describe("Preview without signing (default: false)")
|
|
21384
|
+
},
|
|
21385
|
+
async ({ action, asset, amount, slippage, dryRun }) => {
|
|
21386
|
+
try {
|
|
21387
|
+
if (dryRun) {
|
|
21388
|
+
agent.enforcer.assertNotLocked();
|
|
21389
|
+
const balance = await agent.balance();
|
|
21390
|
+
const portfolio = await agent.getPortfolio();
|
|
21391
|
+
const position = portfolio.positions.find((p) => p.asset === asset);
|
|
21392
|
+
if (action === "sell" && amount === "all" && !position) {
|
|
21393
|
+
return {
|
|
21394
|
+
content: [{ type: "text", text: JSON.stringify({ preview: true, error: `No ${asset} position to sell` }) }]
|
|
21395
|
+
};
|
|
21396
|
+
}
|
|
21397
|
+
return {
|
|
21398
|
+
content: [{
|
|
21399
|
+
type: "text",
|
|
21400
|
+
text: JSON.stringify({
|
|
21401
|
+
preview: true,
|
|
21402
|
+
action,
|
|
21403
|
+
asset,
|
|
21404
|
+
amount: amount === "all" ? position?.currentValue ?? 0 : amount,
|
|
21405
|
+
currentBalance: balance.available,
|
|
21406
|
+
currentPosition: position ?? null
|
|
21407
|
+
})
|
|
21408
|
+
}]
|
|
21409
|
+
};
|
|
21410
|
+
}
|
|
21411
|
+
const maxSlippage = slippage ? slippage / 100 : void 0;
|
|
21412
|
+
if (action === "buy") {
|
|
21413
|
+
if (typeof amount !== "number") throw new Error("Buy amount must be a number");
|
|
21414
|
+
const result = await mutex.run(() => agent.investBuy({ asset, usdAmount: amount, maxSlippage }));
|
|
21415
|
+
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
|
21416
|
+
} else {
|
|
21417
|
+
const usdAmount = amount === "all" ? "all" : amount;
|
|
21418
|
+
const result = await mutex.run(() => agent.investSell({ asset, usdAmount, maxSlippage }));
|
|
21419
|
+
return { content: [{ type: "text", text: JSON.stringify(result) }] };
|
|
21420
|
+
}
|
|
21421
|
+
} catch (err) {
|
|
21422
|
+
return errorResult(err);
|
|
21423
|
+
}
|
|
21424
|
+
}
|
|
21425
|
+
);
|
|
21354
21426
|
server.tool(
|
|
21355
21427
|
"t2000_rebalance",
|
|
21356
21428
|
"Optimize yield by moving funds to the highest-rate protocol. Always previews first \u2014 set dryRun: false to execute. Shows plan with expected APY gain and break-even period.",
|
|
@@ -21464,6 +21536,7 @@ function registerPrompts(server) {
|
|
|
21464
21536
|
"3. Check the health factor (t2000_health)",
|
|
21465
21537
|
"4. Show yield earnings (t2000_earnings)",
|
|
21466
21538
|
"5. Review current interest rates (t2000_rates)",
|
|
21539
|
+
"6. Check investment portfolio (t2000_portfolio)",
|
|
21467
21540
|
"",
|
|
21468
21541
|
"Summarize the agent's financial health in a clear, concise format with actionable recommendations."
|
|
21469
21542
|
].join("\n")
|
|
@@ -21581,6 +21654,7 @@ ${context}
|
|
|
21581
21654
|
"- Which protocol offers the best rate right now",
|
|
21582
21655
|
"- Expected annual yield on the recommended amount",
|
|
21583
21656
|
"- If they should rebalance existing savings (t2000_rebalance with dryRun: true)",
|
|
21657
|
+
"- Whether investing in SUI or other assets could complement their savings strategy",
|
|
21584
21658
|
"",
|
|
21585
21659
|
"If they want to proceed, use t2000_save to deposit. Always preview first."
|
|
21586
21660
|
].join("\n")
|
|
@@ -21588,6 +21662,34 @@ ${context}
|
|
|
21588
21662
|
}]
|
|
21589
21663
|
})
|
|
21590
21664
|
);
|
|
21665
|
+
server.prompt(
|
|
21666
|
+
"investment-strategy",
|
|
21667
|
+
"Analyze investment portfolio, suggest allocation, review risk, and recommend next steps.",
|
|
21668
|
+
async () => ({
|
|
21669
|
+
messages: [{
|
|
21670
|
+
role: "user",
|
|
21671
|
+
content: {
|
|
21672
|
+
type: "text",
|
|
21673
|
+
text: [
|
|
21674
|
+
"You are an investment advisor for a t2000 AI agent bank account.",
|
|
21675
|
+
"",
|
|
21676
|
+
"Analyze the user's investment position:",
|
|
21677
|
+
"1. Check current balance (t2000_balance) \u2014 available checking, savings, investment value",
|
|
21678
|
+
"2. Check investment portfolio (t2000_portfolio) \u2014 positions, cost basis, P&L",
|
|
21679
|
+
"3. Compare current rates (t2000_rates) \u2014 yield alternatives",
|
|
21680
|
+
"",
|
|
21681
|
+
"Recommend:",
|
|
21682
|
+
"- Portfolio allocation assessment (what % is in checking vs savings vs investment)",
|
|
21683
|
+
"- Whether current positions are performing well or need adjustment",
|
|
21684
|
+
"- If idle checking funds should be invested or saved for yield",
|
|
21685
|
+
"- Risk assessment \u2014 concentration, unrealized losses, cost basis vs current price",
|
|
21686
|
+
"",
|
|
21687
|
+
"If they want to invest, use t2000_invest with dryRun: true to preview first."
|
|
21688
|
+
].join("\n")
|
|
21689
|
+
}
|
|
21690
|
+
}]
|
|
21691
|
+
})
|
|
21692
|
+
);
|
|
21591
21693
|
}
|
|
21592
21694
|
async function startMcpServer(opts) {
|
|
21593
21695
|
const agent = await createAgent(opts?.keyPath);
|
|
@@ -21608,4 +21710,4 @@ async function startMcpServer(opts) {
|
|
|
21608
21710
|
export {
|
|
21609
21711
|
startMcpServer
|
|
21610
21712
|
};
|
|
21611
|
-
//# sourceMappingURL=dist-
|
|
21713
|
+
//# sourceMappingURL=dist-4YM7JZSI.js.map
|