lido-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/api/client.d.ts +63 -0
  2. package/dist/api/client.d.ts.map +1 -0
  3. package/dist/api/client.js +146 -0
  4. package/dist/api/client.js.map +1 -0
  5. package/dist/commands/balance.d.ts +3 -0
  6. package/dist/commands/balance.d.ts.map +1 -0
  7. package/dist/commands/balance.js +62 -0
  8. package/dist/commands/balance.js.map +1 -0
  9. package/dist/commands/rewards.d.ts +3 -0
  10. package/dist/commands/rewards.d.ts.map +1 -0
  11. package/dist/commands/rewards.js +72 -0
  12. package/dist/commands/rewards.js.map +1 -0
  13. package/dist/commands/stake.d.ts +3 -0
  14. package/dist/commands/stake.d.ts.map +1 -0
  15. package/dist/commands/stake.js +45 -0
  16. package/dist/commands/stake.js.map +1 -0
  17. package/dist/commands/stats.d.ts +3 -0
  18. package/dist/commands/stats.d.ts.map +1 -0
  19. package/dist/commands/stats.js +59 -0
  20. package/dist/commands/stats.js.map +1 -0
  21. package/dist/commands/withdraw.d.ts +3 -0
  22. package/dist/commands/withdraw.d.ts.map +1 -0
  23. package/dist/commands/withdraw.js +109 -0
  24. package/dist/commands/withdraw.js.map +1 -0
  25. package/dist/commands/wrap.d.ts +4 -0
  26. package/dist/commands/wrap.d.ts.map +1 -0
  27. package/dist/commands/wrap.js +89 -0
  28. package/dist/commands/wrap.js.map +1 -0
  29. package/dist/config/abis.d.ts +212 -0
  30. package/dist/config/abis.d.ts.map +1 -0
  31. package/dist/config/abis.js +146 -0
  32. package/dist/config/abis.js.map +1 -0
  33. package/dist/config/contracts.d.ts +9 -0
  34. package/dist/config/contracts.d.ts.map +1 -0
  35. package/dist/config/contracts.js +19 -0
  36. package/dist/config/contracts.js.map +1 -0
  37. package/dist/config/store.d.ts +11 -0
  38. package/dist/config/store.d.ts.map +1 -0
  39. package/dist/config/store.js +93 -0
  40. package/dist/config/store.js.map +1 -0
  41. package/dist/index.d.ts +3 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +66 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/mcp.d.ts +2 -0
  46. package/dist/mcp.d.ts.map +1 -0
  47. package/dist/mcp.js +226 -0
  48. package/dist/mcp.js.map +1 -0
  49. package/dist/utils/format.d.ts +15 -0
  50. package/dist/utils/format.d.ts.map +1 -0
  51. package/dist/utils/format.js +43 -0
  52. package/dist/utils/format.js.map +1 -0
  53. package/package.json +48 -0
