aether-hub 1.1.5 → 1.1.6
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/commands/rewards.js +83 -0
- package/index.js +1 -1
- package/package.json +1 -1
package/commands/rewards.js
CHANGED
|
@@ -397,6 +397,85 @@ async function rewardsSummary(args) {
|
|
|
397
397
|
// Rewards claim command
|
|
398
398
|
// ---------------------------------------------------------------------------
|
|
399
399
|
|
|
400
|
+
async function rewardsPending(args) {
|
|
401
|
+
const rpc = args.rpc || getDefaultRpc();
|
|
402
|
+
const isJson = args.json || false;
|
|
403
|
+
let address = args.address || null;
|
|
404
|
+
|
|
405
|
+
const config = loadConfig();
|
|
406
|
+
const rl = createRl();
|
|
407
|
+
|
|
408
|
+
if (!address) {
|
|
409
|
+
const ans = await question(rl, `\n${C.cyan}Enter wallet address: ${C.reset}`);
|
|
410
|
+
address = ans.trim();
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (!address) {
|
|
414
|
+
console.log(`\n${C.red}✗ No address provided.${C.reset}\n`);
|
|
415
|
+
rl.close();
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
rl.close();
|
|
420
|
+
|
|
421
|
+
const stakeAccounts = await fetchWalletStakeAccounts(address);
|
|
422
|
+
if (stakeAccounts.length === 0) {
|
|
423
|
+
if (isJson) {
|
|
424
|
+
console.log(JSON.stringify({ address, pending: [], total_pending: '0' }, null, 2));
|
|
425
|
+
} else {
|
|
426
|
+
console.log(`\n${C.red}✗ No stake accounts found for ${address}${C.reset}\n`);
|
|
427
|
+
}
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const results = [];
|
|
432
|
+
let totalPending = BigInt(0);
|
|
433
|
+
|
|
434
|
+
for (const sa of stakeAccounts) {
|
|
435
|
+
const rd = await fetchStakeRewards(rpc, sa);
|
|
436
|
+
if (!rd.error) {
|
|
437
|
+
const pending = BigInt(rd.estimatedRewards || 0);
|
|
438
|
+
totalPending += pending;
|
|
439
|
+
results.push({
|
|
440
|
+
stake_account: sa,
|
|
441
|
+
validator: rd.validator || 'unknown',
|
|
442
|
+
delegated_stake: rd.delegatedStakeFormatted || '0',
|
|
443
|
+
pending_rewards: rd.estimatedRewardsFormatted || '0',
|
|
444
|
+
pending_lamports: pending.toString(),
|
|
445
|
+
apy_bps: rd.apyBps || 0,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
if (isJson) {
|
|
451
|
+
console.log(JSON.stringify({
|
|
452
|
+
address,
|
|
453
|
+
total_pending: totalPending.toString(),
|
|
454
|
+
total_pending_formatted: formatAether(totalPending.toString()),
|
|
455
|
+
accounts: results,
|
|
456
|
+
}, null, 2));
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
console.log(`\n${C.bright}${C.cyan}╔══════════════════════════════════════════════════════════════╗${C.reset}`);
|
|
461
|
+
console.log(`${C.bright}${C.cyan}║ Pending Staking Rewards ║${C.reset}`);
|
|
462
|
+
console.log(`${C.bright}${C.cyan}╚══════════════════════════════════════════════════════════════╝${C.reset}\n`);
|
|
463
|
+
console.log(` ${C.dim}Wallet:${C.reset} ${C.bright}${address}${C.reset}`);
|
|
464
|
+
console.log();
|
|
465
|
+
console.log(` ${C.yellow}Stake Account${C.reset.padEnd(48)} ${C.yellow}Pending${C.reset} ${C.yellow}APY${C.reset}`);
|
|
466
|
+
console.log(` ${C.dim}${'─'.repeat(72)}${C.reset}`);
|
|
467
|
+
|
|
468
|
+
for (const r of results) {
|
|
469
|
+
const shortSa = r.stake_account.substring(0, 12) + '...' + r.stake_account.slice(-6);
|
|
470
|
+
console.log(` ${C.cyan}${shortSa}${C.reset.padEnd(52)} ${C.green}${r.pending_rewards.padStart(12)}${C.reset} ${(r.apy_bps / 100).toFixed(2)}%`);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
console.log(` ${C.dim}${'─'.repeat(72)}${C.reset}`);
|
|
474
|
+
console.log(` ${C.bright}TOTAL PENDING${C.reset.padEnd(52)} ${C.green}${formatAethFull(totalPending.toString()).padStart(12)}${C.reset}`);
|
|
475
|
+
console.log();
|
|
476
|
+
console.log(` ${C.dim}Run ${C.cyan}aether rewards claim${C.dim} to claim.${C.reset}\n`);
|
|
477
|
+
}
|
|
478
|
+
|
|
400
479
|
async function rewardsClaim(args) {
|
|
401
480
|
const rpc = args.rpc || getDefaultRpc();
|
|
402
481
|
const isJson = args.json || false;
|
|
@@ -579,6 +658,9 @@ async function main() {
|
|
|
579
658
|
case 'summary':
|
|
580
659
|
await rewardsSummary(parsed);
|
|
581
660
|
break;
|
|
661
|
+
case 'pending':
|
|
662
|
+
await rewardsPending(parsed);
|
|
663
|
+
break;
|
|
582
664
|
case 'claim':
|
|
583
665
|
await rewardsClaim(parsed);
|
|
584
666
|
break;
|
|
@@ -586,6 +668,7 @@ async function main() {
|
|
|
586
668
|
console.log(`\n${C.cyan}Usage:${C.reset}`);
|
|
587
669
|
console.log(` aether rewards list --address <addr> List all staking rewards`);
|
|
588
670
|
console.log(` aether rewards summary --address <addr> One-line rewards summary`);
|
|
671
|
+
console.log(` aether rewards pending --address <addr> Show pending (unclaimed) rewards`);
|
|
589
672
|
console.log(` aether rewards claim --address <addr> [--account <stakeAcct>] Claim rewards`);
|
|
590
673
|
console.log();
|
|
591
674
|
console.log(` ${C.dim}--json Output as JSON`);
|
package/index.js
CHANGED
|
@@ -292,7 +292,7 @@ const COMMANDS = {
|
|
|
292
292
|
},
|
|
293
293
|
},
|
|
294
294
|
rewards: {
|
|
295
|
-
description: 'View staking rewards — aether rewards list
|
|
295
|
+
description: 'View staking rewards — aether rewards list | rewards summary | rewards pending | rewards claim',
|
|
296
296
|
handler: () => {
|
|
297
297
|
rewardsCommand();
|
|
298
298
|
},
|