@t2000/cli 0.22.23 → 0.22.24
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 +1 -10
- package/dist/{chunk-RN7Z6TWD.js → chunk-BPTNEFB5.js} +69 -303
- package/dist/chunk-BPTNEFB5.js.map +1 -0
- package/dist/{chunk-KHIL2KNW.js → chunk-XOAZJ42V.js} +32 -32
- package/dist/{chunk-KHIL2KNW.js.map → chunk-XOAZJ42V.js.map} +1 -1
- package/dist/{client-I4SGZLVD.js → client-CK5OR2TP.js} +2 -2
- package/dist/{dist-FDS4MNUV.js → dist-MJOXMRDV.js} +3 -102
- package/dist/{dist-FDS4MNUV.js.map → dist-MJOXMRDV.js.map} +1 -1
- package/dist/{dist-G5YKLWC5.js → dist-TWST5EWE.js} +9 -25
- package/dist/index.js +81 -252
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-RN7Z6TWD.js.map +0 -1
- /package/dist/{client-I4SGZLVD.js.map → client-CK5OR2TP.js.map} +0 -0
- /package/dist/{dist-G5YKLWC5.js.map → dist-TWST5EWE.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
ContactManager,
|
|
9
9
|
INVESTMENT_ASSETS,
|
|
10
|
-
MIST_PER_SUI,
|
|
11
10
|
STABLE_ASSETS,
|
|
12
11
|
SUPPORTED_ASSETS,
|
|
13
12
|
SafeguardEnforcer,
|
|
@@ -16,13 +15,12 @@ import {
|
|
|
16
15
|
formatUsd,
|
|
17
16
|
getGasStatus,
|
|
18
17
|
keypairFromPrivateKey,
|
|
19
|
-
listSentinels,
|
|
20
18
|
saveKey,
|
|
21
19
|
truncateAddress,
|
|
22
20
|
walletExists
|
|
23
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-BPTNEFB5.js";
|
|
24
22
|
import "./chunk-V7PXDEKG.js";
|
|
25
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-XOAZJ42V.js";
|
|
26
24
|
import "./chunk-3XUF7GM3.js";
|
|
27
25
|
import {
|
|
28
26
|
__commonJS,
|
|
@@ -7872,7 +7870,7 @@ function registerLock(program3) {
|
|
|
7872
7870
|
});
|
|
7873
7871
|
program3.command("unlock").description("Unlock agent \u2014 resume operations").action(async () => {
|
|
7874
7872
|
try {
|
|
7875
|
-
const { T2000: T20003 } = await import("./dist-
|
|
7873
|
+
const { T2000: T20003 } = await import("./dist-TWST5EWE.js");
|
|
7876
7874
|
const MAX_ATTEMPTS2 = 3;
|
|
7877
7875
|
let pin;
|
|
7878
7876
|
for (let attempt = 1; attempt <= MAX_ATTEMPTS2; attempt++) {
|
|
@@ -7923,161 +7921,26 @@ function registerLock(program3) {
|
|
|
7923
7921
|
});
|
|
7924
7922
|
}
|
|
7925
7923
|
|
|
7926
|
-
// src/commands/sentinel.ts
|
|
7927
|
-
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
7928
|
-
function formatSui(mist) {
|
|
7929
|
-
return (Number(mist) / Number(MIST_PER_SUI)).toFixed(2);
|
|
7930
|
-
}
|
|
7931
|
-
function registerSentinel(program3) {
|
|
7932
|
-
const sentinel = program3.command("sentinel").description("Interact with Sui Sentinel \u2014 attack AI agents, earn bounties");
|
|
7933
|
-
sentinel.command("list").description("List active sentinels with prize pools").action(async () => {
|
|
7934
|
-
try {
|
|
7935
|
-
const pin = await resolvePin();
|
|
7936
|
-
const agent = await T2000.create({ pin });
|
|
7937
|
-
const sentinels = await agent.sentinelList();
|
|
7938
|
-
if (isJsonMode()) {
|
|
7939
|
-
printJson(sentinels.map((s) => ({
|
|
7940
|
-
...s,
|
|
7941
|
-
attackFee: s.attackFee.toString(),
|
|
7942
|
-
prizePool: s.prizePool.toString()
|
|
7943
|
-
})));
|
|
7944
|
-
return;
|
|
7945
|
-
}
|
|
7946
|
-
if (sentinels.length === 0) {
|
|
7947
|
-
printBlank();
|
|
7948
|
-
printInfo("No active sentinels found.");
|
|
7949
|
-
printBlank();
|
|
7950
|
-
return;
|
|
7951
|
-
}
|
|
7952
|
-
printHeader("Active Sentinels");
|
|
7953
|
-
sentinels.forEach((s) => {
|
|
7954
|
-
const pool = `${formatSui(s.prizePool)} SUI`.padEnd(12);
|
|
7955
|
-
const fee = `${formatSui(s.attackFee)} SUI`.padEnd(12);
|
|
7956
|
-
printLine(` ${s.name}`);
|
|
7957
|
-
printLine(` ${import_picocolors11.default.dim(`Pool: ${pool}Fee: ${fee}Attacks: ${s.totalAttacks}`)}`);
|
|
7958
|
-
printLine(` ${import_picocolors11.default.dim(s.objectId)}`);
|
|
7959
|
-
printBlank();
|
|
7960
|
-
});
|
|
7961
|
-
printBlank();
|
|
7962
|
-
printInfo(`${sentinels.length} active sentinel${sentinels.length === 1 ? "" : "s"}`);
|
|
7963
|
-
printBlank();
|
|
7964
|
-
} catch (error) {
|
|
7965
|
-
handleError(error);
|
|
7966
|
-
}
|
|
7967
|
-
});
|
|
7968
|
-
sentinel.command("info").description("Show details for a sentinel").argument("<id>", "Sentinel object ID").action(async (id) => {
|
|
7969
|
-
try {
|
|
7970
|
-
const pin = await resolvePin();
|
|
7971
|
-
const agent = await T2000.create({ pin });
|
|
7972
|
-
const s = await agent.sentinelInfo(id);
|
|
7973
|
-
if (isJsonMode()) {
|
|
7974
|
-
printJson({
|
|
7975
|
-
...s,
|
|
7976
|
-
attackFee: s.attackFee.toString(),
|
|
7977
|
-
prizePool: s.prizePool.toString()
|
|
7978
|
-
});
|
|
7979
|
-
return;
|
|
7980
|
-
}
|
|
7981
|
-
printHeader(s.name);
|
|
7982
|
-
printKeyValue("Object ID", s.objectId);
|
|
7983
|
-
printKeyValue("Agent ID", s.id);
|
|
7984
|
-
printKeyValue("Model", s.model);
|
|
7985
|
-
printKeyValue("State", s.state);
|
|
7986
|
-
printKeyValue("Attack Fee", `${formatSui(s.attackFee)} SUI`);
|
|
7987
|
-
printKeyValue("Prize Pool", `${formatSui(s.prizePool)} SUI`);
|
|
7988
|
-
printKeyValue("Total Attacks", String(s.totalAttacks));
|
|
7989
|
-
printKeyValue("Breaches", String(s.successfulBreaches));
|
|
7990
|
-
if (s.systemPrompt) {
|
|
7991
|
-
printBlank();
|
|
7992
|
-
printKeyValue("System Prompt", "");
|
|
7993
|
-
printLine(` ${import_picocolors11.default.dim(s.systemPrompt.slice(0, 500))}`);
|
|
7994
|
-
}
|
|
7995
|
-
printBlank();
|
|
7996
|
-
} catch (error) {
|
|
7997
|
-
handleError(error);
|
|
7998
|
-
}
|
|
7999
|
-
});
|
|
8000
|
-
sentinel.command("attack").description("Attack a sentinel with a prompt (costs SUI)").argument("<id>", "Sentinel object ID").argument("[prompt]", "Attack prompt").option("--fee <sui>", "Override attack fee in SUI").option("--key <path>", "Key file path").action(async (id, prompt, opts) => {
|
|
8001
|
-
try {
|
|
8002
|
-
if (!prompt) {
|
|
8003
|
-
throw new Error('Prompt is required. Usage: t2000 sentinel attack <id> "your prompt"');
|
|
8004
|
-
}
|
|
8005
|
-
const pin = await resolvePin();
|
|
8006
|
-
const agent = await T2000.create({ pin, keyPath: opts.key });
|
|
8007
|
-
const feeMist = opts.fee ? BigInt(Math.round(parseFloat(opts.fee) * Number(MIST_PER_SUI))) : void 0;
|
|
8008
|
-
if (isJsonMode()) {
|
|
8009
|
-
const result2 = await agent.sentinelAttack(id, prompt, feeMist);
|
|
8010
|
-
printJson({
|
|
8011
|
-
...result2,
|
|
8012
|
-
verdict: {
|
|
8013
|
-
...result2.verdict
|
|
8014
|
-
}
|
|
8015
|
-
});
|
|
8016
|
-
return;
|
|
8017
|
-
}
|
|
8018
|
-
printBlank();
|
|
8019
|
-
printLine(` ${import_picocolors11.default.dim("\u23F3")} Requesting attack...`);
|
|
8020
|
-
const result = await agent.sentinelAttack(id, prompt, feeMist);
|
|
8021
|
-
printBlank();
|
|
8022
|
-
if (result.won) {
|
|
8023
|
-
printSuccess(`BREACHED! (score: ${result.verdict.score}/100)`);
|
|
8024
|
-
} else {
|
|
8025
|
-
printError(`DEFENDED (score: ${result.verdict.score}/100)`);
|
|
8026
|
-
}
|
|
8027
|
-
printBlank();
|
|
8028
|
-
printKeyValue("Agent", result.verdict.agentResponse.slice(0, 200));
|
|
8029
|
-
printKeyValue("Jury", result.verdict.juryResponse.slice(0, 200));
|
|
8030
|
-
if (result.verdict.funResponse) {
|
|
8031
|
-
printKeyValue("Fun", result.verdict.funResponse.slice(0, 200));
|
|
8032
|
-
}
|
|
8033
|
-
printBlank();
|
|
8034
|
-
printKeyValue("Fee Paid", `${result.feePaid} SUI`);
|
|
8035
|
-
printKeyValue("Request Tx", explorerUrl(result.requestTx));
|
|
8036
|
-
printKeyValue("Settle Tx", explorerUrl(result.settleTx));
|
|
8037
|
-
printBlank();
|
|
8038
|
-
} catch (error) {
|
|
8039
|
-
handleError(error);
|
|
8040
|
-
}
|
|
8041
|
-
});
|
|
8042
|
-
}
|
|
8043
|
-
|
|
8044
7924
|
// src/commands/earn.ts
|
|
8045
|
-
var
|
|
8046
|
-
function mistToSui(mist) {
|
|
8047
|
-
return Number(mist) / Number(MIST_PER_SUI);
|
|
8048
|
-
}
|
|
8049
|
-
function bestTarget(sentinels) {
|
|
8050
|
-
const withPool = sentinels.filter((s) => s.prizePool > 0n && s.attackFee > 0n);
|
|
8051
|
-
if (withPool.length === 0) return void 0;
|
|
8052
|
-
return withPool.sort((a, b) => {
|
|
8053
|
-
const ratioA = Number(a.prizePool) / Number(a.attackFee);
|
|
8054
|
-
const ratioB = Number(b.prizePool) / Number(b.attackFee);
|
|
8055
|
-
return ratioB - ratioA;
|
|
8056
|
-
})[0];
|
|
8057
|
-
}
|
|
7925
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
8058
7926
|
function registerEarn(program3) {
|
|
8059
|
-
program3.command("earn").description("Show all earning opportunities \u2014 savings yield +
|
|
7927
|
+
program3.command("earn").description("Show all earning opportunities \u2014 savings yield + investment yield").option("--key <path>", "Key file path").action(async (opts) => {
|
|
8060
7928
|
try {
|
|
8061
7929
|
const pin = await resolvePin();
|
|
8062
7930
|
const agent = await T2000.create({ pin, keyPath: opts.key });
|
|
8063
|
-
const [positionsResult, portfolioResult, ratesResult
|
|
7931
|
+
const [positionsResult, portfolioResult, ratesResult] = await Promise.allSettled([
|
|
8064
7932
|
agent.positions(),
|
|
8065
7933
|
agent.getPortfolio(),
|
|
8066
|
-
agent.allRates("USDC")
|
|
8067
|
-
listSentinels()
|
|
7934
|
+
agent.allRates("USDC")
|
|
8068
7935
|
]);
|
|
8069
7936
|
const posData = positionsResult.status === "fulfilled" ? positionsResult.value : null;
|
|
8070
7937
|
const portfolio = portfolioResult.status === "fulfilled" ? portfolioResult.value : null;
|
|
8071
7938
|
const ratesData = ratesResult.status === "fulfilled" ? ratesResult.value : null;
|
|
8072
|
-
const agents = sentinels.status === "fulfilled" ? sentinels.value : null;
|
|
8073
7939
|
const savePositions = posData?.positions.filter((p) => p.type === "save") ?? [];
|
|
8074
7940
|
const totalSaved = savePositions.reduce((s, p) => s + p.amount, 0);
|
|
8075
7941
|
const earningInvestments = portfolio?.positions.filter((p) => p.earning && p.currentValue > 0) ?? [];
|
|
8076
7942
|
const bestSaveApy = ratesData?.length ? Math.max(...ratesData.map((r) => r.rates.saveApy)) : 0;
|
|
8077
7943
|
if (isJsonMode()) {
|
|
8078
|
-
const best = agents ? bestTarget(agents) : void 0;
|
|
8079
|
-
const totalPool = agents ? agents.reduce((sum, s) => sum + mistToSui(s.prizePool), 0) : 0;
|
|
8080
|
-
const cheapest = agents ? Math.min(...agents.map((s) => mistToSui(s.attackFee))) : 0;
|
|
8081
7944
|
printJson({
|
|
8082
7945
|
savings: savePositions.map((p) => ({
|
|
8083
7946
|
protocol: p.protocol,
|
|
@@ -8097,24 +7960,12 @@ function registerEarn(program3) {
|
|
|
8097
7960
|
value: p.currentValue,
|
|
8098
7961
|
protocol: p.earningProtocol,
|
|
8099
7962
|
apy: p.earningApy
|
|
8100
|
-
}))
|
|
8101
|
-
sentinel: agents ? {
|
|
8102
|
-
activeSentinels: agents.length,
|
|
8103
|
-
totalPrizePool: Number(totalPool.toFixed(2)),
|
|
8104
|
-
cheapestFee: Number(cheapest.toFixed(2)),
|
|
8105
|
-
bestTarget: best ? {
|
|
8106
|
-
name: best.name,
|
|
8107
|
-
objectId: best.objectId,
|
|
8108
|
-
prizePool: mistToSui(best.prizePool),
|
|
8109
|
-
attackFee: mistToSui(best.attackFee),
|
|
8110
|
-
ratio: Number((Number(best.prizePool) / Number(best.attackFee)).toFixed(1))
|
|
8111
|
-
} : null
|
|
8112
|
-
} : null
|
|
7963
|
+
}))
|
|
8113
7964
|
});
|
|
8114
7965
|
return;
|
|
8115
7966
|
}
|
|
8116
7967
|
printHeader("Earning Opportunities");
|
|
8117
|
-
printLine(
|
|
7968
|
+
printLine(import_picocolors11.default.bold("SAVINGS") + import_picocolors11.default.dim(" \u2014 Passive Yield"));
|
|
8118
7969
|
printDivider();
|
|
8119
7970
|
if (savePositions.length > 0) {
|
|
8120
7971
|
for (const pos of savePositions) {
|
|
@@ -8123,7 +7974,7 @@ function registerEarn(program3) {
|
|
|
8123
7974
|
if (dailyYield > 1e-4) {
|
|
8124
7975
|
const dailyStr = dailyYield < 0.01 ? `$${dailyYield.toFixed(4)}` : formatUsd(dailyYield);
|
|
8125
7976
|
const monthlyStr = dailyYield * 30 < 0.01 ? `$${(dailyYield * 30).toFixed(4)}` : formatUsd(dailyYield * 30);
|
|
8126
|
-
printLine(
|
|
7977
|
+
printLine(import_picocolors11.default.dim(` ~${dailyStr}/day \xB7 ~${monthlyStr}/month`));
|
|
8127
7978
|
}
|
|
8128
7979
|
}
|
|
8129
7980
|
if (savePositions.length > 1) {
|
|
@@ -8138,7 +7989,7 @@ function registerEarn(program3) {
|
|
|
8138
7989
|
const example = 100;
|
|
8139
7990
|
const daily = example * bestSaveApy / 100 / 365;
|
|
8140
7991
|
const monthly = daily * 30;
|
|
8141
|
-
printLine(
|
|
7992
|
+
printLine(import_picocolors11.default.dim(` Save $${example} \u2192 ~$${daily.toFixed(2)}/day \xB7 ~$${monthly.toFixed(2)}/month`));
|
|
8142
7993
|
printBlank();
|
|
8143
7994
|
printInfo("No savings yet \u2014 run `t2000 save <amount>` to start");
|
|
8144
7995
|
} else if (posData) {
|
|
@@ -8148,7 +7999,7 @@ function registerEarn(program3) {
|
|
|
8148
7999
|
}
|
|
8149
8000
|
if (earningInvestments.length > 0) {
|
|
8150
8001
|
printBlank();
|
|
8151
|
-
printLine(
|
|
8002
|
+
printLine(import_picocolors11.default.bold("INVESTMENTS") + import_picocolors11.default.dim(" \u2014 Earning Yield"));
|
|
8152
8003
|
printDivider();
|
|
8153
8004
|
let totalInvestValue = 0;
|
|
8154
8005
|
for (const pos of earningInvestments) {
|
|
@@ -8161,7 +8012,7 @@ function registerEarn(program3) {
|
|
|
8161
8012
|
if (dailyYield > 1e-4) {
|
|
8162
8013
|
const dailyStr = dailyYield < 0.01 ? `$${dailyYield.toFixed(4)}` : formatUsd(dailyYield);
|
|
8163
8014
|
const monthlyStr = dailyYield * 30 < 0.01 ? `$${(dailyYield * 30).toFixed(4)}` : formatUsd(dailyYield * 30);
|
|
8164
|
-
printLine(
|
|
8015
|
+
printLine(import_picocolors11.default.dim(` ~${dailyStr}/day \xB7 ~${monthlyStr}/month`));
|
|
8165
8016
|
}
|
|
8166
8017
|
totalInvestValue += pos.currentValue;
|
|
8167
8018
|
}
|
|
@@ -8171,31 +8022,10 @@ function registerEarn(program3) {
|
|
|
8171
8022
|
}
|
|
8172
8023
|
}
|
|
8173
8024
|
printBlank();
|
|
8174
|
-
printLine(
|
|
8175
|
-
printDivider();
|
|
8176
|
-
if (agents && agents.length > 0) {
|
|
8177
|
-
const totalPool = agents.reduce((sum, s) => sum + mistToSui(s.prizePool), 0);
|
|
8178
|
-
const cheapest = Math.min(...agents.map((s) => mistToSui(s.attackFee)));
|
|
8179
|
-
const best = bestTarget(agents);
|
|
8180
|
-
printKeyValue("Active", `${agents.length} sentinels`);
|
|
8181
|
-
printKeyValue("Prize Pools", `${totalPool.toFixed(2)} SUI available`);
|
|
8182
|
-
printKeyValue("Cheapest Fee", `${cheapest.toFixed(2)} SUI`);
|
|
8183
|
-
if (best) {
|
|
8184
|
-
const ratio = (Number(best.prizePool) / Number(best.attackFee)).toFixed(1);
|
|
8185
|
-
printKeyValue("Best Target", `${best.name} \u2014 ${mistToSui(best.prizePool).toFixed(2)} SUI pool (${ratio}x ratio)`);
|
|
8186
|
-
}
|
|
8187
|
-
} else if (agents) {
|
|
8188
|
-
printInfo("No active bounties right now");
|
|
8189
|
-
} else {
|
|
8190
|
-
printInfo("Sentinel data unavailable");
|
|
8191
|
-
}
|
|
8192
|
-
printBlank();
|
|
8193
|
-
printLine(import_picocolors12.default.bold("Quick Actions"));
|
|
8025
|
+
printLine(import_picocolors11.default.bold("Quick Actions"));
|
|
8194
8026
|
printDivider();
|
|
8195
|
-
printLine(` ${
|
|
8196
|
-
printLine(` ${
|
|
8197
|
-
printLine(` ${import_picocolors12.default.dim("t2000 sentinel list")} Browse sentinel bounties`);
|
|
8198
|
-
printLine(` ${import_picocolors12.default.dim("t2000 sentinel attack <id>")} Attack a sentinel`);
|
|
8027
|
+
printLine(` ${import_picocolors11.default.dim("t2000 save <amount> [asset]")} Save stablecoins for yield`);
|
|
8028
|
+
printLine(` ${import_picocolors11.default.dim("t2000 invest earn <asset>")} Earn yield on investments`);
|
|
8199
8029
|
printBlank();
|
|
8200
8030
|
} catch (error) {
|
|
8201
8031
|
handleError(error);
|
|
@@ -8204,7 +8034,7 @@ function registerEarn(program3) {
|
|
|
8204
8034
|
}
|
|
8205
8035
|
|
|
8206
8036
|
// src/commands/rebalance.ts
|
|
8207
|
-
var
|
|
8037
|
+
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
8208
8038
|
function registerRebalance(program3) {
|
|
8209
8039
|
program3.command("rebalance").description("Optimize yield \u2014 move savings to the best rate across protocols and stablecoins").option("--key <path>", "Key file path").option("--dry-run", "Show what would happen without executing").option("--min-diff <pct>", "Minimum APY difference to trigger (default: 0.5)", "0.5").option("--max-break-even <days>", "Max break-even days for cross-asset moves (default: 30)", "30").action(async (opts) => {
|
|
8210
8040
|
try {
|
|
@@ -8231,24 +8061,24 @@ function registerRebalance(program3) {
|
|
|
8231
8061
|
const diff = plan.newApy - plan.currentApy;
|
|
8232
8062
|
if (diff < minYieldDiff) {
|
|
8233
8063
|
printInfo(`Already optimized \u2014 ${plan.currentApy.toFixed(2)}% APY on ${plan.fromProtocol}`);
|
|
8234
|
-
printLine(
|
|
8235
|
-
printLine(
|
|
8064
|
+
printLine(import_picocolors12.default.dim(` Best available: ${plan.newApy.toFixed(2)}% (${displayAsset(plan.toAsset)} on ${plan.toProtocol})`));
|
|
8065
|
+
printLine(import_picocolors12.default.dim(` Difference: ${diff.toFixed(2)}% (below ${minYieldDiff}% threshold)`));
|
|
8236
8066
|
} else if (plan.breakEvenDays > maxBreakEven && plan.estimatedSwapCost > 0) {
|
|
8237
8067
|
printInfo(`Skipped \u2014 break-even of ${plan.breakEvenDays} days exceeds ${maxBreakEven}-day limit`);
|
|
8238
|
-
printLine(
|
|
8068
|
+
printLine(import_picocolors12.default.dim(` ${displayAsset(plan.fromAsset)} on ${plan.fromProtocol} (${plan.currentApy.toFixed(2)}%) \u2192 ${displayAsset(plan.toAsset)} on ${plan.toProtocol} (${plan.newApy.toFixed(2)}%)`));
|
|
8239
8069
|
} else {
|
|
8240
8070
|
printInfo("Already at the best rate. Nothing to rebalance.");
|
|
8241
8071
|
}
|
|
8242
8072
|
printBlank();
|
|
8243
8073
|
return;
|
|
8244
8074
|
}
|
|
8245
|
-
printLine(
|
|
8075
|
+
printLine(import_picocolors12.default.bold("Rebalance Plan"));
|
|
8246
8076
|
printDivider();
|
|
8247
8077
|
printKeyValue("From", `${displayAsset(plan.fromAsset)} on ${plan.fromProtocol} (${plan.currentApy.toFixed(2)}% APY)`);
|
|
8248
8078
|
printKeyValue("To", `${displayAsset(plan.toAsset)} on ${plan.toProtocol} (${plan.newApy.toFixed(2)}% APY)`);
|
|
8249
8079
|
printKeyValue("Amount", formatUsd(plan.amount));
|
|
8250
8080
|
printBlank();
|
|
8251
|
-
printLine(
|
|
8081
|
+
printLine(import_picocolors12.default.bold("Economics"));
|
|
8252
8082
|
printDivider();
|
|
8253
8083
|
printKeyValue("APY Gain", `+${(plan.newApy - plan.currentApy).toFixed(2)}%`);
|
|
8254
8084
|
printKeyValue("Annual Gain", `${formatUsd(plan.annualGain)}/year`);
|
|
@@ -8258,7 +8088,7 @@ function registerRebalance(program3) {
|
|
|
8258
8088
|
}
|
|
8259
8089
|
printBlank();
|
|
8260
8090
|
if (plan.steps.length > 0) {
|
|
8261
|
-
printLine(
|
|
8091
|
+
printLine(import_picocolors12.default.bold("Steps"));
|
|
8262
8092
|
printDivider();
|
|
8263
8093
|
for (let i = 0; i < plan.steps.length; i++) {
|
|
8264
8094
|
const step = plan.steps[i];
|
|
@@ -8274,8 +8104,8 @@ function registerRebalance(program3) {
|
|
|
8274
8104
|
printBlank();
|
|
8275
8105
|
}
|
|
8276
8106
|
if (opts.dryRun) {
|
|
8277
|
-
printLine(
|
|
8278
|
-
printLine(
|
|
8107
|
+
printLine(import_picocolors12.default.bold(import_picocolors12.default.yellow("DRY RUN \u2014 Preview only, no transactions executed")));
|
|
8108
|
+
printLine(import_picocolors12.default.dim(" Run `t2000 rebalance` to execute."));
|
|
8279
8109
|
printBlank();
|
|
8280
8110
|
return;
|
|
8281
8111
|
}
|
|
@@ -8298,7 +8128,7 @@ function displayAsset(asset) {
|
|
|
8298
8128
|
}
|
|
8299
8129
|
|
|
8300
8130
|
// src/commands/exchange.ts
|
|
8301
|
-
var
|
|
8131
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
8302
8132
|
function resolveAssetName(input) {
|
|
8303
8133
|
const upper = input.toUpperCase();
|
|
8304
8134
|
for (const key of Object.keys(SUPPORTED_ASSETS)) {
|
|
@@ -8309,7 +8139,7 @@ function resolveAssetName(input) {
|
|
|
8309
8139
|
function registerExchange(program3) {
|
|
8310
8140
|
program3.command("exchange <amount> <from> <to>").description('[deprecated \u2014 use "swap" instead] Exchange between tokens').option("--key <path>", "Key file path").option("--slippage <pct>", "Max slippage percentage (default: 3)", "3").action(async (amount, from, to, opts) => {
|
|
8311
8141
|
try {
|
|
8312
|
-
console.error(
|
|
8142
|
+
console.error(import_picocolors13.default.yellow(' \u26A0 "exchange" is deprecated. Use "swap" instead: t2000 swap %s %s %s'), amount, from, to);
|
|
8313
8143
|
const pin = await resolvePin();
|
|
8314
8144
|
const agent = await T2000.create({ pin, keyPath: opts.key });
|
|
8315
8145
|
const parsedAmount = parseFloat(amount);
|
|
@@ -8324,7 +8154,7 @@ function registerExchange(program3) {
|
|
|
8324
8154
|
printJson(result);
|
|
8325
8155
|
return;
|
|
8326
8156
|
}
|
|
8327
|
-
console.log(
|
|
8157
|
+
console.log(import_picocolors13.default.green(" \u2713 Swapped. Tx: %s"), result.tx);
|
|
8328
8158
|
} catch (error) {
|
|
8329
8159
|
handleError(error);
|
|
8330
8160
|
}
|
|
@@ -8506,7 +8336,7 @@ function registerMcp(program3) {
|
|
|
8506
8336
|
mcp.command("start", { isDefault: true }).description("Start MCP server (stdio transport)").option("--key <path>", "Key file path").action(async (opts) => {
|
|
8507
8337
|
let mod;
|
|
8508
8338
|
try {
|
|
8509
|
-
mod = await import("./dist-
|
|
8339
|
+
mod = await import("./dist-MJOXMRDV.js");
|
|
8510
8340
|
} catch {
|
|
8511
8341
|
console.error(
|
|
8512
8342
|
"MCP server not installed. Run:\n npm install -g @t2000/mcp"
|
|
@@ -8657,15 +8487,15 @@ function registerContacts(program3) {
|
|
|
8657
8487
|
}
|
|
8658
8488
|
|
|
8659
8489
|
// src/commands/invest.ts
|
|
8660
|
-
var
|
|
8490
|
+
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
8661
8491
|
function registerInvest(program3) {
|
|
8662
8492
|
const investCmd = program3.command("invest").description("Investment strategies, DCA, and yield earning");
|
|
8663
8493
|
investCmd.command("buy <amount> <asset>").description('[deprecated \u2014 use "buy" instead] Buy an asset').option("--key <path>", "Key file path").option("--slippage <pct>", "Max slippage percent", "3").action(async (amount, asset, opts) => {
|
|
8664
8494
|
try {
|
|
8665
|
-
console.error(
|
|
8495
|
+
console.error(import_picocolors14.default.yellow(` \u26A0 "invest buy" is deprecated. Use: t2000 buy ${amount} ${asset}`));
|
|
8666
8496
|
const parsed = parseFloat(amount);
|
|
8667
8497
|
if (isNaN(parsed) || parsed <= 0 || !isFinite(parsed)) {
|
|
8668
|
-
console.error(
|
|
8498
|
+
console.error(import_picocolors14.default.red(" \u2717 Amount must be greater than $0"));
|
|
8669
8499
|
process.exitCode = 1;
|
|
8670
8500
|
return;
|
|
8671
8501
|
}
|
|
@@ -8692,12 +8522,12 @@ function registerInvest(program3) {
|
|
|
8692
8522
|
});
|
|
8693
8523
|
investCmd.command("sell <amount> <asset>").description('[deprecated \u2014 use "sell" instead] Sell an asset').option("--key <path>", "Key file path").option("--slippage <pct>", "Max slippage percent", "3").action(async (amount, asset, opts) => {
|
|
8694
8524
|
try {
|
|
8695
|
-
console.error(
|
|
8525
|
+
console.error(import_picocolors14.default.yellow(` \u26A0 "invest sell" is deprecated. Use: t2000 sell ${amount} ${asset}`));
|
|
8696
8526
|
const isAll = amount.toLowerCase() === "all";
|
|
8697
8527
|
if (!isAll) {
|
|
8698
8528
|
const parsed = parseFloat(amount);
|
|
8699
8529
|
if (isNaN(parsed) || parsed <= 0 || !isFinite(parsed)) {
|
|
8700
|
-
console.error(
|
|
8530
|
+
console.error(import_picocolors14.default.red(" \u2717 Amount must be greater than $0"));
|
|
8701
8531
|
process.exitCode = 1;
|
|
8702
8532
|
return;
|
|
8703
8533
|
}
|
|
@@ -8719,7 +8549,7 @@ function registerInvest(program3) {
|
|
|
8719
8549
|
printSuccess(`Sold ${formatAssetAmount(result.amount, sym)} ${sym} at ${formatUsd(result.price)}`);
|
|
8720
8550
|
printKeyValue("Proceeds", formatUsd(result.usdValue));
|
|
8721
8551
|
if (result.realizedPnL !== void 0) {
|
|
8722
|
-
const pnlColor = result.realizedPnL >= 0 ?
|
|
8552
|
+
const pnlColor = result.realizedPnL >= 0 ? import_picocolors14.default.green : import_picocolors14.default.red;
|
|
8723
8553
|
const pnlSign = result.realizedPnL >= 0 ? "+" : "";
|
|
8724
8554
|
printKeyValue("Realized P&L", pnlColor(`${pnlSign}${formatUsd(result.realizedPnL)}`));
|
|
8725
8555
|
}
|
|
@@ -8847,9 +8677,9 @@ function registerInvest(program3) {
|
|
|
8847
8677
|
printSeparator();
|
|
8848
8678
|
for (const [key, def] of Object.entries(all)) {
|
|
8849
8679
|
const allocs = Object.entries(def.allocations).map(([a, p]) => `${a} ${p}%`).join(", ");
|
|
8850
|
-
const tag = def.custom ?
|
|
8680
|
+
const tag = def.custom ? import_picocolors14.default.dim(" (custom)") : "";
|
|
8851
8681
|
printKeyValue(key, `${allocs}${tag}`);
|
|
8852
|
-
printLine(` ${
|
|
8682
|
+
printLine(` ${import_picocolors14.default.dim(def.description)}`);
|
|
8853
8683
|
}
|
|
8854
8684
|
printSeparator();
|
|
8855
8685
|
const hasPositions = Object.keys(all).some((k) => agent.portfolio.hasStrategyPositions(k));
|
|
@@ -8865,7 +8695,7 @@ function registerInvest(program3) {
|
|
|
8865
8695
|
try {
|
|
8866
8696
|
const parsed = parseFloat(amount);
|
|
8867
8697
|
if (isNaN(parsed) || parsed <= 0) {
|
|
8868
|
-
console.error(
|
|
8698
|
+
console.error(import_picocolors14.default.red(" \u2717 Amount must be greater than $0"));
|
|
8869
8699
|
process.exitCode = 1;
|
|
8870
8700
|
return;
|
|
8871
8701
|
}
|
|
@@ -8899,7 +8729,7 @@ function registerInvest(program3) {
|
|
|
8899
8729
|
printKeyValue("Tx", explorerUrl(txDigests[0]));
|
|
8900
8730
|
} else {
|
|
8901
8731
|
for (const buy of result.buys) {
|
|
8902
|
-
printLine(` ${
|
|
8732
|
+
printLine(` ${import_picocolors14.default.dim(`${buy.asset}: ${explorerUrl(buy.tx)}`)}`);
|
|
8903
8733
|
}
|
|
8904
8734
|
}
|
|
8905
8735
|
}
|
|
@@ -8921,18 +8751,18 @@ function registerInvest(program3) {
|
|
|
8921
8751
|
printSuccess(`Sold all ${name} strategy positions`);
|
|
8922
8752
|
printSeparator();
|
|
8923
8753
|
for (const sell of result.sells) {
|
|
8924
|
-
const pnlColor = sell.realizedPnL >= 0 ?
|
|
8754
|
+
const pnlColor = sell.realizedPnL >= 0 ? import_picocolors14.default.green : import_picocolors14.default.red;
|
|
8925
8755
|
const pnlSign = sell.realizedPnL >= 0 ? "+" : "";
|
|
8926
8756
|
printKeyValue(sell.asset, `${formatAssetAmount(sell.amount, sell.asset)} \u2192 ${formatUsd(sell.usdValue)} ${pnlColor(`${pnlSign}${formatUsd(sell.realizedPnL)}`)}`);
|
|
8927
8757
|
}
|
|
8928
8758
|
if (result.failed && result.failed.length > 0) {
|
|
8929
8759
|
for (const f of result.failed) {
|
|
8930
|
-
console.error(
|
|
8760
|
+
console.error(import_picocolors14.default.yellow(` \u26A0 ${f.asset}: ${f.reason}`));
|
|
8931
8761
|
}
|
|
8932
8762
|
}
|
|
8933
8763
|
printSeparator();
|
|
8934
8764
|
printKeyValue("Total proceeds", formatUsd(result.totalProceeds));
|
|
8935
|
-
const rpnlColor = result.realizedPnL >= 0 ?
|
|
8765
|
+
const rpnlColor = result.realizedPnL >= 0 ? import_picocolors14.default.green : import_picocolors14.default.red;
|
|
8936
8766
|
const rpnlSign = result.realizedPnL >= 0 ? "+" : "";
|
|
8937
8767
|
printKeyValue("Realized P&L", rpnlColor(`${rpnlSign}${formatUsd(result.realizedPnL)}`));
|
|
8938
8768
|
printBlank();
|
|
@@ -8959,8 +8789,8 @@ function registerInvest(program3) {
|
|
|
8959
8789
|
const target = status.definition.allocations[pos.asset] ?? 0;
|
|
8960
8790
|
const actual = status.currentWeights[pos.asset] ?? 0;
|
|
8961
8791
|
const drift = actual - target;
|
|
8962
|
-
const driftColor = Math.abs(drift) > 3 ?
|
|
8963
|
-
const pnlColor = pos.unrealizedPnL >= 0 ?
|
|
8792
|
+
const driftColor = Math.abs(drift) > 3 ? import_picocolors14.default.yellow : import_picocolors14.default.dim;
|
|
8793
|
+
const pnlColor = pos.unrealizedPnL >= 0 ? import_picocolors14.default.green : import_picocolors14.default.red;
|
|
8964
8794
|
const pnlSign = pos.unrealizedPnL >= 0 ? "+" : "";
|
|
8965
8795
|
printKeyValue(
|
|
8966
8796
|
pos.asset,
|
|
@@ -8991,7 +8821,7 @@ function registerInvest(program3) {
|
|
|
8991
8821
|
printSuccess(`Rebalanced ${name} strategy`);
|
|
8992
8822
|
printSeparator();
|
|
8993
8823
|
for (const t of result.trades) {
|
|
8994
|
-
const action = t.action === "buy" ?
|
|
8824
|
+
const action = t.action === "buy" ? import_picocolors14.default.green("BUY") : import_picocolors14.default.red("SELL");
|
|
8995
8825
|
printKeyValue(t.asset, `${action} ${formatUsd(t.usdAmount)} (${formatAssetAmount(t.amount, t.asset)})`);
|
|
8996
8826
|
}
|
|
8997
8827
|
printSeparator();
|
|
@@ -9008,7 +8838,7 @@ function registerInvest(program3) {
|
|
|
9008
8838
|
for (const pair of opts.alloc) {
|
|
9009
8839
|
const [asset, pctStr] = pair.split(":");
|
|
9010
8840
|
if (!asset || !pctStr) {
|
|
9011
|
-
console.error(
|
|
8841
|
+
console.error(import_picocolors14.default.red(` \u2717 Invalid allocation: '${pair}'. Use ASSET:PCT format (e.g. SUI:60)`));
|
|
9012
8842
|
process.exitCode = 1;
|
|
9013
8843
|
return;
|
|
9014
8844
|
}
|
|
@@ -9035,7 +8865,7 @@ function registerInvest(program3) {
|
|
|
9035
8865
|
const pin = await resolvePin();
|
|
9036
8866
|
const agent = await T2000.create({ pin, keyPath: opts.key });
|
|
9037
8867
|
if (agent.portfolio.hasStrategyPositions(name.toLowerCase())) {
|
|
9038
|
-
console.error(
|
|
8868
|
+
console.error(import_picocolors14.default.red(` \u2717 Strategy '${name}' has open positions. Sell first: t2000 invest strategy sell ${name}`));
|
|
9039
8869
|
process.exitCode = 1;
|
|
9040
8870
|
return;
|
|
9041
8871
|
}
|
|
@@ -9056,12 +8886,12 @@ function registerInvest(program3) {
|
|
|
9056
8886
|
try {
|
|
9057
8887
|
const parsed = parseFloat(amount);
|
|
9058
8888
|
if (isNaN(parsed) || parsed < 1) {
|
|
9059
|
-
console.error(
|
|
8889
|
+
console.error(import_picocolors14.default.red(" \u2717 Amount must be at least $1"));
|
|
9060
8890
|
process.exitCode = 1;
|
|
9061
8891
|
return;
|
|
9062
8892
|
}
|
|
9063
8893
|
if (!["daily", "weekly", "monthly"].includes(frequency)) {
|
|
9064
|
-
console.error(
|
|
8894
|
+
console.error(import_picocolors14.default.red(" \u2717 Frequency must be daily, weekly, or monthly"));
|
|
9065
8895
|
process.exitCode = 1;
|
|
9066
8896
|
return;
|
|
9067
8897
|
}
|
|
@@ -9071,7 +8901,7 @@ function registerInvest(program3) {
|
|
|
9071
8901
|
const isStrategy = target ? target.toLowerCase() in allStrategies : false;
|
|
9072
8902
|
const isAsset = target ? target.toUpperCase() in INVESTMENT_ASSETS : false;
|
|
9073
8903
|
if (target && !isStrategy && !isAsset) {
|
|
9074
|
-
console.error(
|
|
8904
|
+
console.error(import_picocolors14.default.red(` \u2717 '${target}' is not a valid strategy or asset`));
|
|
9075
8905
|
process.exitCode = 1;
|
|
9076
8906
|
return;
|
|
9077
8907
|
}
|
|
@@ -9118,9 +8948,9 @@ function registerInvest(program3) {
|
|
|
9118
8948
|
printSeparator();
|
|
9119
8949
|
for (const s of status.schedules) {
|
|
9120
8950
|
const target = s.strategy ?? s.asset ?? "?";
|
|
9121
|
-
const statusTag = s.enabled ?
|
|
8951
|
+
const statusTag = s.enabled ? import_picocolors14.default.green("active") : import_picocolors14.default.dim("paused");
|
|
9122
8952
|
printKeyValue(s.id, `${formatUsd(s.amount)} ${s.frequency} \u2192 ${target} ${statusTag}`);
|
|
9123
|
-
printLine(` ${
|
|
8953
|
+
printLine(` ${import_picocolors14.default.dim(`Next: ${new Date(s.nextRun).toLocaleDateString()} \xB7 Runs: ${s.runCount} \xB7 Total: ${formatUsd(s.totalInvested)}`)}`);
|
|
9124
8954
|
}
|
|
9125
8955
|
printSeparator();
|
|
9126
8956
|
if (status.pendingRuns.length > 0) {
|
|
@@ -9163,7 +8993,7 @@ function registerInvest(program3) {
|
|
|
9163
8993
|
}
|
|
9164
8994
|
if (result.skipped.length > 0) {
|
|
9165
8995
|
for (const skip of result.skipped) {
|
|
9166
|
-
printLine(` ${
|
|
8996
|
+
printLine(` ${import_picocolors14.default.yellow("\u26A0")} Skipped ${skip.scheduleId}: ${skip.reason}`);
|
|
9167
8997
|
}
|
|
9168
8998
|
}
|
|
9169
8999
|
printBlank();
|
|
@@ -9190,21 +9020,21 @@ function registerInvest(program3) {
|
|
|
9190
9020
|
}
|
|
9191
9021
|
|
|
9192
9022
|
// src/commands/portfolio.ts
|
|
9193
|
-
var
|
|
9023
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
9194
9024
|
function printPositionLine(pos, rewardKeys) {
|
|
9195
9025
|
if (pos.currentPrice === 0 && pos.totalAmount > 0) {
|
|
9196
9026
|
printKeyValue(
|
|
9197
9027
|
pos.asset,
|
|
9198
|
-
`${formatAssetAmount(pos.totalAmount, pos.asset)} Avg: ${formatUsd(pos.avgPrice)} Now: ${
|
|
9028
|
+
`${formatAssetAmount(pos.totalAmount, pos.asset)} Avg: ${formatUsd(pos.avgPrice)} Now: ${import_picocolors15.default.yellow("unavailable")}`
|
|
9199
9029
|
);
|
|
9200
9030
|
} else {
|
|
9201
|
-
const pnlColor = pos.unrealizedPnL >= 0 ?
|
|
9031
|
+
const pnlColor = pos.unrealizedPnL >= 0 ? import_picocolors15.default.green : import_picocolors15.default.red;
|
|
9202
9032
|
const pnlSign = pos.unrealizedPnL >= 0 ? "+" : "";
|
|
9203
9033
|
let yieldSuffix = "";
|
|
9204
9034
|
if (pos.earning && pos.earningApy) {
|
|
9205
9035
|
const hasRewards = rewardKeys?.has(`${pos.earningProtocol}:${pos.asset}`);
|
|
9206
|
-
const rewardTag = hasRewards ? ` ${
|
|
9207
|
-
yieldSuffix = ` ${
|
|
9036
|
+
const rewardTag = hasRewards ? ` ${import_picocolors15.default.yellow("+rewards")}` : "";
|
|
9037
|
+
yieldSuffix = ` ${import_picocolors15.default.cyan(`${pos.earningApy.toFixed(1)}% APY (${pos.earningProtocol})`)}${rewardTag}`;
|
|
9208
9038
|
}
|
|
9209
9039
|
printKeyValue(
|
|
9210
9040
|
pos.asset,
|
|
@@ -9245,19 +9075,19 @@ function registerPortfolio(program3) {
|
|
|
9245
9075
|
stratLabel = def.name;
|
|
9246
9076
|
} catch {
|
|
9247
9077
|
}
|
|
9248
|
-
printLine(` ${
|
|
9078
|
+
printLine(` ${import_picocolors15.default.bold(import_picocolors15.default.cyan(`\u25B8 ${stratLabel}`))}`);
|
|
9249
9079
|
printSeparator();
|
|
9250
9080
|
for (const pos of positions) {
|
|
9251
9081
|
printPositionLine(pos, rewardKeys);
|
|
9252
9082
|
}
|
|
9253
9083
|
const stratValue = positions.reduce((s, p) => s + p.currentValue, 0);
|
|
9254
|
-
printLine(` ${
|
|
9084
|
+
printLine(` ${import_picocolors15.default.dim(`Subtotal: ${formatUsd(stratValue)}`)}`);
|
|
9255
9085
|
printBlank();
|
|
9256
9086
|
}
|
|
9257
9087
|
}
|
|
9258
9088
|
if (hasDirectPositions) {
|
|
9259
9089
|
if (hasStrategyPositions) {
|
|
9260
|
-
printLine(` ${
|
|
9090
|
+
printLine(` ${import_picocolors15.default.bold(import_picocolors15.default.cyan("\u25B8 Direct"))}`);
|
|
9261
9091
|
}
|
|
9262
9092
|
printSeparator();
|
|
9263
9093
|
for (const pos of portfolio.positions) {
|
|
@@ -9265,21 +9095,21 @@ function registerPortfolio(program3) {
|
|
|
9265
9095
|
}
|
|
9266
9096
|
if (hasStrategyPositions) {
|
|
9267
9097
|
const directValue = portfolio.positions.reduce((s, p) => s + p.currentValue, 0);
|
|
9268
|
-
printLine(` ${
|
|
9098
|
+
printLine(` ${import_picocolors15.default.dim(`Subtotal: ${formatUsd(directValue)}`)}`);
|
|
9269
9099
|
}
|
|
9270
9100
|
}
|
|
9271
9101
|
printSeparator();
|
|
9272
9102
|
const hasPriceUnavailable = portfolio.positions.some((p) => p.currentPrice === 0 && p.totalAmount > 0);
|
|
9273
9103
|
if (hasPriceUnavailable) {
|
|
9274
|
-
printInfo(
|
|
9104
|
+
printInfo(import_picocolors15.default.yellow("\u26A0 Price data unavailable for some assets. Values may be inaccurate."));
|
|
9275
9105
|
}
|
|
9276
9106
|
printKeyValue("Total invested", formatUsd(portfolio.totalInvested));
|
|
9277
9107
|
printKeyValue("Current value", formatUsd(portfolio.totalValue));
|
|
9278
|
-
const upnlColor = portfolio.unrealizedPnL >= 0 ?
|
|
9108
|
+
const upnlColor = portfolio.unrealizedPnL >= 0 ? import_picocolors15.default.green : import_picocolors15.default.red;
|
|
9279
9109
|
const upnlSign = portfolio.unrealizedPnL >= 0 ? "+" : "";
|
|
9280
9110
|
printKeyValue("Unrealized P&L", upnlColor(`${upnlSign}${formatUsd(portfolio.unrealizedPnL)} (${upnlSign}${portfolio.unrealizedPnLPct.toFixed(1)}%)`));
|
|
9281
9111
|
if (portfolio.realizedPnL !== 0) {
|
|
9282
|
-
const rpnlColor = portfolio.realizedPnL >= 0 ?
|
|
9112
|
+
const rpnlColor = portfolio.realizedPnL >= 0 ? import_picocolors15.default.green : import_picocolors15.default.red;
|
|
9283
9113
|
const rpnlSign = portfolio.realizedPnL >= 0 ? "+" : "";
|
|
9284
9114
|
printKeyValue("Realized P&L", rpnlColor(`${rpnlSign}${formatUsd(portfolio.realizedPnL)}`));
|
|
9285
9115
|
}
|
|
@@ -9291,7 +9121,7 @@ function registerPortfolio(program3) {
|
|
|
9291
9121
|
}
|
|
9292
9122
|
|
|
9293
9123
|
// src/commands/claimRewards.ts
|
|
9294
|
-
var
|
|
9124
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
9295
9125
|
function registerClaimRewards(program3) {
|
|
9296
9126
|
program3.command("claim-rewards").description("Claim pending protocol rewards").option("--key <path>", "Key file path").action(async (opts) => {
|
|
9297
9127
|
try {
|
|
@@ -9304,20 +9134,20 @@ function registerClaimRewards(program3) {
|
|
|
9304
9134
|
}
|
|
9305
9135
|
printBlank();
|
|
9306
9136
|
if (result.rewards.length === 0) {
|
|
9307
|
-
printLine(` ${
|
|
9137
|
+
printLine(` ${import_picocolors16.default.dim("No rewards to claim")}`);
|
|
9308
9138
|
printBlank();
|
|
9309
9139
|
return;
|
|
9310
9140
|
}
|
|
9311
9141
|
const protocols = [...new Set(result.rewards.map((r) => r.protocol))];
|
|
9312
|
-
printLine(` ${
|
|
9142
|
+
printLine(` ${import_picocolors16.default.green("\u2713")} Claimed and converted rewards to USDC`);
|
|
9313
9143
|
printSeparator();
|
|
9314
9144
|
const received = result.usdcReceived;
|
|
9315
9145
|
if (received >= 0.01) {
|
|
9316
|
-
printKeyValue("Received", `${
|
|
9146
|
+
printKeyValue("Received", `${import_picocolors16.default.green(formatUsd(received))} USDC`);
|
|
9317
9147
|
} else if (received > 0) {
|
|
9318
|
-
printKeyValue("Received", `${
|
|
9148
|
+
printKeyValue("Received", `${import_picocolors16.default.green("< $0.01")} USDC`);
|
|
9319
9149
|
} else {
|
|
9320
|
-
printKeyValue("Received", `${
|
|
9150
|
+
printKeyValue("Received", `${import_picocolors16.default.dim("< $0.01 USDC (rewards are still accruing)")}`);
|
|
9321
9151
|
}
|
|
9322
9152
|
printKeyValue("Source", protocols.join(", "));
|
|
9323
9153
|
if (result.tx) {
|
|
@@ -9331,7 +9161,7 @@ function registerClaimRewards(program3) {
|
|
|
9331
9161
|
}
|
|
9332
9162
|
|
|
9333
9163
|
// src/commands/gas.ts
|
|
9334
|
-
var
|
|
9164
|
+
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
9335
9165
|
function registerGas(program3) {
|
|
9336
9166
|
program3.command("gas").description("Check gas station status and wallet gas balance").option("--key <path>", "Key file path").action(async (opts) => {
|
|
9337
9167
|
try {
|
|
@@ -9353,36 +9183,36 @@ function registerGas(program3) {
|
|
|
9353
9183
|
}
|
|
9354
9184
|
printHeader("Gas Status");
|
|
9355
9185
|
if (gasStatus) {
|
|
9356
|
-
const cbStatus = gasStatus.circuitBreaker ?
|
|
9186
|
+
const cbStatus = gasStatus.circuitBreaker ? import_picocolors17.default.red("TRIPPED \u2014 sponsorship paused") : import_picocolors17.default.green("OK");
|
|
9357
9187
|
printKeyValue("Gas Station", cbStatus);
|
|
9358
9188
|
printKeyValue("SUI Price (TWAP)", `$${gasStatus.suiPrice.toFixed(4)}`);
|
|
9359
9189
|
if (gasStatus.bootstrapRemaining !== void 0) {
|
|
9360
9190
|
printKeyValue("Bootstrap", `${gasStatus.bootstrapUsed}/10 used (${gasStatus.bootstrapRemaining} remaining)`);
|
|
9361
9191
|
}
|
|
9362
9192
|
} else {
|
|
9363
|
-
printKeyValue("Gas Station",
|
|
9193
|
+
printKeyValue("Gas Station", import_picocolors17.default.red("unreachable"));
|
|
9364
9194
|
const reason = status.status === "rejected" ? status.reason : "unknown";
|
|
9365
|
-
printLine(` ${
|
|
9195
|
+
printLine(` ${import_picocolors17.default.dim(reason instanceof Error ? reason.message : String(reason))}`);
|
|
9366
9196
|
}
|
|
9367
9197
|
printDivider();
|
|
9368
9198
|
if (balData) {
|
|
9369
9199
|
const suiBal = balData.gasReserve.sui;
|
|
9370
|
-
const suiColor = suiBal < 0.05 ?
|
|
9200
|
+
const suiColor = suiBal < 0.05 ? import_picocolors17.default.red : import_picocolors17.default.green;
|
|
9371
9201
|
printKeyValue("SUI (gas)", suiColor(`${suiBal.toFixed(4)} SUI`));
|
|
9372
9202
|
if (suiBal < 0.05) {
|
|
9373
|
-
printLine(` ${
|
|
9203
|
+
printLine(` ${import_picocolors17.default.yellow("\u26A0")} Below gas threshold (0.05 SUI) \u2014 transactions will need sponsorship`);
|
|
9374
9204
|
}
|
|
9375
9205
|
printKeyValue("Available", `$${balData.available.toFixed(2)}`);
|
|
9376
9206
|
} else {
|
|
9377
|
-
printKeyValue("Wallet",
|
|
9207
|
+
printKeyValue("Wallet", import_picocolors17.default.dim("could not fetch balances"));
|
|
9378
9208
|
}
|
|
9379
9209
|
printBlank();
|
|
9380
9210
|
if (gasStatus && !gasStatus.circuitBreaker && (balData?.gasReserve.sui ?? 0) >= 0.05) {
|
|
9381
|
-
printLine(` ${
|
|
9211
|
+
printLine(` ${import_picocolors17.default.green("\u2713")} Gas is healthy \u2014 transactions should succeed`);
|
|
9382
9212
|
} else if (gasStatus && !gasStatus.circuitBreaker) {
|
|
9383
|
-
printLine(` ${
|
|
9213
|
+
printLine(` ${import_picocolors17.default.yellow("\u26A0")} Low SUI but gas station is online \u2014 sponsorship available`);
|
|
9384
9214
|
} else {
|
|
9385
|
-
printLine(` ${
|
|
9215
|
+
printLine(` ${import_picocolors17.default.red("\u2717")} Gas station issues detected \u2014 fund wallet with SUI directly`);
|
|
9386
9216
|
printInfo("Send SUI to your address: t2000 address");
|
|
9387
9217
|
}
|
|
9388
9218
|
printBlank();
|
|
@@ -9433,7 +9263,6 @@ Examples:
|
|
|
9433
9263
|
registerServe(program3);
|
|
9434
9264
|
registerPay(program3);
|
|
9435
9265
|
registerLock(program3);
|
|
9436
|
-
registerSentinel(program3);
|
|
9437
9266
|
registerEarn(program3);
|
|
9438
9267
|
registerRebalance(program3);
|
|
9439
9268
|
registerSwap(program3);
|