@@ -0,0 +1,63 @@
1
+ import { type Address } from 'viem';
2
+ export declare class LidoClient {
3
+ private client;
4
+ constructor(rpcUrl: string);
5
+ getStETHBalance(address: Address): Promise<{
6
+ balance: bigint;
7
+ formatted: string;
8
+ }>;
9
+ getWstETHBalance(address: Address): Promise<{
10
+ balance: bigint;
11
+ formatted: string;
12
+ }>;
13
+ getETHBalance(address: Address): Promise<{
14
+ balance: bigint;
15
+ formatted: string;
16
+ }>;
17
+ getExchangeRate(): Promise<{
18
+ stEthPerWstEth: string;
19
+ wstEthPerStEth: string;
20
+ }>;
21
+ getProtocolStats(): Promise<{
22
+ totalPooledEther: string;
23
+ totalShares: string;
24
+ totalSupply: string;
25
+ }>;
26
+ getWithdrawalRequests(address: Address): Promise<bigint[]>;
27
+ getWithdrawalStatus(requestIds: bigint[]): Promise<Array<{
28
+ amountOfStETH: bigint;
29
+ amountOfShares: bigint;
30
+ owner: Address;
31
+ timestamp: bigint;
32
+ isFinalized: boolean;
33
+ isClaimed: boolean;
34
+ }>>;
35
+ getWithdrawalQueueStats(): Promise<{
36
+ lastFinalizedRequestId: string;
37
+ unfinalizedStETH: string;
38
+ }>;
39
+ buildStakeTransaction(amount: string, referral?: Address): {
40
+ to: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84";
41
+ value: string;
42
+ data: string;
43
+ description: string;
44
+ };
45
+ buildWrapTransaction(stETHAmount: string): {
46
+ to: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0";
47
+ data: string;
48
+ description: string;
49
+ note: string;
50
+ };
51
+ buildUnwrapTransaction(wstETHAmount: string): {
52
+ to: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0";
53
+ data: string;
54
+ description: string;
55
+ };
56
+ buildWithdrawTransaction(stETHAmount: string, owner: Address): {
57
+ to: "0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1";
58
+ data: string;
59
+ description: string;
60
+ note: string;
61
+ };
62
+ }
63
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAK1G,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,MAAM;IAOpB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAUlF,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAUnF,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAKhF,eAAe,IAAI,OAAO,CAAC;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC;IAc9E,gBAAgB,IAAI,OAAO,CAAC;QAChC,gBAAgB,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IAyBI,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAS1D,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CACtD,KAAK,CAAC;QACJ,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,KAAK,EAAE,OAAO,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC,CACH;IAWK,uBAAuB,IAAI,OAAO,CAAC;QACvC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IAoBF,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,OAAsD;;;;;;IAStG,oBAAoB,CAAC,WAAW,EAAE,MAAM;;;;;;IASxC,sBAAsB,CAAC,YAAY,EAAE,MAAM;;;;;IAQ3C,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;;;;;;CAQ7D"}
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LidoClient = void 0;
4
+ const viem_1 = require("viem");
5
+ const chains_1 = require("viem/chains");
6
+ const contracts_1 = require("../config/contracts");
7
+ const abis_1 = require("../config/abis");
8
+ class LidoClient {
9
+ client;
10
+ constructor(rpcUrl) {
11
+ this.client = (0, viem_1.createPublicClient)({
12
+ chain: chains_1.mainnet,
13
+ transport: (0, viem_1.http)(rpcUrl),
14
+ });
15
+ }
16
+ async getStETHBalance(address) {
17
+ const balance = await this.client.readContract({
18
+ address: contracts_1.CONTRACTS.stETH,
19
+ abi: abis_1.stETHAbi,
20
+ functionName: 'balanceOf',
21
+ args: [address],
22
+ });
23
+ return { balance, formatted: (0, viem_1.formatEther)(balance) };
24
+ }
25
+ async getWstETHBalance(address) {
26
+ const balance = await this.client.readContract({
27
+ address: contracts_1.CONTRACTS.wstETH,
28
+ abi: abis_1.wstETHAbi,
29
+ functionName: 'balanceOf',
30
+ args: [address],
31
+ });
32
+ return { balance, formatted: (0, viem_1.formatEther)(balance) };
33
+ }
34
+ async getETHBalance(address) {
35
+ const balance = await this.client.getBalance({ address });
36
+ return { balance, formatted: (0, viem_1.formatEther)(balance) };
37
+ }
38
+ async getExchangeRate() {
39
+ const stEthPerToken = await this.client.readContract({
40
+ address: contracts_1.CONTRACTS.wstETH,
41
+ abi: abis_1.wstETHAbi,
42
+ functionName: 'stEthPerToken',
43
+ });
44
+ // Compute inverse: wstETH per stETH = 1e18 * 1e18 / stEthPerToken
45
+ const wstEthPerStEth = (BigInt(10 ** 18) * BigInt(10 ** 18)) / stEthPerToken;
46
+ return {
47
+ stEthPerWstEth: (0, viem_1.formatEther)(stEthPerToken),
48
+ wstEthPerStEth: (0, viem_1.formatEther)(wstEthPerStEth),
49
+ };
50
+ }
51
+ async getProtocolStats() {
52
+ const [totalPooledEther, totalShares, totalSupply] = await Promise.all([
53
+ this.client.readContract({
54
+ address: contracts_1.CONTRACTS.stETH,
55
+ abi: abis_1.stETHAbi,
56
+ functionName: 'getTotalPooledEther',
57
+ }),
58
+ this.client.readContract({
59
+ address: contracts_1.CONTRACTS.stETH,
60
+ abi: abis_1.stETHAbi,
61
+ functionName: 'getTotalShares',
62
+ }),
63
+ this.client.readContract({
64
+ address: contracts_1.CONTRACTS.stETH,
65
+ abi: abis_1.stETHAbi,
66
+ functionName: 'totalSupply',
67
+ }),
68
+ ]);
69
+ return {
70
+ totalPooledEther: (0, viem_1.formatEther)(totalPooledEther),
71
+ totalShares: (0, viem_1.formatEther)(totalShares),
72
+ totalSupply: (0, viem_1.formatEther)(totalSupply),
73
+ };
74
+ }
75
+ async getWithdrawalRequests(address) {
76
+ return [...await this.client.readContract({
77
+ address: contracts_1.CONTRACTS.withdrawalQueue,
78
+ abi: abis_1.withdrawalQueueAbi,
79
+ functionName: 'getWithdrawalRequests',
80
+ args: [address],
81
+ })];
82
+ }
83
+ async getWithdrawalStatus(requestIds) {
84
+ if (requestIds.length === 0)
85
+ return [];
86
+ const result = await this.client.readContract({
87
+ address: contracts_1.CONTRACTS.withdrawalQueue,
88
+ abi: abis_1.withdrawalQueueAbi,
89
+ functionName: 'getWithdrawalStatus',
90
+ args: [requestIds],
91
+ });
92
+ return result;
93
+ }
94
+ async getWithdrawalQueueStats() {
95
+ const [lastFinalized, unfinalized] = await Promise.all([
96
+ this.client.readContract({
97
+ address: contracts_1.CONTRACTS.withdrawalQueue,
98
+ abi: abis_1.withdrawalQueueAbi,
99
+ functionName: 'getLastFinalizedRequestId',
100
+ }),
101
+ this.client.readContract({
102
+ address: contracts_1.CONTRACTS.withdrawalQueue,
103
+ abi: abis_1.withdrawalQueueAbi,
104
+ functionName: 'unfinalizedStETH',
105
+ }),
106
+ ]);
107
+ return {
108
+ lastFinalizedRequestId: lastFinalized.toString(),
109
+ unfinalizedStETH: (0, viem_1.formatEther)(unfinalized),
110
+ };
111
+ }
112
+ // Build transaction calldata (does not execute)
113
+ buildStakeTransaction(amount, referral = '0x0000000000000000000000000000000000000000') {
114
+ return {
115
+ to: contracts_1.CONTRACTS.stETH,
116
+ value: (0, viem_1.parseEther)(amount).toString(),
117
+ data: `submit(${referral})`,
118
+ description: `Stake ${amount} ETH via Lido to receive stETH`,
119
+ };
120
+ }
121
+ buildWrapTransaction(stETHAmount) {
122
+ return {
123
+ to: contracts_1.CONTRACTS.wstETH,
124
+ data: `wrap(${(0, viem_1.parseEther)(stETHAmount).toString()})`,
125
+ description: `Wrap ${stETHAmount} stETH into wstETH`,
126
+ note: 'Requires stETH approval for wstETH contract first',
127
+ };
128
+ }
129
+ buildUnwrapTransaction(wstETHAmount) {
130
+ return {
131
+ to: contracts_1.CONTRACTS.wstETH,
132
+ data: `unwrap(${(0, viem_1.parseEther)(wstETHAmount).toString()})`,
133
+ description: `Unwrap ${wstETHAmount} wstETH back to stETH`,
134
+ };
135
+ }
136
+ buildWithdrawTransaction(stETHAmount, owner) {
137
+ return {
138
+ to: contracts_1.CONTRACTS.withdrawalQueue,
139
+ data: `requestWithdrawals([${(0, viem_1.parseEther)(stETHAmount).toString()}], ${owner})`,
140
+ description: `Request withdrawal of ${stETHAmount} stETH to ETH`,
141
+ note: 'Requires stETH approval for withdrawal queue contract first',
142
+ };
143
+ }
144
+ }
145
+ exports.LidoClient = LidoClient;
146
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":";;;AAAA,+BAA0G;AAC1G,wCAAsC;AACtC,mDAAgD;AAChD,yCAAyE;AAEzE,MAAa,UAAU;IACb,MAAM,CAAe;IAE7B,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,IAAA,yBAAkB,EAAC;YAC/B,KAAK,EAAE,gBAAO;YACd,SAAS,EAAE,IAAA,WAAI,EAAC,MAAM,CAAC;SACxB,CAAiB,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAgB;QACpC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YAC7C,OAAO,EAAE,qBAAS,CAAC,KAAK;YACxB,GAAG,EAAE,eAAQ;YACb,YAAY,EAAE,WAAW;YACzB,IAAI,EAAE,CAAC,OAAO,CAAC;SAChB,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAA,kBAAW,EAAC,OAAO,CAAC,EAAE,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAAgB;QACrC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YAC7C,OAAO,EAAE,qBAAS,CAAC,MAAM;YACzB,GAAG,EAAE,gBAAS;YACd,YAAY,EAAE,WAAW;YACzB,IAAI,EAAE,CAAC,OAAO,CAAC;SAChB,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,I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,CAAC;IACJ,CAAC;CACF;AApKD,gCAoKC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function makeBalanceCommand(): Command;
3
+ //# sourceMappingURL=balance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../src/commands/balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,wBAAgB,kBAAkB,IAAI,OAAO,CAqD5C"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.makeBalanceCommand = makeBalanceCommand;
7
+ const commander_1 = require("commander");
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const client_1 = require("../api/client");
10
+ const store_1 = require("../config/store");
11
+ const format_1 = require("../utils/format");
12
+ function makeBalanceCommand() {
13
+ const cmd = new commander_1.Command('balance')
14
+ .description('Get stETH, wstETH, and ETH balances for a wallet')
15
+ .requiredOption('--wallet <address>', 'Ethereum wallet address')
16
+ .option('--pretty', 'Human-readable colored output')
17
+ .action(async (opts) => {
18
+ try {
19
+ const address = opts.wallet;
20
+ const client = new client_1.LidoClient((0, store_1.getRpcUrl)());
21
+ const [eth, stETH, wstETH, rate] = await Promise.all([
22
+ client.getETHBalance(address),
23
+ client.getStETHBalance(address),
24
+ client.getWstETHBalance(address),
25
+ client.getExchangeRate(),
26
+ ]);
27
+ const wstETHInStETH = parseFloat(wstETH.formatted) * parseFloat(rate.stEthPerWstEth);
28
+ const totalStETH = parseFloat(stETH.formatted) + wstETHInStETH;
29
+ const data = {
30
+ wallet: address,
31
+ eth: eth.formatted,
32
+ stETH: stETH.formatted,
33
+ wstETH: wstETH.formatted,
34
+ wstETHValueInStETH: wstETHInStETH.toString(),
35
+ totalStETHEquivalent: totalStETH.toString(),
36
+ exchangeRate: rate.stEthPerWstEth,
37
+ };
38
+ if (opts.pretty) {
39
+ (0, format_1.header)(`Balances for ${address.slice(0, 6)}...${address.slice(-4)}`);
40
+ (0, format_1.row)('ETH', `${(0, format_1.formatEth)(eth.formatted)} ETH`);
41
+ (0, format_1.row)('stETH', `${(0, format_1.formatEth)(stETH.formatted)} stETH`);
42
+ (0, format_1.row)('wstETH', `${(0, format_1.formatEth)(wstETH.formatted)} wstETH`);
43
+ (0, format_1.row)('wstETH (in stETH)', `${(0, format_1.formatEth)(wstETHInStETH.toString())} stETH`);
44
+ console.log(chalk_1.default.cyan(' ' + '-'.repeat(40)));
45
+ (0, format_1.row)('Total stETH equivalent', `${(0, format_1.formatEth)(totalStETH.toString())} stETH`);
46
+ (0, format_1.row)('Exchange rate', `1 wstETH = ${(0, format_1.formatEth)(rate.stEthPerWstEth)} stETH`);
47
+ return;
48
+ }
49
+ console.log(JSON.stringify(data));
50
+ }
51
+ catch (err) {
52
+ if (err instanceof Error) {
53
+ (0, format_1.jsonError)(err.message, 'RPC_ERROR', 1);
54
+ }
55
+ else {
56
+ (0, format_1.jsonError)('Unknown error', 'UNKNOWN', 1);
57
+ }
58
+ }
59
+ });
60
+ return cmd;
61
+ }
62
+ //# sourceMappingURL=balance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/commands/balance.ts"],"names":[],"mappings":";;;;;AAOA,gDAqDC;AA5DD,yCAAoC;AAEpC,kDAA0B;AAC1B,0CAA2C;AAC3C,2CAA4C;AAC5C,4CAAoE;AAEpE,SAAgB,kBAAkB;IAChC,MAAM,GAAG,GAAG,IAAI,mBAAO,CAAC,SAAS,CAAC;SAC/B,WAAW,CAAC,kDAAkD,CAAC;SAC/D,cAAc,CAAC,oBAAoB,EAAE,yBAAyB,CAAC;SAC/D,MAAM,CAAC,UAAU,EAAE,+BAA+B,CAAC;SACnD,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE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rewards.d.ts","sourceRoot":"","sources":["../../src/commands/rewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,kBAAkB,IAAI,OAAO,CAoE5C"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeRewardsCommand = makeRewardsCommand;
4
+ const commander_1 = require("commander");
5
+ const client_1 = require("../api/client");
6
+ const store_1 = require("../config/store");
7
+ const format_1 = require("../utils/format");
8
+ function makeRewardsCommand() {
9
+ const cmd = new commander_1.Command('rewards')
10
+ .description('Get staking rewards and protocol APR information')
11
+ .option('--wallet <address>', 'Wallet address (optional, shows personal position)')
12
+ .option('--pretty', 'Human-readable colored output')
13
+ .action(async (opts) => {
14
+ try {
15
+ const client = new client_1.LidoClient((0, store_1.getRpcUrl)());
16
+ const [protocol, rate, queue] = await Promise.all([
17
+ client.getProtocolStats(),
18
+ client.getExchangeRate(),
19
+ client.getWithdrawalQueueStats(),
20
+ ]);
21
+ const stEthPerWstEth = parseFloat(rate.stEthPerWstEth);
22
+ let walletData = null;
23
+ if (opts.wallet) {
24
+ const address = opts.wallet;
25
+ const [stETH, wstETH] = await Promise.all([
26
+ client.getStETHBalance(address),
27
+ client.getWstETHBalance(address),
28
+ ]);
29
+ const wstETHInStETH = parseFloat(wstETH.formatted) * stEthPerWstEth;
30
+ walletData = {
31
+ wallet: address,
32
+ stETH: stETH.formatted,
33
+ wstETH: wstETH.formatted,
34
+ totalStakedStETH: (parseFloat(stETH.formatted) + wstETHInStETH).toString(),
35
+ };
36
+ }
37
+ const data = {
38
+ protocol: {
39
+ totalPooledEther: protocol.totalPooledEther,
40
+ exchangeRate: rate.stEthPerWstEth,
41
+ unfinalizedWithdrawals: queue.unfinalizedStETH,
42
+ },
43
+ ...(walletData ? { wallet: walletData } : {}),
44
+ };
45
+ if (opts.pretty) {
46
+ (0, format_1.header)('Lido Staking Rewards');
47
+ (0, format_1.row)('Total Pooled ETH', `${(0, format_1.formatEth)(protocol.totalPooledEther)} ETH`);
48
+ (0, format_1.row)('Exchange Rate', `1 wstETH = ${(0, format_1.formatEth)(rate.stEthPerWstEth)} stETH`);
49
+ (0, format_1.row)('Pending Withdrawals', `${(0, format_1.formatEth)(queue.unfinalizedStETH)} stETH`);
50
+ if (walletData) {
51
+ console.log();
52
+ (0, format_1.header)(`Your Position (${walletData.wallet.slice(0, 6)}...${walletData.wallet.slice(-4)})`);
53
+ (0, format_1.row)('stETH Balance', `${(0, format_1.formatEth)(walletData.stETH)} stETH`);
54
+ (0, format_1.row)('wstETH Balance', `${(0, format_1.formatEth)(walletData.wstETH)} wstETH`);
55
+ (0, format_1.row)('Total Staked', `${(0, format_1.formatEth)(walletData.totalStakedStETH)} stETH`);
56
+ }
57
+ return;
58
+ }
59
+ console.log(JSON.stringify(data));
60
+ }
61
+ catch (err) {
62
+ if (err instanceof Error) {
63
+ (0, format_1.jsonError)(err.message, 'RPC_ERROR', 1);
64
+ }
65
+ else {
66
+ (0, format_1.jsonError)('Unknown error', 'UNKNOWN', 1);
67
+ }
68
+ }
69
+ });
70
+ return cmd;
71
+ }
72
+ //# sourceMappingURL=rewards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rewards.js","sourceRoot":"","sources":["../../src/commands/rewards.ts"],"names":[],"mappings":";;AAMA,gDAoEC;AA1ED,yCAAoC;AAEpC,0CAA2C;AAC3C,2CAA4C;AAC5C,4CAAoE;AAEpE,SAAgB,kBAAkB;IAChC,MAAM,GAAG,GAAG,IAAI,mBAAO,CAAC,SAAS,CAAC;SAC/B,WAAW,CAAC,kDAAkD,CAAC;SAC/D,MAAM,CAAC,oBAAoB,EAAE,oDAAoD,CAAC;SAClF,MAAM,CAAC,UAAU,EAAE,+BAA+B,CAAC;SACnD,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,mBAAU,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EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,IAAA,kBAAS,EAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function makeStakeCommand(): Command;
3
+ //# sourceMappingURL=stake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stake.d.ts","sourceRoot":"","sources":["../../src/commands/stake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,gBAAgB,IAAI,OAAO,CAsC1C"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeStakeCommand = makeStakeCommand;
4
+ const commander_1 = require("commander");
5
+ const client_1 = require("../api/client");
6
+ const store_1 = require("../config/store");
7
+ const format_1 = require("../utils/format");
8
+ function makeStakeCommand() {
9
+ const cmd = new commander_1.Command('stake')
10
+ .description('Build a transaction to stake ETH via Lido')
11
+ .requiredOption('--amount <eth>', 'Amount of ETH to stake')
12
+ .requiredOption('--wallet <address>', 'Wallet address')
13
+ .option('--pretty', 'Human-readable colored output')
14
+ .action(async (opts) => {
15
+ try {
16
+ const num = parseFloat(opts.amount);
17
+ if (isNaN(num) || num <= 0) {
18
+ (0, format_1.jsonError)('Invalid amount. Must be a positive number.', 'INVALID_INPUT', 1);
19
+ return;
20
+ }
21
+ const client = new client_1.LidoClient((0, store_1.getRpcUrl)());
22
+ const tx = client.buildStakeTransaction(opts.amount);
23
+ const data = { ...tx, from: opts.wallet };
24
+ if (opts.pretty) {
25
+ (0, format_1.header)(`Stake ${opts.amount} ETH via Lido`);
26
+ (0, format_1.row)('From', opts.wallet);
27
+ (0, format_1.row)('To (Lido)', tx.to);
28
+ (0, format_1.row)('Value', `${opts.amount} ETH`);
29
+ (0, format_1.row)('Action', tx.description);
30
+ return;
31
+ }
32
+ console.log(JSON.stringify(data));
33
+ }
34
+ catch (err) {
35
+ if (err instanceof Error) {
36
+ (0, format_1.jsonError)(err.message, 'RPC_ERROR', 1);
37
+ }
38
+ else {
39
+ (0, format_1.jsonError)('Unknown error', 'UNKNOWN', 1);
40
+ }
41
+ }
42
+ });
43
+ return cmd;
44
+ }
45
+ //# sourceMappingURL=stake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stake.js","sourceRoot":"","sources":["../../src/commands/stake.ts"],"names":[],"mappings":";;AAKA,4CAsCC;AA3CD,yCAAoC;AACpC,0CAA2C;AAC3C,2CAA4C;AAC5C,4CAAyD;AAEzD,SAAgB,gBAAgB;IAC9B,MAAM,GAAG,GAAG,IAAI,mBAAO,CAAC,OAAO,CAAC;SAC7B,WAAW,CAAC,2CAA2C,CAAC;SACxD,cAAc,CAAC,gBAAgB,EAAE,wBAAwB,CAAC;SAC1D,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAAC;SACtD,MAAM,CAAC,UAAU,EAAE,+BAA+B,CAAC;SACnD,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpC,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;gBAC3B,IAAA,kBAAS,EAAC,4CAA4C,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;gBAC5E,OAAO;YACT,CAAC;YAED,MAAM,MAAM,GAAG,IAAI,mBAAU,CAAC,IAAA,iBAAS,GAAE,CAAC,CAAC;YAC3C,MAAM,EAAE,GAAG,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrD,MAAM,IAAI,GAAG,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;YAE1C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,IAAA,eAAM,EAAC,SAAS,IAAI,CAAC,MAAM,eAAe,CAAC,CAAC;gBAC5C,IAAA,YAAG,EAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;gBACzB,IAAA,YAAG,EAAC,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;gBACxB,IAAA,YAAG,EAAC,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC;gBACnC,IAAA,YAAG,EAAC,QAAQ,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;gBAC9B,OAAO;YACT,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;gBACzB,IAAA,kBAAS,EAAC,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,IAAA,kBAAS,EAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function makeStatsCommand(): Command;
3
+ //# sourceMappingURL=stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/commands/stats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,gBAAgB,IAAI,OAAO,CAoD1C"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeStatsCommand = makeStatsCommand;
4
+ const commander_1 = require("commander");
5
+ const client_1 = require("../api/client");
6
+ const store_1 = require("../config/store");
7
+ const contracts_1 = require("../config/contracts");
8
+ const format_1 = require("../utils/format");
9
+ function makeStatsCommand() {
10
+ const cmd = new commander_1.Command('stats')
11
+ .description('Get Lido protocol statistics')
12
+ .option('--pretty', 'Human-readable colored output')
13
+ .action(async (opts) => {
14
+ try {
15
+ const client = new client_1.LidoClient((0, store_1.getRpcUrl)());
16
+ const [protocol, rate, queue] = await Promise.all([
17
+ client.getProtocolStats(),
18
+ client.getExchangeRate(),
19
+ client.getWithdrawalQueueStats(),
20
+ ]);
21
+ const data = {
22
+ totalPooledEther: protocol.totalPooledEther,
23
+ totalShares: protocol.totalShares,
24
+ totalSupply: protocol.totalSupply,
25
+ exchangeRate: rate,
26
+ withdrawalQueue: queue,
27
+ contracts: contracts_1.CONTRACTS,
28
+ };
29
+ if (opts.pretty) {
30
+ (0, format_1.header)('Lido Protocol Statistics');
31
+ (0, format_1.row)('Total Pooled ETH', `${(0, format_1.formatEth)(protocol.totalPooledEther)} ETH`);
32
+ (0, format_1.row)('Total stETH Supply', `${(0, format_1.formatEth)(protocol.totalSupply)} stETH`);
33
+ (0, format_1.row)('Total Shares', (0, format_1.formatEth)(protocol.totalShares));
34
+ console.log();
35
+ (0, format_1.row)('stETH per wstETH', (0, format_1.formatEth)(rate.stEthPerWstEth));
36
+ (0, format_1.row)('wstETH per stETH', (0, format_1.formatEth)(rate.wstEthPerStEth));
37
+ console.log();
38
+ (0, format_1.row)('Last Finalized ID', queue.lastFinalizedRequestId);
39
+ (0, format_1.row)('Unfinalized stETH', `${(0, format_1.formatEth)(queue.unfinalizedStETH)} stETH`);
40
+ console.log();
41
+ (0, format_1.row)('stETH Contract', contracts_1.CONTRACTS.stETH);
42
+ (0, format_1.row)('wstETH Contract', contracts_1.CONTRACTS.wstETH);
43
+ (0, format_1.row)('Withdrawal Queue', contracts_1.CONTRACTS.withdrawalQueue);
44
+ return;
45
+ }
46
+ console.log(JSON.stringify(data));
47
+ }
48
+ catch (err) {
49
+ if (err instanceof Error) {
50
+ (0, format_1.jsonError)(err.message, 'RPC_ERROR', 1);
51
+ }
52
+ else {
53
+ (0, format_1.jsonError)('Unknown error', 'UNKNOWN', 1);
54
+ }
55
+ }
56
+ });
57
+ return cmd;
58
+ }
59
+ //# sourceMappingURL=stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/commands/stats.ts"],"names":[],"mappings":";;AAMA,4CAoDC;AA1DD,yCAAoC;AACpC,0CAA2C;AAC3C,2CAA4C;AAC5C,mDAAgD;AAChD,4CAAoE;AAEpE,SAAgB,gBAAgB;IAC9B,MAAM,GAAG,GAAG,IAAI,mBAAO,CAAC,OAAO,CAAC;SAC7B,WAAW,CAAC,8BAA8B,CAAC;SAC3C,MAAM,CAAC,UAAU,EAAE,+BAA+B,CAAC;SACnD,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,mBAAU,CAAC,IAAA,iBAAS,GAAE,CAAC,CAAC;YAE3C,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBAChD,MAAM,CAAC,gBAAgB,EAAE;gBACzB,MAAM,CAAC,eAAe,EAAE;gBACxB,MAAM,CAAC,uBAAuB,EAAE;aACjC,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG;gBACX,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;gBAC3C,WAAW,EAAE,QAAQ,CAAC,WAAW;gBACjC,WAAW,EAAE,QAAQ,CAAC,WAAW;gBACjC,YAAY,EAAE,IAAI;gBAClB,eAAe,EAAE,KAAK;gBACtB,SAAS,EAAE,qBAAS;aACrB,CAAC;YAEF,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,IAAA,eAAM,EAAC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S,EAAC,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,IAAA,kBAAS,EAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function makeWithdrawCommand(): Command;
3
+ //# sourceMappingURL=withdraw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withdraw.d.ts","sourceRoot":"","sources":["../../src/commands/withdraw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,wBAAgB,mBAAmB,IAAI,OAAO,CAsG7C"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.makeWithdrawCommand = makeWithdrawCommand;
7
+ const commander_1 = require("commander");
8
+ const viem_1 = require("viem");
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const client_1 = require("../api/client");
11
+ const store_1 = require("../config/store");
12
+ const format_1 = require("../utils/format");
13
+ function makeWithdrawCommand() {
14
+ const cmd = new commander_1.Command('withdraw')
15
+ .description('Manage stETH -> ETH withdrawals');
16
+ cmd
17
+ .command('status')
18
+ .description('Check withdrawal request status')
19
+ .requiredOption('--wallet <address>', 'Wallet address')
20
+ .option('--pretty', 'Human-readable colored output')
21
+ .action(async (opts) => {
22
+ try {
23
+ const address = opts.wallet;
24
+ const client = new client_1.LidoClient((0, store_1.getRpcUrl)());
25
+ const requestIds = await client.getWithdrawalRequests(address);
26
+ if (requestIds.length === 0) {
27
+ if (opts.pretty) {
28
+ (0, format_1.header)('Withdrawal Requests');
29
+ console.log(' No pending withdrawal requests found.');
30
+ return;
31
+ }
32
+ console.log(JSON.stringify({ wallet: address, requests: [] }));
33
+ return;
34
+ }
35
+ const statuses = await client.getWithdrawalStatus(requestIds);
36
+ const requests = requestIds.map((id, i) => ({
37
+ requestId: id.toString(),
38
+ amountStETH: (0, viem_1.formatEther)(statuses[i].amountOfStETH),
39
+ timestamp: (0, format_1.formatTimestamp)(statuses[i].timestamp),
40
+ isFinalized: statuses[i].isFinalized,
41
+ isClaimed: statuses[i].isClaimed,
42
+ status: statuses[i].isClaimed ? 'claimed' : statuses[i].isFinalized ? 'ready_to_claim' : 'pending',
43
+ }));
44
+ if (opts.pretty) {
45
+ (0, format_1.header)(`Withdrawal Requests for ${address.slice(0, 6)}...${address.slice(-4)}`);
46
+ console.log();
47
+ for (const r of requests) {
48
+ const statusLabel = r.status === 'claimed'
49
+ ? chalk_1.default.gray('Claimed')
50
+ : r.status === 'ready_to_claim'
51
+ ? chalk_1.default.green('Ready to claim')
52
+ : chalk_1.default.yellow('Pending');
53
+ (0, format_1.row)(`Request #${r.requestId}`, '');
54
+ (0, format_1.row)(' Amount', `${(0, format_1.formatEth)(r.amountStETH)} stETH`);
55
+ (0, format_1.row)(' Requested', r.timestamp);
56
+ (0, format_1.row)(' Status', statusLabel);
57
+ console.log();
58
+ }
59
+ return;
60
+ }
61
+ console.log(JSON.stringify({ wallet: address, requests }));
62
+ }
63
+ catch (err) {
64
+ if (err instanceof Error) {
65
+ (0, format_1.jsonError)(err.message, 'RPC_ERROR', 1);
66
+ }
67
+ else {
68
+ (0, format_1.jsonError)('Unknown error', 'UNKNOWN', 1);
69
+ }
70
+ }
71
+ });
72
+ cmd
73
+ .command('request')
74
+ .description('Build a transaction to request a withdrawal')
75
+ .requiredOption('--amount <stETH>', 'Amount of stETH to withdraw')
76
+ .requiredOption('--wallet <address>', 'Wallet address (owner of withdrawal)')
77
+ .option('--pretty', 'Human-readable colored output')
78
+ .action(async (opts) => {
79
+ try {
80
+ const num = parseFloat(opts.amount);
81
+ if (isNaN(num) || num <= 0) {
82
+ (0, format_1.jsonError)('Invalid amount. Must be a positive number.', 'INVALID_INPUT', 1);
83
+ return;
84
+ }
85
+ const client = new client_1.LidoClient((0, store_1.getRpcUrl)());
86
+ const tx = client.buildWithdrawTransaction(opts.amount, opts.wallet);
87
+ const data = { ...tx, from: opts.wallet };
88
+ if (opts.pretty) {
89
+ (0, format_1.header)(`Request Withdrawal: ${opts.amount} stETH -> ETH`);
90
+ (0, format_1.row)('From', opts.wallet);
91
+ (0, format_1.row)('Amount', `${opts.amount} stETH`);
92
+ (0, format_1.row)('Contract', tx.to);
93
+ (0, format_1.row)('Action', tx.description);
94
+ return;
95
+ }
96
+ console.log(JSON.stringify(data));
97
+ }
98
+ catch (err) {
99
+ if (err instanceof Error) {
100
+ (0, format_1.jsonError)(err.message, 'RPC_ERROR', 1);
101
+ }
102
+ else {
103
+ (0, format_1.jsonError)('Unknown error', 'UNKNOWN', 1);
104
+ }
105
+ }
106
+ });
107
+ return cmd;
108
+ }
109
+ //# sourceMappingURL=withdraw.js.map