@t2000/cli 0.12.2 → 0.13.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/dist/index.js
CHANGED
|
@@ -202,7 +202,8 @@ function registerSend(program2) {
|
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
printBlank();
|
|
205
|
-
|
|
205
|
+
const displayTo = result.contactName ? `${result.contactName} (${truncateAddress(result.to)})` : truncateAddress(result.to);
|
|
206
|
+
printSuccess(`Sent ${formatUsd(result.amount)} ${asset.toUpperCase()} \u2192 ${displayTo}`);
|
|
206
207
|
printKeyValue("Gas", `${result.gasCost.toFixed(4)} ${result.gasCostUnit} (${result.gasMethod})`);
|
|
207
208
|
printKeyValue("Balance", formatUsd(result.balance.available) + " USDC");
|
|
208
209
|
printKeyValue("Tx", explorerUrl(result.tx));
|
|
@@ -254,9 +255,14 @@ function registerBalance(program2) {
|
|
|
254
255
|
if (bal.savings > 0.01) {
|
|
255
256
|
const positions = await agent.positions();
|
|
256
257
|
const saves = positions.positions.filter((p) => p.type === "save");
|
|
258
|
+
const borrows = positions.positions.filter((p) => p.type === "borrow");
|
|
257
259
|
const weightedApy = saves.length > 0 ? saves.reduce((sum, p) => sum + p.amount * p.apy, 0) / saves.reduce((sum, p) => sum + p.amount, 0) : 0;
|
|
258
260
|
const dailyEarning = bal.savings * (weightedApy / 100) / 365;
|
|
259
261
|
printKeyValue("Savings", `${formatUsd2(bal.savings)} ${pc3.dim(`(earning ${weightedApy.toFixed(2)}% APY)`)}`);
|
|
262
|
+
if (bal.debt > 0.01) {
|
|
263
|
+
const borrowApy = borrows.length > 0 ? borrows.reduce((sum, p) => sum + p.amount * p.apy, 0) / borrows.reduce((sum, p) => sum + p.amount, 0) : 0;
|
|
264
|
+
printKeyValue("Credit", `${pc3.red(`-${formatUsd2(bal.debt)}`)} ${pc3.dim(`(${borrowApy.toFixed(2)}% APY)`)}`);
|
|
265
|
+
}
|
|
260
266
|
printKeyValue("Gas", `${bal.gasReserve.sui.toFixed(2)} SUI ${pc3.dim(`(~${formatUsd2(bal.gasReserve.usdEquiv)})`)}`);
|
|
261
267
|
printSeparator();
|
|
262
268
|
printKeyValue("Total", `${formatUsd2(bal.total)}`);
|
|
@@ -264,6 +270,9 @@ function registerBalance(program2) {
|
|
|
264
270
|
printLine(` ${pc3.dim(`Earning ~${formatUsd2(dailyEarning)}/day`)}`);
|
|
265
271
|
}
|
|
266
272
|
} else {
|
|
273
|
+
if (bal.debt > 0.01) {
|
|
274
|
+
printKeyValue("Credit", `${pc3.red(`-${formatUsd2(bal.debt)}`)}`);
|
|
275
|
+
}
|
|
267
276
|
printKeyValue("Savings", `${formatUsd2(bal.savings)}`);
|
|
268
277
|
printKeyValue("Gas", `${bal.gasReserve.sui.toFixed(2)} SUI ${pc3.dim(`(~${formatUsd2(bal.gasReserve.usdEquiv)})`)}`);
|
|
269
278
|
printSeparator();
|
|
@@ -1751,7 +1760,7 @@ function registerMcp(program2) {
|
|
|
1751
1760
|
mcp.command("start", { isDefault: true }).description("Start MCP server (stdio transport)").option("--key <path>", "Key file path").action(async (opts) => {
|
|
1752
1761
|
let mod;
|
|
1753
1762
|
try {
|
|
1754
|
-
mod = await import("./dist-
|
|
1763
|
+
mod = await import("./dist-QGTOSQO3.js");
|
|
1755
1764
|
} catch {
|
|
1756
1765
|
console.error(
|
|
1757
1766
|
"MCP server not installed. Run:\n npm install -g @t2000/mcp"
|
|
@@ -1834,6 +1843,74 @@ function registerMcp(program2) {
|
|
|
1834
1843
|
});
|
|
1835
1844
|
}
|
|
1836
1845
|
|
|
1846
|
+
// src/commands/contacts.ts
|
|
1847
|
+
import { ContactManager, truncateAddress as truncateAddress3 } from "@t2000/sdk";
|
|
1848
|
+
function registerContacts(program2) {
|
|
1849
|
+
const contacts = program2.command("contacts").description("Manage contacts (send by name instead of address)");
|
|
1850
|
+
contacts.command("add <name> <address>").description("Add or update a contact").action((name, address) => {
|
|
1851
|
+
try {
|
|
1852
|
+
const manager = new ContactManager();
|
|
1853
|
+
const result = manager.add(name, address);
|
|
1854
|
+
if (isJsonMode()) {
|
|
1855
|
+
const contact2 = manager.get(name);
|
|
1856
|
+
printJson({ action: result.action, name: contact2.name, address: contact2.address });
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1859
|
+
const contact = manager.get(name);
|
|
1860
|
+
printBlank();
|
|
1861
|
+
printSuccess(`${result.action === "added" ? "Added" : "Updated"} ${contact.name} (${truncateAddress3(contact.address)})`);
|
|
1862
|
+
printBlank();
|
|
1863
|
+
} catch (error) {
|
|
1864
|
+
handleError(error);
|
|
1865
|
+
}
|
|
1866
|
+
});
|
|
1867
|
+
contacts.command("remove <name>").description("Remove a contact").action((name) => {
|
|
1868
|
+
try {
|
|
1869
|
+
const manager = new ContactManager();
|
|
1870
|
+
const removed = manager.remove(name);
|
|
1871
|
+
if (isJsonMode()) {
|
|
1872
|
+
printJson({ removed, name });
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
printBlank();
|
|
1876
|
+
if (removed) {
|
|
1877
|
+
printSuccess(`Removed ${name}`);
|
|
1878
|
+
} else {
|
|
1879
|
+
printError(`Contact "${name}" not found`);
|
|
1880
|
+
}
|
|
1881
|
+
printBlank();
|
|
1882
|
+
} catch (error) {
|
|
1883
|
+
handleError(error);
|
|
1884
|
+
}
|
|
1885
|
+
});
|
|
1886
|
+
contacts.command("list", { isDefault: true }).description("List all contacts").action(() => {
|
|
1887
|
+
try {
|
|
1888
|
+
const manager = new ContactManager();
|
|
1889
|
+
const list = manager.list();
|
|
1890
|
+
if (isJsonMode()) {
|
|
1891
|
+
printJson(list);
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
if (list.length === 0) {
|
|
1895
|
+
printBlank();
|
|
1896
|
+
printLine("No contacts yet.");
|
|
1897
|
+
printLine("Add one: t2000 contacts add Tom 0x...");
|
|
1898
|
+
printBlank();
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
printHeader("Contacts");
|
|
1902
|
+
const maxNameLen = Math.max(...list.map((c) => c.name.length));
|
|
1903
|
+
for (const contact of list) {
|
|
1904
|
+
const padded = contact.name.padEnd(maxNameLen + 4);
|
|
1905
|
+
printLine(`${padded}${truncateAddress3(contact.address)}`);
|
|
1906
|
+
}
|
|
1907
|
+
printBlank();
|
|
1908
|
+
} catch (error) {
|
|
1909
|
+
handleError(error);
|
|
1910
|
+
}
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1837
1914
|
// src/program.ts
|
|
1838
1915
|
var require2 = createRequire(import.meta.url);
|
|
1839
1916
|
var { version: CLI_VERSION } = require2("../package.json");
|
|
@@ -1869,6 +1946,7 @@ function createProgram() {
|
|
|
1869
1946
|
registerRebalance(program2);
|
|
1870
1947
|
registerExchange(program2);
|
|
1871
1948
|
registerMcp(program2);
|
|
1949
|
+
registerContacts(program2);
|
|
1872
1950
|
return program2;
|
|
1873
1951
|
}
|
|
1874
1952
|
|