@t2000/cli 3.1.0 → 3.2.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 +15 -24
- package/dist/{chunk-R7KXQRHQ.js → chunk-ZH6PX6WS.js} +91 -82
- package/dist/{chunk-R7KXQRHQ.js.map → chunk-ZH6PX6WS.js.map} +1 -1
- package/dist/{dist-CIFLOG63.js → dist-NH7XYB4F.js} +105 -50
- package/dist/{dist-CIFLOG63.js.map → dist-NH7XYB4F.js.map} +1 -1
- package/dist/{dist-A7D5R6SM.js → dist-UOJPIH47.js} +4 -2
- package/dist/index.js +71 -53
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- /package/dist/{dist-A7D5R6SM.js.map → dist-UOJPIH47.js.map} +0 -0
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
OUTBOUND_OPS,
|
|
30
30
|
OVERLAY_FEE_RATE,
|
|
31
31
|
ProtocolRegistry,
|
|
32
|
+
SAVEABLE_ASSETS,
|
|
32
33
|
SAVE_FEE_BPS,
|
|
33
34
|
SPONSORED_PYTH_DEPENDENT_PROVIDERS,
|
|
34
35
|
STABLE_ASSETS,
|
|
@@ -149,7 +150,7 @@ import {
|
|
|
149
150
|
validateLabel,
|
|
150
151
|
verifyCetusRouteCoinMatch,
|
|
151
152
|
walletExists
|
|
152
|
-
} from "./chunk-
|
|
153
|
+
} from "./chunk-ZH6PX6WS.js";
|
|
153
154
|
import "./chunk-ZRPJE7U5.js";
|
|
154
155
|
import "./chunk-OCLKPYUU.js";
|
|
155
156
|
import "./chunk-SI54PO2N.js";
|
|
@@ -190,6 +191,7 @@ export {
|
|
|
190
191
|
OUTBOUND_OPS,
|
|
191
192
|
OVERLAY_FEE_RATE,
|
|
192
193
|
ProtocolRegistry,
|
|
194
|
+
SAVEABLE_ASSETS,
|
|
193
195
|
SAVE_FEE_BPS,
|
|
194
196
|
SPONSORED_PYTH_DEPENDENT_PROVIDERS,
|
|
195
197
|
STABLE_ASSETS,
|
|
@@ -311,4 +313,4 @@ export {
|
|
|
311
313
|
verifyCetusRouteCoinMatch,
|
|
312
314
|
walletExists
|
|
313
315
|
};
|
|
314
|
-
//# sourceMappingURL=dist-
|
|
316
|
+
//# sourceMappingURL=dist-UOJPIH47.js.map
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
saveKey,
|
|
13
13
|
truncateAddress,
|
|
14
14
|
walletExists
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZH6PX6WS.js";
|
|
16
16
|
import {
|
|
17
17
|
esm_default3 as esm_default,
|
|
18
18
|
esm_default8 as esm_default2
|
|
@@ -3483,6 +3483,9 @@ function printSeparator() {
|
|
|
3483
3483
|
if (jsonMode) return;
|
|
3484
3484
|
console.log(` ${import_picocolors.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")}`);
|
|
3485
3485
|
}
|
|
3486
|
+
function formatApyPercent(decimal, digits = 2) {
|
|
3487
|
+
return `${(decimal * 100).toFixed(digits)}%`;
|
|
3488
|
+
}
|
|
3486
3489
|
function explorerUrl(txHash, network = "mainnet") {
|
|
3487
3490
|
const base = network === "testnet" ? "https://suiscan.xyz/testnet/tx" : "https://suiscan.xyz/mainnet/tx";
|
|
3488
3491
|
const suffix = "";
|
|
@@ -3610,13 +3613,13 @@ async function installMcpForPlatforms(platforms) {
|
|
|
3610
3613
|
}
|
|
3611
3614
|
}
|
|
3612
3615
|
function registerInit(program3) {
|
|
3613
|
-
program3.command("init").description("Create a new
|
|
3616
|
+
program3.command("init").description("Create a new Agentic Wallet \u2014 guided setup with MCP + safeguards").option("--key <path>", "Key file path").action(async (opts) => {
|
|
3614
3617
|
try {
|
|
3615
3618
|
const { checkbox, input, password } = await import("./esm-G2QBGTGV.js");
|
|
3616
3619
|
console.log("");
|
|
3617
3620
|
console.log(` \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510`);
|
|
3618
3621
|
console.log(` \u2502 ${import_picocolors2.default.bold("Welcome to t2000")} \u2502`);
|
|
3619
|
-
console.log(` \u2502
|
|
3622
|
+
console.log(` \u2502 Agentic Wallet for AI agents \u2502`);
|
|
3620
3623
|
console.log(` \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518`);
|
|
3621
3624
|
console.log("");
|
|
3622
3625
|
const hasWallet = await walletExists(opts.key);
|
|
@@ -3652,7 +3655,7 @@ function registerInit(program3) {
|
|
|
3652
3655
|
` ${import_picocolors2.default.green("\u2713")} Checking ${import_picocolors2.default.green("\u2713")} Savings ${import_picocolors2.default.green("\u2713")} Credit`
|
|
3653
3656
|
);
|
|
3654
3657
|
printBlank();
|
|
3655
|
-
printLine(` \u{1F389} ${import_picocolors2.default.green("
|
|
3658
|
+
printLine(` \u{1F389} ${import_picocolors2.default.green("Agentic Wallet created")}`);
|
|
3656
3659
|
printLine(` Address: ${import_picocolors2.default.yellow(address.slice(0, 6) + "..." + address.slice(-4))}`);
|
|
3657
3660
|
printBlank();
|
|
3658
3661
|
printInfo("Fund your wallet to start:");
|
|
@@ -3811,11 +3814,11 @@ function registerBalance(program3) {
|
|
|
3811
3814
|
const saves = positions.positions.filter((p) => p.type === "save");
|
|
3812
3815
|
const borrows = positions.positions.filter((p) => p.type === "borrow");
|
|
3813
3816
|
const weightedApy = saves.length > 0 ? saves.reduce((sum, p) => sum + (p.amountUsd ?? p.amount) * p.apy, 0) / saves.reduce((sum, p) => sum + (p.amountUsd ?? p.amount), 0) : 0;
|
|
3814
|
-
const dailyEarning = bal.savings *
|
|
3815
|
-
printKeyValue("Savings", `${formatUsd(bal.savings)} ${import_picocolors3.default.dim(`(earning ${weightedApy
|
|
3817
|
+
const dailyEarning = bal.savings * weightedApy / 365;
|
|
3818
|
+
printKeyValue("Savings", `${formatUsd(bal.savings)} ${import_picocolors3.default.dim(`(earning ${formatApyPercent(weightedApy)} APY)`)}`);
|
|
3816
3819
|
if (bal.debt > 0.01) {
|
|
3817
3820
|
const borrowApy = borrows.length > 0 ? borrows.reduce((sum, p) => sum + (p.amountUsd ?? p.amount) * p.apy, 0) / borrows.reduce((sum, p) => sum + (p.amountUsd ?? p.amount), 0) : 0;
|
|
3818
|
-
printKeyValue("Credit", `${import_picocolors3.default.red(`-${formatUsd(bal.debt)}`)} ${import_picocolors3.default.dim(`(${borrowApy
|
|
3821
|
+
printKeyValue("Credit", `${import_picocolors3.default.red(`-${formatUsd(bal.debt)}`)} ${import_picocolors3.default.dim(`(${formatApyPercent(borrowApy)} APY)`)}`);
|
|
3819
3822
|
}
|
|
3820
3823
|
if (bal.gasReserve && bal.gasReserve.usdEquiv >= 0.01) {
|
|
3821
3824
|
printKeyValue("Gas reserve", `${formatUsd(bal.gasReserve.usdEquiv)} ${import_picocolors3.default.dim(`(${bal.gasReserve.sui.toFixed(2)} SUI)`)}`);
|
|
@@ -3872,23 +3875,28 @@ function registerAddress(program3) {
|
|
|
3872
3875
|
});
|
|
3873
3876
|
}
|
|
3874
3877
|
|
|
3875
|
-
// src/commands/
|
|
3876
|
-
function
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
return;
|
|
3885
|
-
}
|
|
3886
|
-
printHeader("Fund your wallet");
|
|
3887
|
-
console.log(info.instructions);
|
|
3888
|
-
printBlank();
|
|
3889
|
-
} catch (error) {
|
|
3890
|
-
handleError(error);
|
|
3878
|
+
// src/commands/fund.ts
|
|
3879
|
+
async function runFund(opts) {
|
|
3880
|
+
try {
|
|
3881
|
+
const pin = await resolvePin();
|
|
3882
|
+
const agent = await T2000.create({ pin, keyPath: opts.key });
|
|
3883
|
+
const info = await agent.fund();
|
|
3884
|
+
if (isJsonMode()) {
|
|
3885
|
+
printJson(info);
|
|
3886
|
+
return;
|
|
3891
3887
|
}
|
|
3888
|
+
printHeader("Fund your Agentic Wallet");
|
|
3889
|
+
console.log(info.instructions);
|
|
3890
|
+
printBlank();
|
|
3891
|
+
} catch (error) {
|
|
3892
|
+
handleError(error);
|
|
3893
|
+
}
|
|
3894
|
+
}
|
|
3895
|
+
function registerFund(program3) {
|
|
3896
|
+
program3.command("fund").description("Show how to fund your Agentic Wallet (receive address + supported networks)").option("--key <path>", "Key file path").action(runFund);
|
|
3897
|
+
program3.command("deposit").description("[deprecated] Use `t2000 fund` instead").option("--key <path>", "Key file path").action(async (opts) => {
|
|
3898
|
+
console.error("Warning: `t2000 deposit` is deprecated. Use `t2000 fund` instead.");
|
|
3899
|
+
await runFund(opts);
|
|
3892
3900
|
});
|
|
3893
3901
|
}
|
|
3894
3902
|
|
|
@@ -4127,7 +4135,7 @@ function registerSave(program3) {
|
|
|
4127
4135
|
const feeRate = (result.fee / result.amount * 100).toFixed(1);
|
|
4128
4136
|
printSuccess(`Protocol fee: ${import_picocolors5.default.dim(`${formatUsd(result.fee)} ${asset} (${feeRate}%)`)}`);
|
|
4129
4137
|
}
|
|
4130
|
-
printSuccess(`Current APY: ${import_picocolors5.default.green(
|
|
4138
|
+
printSuccess(`Current APY: ${import_picocolors5.default.green(formatApyPercent(result.apy))}`);
|
|
4131
4139
|
printSuccess(`Savings balance: ${import_picocolors5.default.yellow(formatUsd(result.savingsBalance))} ${asset}`);
|
|
4132
4140
|
printKeyValue("Tx", explorerUrl(result.tx));
|
|
4133
4141
|
printBlank();
|
|
@@ -4136,7 +4144,6 @@ function registerSave(program3) {
|
|
|
4136
4144
|
}
|
|
4137
4145
|
};
|
|
4138
4146
|
program3.command("save").description("Deposit USDC or USDsui into NAVI lending to earn yield").argument("<amount>", 'Amount of the chosen asset to save (or "all")').option("--key <path>", "Key file path").option("--protocol <name>", "Protocol to use (e.g. navi)").option("--asset <symbol>", "Asset to save: USDC (default) or USDsui").action(action);
|
|
4139
|
-
program3.command("supply").description("Deposit USDC or USDsui into NAVI lending (alias for save)").argument("<amount>", 'Amount of the chosen asset to save (or "all")').option("--key <path>", "Key file path").option("--protocol <name>", "Protocol to use (e.g. navi)").option("--asset <symbol>", "Asset to save: USDC (default) or USDsui").action(action);
|
|
4140
4147
|
}
|
|
4141
4148
|
|
|
4142
4149
|
// src/commands/withdraw.ts
|
|
@@ -4293,7 +4300,7 @@ function registerRates(program3) {
|
|
|
4293
4300
|
if (allRates.length > 0) {
|
|
4294
4301
|
const best = allRates.reduce((a, b) => b.rates.saveApy > a.rates.saveApy ? b : a);
|
|
4295
4302
|
const bestDisplay = SUPPORTED_ASSETS[best.asset]?.displayName ?? best.asset;
|
|
4296
|
-
printLine(import_picocolors6.default.bold(import_picocolors6.default.green(`Best yield: ${best.rates.saveApy
|
|
4303
|
+
printLine(import_picocolors6.default.bold(import_picocolors6.default.green(`Best yield: ${formatApyPercent(best.rates.saveApy)} APY`)) + import_picocolors6.default.dim(` (${bestDisplay} on ${best.protocol})`));
|
|
4297
4304
|
printBlank();
|
|
4298
4305
|
}
|
|
4299
4306
|
for (const asset of STABLE_ASSETS) {
|
|
@@ -4303,7 +4310,7 @@ function registerRates(program3) {
|
|
|
4303
4310
|
printLine(import_picocolors6.default.bold(display));
|
|
4304
4311
|
printDivider();
|
|
4305
4312
|
for (const entry of assetRates) {
|
|
4306
|
-
printKeyValue(entry.protocol, `Save ${entry.rates.saveApy
|
|
4313
|
+
printKeyValue(entry.protocol, `Save ${formatApyPercent(entry.rates.saveApy)} Borrow ${formatApyPercent(entry.rates.borrowApy)}`);
|
|
4307
4314
|
}
|
|
4308
4315
|
printBlank();
|
|
4309
4316
|
}
|
|
@@ -4351,7 +4358,7 @@ function registerPositions(program3) {
|
|
|
4351
4358
|
for (const pos of saves) {
|
|
4352
4359
|
const earning = rewardsByKey.has(`${pos.protocol}:${pos.asset}`) ? ` ${import_picocolors7.default.yellow("+rewards")}` : "";
|
|
4353
4360
|
const usd = formatUsd(pos.amountUsd ?? pos.amount);
|
|
4354
|
-
printKeyValue(pos.protocol, `${formatAssetAmount(pos.amount, pos.asset)} ${pos.asset} (${usd}) @ ${pos.apy
|
|
4361
|
+
printKeyValue(pos.protocol, `${formatAssetAmount(pos.amount, pos.asset)} ${pos.asset} (${usd}) @ ${formatApyPercent(pos.apy)} APY${earning}`);
|
|
4355
4362
|
}
|
|
4356
4363
|
const totalSaved = saves.reduce((s, p) => s + (p.amountUsd ?? p.amount), 0);
|
|
4357
4364
|
if (saves.length > 1) {
|
|
@@ -4367,7 +4374,7 @@ function registerPositions(program3) {
|
|
|
4367
4374
|
printDivider();
|
|
4368
4375
|
for (const pos of borrows) {
|
|
4369
4376
|
const usd = formatUsd(pos.amountUsd ?? pos.amount);
|
|
4370
|
-
printKeyValue(pos.protocol, `${formatAssetAmount(pos.amount, pos.asset)} ${pos.asset} (${usd}) @ ${pos.apy
|
|
4377
|
+
printKeyValue(pos.protocol, `${formatAssetAmount(pos.amount, pos.asset)} ${pos.asset} (${usd}) @ ${formatApyPercent(pos.apy)} APY`);
|
|
4371
4378
|
}
|
|
4372
4379
|
const totalBorrowed = borrows.reduce((s, p) => s + (p.amountUsd ?? p.amount), 0);
|
|
4373
4380
|
if (borrows.length > 1) {
|
|
@@ -4400,10 +4407,10 @@ function registerEarnings(program3) {
|
|
|
4400
4407
|
printKeyValue("Total Saved", formatUsd(result.supplied));
|
|
4401
4408
|
if (savePositions.length > 0) {
|
|
4402
4409
|
for (const p of savePositions) {
|
|
4403
|
-
printLine(` ${import_picocolors8.default.dim("\u2022")} ${formatAssetAmount(p.amount, p.asset)} ${p.asset} (${formatUsd(p.amountUsd ?? p.amount)}) on ${p.protocol} @ ${p.apy
|
|
4410
|
+
printLine(` ${import_picocolors8.default.dim("\u2022")} ${formatAssetAmount(p.amount, p.asset)} ${p.asset} (${formatUsd(p.amountUsd ?? p.amount)}) on ${p.protocol} @ ${formatApyPercent(p.apy)} APY`);
|
|
4404
4411
|
}
|
|
4405
4412
|
}
|
|
4406
|
-
printKeyValue("Blended APY",
|
|
4413
|
+
printKeyValue("Blended APY", formatApyPercent(result.currentApy));
|
|
4407
4414
|
printKeyValue("Daily Yield", `~${formatUsd(result.dailyEarning)}/day`);
|
|
4408
4415
|
printKeyValue("Est. Earned", `~${formatUsd(result.totalYieldEarned)}`);
|
|
4409
4416
|
printBlank();
|
|
@@ -4437,10 +4444,10 @@ function registerFundStatus(program3) {
|
|
|
4437
4444
|
printKeyValue("Total Saved", formatUsd(result.supplied));
|
|
4438
4445
|
if (savePositions.length > 0) {
|
|
4439
4446
|
for (const p of savePositions) {
|
|
4440
|
-
printLine(` ${import_picocolors9.default.dim("\u2022")} ${formatAssetAmount(p.amount, p.asset)} ${p.asset} (${formatUsd(p.amountUsd ?? p.amount)}) on ${p.protocol} @ ${p.apy
|
|
4447
|
+
printLine(` ${import_picocolors9.default.dim("\u2022")} ${formatAssetAmount(p.amount, p.asset)} ${p.asset} (${formatUsd(p.amountUsd ?? p.amount)}) on ${p.protocol} @ ${formatApyPercent(p.apy)} APY`);
|
|
4441
4448
|
}
|
|
4442
4449
|
}
|
|
4443
|
-
printKeyValue("Blended APY",
|
|
4450
|
+
printKeyValue("Blended APY", formatApyPercent(result.apy));
|
|
4444
4451
|
printKeyValue("Earned today", `~${formatUsd(result.earnedToday)}`);
|
|
4445
4452
|
printKeyValue("Earned all time", `~${formatUsd(result.earnedAllTime)}`);
|
|
4446
4453
|
printKeyValue("Monthly projected", `~${formatUsd(result.projectedMonthly)}/month`);
|
|
@@ -7874,7 +7881,7 @@ function registerLock(program3) {
|
|
|
7874
7881
|
});
|
|
7875
7882
|
program3.command("unlock").description("Unlock agent \u2014 resume operations").action(async () => {
|
|
7876
7883
|
try {
|
|
7877
|
-
const { T2000: T20003 } = await import("./dist-
|
|
7884
|
+
const { T2000: T20003 } = await import("./dist-UOJPIH47.js");
|
|
7878
7885
|
const MAX_ATTEMPTS2 = 3;
|
|
7879
7886
|
let pin;
|
|
7880
7887
|
for (let attempt = 1; attempt <= MAX_ATTEMPTS2; attempt++) {
|
|
@@ -7963,8 +7970,8 @@ function registerEarn(program3) {
|
|
|
7963
7970
|
printDivider();
|
|
7964
7971
|
if (savePositions.length > 0) {
|
|
7965
7972
|
for (const pos of savePositions) {
|
|
7966
|
-
const dailyYield = pos.amount * pos.apy /
|
|
7967
|
-
printKeyValue(pos.protocol, `${formatUsd(pos.amount)} ${pos.asset} @ ${pos.apy
|
|
7973
|
+
const dailyYield = pos.amount * pos.apy / 365;
|
|
7974
|
+
printKeyValue(pos.protocol, `${formatUsd(pos.amount)} ${pos.asset} @ ${formatApyPercent(pos.apy)} APY`);
|
|
7968
7975
|
if (dailyYield > 1e-4) {
|
|
7969
7976
|
const dailyStr = dailyYield < 0.01 ? `$${dailyYield.toFixed(4)}` : formatUsd(dailyYield);
|
|
7970
7977
|
const monthlyStr = dailyYield * 30 < 0.01 ? `$${(dailyYield * 30).toFixed(4)}` : formatUsd(dailyYield * 30);
|
|
@@ -7978,10 +7985,10 @@ function registerEarn(program3) {
|
|
|
7978
7985
|
} else if (ratesData && ratesData.length > 0) {
|
|
7979
7986
|
const sorted = [...ratesData].sort((a, b) => b.rates.saveApy - a.rates.saveApy);
|
|
7980
7987
|
for (const r of sorted) {
|
|
7981
|
-
printKeyValue(r.protocol, `USDC @ ${r.rates.saveApy
|
|
7988
|
+
printKeyValue(r.protocol, `USDC @ ${formatApyPercent(r.rates.saveApy)} APY`);
|
|
7982
7989
|
}
|
|
7983
7990
|
const example = 100;
|
|
7984
|
-
const daily = example * bestSaveApy /
|
|
7991
|
+
const daily = example * bestSaveApy / 365;
|
|
7985
7992
|
const monthly = daily * 30;
|
|
7986
7993
|
printLine(import_picocolors11.default.dim(` Save $${example} \u2192 ~$${daily.toFixed(2)}/day \xB7 ~$${monthly.toFixed(2)}/month`));
|
|
7987
7994
|
printBlank();
|
|
@@ -8048,7 +8055,7 @@ function registerMcp(program3) {
|
|
|
8048
8055
|
mcp.command("start", { isDefault: true }).description("Start MCP server (stdio transport)").option("--key <path>", "Key file path").action(async (opts) => {
|
|
8049
8056
|
let mod;
|
|
8050
8057
|
try {
|
|
8051
|
-
mod = await import("./dist-
|
|
8058
|
+
mod = await import("./dist-NH7XYB4F.js");
|
|
8052
8059
|
} catch {
|
|
8053
8060
|
console.error(
|
|
8054
8061
|
"MCP server not installed. Run:\n npm install -g @t2000/mcp"
|
|
@@ -8240,17 +8247,24 @@ function registerClaimRewards(program3) {
|
|
|
8240
8247
|
|
|
8241
8248
|
// src/commands/swap.ts
|
|
8242
8249
|
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
8250
|
+
function parseSwapArgs(amountStr, from, toKeywordOrTo, to) {
|
|
8251
|
+
const amount = parseFloat(amountStr);
|
|
8252
|
+
if (isNaN(amount) || amount <= 0) {
|
|
8253
|
+
throw new Error("Amount must be a positive number");
|
|
8254
|
+
}
|
|
8255
|
+
if (toKeywordOrTo?.toLowerCase() === "for" && !to) {
|
|
8256
|
+
throw new Error("Usage: t2000 swap <amount> <from> [for] <to>");
|
|
8257
|
+
}
|
|
8258
|
+
const actualTo = to ?? toKeywordOrTo;
|
|
8259
|
+
if (!actualTo) {
|
|
8260
|
+
throw new Error("Usage: t2000 swap <amount> <from> [for] <to>");
|
|
8261
|
+
}
|
|
8262
|
+
return { amount, from, to: actualTo };
|
|
8263
|
+
}
|
|
8243
8264
|
function registerSwap(program3) {
|
|
8244
8265
|
program3.command("swap").description("Swap tokens via Cetus Aggregator (20+ DEXs)").argument("<amount>", "Amount to swap").argument("<from>", "Source token (e.g. SUI, USDC, CETUS)").argument("[to_keyword]", '"for" keyword (optional)').argument("<to>", "Target token (e.g. USDC, SUI, DEEP)").option("--slippage <pct>", "Max slippage percentage (default: 1)", "1").option("--key <path>", "Key file path").action(async (amountStr, from, toKeywordOrTo, to, opts) => {
|
|
8245
8266
|
try {
|
|
8246
|
-
const amount =
|
|
8247
|
-
if (isNaN(amount) || amount <= 0) {
|
|
8248
|
-
throw new Error("Amount must be a positive number");
|
|
8249
|
-
}
|
|
8250
|
-
if (toKeywordOrTo?.toLowerCase() === "for" && !to) {
|
|
8251
|
-
throw new Error("Usage: t2000 swap <amount> <from> [for] <to>");
|
|
8252
|
-
}
|
|
8253
|
-
const actualTo = to ?? toKeywordOrTo;
|
|
8267
|
+
const { amount, to: actualTo } = parseSwapArgs(amountStr, from, toKeywordOrTo, to);
|
|
8254
8268
|
const slippage = Math.min(parseFloat(opts.slippage ?? "1") / 100, 0.05);
|
|
8255
8269
|
const pin = await resolvePin();
|
|
8256
8270
|
const agent = await T2000.create({ pin, keyPath: opts.key });
|
|
@@ -8420,23 +8434,27 @@ var require2 = createRequire(import.meta.url);
|
|
|
8420
8434
|
var { version: CLI_VERSION } = require2("../package.json");
|
|
8421
8435
|
function createProgram() {
|
|
8422
8436
|
const program3 = new Command();
|
|
8423
|
-
program3.name("t2000").description("
|
|
8437
|
+
program3.name("t2000").description("Agentic Wallet for AI agents").version(`${CLI_VERSION} (beta)`).option("--json", "Output in JSON format").hook("preAction", (thisCommand) => {
|
|
8424
8438
|
const opts = thisCommand.optsWithGlobals();
|
|
8425
8439
|
if (opts.json) setJsonMode(true);
|
|
8426
8440
|
}).addHelpText("after", `
|
|
8427
8441
|
Examples:
|
|
8428
|
-
$ t2000 init Create a new
|
|
8442
|
+
$ t2000 init Create a new Agentic Wallet
|
|
8443
|
+
$ t2000 fund Show how to fund your wallet
|
|
8429
8444
|
$ t2000 balance Show wallet balance
|
|
8430
|
-
$ t2000 save 100 Save $100 to earn yield
|
|
8431
|
-
$ t2000
|
|
8445
|
+
$ t2000 save 100 Save $100 USDC to earn yield
|
|
8446
|
+
$ t2000 save 50 --asset USDsui Save 50 USDsui to NAVI
|
|
8447
|
+
$ t2000 send 50 to 0xabc... Send $50 USDC
|
|
8448
|
+
$ t2000 receive --amount 25 Generate a payment link
|
|
8449
|
+
$ t2000 swap 100 USDC SUI Swap 100 USDC for SUI
|
|
8432
8450
|
$ t2000 borrow 200 Borrow $200 against savings
|
|
8433
8451
|
$ t2000 pay openai ... Pay for an API via MPP gateway
|
|
8434
|
-
$ t2000 mcp install
|
|
8452
|
+
$ t2000 mcp install Connect Claude / Cursor / Windsurf`);
|
|
8435
8453
|
registerInit(program3);
|
|
8436
8454
|
registerSend(program3);
|
|
8437
8455
|
registerBalance(program3);
|
|
8438
8456
|
registerAddress(program3);
|
|
8439
|
-
|
|
8457
|
+
registerFund(program3);
|
|
8440
8458
|
registerHistory(program3);
|
|
8441
8459
|
registerExport(program3);
|
|
8442
8460
|
registerImport(program3);
|