@byreal-io/byreal-cli-realclaw 0.3.6 → 0.3.7
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.cjs +220 -76
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3033,7 +3033,7 @@ var INJECTED_VERSION, VERSION, CLI_NAME, NPM_PACKAGE, API_BASE_URL, API_ENDPOINT
|
|
|
3033
3033
|
var init_constants = __esm({
|
|
3034
3034
|
"src/core/constants.ts"() {
|
|
3035
3035
|
"use strict";
|
|
3036
|
-
INJECTED_VERSION = true ? "0.3.
|
|
3036
|
+
INJECTED_VERSION = true ? "0.3.7" : void 0;
|
|
3037
3037
|
VERSION = INJECTED_VERSION ?? process.env.npm_package_version ?? "0.0.0";
|
|
3038
3038
|
CLI_NAME = "byreal-cli";
|
|
3039
3039
|
NPM_PACKAGE = "@byreal-io/byreal-cli-realclaw";
|
|
@@ -3071,7 +3071,7 @@ var init_constants = __esm({
|
|
|
3071
3071
|
CONFIG_FILE = "config.json";
|
|
3072
3072
|
DEFAULTS = {
|
|
3073
3073
|
OUTPUT_FORMAT: "table",
|
|
3074
|
-
LIST_LIMIT:
|
|
3074
|
+
LIST_LIMIT: 100,
|
|
3075
3075
|
MAX_LIST_LIMIT: 100,
|
|
3076
3076
|
SLIPPAGE_BPS: 200,
|
|
3077
3077
|
MAX_SLIPPAGE_BPS: 500,
|
|
@@ -83149,8 +83149,9 @@ function outputWalletBalance(balance, address) {
|
|
|
83149
83149
|
console.log(source_default.cyan.bold(`
|
|
83150
83150
|
Balance: ${address}
|
|
83151
83151
|
`));
|
|
83152
|
-
const table = createTable(["Mint", "Balance", "Program"]);
|
|
83152
|
+
const table = createTable(["Symbol", "Mint", "Balance", "Program"]);
|
|
83153
83153
|
table.push([
|
|
83154
|
+
source_default.white.bold("SOL"),
|
|
83154
83155
|
source_default.gray("native"),
|
|
83155
83156
|
`${balance.sol.amount_sol.toFixed(9)} SOL${balance.sol.amount_usd ? ` (${formatUsd(balance.sol.amount_usd)})` : ""}`,
|
|
83156
83157
|
"spl-token"
|
|
@@ -83160,7 +83161,11 @@ Balance: ${address}
|
|
|
83160
83161
|
if (token.multiplier && token.amount_ui_display) {
|
|
83161
83162
|
balanceDisplay = `${token.amount_ui} ${source_default.gray(`(display: ${token.amount_ui_display}, x${token.multiplier})`)}`;
|
|
83162
83163
|
}
|
|
83164
|
+
if (token.amount_usd) {
|
|
83165
|
+
balanceDisplay += ` ${source_default.green(token.amount_usd)}`;
|
|
83166
|
+
}
|
|
83163
83167
|
table.push([
|
|
83168
|
+
token.symbol ? source_default.white.bold(token.symbol) : "",
|
|
83164
83169
|
source_default.gray(token.mint),
|
|
83165
83170
|
balanceDisplay,
|
|
83166
83171
|
token.is_token_2022 ? "token-2022" : "spl-token"
|
|
@@ -83278,16 +83283,20 @@ function outputPositionOpenPreview(data) {
|
|
|
83278
83283
|
}
|
|
83279
83284
|
function outputPositionClosePreview(data) {
|
|
83280
83285
|
console.log(source_default.cyan.bold("\nClose Position Preview\n"));
|
|
83286
|
+
const usdSuffix = (usd) => usd ? ` (${usd})` : "";
|
|
83281
83287
|
const table = createTable(["Field", "Value"]);
|
|
83282
83288
|
table.push(
|
|
83283
83289
|
["NFT Mint", source_default.gray(data.nftMint)],
|
|
83284
83290
|
["Pool", source_default.gray(data.poolAddress)],
|
|
83285
83291
|
["Price Range", `${data.priceLower} \u2192 ${data.priceUpper}`],
|
|
83286
|
-
["Token A to Receive", `${data.tokenAmountA} ${data.symbolA}`],
|
|
83287
|
-
["Token B to Receive", `${data.tokenAmountB} ${data.symbolB}`],
|
|
83288
|
-
["Fee A to Claim", `${data.feeAmountA} ${data.symbolA}`],
|
|
83289
|
-
["Fee B to Claim", `${data.feeAmountB} ${data.symbolB}`]
|
|
83292
|
+
["Token A to Receive", `${data.tokenAmountA} ${data.symbolA}${usdSuffix(data.tokenAmountAUsd)}`],
|
|
83293
|
+
["Token B to Receive", `${data.tokenAmountB} ${data.symbolB}${usdSuffix(data.tokenAmountBUsd)}`],
|
|
83294
|
+
["Fee A to Claim", `${data.feeAmountA} ${data.symbolA}${usdSuffix(data.feeAmountAUsd)}`],
|
|
83295
|
+
["Fee B to Claim", `${data.feeAmountB} ${data.symbolB}${usdSuffix(data.feeAmountBUsd)}`]
|
|
83290
83296
|
);
|
|
83297
|
+
if (data.totalUsd) {
|
|
83298
|
+
table.push(["Total Value", source_default.bold(data.totalUsd)]);
|
|
83299
|
+
}
|
|
83291
83300
|
console.log(table.toString());
|
|
83292
83301
|
}
|
|
83293
83302
|
function outputPositionIncreasePreview(data) {
|
|
@@ -83299,38 +83308,48 @@ function outputPositionIncreasePreview(data) {
|
|
|
83299
83308
|
["Price Range", `${data.priceLower} \u2192 ${data.priceUpper}`]
|
|
83300
83309
|
);
|
|
83301
83310
|
if (data.currentTokenA && data.symbolA) {
|
|
83302
|
-
|
|
83311
|
+
const usd = data.currentTokenAUsd;
|
|
83312
|
+
table.push(["Current Token A", `${data.currentTokenA} ${data.symbolA}${usd ? ` (${usd})` : ""}`]);
|
|
83303
83313
|
}
|
|
83304
83314
|
if (data.currentTokenB && data.symbolB) {
|
|
83305
|
-
|
|
83315
|
+
const usd = data.currentTokenBUsd;
|
|
83316
|
+
table.push(["Current Token B", `${data.currentTokenB} ${data.symbolB}${usd ? ` (${usd})` : ""}`]);
|
|
83306
83317
|
}
|
|
83307
83318
|
table.push(
|
|
83308
83319
|
["Base Amount to Add", `${data.baseAmount} ${data.baseToken}`],
|
|
83309
83320
|
["Other Amount to Add", `${data.otherAmount} ${data.otherToken}`]
|
|
83310
83321
|
);
|
|
83322
|
+
const totalUsd = data.totalUsd;
|
|
83323
|
+
if (totalUsd) {
|
|
83324
|
+
table.push(["Total to Add", source_default.bold(totalUsd)]);
|
|
83325
|
+
}
|
|
83311
83326
|
console.log(table.toString());
|
|
83312
83327
|
}
|
|
83313
83328
|
function outputPositionDecreasePreview(data) {
|
|
83314
83329
|
console.log(source_default.cyan.bold("\nDecrease Liquidity Preview\n"));
|
|
83330
|
+
const usdSuffix = (usd) => usd ? ` (${usd})` : "";
|
|
83315
83331
|
const table = createTable(["Field", "Value"]);
|
|
83316
83332
|
table.push(
|
|
83317
83333
|
["NFT Mint", source_default.gray(data.nftMint)],
|
|
83318
83334
|
["Pool", source_default.gray(data.poolAddress)],
|
|
83319
83335
|
["Price Range", `${data.priceLower} \u2192 ${data.priceUpper}`],
|
|
83320
|
-
["Current Token A", `${data.tokenAmountA} ${data.symbolA}`],
|
|
83321
|
-
["Current Token B", `${data.tokenAmountB} ${data.symbolB}`]
|
|
83336
|
+
["Current Token A", `${data.tokenAmountA} ${data.symbolA}${usdSuffix(data.tokenAmountAUsd)}`],
|
|
83337
|
+
["Current Token B", `${data.tokenAmountB} ${data.symbolB}${usdSuffix(data.tokenAmountBUsd)}`]
|
|
83322
83338
|
);
|
|
83323
83339
|
if (data.totalPositionUsd) {
|
|
83324
|
-
table.push(["Total Position Value",
|
|
83340
|
+
table.push(["Total Position Value", data.totalPositionUsd]);
|
|
83325
83341
|
}
|
|
83326
83342
|
if (data.requestedUsd) {
|
|
83327
83343
|
table.push(["Remove Amount", `$${data.requestedUsd}`]);
|
|
83328
83344
|
}
|
|
83329
83345
|
table.push(
|
|
83330
83346
|
["Remove Percentage", `${data.percentage}%`],
|
|
83331
|
-
["Token A to Receive", `${data.receiveAmountA} ${data.symbolA}`],
|
|
83332
|
-
["Token B to Receive", `${data.receiveAmountB} ${data.symbolB}`]
|
|
83347
|
+
["Token A to Receive", `${data.receiveAmountA} ${data.symbolA}${usdSuffix(data.receiveAmountAUsd)}`],
|
|
83348
|
+
["Token B to Receive", `${data.receiveAmountB} ${data.symbolB}${usdSuffix(data.receiveAmountBUsd)}`]
|
|
83333
83349
|
);
|
|
83350
|
+
if (data.receiveUsdTotal) {
|
|
83351
|
+
table.push(["Receive Total", source_default.bold(data.receiveUsdTotal)]);
|
|
83352
|
+
}
|
|
83334
83353
|
console.log(table.toString());
|
|
83335
83354
|
}
|
|
83336
83355
|
function outputPositionClaimPreview(entries) {
|
|
@@ -83339,7 +83358,12 @@ function outputPositionClaimPreview(entries) {
|
|
|
83339
83358
|
console.log(source_default.white.bold(` Position: ${entry.positionAddress}`));
|
|
83340
83359
|
for (const token of entry.tokens) {
|
|
83341
83360
|
const uiAmount = rawToUi(String(token.tokenAmount), token.tokenDecimals);
|
|
83342
|
-
|
|
83361
|
+
const usdPart = token.amountUsd ? ` (${token.amountUsd})` : "";
|
|
83362
|
+
console.log(source_default.gray(` ${uiAmount} ${token.tokenSymbol}${usdPart} (${token.tokenAddress})`));
|
|
83363
|
+
}
|
|
83364
|
+
const totalUsd = entry.totalUsd;
|
|
83365
|
+
if (totalUsd) {
|
|
83366
|
+
console.log(source_default.gray(` Total: ${totalUsd}`));
|
|
83343
83367
|
}
|
|
83344
83368
|
console.log();
|
|
83345
83369
|
}
|
|
@@ -83369,7 +83393,7 @@ ${label} Preview
|
|
|
83369
83393
|
const claimed = parseFloat(r.claimedTokenAmount);
|
|
83370
83394
|
const unclaimed = synced - locked - claimed;
|
|
83371
83395
|
if (unclaimed <= 0) continue;
|
|
83372
|
-
const usdValue = parseFloat(r.price) > 0 ? ` (
|
|
83396
|
+
const usdValue = parseFloat(r.price) > 0 ? ` (${formatUsd(unclaimed * parseFloat(r.price))})` : "";
|
|
83373
83397
|
console.log(source_default.gray(` ${unclaimed.toFixed(r.tokenDecimals > 6 ? 6 : r.tokenDecimals)} ${r.tokenSymbol}${usdValue} (${r.tokenAddress})`));
|
|
83374
83398
|
}
|
|
83375
83399
|
console.log();
|
|
@@ -83588,13 +83612,13 @@ Position Analysis: ${data.position.pair}`));
|
|
|
83588
83612
|
console.log();
|
|
83589
83613
|
console.log(source_default.cyan.bold("Performance"));
|
|
83590
83614
|
const perfTable = createTable(["Metric", "Value"]);
|
|
83591
|
-
const pnlColor =
|
|
83592
|
-
const netColor =
|
|
83615
|
+
const pnlColor = data.performance.pnlUsd.startsWith("-") ? source_default.red : source_default.green;
|
|
83616
|
+
const netColor = data.performance.netReturnUsd.startsWith("-") ? source_default.red : source_default.green;
|
|
83593
83617
|
perfTable.push(
|
|
83594
|
-
["Liquidity",
|
|
83595
|
-
["Earned Fees",
|
|
83596
|
-
["PnL (IL)", pnlColor(
|
|
83597
|
-
["Net Return", netColor(
|
|
83618
|
+
["Liquidity", data.performance.liquidityUsd],
|
|
83619
|
+
["Earned Fees", `${data.performance.earnedUsd} (${data.performance.earnedPercent})`],
|
|
83620
|
+
["PnL (IL)", pnlColor(`${data.performance.pnlUsd} (${data.performance.pnlPercent})`)],
|
|
83621
|
+
["Net Return", netColor(`${data.performance.netReturnUsd} (${data.performance.netReturnPercent})`)]
|
|
83598
83622
|
);
|
|
83599
83623
|
console.log(perfTable.toString());
|
|
83600
83624
|
console.log(source_default.cyan.bold("\nRange Health"));
|
|
@@ -83613,16 +83637,17 @@ Position Analysis: ${data.position.pair}`));
|
|
|
83613
83637
|
const poolTable = createTable(["Metric", "Value"]);
|
|
83614
83638
|
poolTable.push(
|
|
83615
83639
|
["Fee APR (24h)", data.poolContext.feeApr24h],
|
|
83616
|
-
["Volume (24h)",
|
|
83617
|
-
["TVL",
|
|
83640
|
+
["Volume (24h)", data.poolContext.volume24h],
|
|
83641
|
+
["TVL", data.poolContext.tvl],
|
|
83618
83642
|
["Price Change (24h)", data.poolContext.priceChange24h]
|
|
83619
83643
|
);
|
|
83620
83644
|
console.log(poolTable.toString());
|
|
83621
83645
|
console.log(source_default.cyan.bold("\nUnclaimed Fees"));
|
|
83622
|
-
const feeTable = createTable(["Token", "Amount"]);
|
|
83646
|
+
const feeTable = createTable(["Token", "Amount", "USD Value"]);
|
|
83623
83647
|
feeTable.push(
|
|
83624
|
-
[data.unclaimedFees.tokenA.symbol, data.unclaimedFees.tokenA.amount],
|
|
83625
|
-
[data.unclaimedFees.tokenB.symbol, data.unclaimedFees.tokenB.amount]
|
|
83648
|
+
[data.unclaimedFees.tokenA.symbol, data.unclaimedFees.tokenA.amount, data.unclaimedFees.tokenA.amountUsd],
|
|
83649
|
+
[data.unclaimedFees.tokenB.symbol, data.unclaimedFees.tokenB.amount, data.unclaimedFees.tokenB.amountUsd],
|
|
83650
|
+
[source_default.bold("Total"), "", source_default.bold(data.unclaimedFees.totalUsd)]
|
|
83626
83651
|
);
|
|
83627
83652
|
console.log(feeTable.toString());
|
|
83628
83653
|
}
|
|
@@ -84271,7 +84296,8 @@ For detailed parameter info on any command, run: \`byreal-cli catalog show <capa
|
|
|
84271
84296
|
\`pools analyze\` returns: pool info, metrics (TVL/volume/fees/feeApr), volatility, active rewards (token, APR, daily amount, end date), rangeAnalysis (per range: price bounds, estimated fee APR, in-range likelihood), riskFactors, wallet info, investmentProjection.
|
|
84272
84297
|
|
|
84273
84298
|
### Position Analysis Response
|
|
84274
|
-
\`positions analyze\` returns: position info (NFT, pool, pair, range, status, inRange), performance (liquidityUsd, earnedUsd/%, pnlUsd/%, netReturnUsd/%), rangeHealth (distance to bounds, outOfRangeRisk), poolContext, unclaimedFees.
|
|
84299
|
+
\`positions analyze\` returns: position info (NFT, pool, pair, range, status, inRange), performance (liquidityUsd, earnedUsd/%, pnlUsd/%, netReturnUsd/% \u2014 all USD values pre-formatted with $ prefix like "$0.0065"), rangeHealth (distance to bounds, outOfRangeRisk), poolContext, unclaimedFees (each token has symbol, amount, amountUsd; plus totalUsd).
|
|
84300
|
+
\`positions list\` JSON includes *UsdDisplay fields (e.g. earnedUsdDisplay: "$0.0065") for LLM-friendly reading.
|
|
84275
84301
|
|
|
84276
84302
|
### Position Lifecycle: decrease vs close
|
|
84277
84303
|
- \`decrease --percentage 100\`: Removes all liquidity but **keeps the position NFT**. Can add liquidity again later with \`increase\`.
|
|
@@ -84419,7 +84445,7 @@ var CAPABILITIES = [
|
|
|
84419
84445
|
{ name: "sort-field", type: "string", required: false, description: "Sort field", default: "tvl", enum: ["tvl", "volumeUsd24h", "feeUsd24h", "apr24h"] },
|
|
84420
84446
|
{ name: "sort-type", type: "string", required: false, description: "Sort order", default: "desc", enum: ["asc", "desc"] },
|
|
84421
84447
|
{ name: "page", type: "integer", required: false, description: "Page number", default: "1" },
|
|
84422
|
-
{ name: "page-size", type: "integer", required: false, description: "Results per page", default: "
|
|
84448
|
+
{ name: "page-size", type: "integer", required: false, description: "Results per page", default: "100" },
|
|
84423
84449
|
{ name: "category", type: "string", required: false, description: "Pool category: 1=stable, 2=xStocks, 4=launchpad, 16=normal" }
|
|
84424
84450
|
]
|
|
84425
84451
|
},
|
|
@@ -84547,7 +84573,7 @@ var CAPABILITIES = [
|
|
|
84547
84573
|
{
|
|
84548
84574
|
id: "dex.position.list",
|
|
84549
84575
|
name: "List Positions",
|
|
84550
|
-
description: "List CLMM positions for your wallet or any wallet address. Use --user to query another wallet (read-only, no --wallet-address needed).",
|
|
84576
|
+
description: "List CLMM positions for your wallet or any wallet address. JSON output includes pre-formatted USD display fields (*UsdDisplay). Use --user to query another wallet (read-only, no --wallet-address needed).",
|
|
84551
84577
|
category: "query",
|
|
84552
84578
|
auth_required: false,
|
|
84553
84579
|
command: "byreal-cli positions list",
|
|
@@ -84564,7 +84590,7 @@ var CAPABILITIES = [
|
|
|
84564
84590
|
{
|
|
84565
84591
|
id: "dex.position.analyze",
|
|
84566
84592
|
name: "Position Analysis",
|
|
84567
|
-
description: "Analyze existing position: performance (earned, PnL, net return), range health, pool context, and unclaimed fees. Requires --wallet-address global option.",
|
|
84593
|
+
description: "Analyze existing position: performance (earned, PnL, net return with formatted USD values), range health, pool context, and unclaimed fees with USD values. Requires --wallet-address global option.",
|
|
84568
84594
|
category: "analyze",
|
|
84569
84595
|
auth_required: true,
|
|
84570
84596
|
command: "byreal-cli positions analyze <nft-mint> --wallet-address <address>",
|
|
@@ -84979,30 +85005,52 @@ function createWalletCommand() {
|
|
|
84979
85005
|
is_token_2022: raw.isToken2022
|
|
84980
85006
|
});
|
|
84981
85007
|
}
|
|
84982
|
-
const t22Mints = tokens.filter((t) => t.is_token_2022).map((t) => t.mint);
|
|
84983
85008
|
try {
|
|
84984
|
-
const
|
|
85009
|
+
const tokenInfo = await fetchToken2022Multipliers(tokens.map((t) => t.mint));
|
|
84985
85010
|
for (const token of tokens) {
|
|
84986
|
-
const info =
|
|
85011
|
+
const info = tokenInfo.get(token.mint);
|
|
84987
85012
|
if (!info) continue;
|
|
84988
85013
|
if (info.symbol) token.symbol = info.symbol;
|
|
84989
85014
|
if (info.name) token.name = info.name;
|
|
84990
|
-
if (info.multiplier && parseFloat(info.multiplier) !== 1) {
|
|
85015
|
+
if (token.is_token_2022 && info.multiplier && parseFloat(info.multiplier) !== 1) {
|
|
84991
85016
|
token.multiplier = info.multiplier;
|
|
84992
85017
|
token.amount_ui_display = (parseFloat(token.amount_ui) * parseFloat(info.multiplier)).toString();
|
|
84993
85018
|
}
|
|
84994
85019
|
}
|
|
84995
85020
|
} catch {
|
|
84996
85021
|
}
|
|
85022
|
+
const SOL_MINT2 = "So11111111111111111111111111111111111111112";
|
|
85023
|
+
const allMints = [SOL_MINT2, ...tokens.map((t) => t.mint)];
|
|
85024
|
+
let prices = {};
|
|
85025
|
+
try {
|
|
85026
|
+
const pricesResult = await api.getTokenPrices(allMints);
|
|
85027
|
+
if (pricesResult.ok) prices = pricesResult.value;
|
|
85028
|
+
} catch {
|
|
85029
|
+
}
|
|
85030
|
+
const solPriceUsd = prices[SOL_MINT2] ?? 0;
|
|
84997
85031
|
const balance = {
|
|
84998
85032
|
sol: {
|
|
84999
85033
|
amount_lamports: lamports.toString(),
|
|
85000
|
-
amount_sol: solBalance
|
|
85034
|
+
amount_sol: solBalance,
|
|
85035
|
+
amount_usd: solPriceUsd > 0 ? solBalance * solPriceUsd : void 0
|
|
85001
85036
|
},
|
|
85002
|
-
tokens
|
|
85037
|
+
tokens: tokens.map((t) => {
|
|
85038
|
+
const price = prices[t.mint] ?? 0;
|
|
85039
|
+
const uiAmount = parseFloat(t.amount_ui_display || t.amount_ui);
|
|
85040
|
+
return {
|
|
85041
|
+
...t,
|
|
85042
|
+
price_usd: price > 0 ? price : void 0,
|
|
85043
|
+
amount_usd: price > 0 ? formatUsd(uiAmount * price) : void 0
|
|
85044
|
+
};
|
|
85045
|
+
})
|
|
85003
85046
|
};
|
|
85047
|
+
const totalUsd = (balance.sol.amount_usd ?? 0) + balance.tokens.reduce((sum3, t) => {
|
|
85048
|
+
const price = prices[t.mint] ?? 0;
|
|
85049
|
+
const uiAmount = parseFloat(t.amount_ui_display || t.amount_ui);
|
|
85050
|
+
return sum3 + uiAmount * price;
|
|
85051
|
+
}, 0);
|
|
85004
85052
|
if (globalOptions.output === "json") {
|
|
85005
|
-
outputJson({ address: walletAddress, balance }, startTime);
|
|
85053
|
+
outputJson({ address: walletAddress, balance, totalUsd: formatUsd(totalUsd) }, startTime);
|
|
85006
85054
|
} else {
|
|
85007
85055
|
outputWalletBalance(balance, walletAddress);
|
|
85008
85056
|
}
|
|
@@ -85213,7 +85261,20 @@ Error: Invalid wallet address: ${userPublicKey}`));
|
|
|
85213
85261
|
if (mode === "dry-run") {
|
|
85214
85262
|
printDryRunBanner();
|
|
85215
85263
|
if (format === "json") {
|
|
85216
|
-
|
|
85264
|
+
let inAmountUsd;
|
|
85265
|
+
let outAmountUsd;
|
|
85266
|
+
try {
|
|
85267
|
+
const pricesResult = await api.getTokenPrices([quote.inputMint, quote.outputMint]);
|
|
85268
|
+
if (pricesResult.ok) {
|
|
85269
|
+
const prices = pricesResult.value;
|
|
85270
|
+
const inPrice = prices[quote.inputMint] ?? 0;
|
|
85271
|
+
const outPrice = prices[quote.outputMint] ?? 0;
|
|
85272
|
+
if (inPrice > 0) inAmountUsd = formatUsd(parseFloat(uiInAmount) * inPrice);
|
|
85273
|
+
if (outPrice > 0) outAmountUsd = formatUsd(parseFloat(uiOutAmount) * outPrice);
|
|
85274
|
+
}
|
|
85275
|
+
} catch {
|
|
85276
|
+
}
|
|
85277
|
+
outputJson({ mode: "dry-run", ...quote, uiInAmount, uiOutAmount, inAmountUsd, outAmountUsd }, startTime);
|
|
85217
85278
|
} else {
|
|
85218
85279
|
outputSwapQuoteTable(quote, uiInAmount, uiOutAmount);
|
|
85219
85280
|
console.log(source_default.yellow("\n Remove --dry-run to generate the unsigned transaction"));
|
|
@@ -85306,7 +85367,17 @@ Error: ${errMsg}`));
|
|
|
85306
85367
|
process.exit(1);
|
|
85307
85368
|
}
|
|
85308
85369
|
if (format === "json") {
|
|
85309
|
-
|
|
85370
|
+
const enriched = {
|
|
85371
|
+
...result.value,
|
|
85372
|
+
positions: result.value.positions.map((p) => ({
|
|
85373
|
+
...p,
|
|
85374
|
+
liquidityUsdDisplay: p.liquidityUsd ? formatUsd(parseFloat(p.liquidityUsd)) : "$0.00",
|
|
85375
|
+
earnedUsdDisplay: p.earnedUsd ? formatUsd(parseFloat(p.earnedUsd)) : "$0.00",
|
|
85376
|
+
pnlUsdDisplay: p.pnlUsd ? parseFloat(p.pnlUsd) < 0 ? `-${formatUsd(Math.abs(parseFloat(p.pnlUsd)))}` : formatUsd(parseFloat(p.pnlUsd)) : "$0.00",
|
|
85377
|
+
bonusUsdDisplay: p.bonusUsd ? formatUsd(parseFloat(p.bonusUsd)) : "$0.00"
|
|
85378
|
+
}))
|
|
85379
|
+
};
|
|
85380
|
+
outputJson(enriched, startTime);
|
|
85310
85381
|
} else {
|
|
85311
85382
|
outputPositionsTable(result.value.positions, result.value.total);
|
|
85312
85383
|
}
|
|
@@ -85620,19 +85691,19 @@ function createPositionsOpenCommand() {
|
|
|
85620
85691
|
otherAmount: rawToUi(otherAmountMax.toString(), otherDecimals),
|
|
85621
85692
|
otherToken: otherSymbol,
|
|
85622
85693
|
...investmentUsd ? { investmentUsd } : {},
|
|
85623
|
-
|
|
85624
|
-
|
|
85625
|
-
|
|
85626
|
-
|
|
85627
|
-
|
|
85628
|
-
|
|
85629
|
-
|
|
85630
|
-
|
|
85631
|
-
|
|
85632
|
-
|
|
85633
|
-
|
|
85634
|
-
|
|
85635
|
-
|
|
85694
|
+
tokenA: {
|
|
85695
|
+
symbol: symbolA,
|
|
85696
|
+
amount: amountAUi,
|
|
85697
|
+
usd: amountAUsd ?? formatUsd(parseFloat(amountAUi) * tokenAPriceUsd)
|
|
85698
|
+
},
|
|
85699
|
+
tokenB: {
|
|
85700
|
+
symbol: symbolB,
|
|
85701
|
+
amount: amountBUi,
|
|
85702
|
+
usd: amountBUsd ?? formatUsd(parseFloat(amountBUi) * tokenBPriceUsd)
|
|
85703
|
+
},
|
|
85704
|
+
totalUsd: totalUsd ?? formatUsd(
|
|
85705
|
+
parseFloat(amountAUi) * tokenAPriceUsd + parseFloat(amountBUi) * tokenBPriceUsd
|
|
85706
|
+
)
|
|
85636
85707
|
};
|
|
85637
85708
|
const balanceWarnings = await checkBalanceSufficiency(
|
|
85638
85709
|
publicKey3,
|
|
@@ -85915,7 +85986,22 @@ Error: ${errMsg}`));
|
|
|
85915
85986
|
currentTokenB: positionInfo.tokenB.uiAmount,
|
|
85916
85987
|
symbolA,
|
|
85917
85988
|
symbolB,
|
|
85918
|
-
...investmentUsd ? { investmentUsd } : {}
|
|
85989
|
+
...investmentUsd ? { investmentUsd } : {},
|
|
85990
|
+
tokenA: {
|
|
85991
|
+
symbol: symbolA,
|
|
85992
|
+
amount: rawToUi((base === "MintA" ? baseAmount : otherAmountMax).toString(), poolInfo.mintDecimalsA),
|
|
85993
|
+
usd: formatUsd(parseFloat(rawToUi((base === "MintA" ? baseAmount : otherAmountMax).toString(), poolInfo.mintDecimalsA)) * tokenAPriceUsd)
|
|
85994
|
+
},
|
|
85995
|
+
tokenB: {
|
|
85996
|
+
symbol: symbolB,
|
|
85997
|
+
amount: rawToUi((base === "MintA" ? otherAmountMax : baseAmount).toString(), poolInfo.mintDecimalsB),
|
|
85998
|
+
usd: formatUsd(parseFloat(rawToUi((base === "MintA" ? otherAmountMax : baseAmount).toString(), poolInfo.mintDecimalsB)) * tokenBPriceUsd)
|
|
85999
|
+
},
|
|
86000
|
+
currentTokenAUsd: formatUsd(parseFloat(positionInfo.tokenA.uiAmount) * tokenAPriceUsd),
|
|
86001
|
+
currentTokenBUsd: formatUsd(parseFloat(positionInfo.tokenB.uiAmount) * tokenBPriceUsd),
|
|
86002
|
+
totalUsd: formatUsd(
|
|
86003
|
+
parseFloat(rawToUi((base === "MintA" ? baseAmount : otherAmountMax).toString(), poolInfo.mintDecimalsA)) * tokenAPriceUsd + parseFloat(rawToUi((base === "MintA" ? otherAmountMax : baseAmount).toString(), poolInfo.mintDecimalsB)) * tokenBPriceUsd
|
|
86004
|
+
)
|
|
85919
86005
|
};
|
|
85920
86006
|
const balanceWarnings = await checkBalanceSufficiency(
|
|
85921
86007
|
publicKey3,
|
|
@@ -86178,6 +86264,8 @@ Error: ${errMsg}`));
|
|
|
86178
86264
|
const slippage = options.slippage ? parseInt(options.slippage, 10) / 1e4 : getSlippageBps() / 1e4;
|
|
86179
86265
|
if (mode === "dry-run") {
|
|
86180
86266
|
printDryRunBanner();
|
|
86267
|
+
const receiveAUsd = parseFloat(receiveAmountAUi) * tokenAPriceUsd;
|
|
86268
|
+
const receiveBUsd = parseFloat(receiveAmountBUi) * tokenBPriceUsd;
|
|
86181
86269
|
const previewData = {
|
|
86182
86270
|
nftMint: options.nftMint,
|
|
86183
86271
|
poolAddress,
|
|
@@ -86185,12 +86273,17 @@ Error: ${errMsg}`));
|
|
|
86185
86273
|
priceUpper: positionInfo.uiPriceUpper,
|
|
86186
86274
|
percentage: Math.round(percentage * 100) / 100,
|
|
86187
86275
|
tokenAmountA: positionInfo.tokenA.uiAmount,
|
|
86276
|
+
tokenAmountAUsd: formatUsd(tokenAUiAmount * tokenAPriceUsd),
|
|
86188
86277
|
tokenAmountB: positionInfo.tokenB.uiAmount,
|
|
86278
|
+
tokenAmountBUsd: formatUsd(tokenBUiAmount * tokenBPriceUsd),
|
|
86189
86279
|
receiveAmountA: receiveAmountAUi,
|
|
86280
|
+
receiveAmountAUsd: formatUsd(receiveAUsd),
|
|
86190
86281
|
receiveAmountB: receiveAmountBUi,
|
|
86282
|
+
receiveAmountBUsd: formatUsd(receiveBUsd),
|
|
86283
|
+
receiveUsdTotal: formatUsd(receiveAUsd + receiveBUsd),
|
|
86191
86284
|
symbolA,
|
|
86192
86285
|
symbolB,
|
|
86193
|
-
...totalPositionUsd > 0 ? { totalPositionUsd: totalPositionUsd
|
|
86286
|
+
...totalPositionUsd > 0 ? { totalPositionUsd: formatUsd(totalPositionUsd) } : {},
|
|
86194
86287
|
...requestedUsd ? { requestedUsd } : {}
|
|
86195
86288
|
};
|
|
86196
86289
|
if (format === "json") {
|
|
@@ -86281,24 +86374,39 @@ Error: ${errMsg}`));
|
|
|
86281
86374
|
const poolAddress = positionInfo.rawPoolInfo.poolId.toBase58();
|
|
86282
86375
|
let symbolA = positionInfo.tokenA.address.toBase58();
|
|
86283
86376
|
let symbolB = positionInfo.tokenB.address.toBase58();
|
|
86377
|
+
let tokenAPriceUsd = 0;
|
|
86378
|
+
let tokenBPriceUsd = 0;
|
|
86284
86379
|
const poolResult = await api.getPoolInfo(poolAddress);
|
|
86285
86380
|
if (poolResult.ok) {
|
|
86286
86381
|
symbolA = poolResult.value.token_a.symbol || symbolA;
|
|
86287
86382
|
symbolB = poolResult.value.token_b.symbol || symbolB;
|
|
86383
|
+
tokenAPriceUsd = poolResult.value.token_a.price_usd ?? 0;
|
|
86384
|
+
tokenBPriceUsd = poolResult.value.token_b.price_usd ?? 0;
|
|
86288
86385
|
}
|
|
86289
86386
|
if (mode === "dry-run") {
|
|
86290
86387
|
printDryRunBanner();
|
|
86388
|
+
const tokenAmountAVal = parseFloat(positionInfo.tokenA.uiAmount || "0");
|
|
86389
|
+
const tokenAmountBVal = parseFloat(positionInfo.tokenB.uiAmount || "0");
|
|
86390
|
+
const feeAmountAVal = parseFloat(positionInfo.tokenA.uiFeeAmount || "0");
|
|
86391
|
+
const feeAmountBVal = parseFloat(positionInfo.tokenB.uiFeeAmount || "0");
|
|
86291
86392
|
const previewData = {
|
|
86292
86393
|
nftMint: options.nftMint,
|
|
86293
86394
|
poolAddress,
|
|
86294
86395
|
priceLower: positionInfo.uiPriceLower,
|
|
86295
86396
|
priceUpper: positionInfo.uiPriceUpper,
|
|
86296
86397
|
tokenAmountA: positionInfo.tokenA.uiAmount,
|
|
86398
|
+
tokenAmountAUsd: formatUsd(tokenAmountAVal * tokenAPriceUsd),
|
|
86297
86399
|
tokenAmountB: positionInfo.tokenB.uiAmount,
|
|
86400
|
+
tokenAmountBUsd: formatUsd(tokenAmountBVal * tokenBPriceUsd),
|
|
86298
86401
|
feeAmountA: positionInfo.tokenA.uiFeeAmount,
|
|
86402
|
+
feeAmountAUsd: formatUsd(feeAmountAVal * tokenAPriceUsd),
|
|
86299
86403
|
feeAmountB: positionInfo.tokenB.uiFeeAmount,
|
|
86404
|
+
feeAmountBUsd: formatUsd(feeAmountBVal * tokenBPriceUsd),
|
|
86300
86405
|
symbolA,
|
|
86301
|
-
symbolB
|
|
86406
|
+
symbolB,
|
|
86407
|
+
totalUsd: formatUsd(
|
|
86408
|
+
(tokenAmountAVal + feeAmountAVal) * tokenAPriceUsd + (tokenAmountBVal + feeAmountBVal) * tokenBPriceUsd
|
|
86409
|
+
)
|
|
86302
86410
|
};
|
|
86303
86411
|
if (format === "json") {
|
|
86304
86412
|
outputJson({ mode: "dry-run", ...previewData }, startTime);
|
|
@@ -86431,10 +86539,26 @@ Error: ${errMsg}`));
|
|
|
86431
86539
|
}
|
|
86432
86540
|
if (mode === "dry-run") {
|
|
86433
86541
|
printDryRunBanner();
|
|
86542
|
+
const allMints = [...new Set(entries.flatMap((e) => e.tokens.map((t) => t.tokenAddress)))];
|
|
86543
|
+
const pricesResult = await api.getTokenPrices(allMints);
|
|
86544
|
+
const prices = pricesResult.ok ? pricesResult.value : {};
|
|
86545
|
+
const enrichedEntries = entries.map((entry) => {
|
|
86546
|
+
const enrichedTokens = entry.tokens.map((t) => {
|
|
86547
|
+
const uiAmount = parseFloat(t.tokenAmount) / Math.pow(10, t.tokenDecimals);
|
|
86548
|
+
const price = prices[t.tokenAddress] ?? 0;
|
|
86549
|
+
return { ...t, amountUsd: formatUsd(uiAmount * price) };
|
|
86550
|
+
});
|
|
86551
|
+
const totalUsd = enrichedTokens.reduce((sum3, t) => {
|
|
86552
|
+
const uiAmount = parseFloat(t.tokenAmount) / Math.pow(10, t.tokenDecimals);
|
|
86553
|
+
const price = prices[t.tokenAddress] ?? 0;
|
|
86554
|
+
return sum3 + uiAmount * price;
|
|
86555
|
+
}, 0);
|
|
86556
|
+
return { ...entry, tokens: enrichedTokens, totalUsd: formatUsd(totalUsd) };
|
|
86557
|
+
});
|
|
86434
86558
|
if (format === "json") {
|
|
86435
|
-
outputJson({ mode: "dry-run", entries }, startTime);
|
|
86559
|
+
outputJson({ mode: "dry-run", entries: enrichedEntries }, startTime);
|
|
86436
86560
|
} else {
|
|
86437
|
-
outputPositionClaimPreview(
|
|
86561
|
+
outputPositionClaimPreview(enrichedEntries);
|
|
86438
86562
|
console.log(source_default.yellow("\n Remove --dry-run to generate the unsigned transaction(s)"));
|
|
86439
86563
|
}
|
|
86440
86564
|
return;
|
|
@@ -86477,13 +86601,24 @@ function createPositionsClaimRewardsCommand() {
|
|
|
86477
86601
|
const openRewards = filterUnclaimed(unclaimedOpenIncentives);
|
|
86478
86602
|
const closedRewards = filterUnclaimed(unclaimedClosedIncentives);
|
|
86479
86603
|
const allRewards = [...openRewards, ...closedRewards];
|
|
86604
|
+
const enrichRewardItem = (item) => {
|
|
86605
|
+
const unclaimed = parseFloat(item.syncedTokenAmount) - parseFloat(item.lockedTokenAmount) - parseFloat(item.claimedTokenAmount);
|
|
86606
|
+
const price = parseFloat(item.price || "0");
|
|
86607
|
+
return {
|
|
86608
|
+
...item,
|
|
86609
|
+
unclaimedAmount: unclaimed.toString(),
|
|
86610
|
+
unclaimedAmountUsd: formatUsd(unclaimed * price)
|
|
86611
|
+
};
|
|
86612
|
+
};
|
|
86480
86613
|
if (mode === "dry-run") {
|
|
86481
86614
|
printDryRunBanner();
|
|
86482
86615
|
if (format === "json") {
|
|
86616
|
+
const enrichedOpen = openRewards.map(enrichRewardItem);
|
|
86617
|
+
const enrichedClosed = closedRewards.map(enrichRewardItem);
|
|
86483
86618
|
outputJson({
|
|
86484
86619
|
mode: "dry-run",
|
|
86485
|
-
openPositionRewards:
|
|
86486
|
-
closedPositionRewards:
|
|
86620
|
+
openPositionRewards: enrichedOpen,
|
|
86621
|
+
closedPositionRewards: enrichedClosed,
|
|
86487
86622
|
totalPositions: new Set(allRewards.map((r) => r.positionAddress)).size
|
|
86488
86623
|
}, startTime);
|
|
86489
86624
|
} else {
|
|
@@ -86810,12 +86945,12 @@ Error: ${errMsg}`));
|
|
|
86810
86945
|
inRange
|
|
86811
86946
|
},
|
|
86812
86947
|
performance: {
|
|
86813
|
-
liquidityUsd: liquidityUsd
|
|
86814
|
-
earnedUsd: earnedUsd
|
|
86948
|
+
liquidityUsd: formatUsd(liquidityUsd),
|
|
86949
|
+
earnedUsd: formatUsd(earnedUsd),
|
|
86815
86950
|
earnedPercent: `${parseFloat(String(earnedPercent)).toFixed(2)}%`,
|
|
86816
|
-
pnlUsd: pnlUsd.
|
|
86951
|
+
pnlUsd: pnlUsd < 0 ? `-${formatUsd(Math.abs(pnlUsd))}` : formatUsd(pnlUsd),
|
|
86817
86952
|
pnlPercent: `${parseFloat(String(pnlPercent)).toFixed(2)}%`,
|
|
86818
|
-
netReturnUsd: netReturnUsd.
|
|
86953
|
+
netReturnUsd: netReturnUsd < 0 ? `-${formatUsd(Math.abs(netReturnUsd))}` : formatUsd(netReturnUsd),
|
|
86819
86954
|
netReturnPercent: `${parseFloat(netReturnPercent).toFixed(2)}%`
|
|
86820
86955
|
},
|
|
86821
86956
|
rangeHealth: {
|
|
@@ -86827,20 +86962,29 @@ Error: ${errMsg}`));
|
|
|
86827
86962
|
},
|
|
86828
86963
|
poolContext: {
|
|
86829
86964
|
feeApr24h: `${pool.apr.toFixed(2)}%`,
|
|
86830
|
-
volume24h: pool.volume_24h_usd
|
|
86831
|
-
tvl: pool.tvl_usd
|
|
86965
|
+
volume24h: formatUsd(pool.volume_24h_usd),
|
|
86966
|
+
tvl: formatUsd(pool.tvl_usd),
|
|
86832
86967
|
priceChange24h: `${(pool.price_change_24h || 0).toFixed(2)}%`
|
|
86833
86968
|
},
|
|
86834
|
-
unclaimedFees: {
|
|
86835
|
-
tokenA
|
|
86836
|
-
|
|
86837
|
-
|
|
86838
|
-
|
|
86839
|
-
|
|
86840
|
-
|
|
86841
|
-
|
|
86842
|
-
|
|
86843
|
-
|
|
86969
|
+
unclaimedFees: (() => {
|
|
86970
|
+
const feeAmountA = parseFloat(positionInfo.tokenA.uiFeeAmount || "0");
|
|
86971
|
+
const feeAmountB = parseFloat(positionInfo.tokenB.uiFeeAmount || "0");
|
|
86972
|
+
const feeAUsd = feeAmountA * (pool.token_a.price_usd ?? 0);
|
|
86973
|
+
const feeBUsd = feeAmountB * (pool.token_b.price_usd ?? 0);
|
|
86974
|
+
return {
|
|
86975
|
+
tokenA: {
|
|
86976
|
+
symbol: symbolA,
|
|
86977
|
+
amount: positionInfo.tokenA.uiFeeAmount,
|
|
86978
|
+
amountUsd: formatUsd(feeAUsd)
|
|
86979
|
+
},
|
|
86980
|
+
tokenB: {
|
|
86981
|
+
symbol: symbolB,
|
|
86982
|
+
amount: positionInfo.tokenB.uiFeeAmount,
|
|
86983
|
+
amountUsd: formatUsd(feeBUsd)
|
|
86984
|
+
},
|
|
86985
|
+
totalUsd: formatUsd(feeAUsd + feeBUsd)
|
|
86986
|
+
};
|
|
86987
|
+
})()
|
|
86844
86988
|
};
|
|
86845
86989
|
if (format === "json") {
|
|
86846
86990
|
outputJson(analysisData, startTime);
|