@byreal-io/byreal-cli-realclaw 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,7 +24,7 @@ npm install -g @byreal-io/byreal-cli-realclaw
24
24
 
25
25
  ## Features
26
26
 
27
- - **Pools** — List, search, and inspect CLMM pools. View K-line charts, APR, TVL, volume, and run comprehensive pool analysis (risk, volatility, range recommendations).
27
+ - **Pools** — List, search, and inspect CLMM pools. View K-line charts, Est. APR (fee + reward incentive breakdown), TVL, volume, and run comprehensive pool analysis (risk, volatility, range recommendations).
28
28
  - **Tokens** — List tokens, search by symbol/name, get real-time prices.
29
29
  - **Swap** — Preview and execute token swaps with slippage control and price impact estimation.
30
30
  - **Positions** — Open, close, and manage CLMM positions. Claim fees and rewards. Analyze position performance. Copy top farmers' positions with one command.
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.3" : void 0;
3036
+ INJECTED_VERSION = true ? "0.3.4" : 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";
@@ -82380,12 +82380,48 @@ var apiClient = {
82380
82380
  // src/api/endpoints.ts
82381
82381
  init_constants();
82382
82382
  init_errors();
82383
+ function transformReward(r) {
82384
+ const isNewFormat = r.token !== void 0;
82385
+ const mintInfo = isNewFormat ? r.token?.mintInfo : r.mint;
82386
+ const mint = mintInfo?.address || "";
82387
+ const symbol = mintInfo?.symbol || "";
82388
+ const priceUsd = isNewFormat ? parseFloat(r.token?.price || "0") : 0;
82389
+ const apr = parseFloat(r.apr || "0") * 100;
82390
+ const rawEndTime = isNewFormat ? r.endTimestamp || 0 : r.rewardEndTime || 0;
82391
+ const endTime = rawEndTime > 1e12 ? Math.floor(rawEndTime / 1e3) : rawEndTime;
82392
+ const rawOpenTime = r.rewardOpenTime || 0;
82393
+ const openTime = rawOpenTime > 1e12 ? Math.floor(rawOpenTime / 1e3) : rawOpenTime;
82394
+ let dailyAmount = r.dailyAmountDisplay || r.dailyMaxAmount || "";
82395
+ if (!dailyAmount && r.rewardPerSecond) {
82396
+ const rps = parseFloat(r.rewardPerSecond);
82397
+ if (rps > 0) {
82398
+ dailyAmount = (rps * 86400).toString();
82399
+ }
82400
+ }
82401
+ const dailyAmountNum = parseFloat(dailyAmount || "0");
82402
+ const dailyAmountUsd = dailyAmountNum * priceUsd;
82403
+ return {
82404
+ mint,
82405
+ symbol,
82406
+ rewardPerSecond: r.rewardPerSecond || "0",
82407
+ openTime,
82408
+ endTime,
82409
+ apr,
82410
+ daily_amount: dailyAmount,
82411
+ daily_amount_usd: dailyAmountUsd,
82412
+ price_usd: priceUsd
82413
+ };
82414
+ }
82383
82415
  function transformPool(apiPool) {
82384
82416
  const mintA = apiPool.mintA?.mintInfo || {};
82385
82417
  const mintB = apiPool.mintB?.mintInfo || {};
82386
82418
  const baseMintPrice = parseFloat(apiPool.baseMint?.price || apiPool.mintA?.price || "0");
82387
82419
  const quoteMintPrice = parseFloat(apiPool.quoteMint?.price || apiPool.mintB?.price || "0");
82388
82420
  const poolPrice = quoteMintPrice > 0 ? baseMintPrice / quoteMintPrice : 0;
82421
+ const now = Math.floor(Date.now() / 1e3);
82422
+ const activeRewards = (apiPool.rewards || []).map(transformReward).filter((r) => r.endTime > now || r.endTime === 0);
82423
+ const feeApr = parseFloat(apiPool.feeApr24h || "0") * 100;
82424
+ const rewardApr = activeRewards.reduce((sum3, r) => sum3 + r.apr, 0);
82389
82425
  return {
82390
82426
  id: apiPool.poolAddress,
82391
82427
  pair: `${mintA.symbol || "Unknown"}/${mintB.symbol || "Unknown"}`,
@@ -82411,13 +82447,15 @@ function transformPool(apiPool) {
82411
82447
  fee_rate_bps: parseInt(apiPool.feeRate?.fixFeeRate || "0", 10) / 100,
82412
82448
  // fixFeeRate is in 1/100 bps
82413
82449
  fee_24h_usd: parseFloat(apiPool.feeUsd1d || apiPool.feeUsd24h || "0"),
82414
- apr: parseFloat(apiPool.feeApr24h || "0") * 100,
82415
- // 转换为百分比
82450
+ apr: feeApr,
82451
+ reward_apr: rewardApr,
82452
+ total_apr: feeApr + rewardApr,
82416
82453
  current_price: poolPrice,
82417
82454
  created_at: apiPool.openTime ? new Date(apiPool.openTime).toISOString() : "",
82418
82455
  price_change_1h: apiPool.priceChange1h ? parseFloat(apiPool.priceChange1h) * 100 : void 0,
82419
82456
  price_change_24h: apiPool.priceChange1d ? parseFloat(apiPool.priceChange1d) * 100 : void 0,
82420
- price_change_7d: apiPool.priceChange7d ? parseFloat(apiPool.priceChange7d) * 100 : void 0
82457
+ price_change_7d: apiPool.priceChange7d ? parseFloat(apiPool.priceChange7d) * 100 : void 0,
82458
+ rewards: activeRewards.length > 0 ? activeRewards : void 0
82421
82459
  };
82422
82460
  }
82423
82461
  function transformToken(apiToken) {
@@ -82505,13 +82543,6 @@ async function getPoolInfo(poolId) {
82505
82543
  };
82506
82544
  }
82507
82545
  const pool = transformPool(poolData);
82508
- const rewards = (poolData.rewards || []).map((r) => ({
82509
- mint: r.mint?.address || "",
82510
- symbol: r.mint?.symbol || "",
82511
- rewardPerSecond: r.rewardPerSecond || "0",
82512
- openTime: r.rewardOpenTime || 0,
82513
- endTime: r.rewardEndTime || 0
82514
- }));
82515
82546
  return {
82516
82547
  ok: true,
82517
82548
  value: {
@@ -82524,8 +82555,7 @@ async function getPoolInfo(poolId) {
82524
82555
  price_change_24h: parseFloat(poolData.priceChange1d || "0") * 100,
82525
82556
  price_change_7d: parseFloat(poolData.priceChange7d || "0") * 100,
82526
82557
  fee_7d_usd: parseFloat(poolData.feeUsd7d || "0"),
82527
- category: poolData.category,
82528
- rewards: rewards.length > 0 ? rewards : void 0
82558
+ category: poolData.category
82529
82559
  }
82530
82560
  };
82531
82561
  }
@@ -82968,20 +82998,26 @@ function formatApr(value) {
82968
82998
  return color(`${value.toFixed(2)}%`);
82969
82999
  }
82970
83000
  function outputPoolsTable(pools, total) {
82971
- const table = createTable(["Pair", "Pool ID", "TVL", "Volume 24h", "APR", "Fee Rate"]);
83001
+ const table = createTable(["Pair", "Pool ID", "TVL", "Volume 24h", "Est. APR", "Fee Rate"]);
82972
83002
  for (const pool of pools) {
83003
+ const hasRewards = pool.reward_apr > 0;
83004
+ const aprDisplay = formatApr(pool.total_apr) + (hasRewards ? source_default.magenta(" (+R)") : "");
82973
83005
  table.push([
82974
83006
  source_default.white.bold(pool.pair),
82975
83007
  source_default.gray(pool.id),
82976
83008
  formatUsd(pool.tvl_usd),
82977
83009
  formatUsd(pool.volume_24h_usd),
82978
- formatApr(pool.apr),
83010
+ aprDisplay,
82979
83011
  `${(pool.fee_rate_bps / 100).toFixed(2)}%`
82980
83012
  ]);
82981
83013
  }
82982
83014
  console.log(table.toString());
82983
83015
  console.log(source_default.gray(`
82984
83016
  Showing ${pools.length} of ${total} pools`));
83017
+ const hasAnyRewards = pools.some((p) => p.reward_apr > 0);
83018
+ if (hasAnyRewards) {
83019
+ console.log(source_default.magenta("(+R)") + source_default.gray(" = includes reward incentives"));
83020
+ }
82985
83021
  }
82986
83022
  function outputPoolDetail(pool) {
82987
83023
  console.log(source_default.cyan.bold(`
@@ -82995,9 +83031,26 @@ ${pool.pair}`));
82995
83031
  ["Volume (7d)", formatUsd(pool.volume_7d_usd)],
82996
83032
  ["Fees (24h)", formatUsd(pool.fee_24h_usd)],
82997
83033
  ["Fee Rate", `${(pool.fee_rate_bps / 100).toFixed(2)}%`],
82998
- ["APR", formatApr(pool.apr)]
83034
+ ["Fee APR", formatApr(pool.apr)],
83035
+ ["Reward APR", pool.reward_apr > 0 ? formatApr(pool.reward_apr) : source_default.gray("None")],
83036
+ ["Total APR", source_default.bold(formatApr(pool.total_apr))]
82999
83037
  );
83000
83038
  console.log(table.toString());
83039
+ if (pool.rewards && pool.rewards.length > 0) {
83040
+ console.log(source_default.cyan("\nActive Rewards:"));
83041
+ const rewardsTable = createTable(["Token", "APR", "Daily Amount", "Daily USD", "Ends"]);
83042
+ for (const r of pool.rewards) {
83043
+ const endDate = r.endTime > 0 ? new Date(r.endTime * 1e3).toISOString().slice(0, 10) : "Ongoing";
83044
+ rewardsTable.push([
83045
+ source_default.white.bold(r.symbol || r.mint),
83046
+ formatApr(r.apr),
83047
+ r.daily_amount ? parseFloat(r.daily_amount).toLocaleString() : "-",
83048
+ r.daily_amount_usd > 0 ? formatUsd(r.daily_amount_usd) : "-",
83049
+ source_default.gray(endDate)
83050
+ ]);
83051
+ }
83052
+ console.log(rewardsTable.toString());
83053
+ }
83001
83054
  console.log(source_default.cyan("\nPrices:"));
83002
83055
  const priceTable = createTable(["Token", "Price (USD)", "Mint"]);
83003
83056
  priceTable.push(
@@ -83427,6 +83480,8 @@ Pool Analysis: ${data.pool.pair}`));
83427
83480
  ["Fees (24h)", `$${data.metrics.fee24h}`],
83428
83481
  ["Fees (7d)", `$${data.metrics.fee7d}`],
83429
83482
  ["Fee APR (24h)", data.metrics.feeApr24h],
83483
+ ["Reward APR", data.metrics.rewardApr || source_default.gray("None")],
83484
+ ["Total APR", source_default.bold(data.metrics.totalApr)],
83430
83485
  ["Volume/TVL", data.metrics.volumeToTvl]
83431
83486
  );
83432
83487
  console.log(metricsTable.toString());
@@ -83439,9 +83494,15 @@ Pool Analysis: ${data.pool.pair}`));
83439
83494
  console.log(volTable.toString());
83440
83495
  if (data.rewards && data.rewards.length > 0) {
83441
83496
  console.log(source_default.cyan.bold("\nRewards"));
83442
- const rewardsTable = createTable(["Token", "End Date"]);
83497
+ const rewardsTable = createTable(["Token", "APR", "Daily Amount", "Daily USD", "End Date"]);
83443
83498
  for (const r of data.rewards) {
83444
- rewardsTable.push([r.token, r.endTime]);
83499
+ rewardsTable.push([
83500
+ r.token,
83501
+ r.apr || "-",
83502
+ r.dailyAmount || "-",
83503
+ r.dailyAmountUsd || "-",
83504
+ r.endTime
83505
+ ]);
83445
83506
  }
83446
83507
  console.log(rewardsTable.toString());
83447
83508
  }
@@ -83793,14 +83854,15 @@ function createPoolsAnalyzeCommand() {
83793
83854
  const dayPriceLow = pool.price_range_24h.low;
83794
83855
  const dayPriceHigh = pool.price_range_24h.high;
83795
83856
  const dayPriceRangePercent = currentPrice > 0 ? (dayPriceHigh - dayPriceLow) / currentPrice * 100 : 0;
83796
- const now = Math.floor(Date.now() / 1e3);
83797
- const rewardsOutput = (pool.rewards || []).filter((r) => r.endTime > now).map((r) => {
83798
- return {
83799
- token: r.symbol || r.mint,
83800
- rewardPerSecond: r.rewardPerSecond,
83801
- endTime: new Date(r.endTime * 1e3).toISOString().slice(0, 10)
83802
- };
83803
- });
83857
+ const activeRewards = pool.rewards || [];
83858
+ const totalRewardApr = pool.reward_apr;
83859
+ const rewardsOutput = activeRewards.map((r) => ({
83860
+ token: r.symbol || r.mint,
83861
+ apr: `${r.apr.toFixed(2)}%`,
83862
+ dailyAmount: r.daily_amount ? parseFloat(r.daily_amount).toLocaleString() : "-",
83863
+ dailyAmountUsd: r.daily_amount_usd > 0 ? `$${r.daily_amount_usd.toFixed(2)}` : "-",
83864
+ endTime: r.endTime > 0 ? new Date(r.endTime * 1e3).toISOString().slice(0, 10) : "Ongoing"
83865
+ }));
83804
83866
  const rangeAprs = calculateRangeAprs2({
83805
83867
  percentRanges: rangePercents,
83806
83868
  volume24h: pool.volume_24h_usd,
@@ -83850,8 +83912,7 @@ function createPoolsAnalyzeCommand() {
83850
83912
  priceLower: alignedPriceLower.toFixed(8).replace(/0+$/, "").replace(/\.$/, ""),
83851
83913
  priceUpper: alignedPriceUpper.toFixed(8).replace(/0+$/, "").replace(/\.$/, ""),
83852
83914
  estimatedFeeApr: `${feeApr.toFixed(1)}%`,
83853
- estimatedTotalApr: `${feeApr.toFixed(1)}%`,
83854
- // same as feeApr if no rewards calculated
83915
+ estimatedTotalApr: `${(feeApr + totalRewardApr).toFixed(1)}%`,
83855
83916
  inRangeLikelihood,
83856
83917
  rebalanceFrequency
83857
83918
  };
@@ -83860,7 +83921,7 @@ function createPoolsAnalyzeCommand() {
83860
83921
  const volatilityRisk = assessVolatilityRisk(dayPriceRangePercent);
83861
83922
  const riskSummary = buildRiskSummary(pool, dayPriceRangePercent);
83862
83923
  const projectionRange = rangePercents.includes(10) ? 10 : rangePercents[Math.floor(rangePercents.length / 2)];
83863
- const projectionApr = rangeAprs[projectionRange] || 0;
83924
+ const projectionApr = (rangeAprs[projectionRange] || 0) + totalRewardApr;
83864
83925
  const dailyFee = projectionApr / 100 / 365 * investAmount;
83865
83926
  const weeklyFee = dailyFee * 7;
83866
83927
  const monthlyFee = dailyFee * 30;
@@ -83881,6 +83942,8 @@ function createPoolsAnalyzeCommand() {
83881
83942
  fee24h: fee24h.toFixed(2),
83882
83943
  fee7d: fee7d.toFixed(2),
83883
83944
  feeApr24h: `${feeApr24h.toFixed(2)}%`,
83945
+ rewardApr: totalRewardApr > 0 ? `${totalRewardApr.toFixed(2)}%` : void 0,
83946
+ totalApr: `${(feeApr24h + totalRewardApr).toFixed(2)}%`,
83884
83947
  volumeToTvl: volumeToTvl.toFixed(2)
83885
83948
  },
83886
83949
  volatility: {
@@ -84221,7 +84284,7 @@ Byreal CLI provides on-chain data only. For complete analysis, **you (the AI age
84221
84284
  ## Commands
84222
84285
 
84223
84286
  ### pools list
84224
- Query available liquidity pools with sorting and filtering.
84287
+ Query available liquidity pools with Est. APR (fee + reward incentive breakdown), sorting and filtering.
84225
84288
 
84226
84289
  \`\`\`bash
84227
84290
  byreal-cli pools list [options]
@@ -84248,7 +84311,7 @@ byreal-cli pools list --category 1 -o json
84248
84311
  \`\`\`
84249
84312
 
84250
84313
  ### pools info
84251
- Get detailed information about a specific pool.
84314
+ Get detailed information about a specific pool, including Fee APR, Reward APR, Total APR breakdown and active reward incentives (token, APR, daily amount, daily USD, end date).
84252
84315
 
84253
84316
  \`\`\`bash
84254
84317
  byreal-cli pools info <pool-id> -o json
@@ -84629,7 +84692,7 @@ Response includes:
84629
84692
  - **pool**: Basic info (address, pair, category, currentPrice, feeRate, tickSpacing)
84630
84693
  - **metrics**: TVL, volume (24h/7d), fees (24h/7d), feeApr24h, volumeToTvl ratio
84631
84694
  - **volatility**: 24h price range (low/high) and dayPriceRangePercent
84632
- - **rewards**: Active reward programs (token, endTime)
84695
+ - **rewards**: Active reward programs (token, APR, daily amount, daily USD value, end date)
84633
84696
  - **rangeAnalysis**: For each range %, shows priceLower/Upper, estimated fee APR, in-range likelihood, rebalance frequency
84634
84697
  - **riskFactors**: TVL risk, volatility risk, and human-readable summary
84635
84698
  - **wallet**: Wallet address, balanceUsd, and optional low-balance warning (included when --wallet-address is provided)
@@ -84914,7 +84977,7 @@ var CAPABILITIES = [
84914
84977
  {
84915
84978
  id: "dex.pool.list",
84916
84979
  name: "List Pools",
84917
- description: "Query available liquidity pools with sorting and filtering",
84980
+ description: "Query available liquidity pools with Est. APR (fee + reward incentive), sorting and filtering",
84918
84981
  category: "query",
84919
84982
  auth_required: false,
84920
84983
  command: "byreal-cli pools list",
@@ -84955,7 +85018,7 @@ var CAPABILITIES = [
84955
85018
  {
84956
85019
  id: "dex.pool.analyze",
84957
85020
  name: "Pool Analysis",
84958
- description: "Comprehensive pool analysis: metrics, volatility, multi-range APR comparison, risk assessment, and investment projection",
85021
+ description: "Comprehensive pool analysis: metrics (fee APR, reward APR, total APR), volatility, multi-range APR comparison, risk assessment, and investment projection",
84959
85022
  category: "analyze",
84960
85023
  auth_required: false,
84961
85024
  command: "byreal-cli pools analyze <pool-id>",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byreal-io/byreal-cli-realclaw",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "AI-native CLI for Byreal CLMM DEX on Solana",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",