csm-dashboard 0.2.0__py3-none-any.whl

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.
@@ -0,0 +1,354 @@
1
+ Metadata-Version: 2.4
2
+ Name: csm-dashboard
3
+ Version: 0.2.0
4
+ Summary: Lido CSM Operator Dashboard for tracking validator earnings
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: fastapi>=0.104
7
+ Requires-Dist: httpx>=0.25
8
+ Requires-Dist: pydantic-settings>=2.0
9
+ Requires-Dist: pydantic>=2.5
10
+ Requires-Dist: python-dotenv>=1.0
11
+ Requires-Dist: rich>=13.0
12
+ Requires-Dist: typer>=0.9
13
+ Requires-Dist: uvicorn>=0.24
14
+ Requires-Dist: web3>=6.0
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
17
+ Requires-Dist: pytest-httpx>=0.21; extra == 'dev'
18
+ Requires-Dist: pytest>=7.0; extra == 'dev'
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Lido CSM Operator Dashboard
22
+
23
+ Track your Lido Community Staking Module (CSM) validator earnings, excess bond, and cumulative rewards.
24
+
25
+ ![CLI Output](img/csm-dash-cli.png)
26
+
27
+ ![Web Dashboard](img/csm-dash-web.png)
28
+
29
+ ## Features
30
+
31
+ - Look up operator by Ethereum address (manager or rewards address) or operator ID
32
+ - View current bond vs required bond (excess is claimable)
33
+ - Track cumulative rewards and unclaimed amounts
34
+ - Detailed validator status from beacon chain (with `--detailed` flag)
35
+ - APY metrics: reward APY, bond APY (stETH rebase), and net APY
36
+ - JSON output for scripting and automation
37
+ - CLI for quick terminal lookups
38
+ - Web interface for browser-based monitoring
39
+
40
+ ## Installation
41
+
42
+ ### Option 1: Docker (Recommended)
43
+
44
+ ```bash
45
+ # Clone the repository
46
+ git clone <repo-url>
47
+ cd lido-csm-dashboard
48
+
49
+ # Copy and configure environment
50
+ cp .env.example .env
51
+
52
+ # Start the web dashboard
53
+ docker compose up -d
54
+
55
+ # View logs
56
+ docker compose logs -f
57
+ ```
58
+
59
+ The web dashboard will be available at http://localhost:3000
60
+
61
+ ### Option 2: Local Python Installation
62
+
63
+ ```bash
64
+ # Clone the repository
65
+ git clone <repo-url>
66
+ cd lido-csm-dashboard
67
+
68
+ # Install with pip
69
+ pip install -e .
70
+
71
+ # Or with uv
72
+ uv pip install -e .
73
+ ```
74
+
75
+ ## Configuration
76
+
77
+ Copy `.env.example` to `.env` and configure:
78
+
79
+ ```bash
80
+ cp .env.example .env
81
+ ```
82
+
83
+ Available settings:
84
+ - `ETH_RPC_URL`: Ethereum RPC endpoint (default: https://eth.llamarpc.com)
85
+ - `BEACON_API_URL`: Beacon chain API (default: https://beaconcha.in/api/v1)
86
+ - `BEACON_API_KEY`: Optional API key for beaconcha.in (higher rate limits)
87
+ - `ETHERSCAN_API_KEY`: Optional API key for Etherscan (recommended for accurate historical data)
88
+ - `CACHE_TTL_SECONDS`: Cache duration in seconds (default: 300)
89
+
90
+ ## Usage
91
+
92
+ ### Docker Usage
93
+
94
+ The web dashboard runs automatically when you start the container. You can also use CLI commands inside the container:
95
+
96
+ ```bash
97
+ # Check operator rewards
98
+ docker compose exec csm-dashboard csm rewards 0xYourAddress
99
+
100
+ # Check by operator ID
101
+ docker compose exec csm-dashboard csm rewards --id 42
102
+
103
+ # Get detailed info with APY metrics
104
+ docker compose exec csm-dashboard csm rewards --id 42 --detailed
105
+
106
+ # JSON output
107
+ docker compose exec csm-dashboard csm rewards --id 42 --json
108
+
109
+ # List all operators
110
+ docker compose exec csm-dashboard csm list
111
+
112
+ # Monitor continuously (refresh every 60 seconds)
113
+ docker compose exec csm-dashboard csm watch 0xYourAddress --interval 60
114
+ ```
115
+
116
+ ### Local CLI Usage
117
+
118
+ ### `csm rewards` - Check operator rewards
119
+
120
+ ```bash
121
+ csm rewards [ADDRESS] [OPTIONS]
122
+ ```
123
+
124
+ > **Note:** The `check` command is still available as an alias for backwards compatibility.
125
+
126
+ | Argument/Option | Short | Description |
127
+ |-----------------|-------|-------------|
128
+ | `ADDRESS` | | Ethereum address (required unless `--id` is provided) |
129
+ | `--id` | `-i` | Operator ID (skips address lookup, faster) |
130
+ | `--detailed` | `-d` | Include validator status from beacon chain and APY metrics |
131
+ | `--json` | `-j` | Output as JSON (same format as API) |
132
+ | `--rpc` | `-r` | Custom RPC URL |
133
+
134
+ **Examples:**
135
+
136
+ ```bash
137
+ # Check by address
138
+ csm rewards 0xYourAddress
139
+
140
+ # Check by operator ID (faster)
141
+ csm rewards --id 42
142
+
143
+ # Get detailed validator info and APY
144
+ csm rewards --id 42 --detailed
145
+
146
+ # JSON output for scripting
147
+ csm rewards --id 42 --json
148
+
149
+ # JSON with detailed info
150
+ csm rewards --id 42 --detailed --json
151
+ ```
152
+
153
+ ### `csm watch` - Continuous monitoring
154
+
155
+ ```bash
156
+ csm watch ADDRESS [OPTIONS]
157
+ ```
158
+
159
+ | Argument/Option | Short | Description |
160
+ |-----------------|-------|-------------|
161
+ | `ADDRESS` | | Ethereum address to monitor (required) |
162
+ | `--interval` | `-i` | Refresh interval in seconds (default: 300) |
163
+ | `--rpc` | `-r` | Custom RPC URL |
164
+
165
+ **Examples:**
166
+
167
+ ```bash
168
+ # Monitor with default 5-minute refresh
169
+ csm watch 0xYourAddress
170
+
171
+ # Monitor with 60-second refresh
172
+ csm watch 0xYourAddress --interval 60
173
+ ```
174
+
175
+ ### `csm list` - List all operators
176
+
177
+ ```bash
178
+ csm list [OPTIONS]
179
+ ```
180
+
181
+ | Option | Short | Description |
182
+ |--------|-------|-------------|
183
+ | `--rpc` | `-r` | Custom RPC URL |
184
+
185
+ Lists all operator IDs that have rewards in the current merkle tree.
186
+
187
+ ### `csm serve` - Start web dashboard
188
+
189
+ ```bash
190
+ csm serve [OPTIONS]
191
+ ```
192
+
193
+ | Option | Description |
194
+ |--------|-------------|
195
+ | `--host` | Host to bind to (default: 127.0.0.1) |
196
+ | `--port` | Port to bind to (default: 8080) |
197
+ | `--reload` | Enable auto-reload for development |
198
+
199
+ **Examples:**
200
+
201
+ ```bash
202
+ # Start on default port
203
+ csm serve
204
+
205
+ # Start on custom port
206
+ csm serve --port 3000
207
+
208
+ # Development mode with auto-reload
209
+ csm serve --reload
210
+ ```
211
+
212
+ Then open http://localhost:8080 in your browser.
213
+
214
+ **Docker:** The web dashboard is already running when you use `docker compose up`. Access it at http://localhost:3000
215
+
216
+ ## JSON Output
217
+
218
+ The `--json` flag outputs data in the same format as the API, making it easy to integrate with scripts or other tools:
219
+
220
+ ```bash
221
+ csm rewards --id 333 --json
222
+ ```
223
+
224
+ ```json
225
+ {
226
+ "operator_id": 333,
227
+ "manager_address": "0x6ac683C503CF210CCF88193ec7ebDe2c993f63a4",
228
+ "reward_address": "0x55915Cf2115c4D6e9085e94c8dAD710cabefef31",
229
+ "rewards": {
230
+ "current_bond_eth": 651.5523536856277,
231
+ "required_bond_eth": 650.2,
232
+ "excess_bond_eth": 1.3523536856277778,
233
+ "cumulative_rewards_shares": 8973877501313655495,
234
+ "cumulative_rewards_eth": 10.9642938931415,
235
+ "distributed_shares": 7867435720490255061,
236
+ "distributed_eth": 9.61244204773546,
237
+ "unclaimed_shares": 1106441780823400434,
238
+ "unclaimed_eth": 1.3518518454060409,
239
+ "total_claimable_eth": 2.7042055310338187
240
+ },
241
+ "validators": {
242
+ "total": 500,
243
+ "active": 500,
244
+ "exited": 0
245
+ }
246
+ }
247
+ ```
248
+
249
+ With `--detailed`, additional fields are included:
250
+
251
+ ```json
252
+ {
253
+ "operator_id": 333,
254
+ "...": "...",
255
+ "validators": {
256
+ "total": 500,
257
+ "active": 500,
258
+ "exited": 0,
259
+ "by_status": {
260
+ "active": 100,
261
+ "pending": 0,
262
+ "exiting": 0,
263
+ "exited": 0,
264
+ "slashed": 0,
265
+ "unknown": 0
266
+ }
267
+ },
268
+ "performance": {
269
+ "avg_effectiveness": 98.5
270
+ },
271
+ "apy": {
272
+ "historical_reward_apy_28d": 2.21,
273
+ "historical_reward_apy_ltd": 2.03,
274
+ "bond_apy": 2.54,
275
+ "net_apy_28d": 4.75,
276
+ "net_apy_ltd": 4.57
277
+ },
278
+ "active_since": "2025-02-16T12:00:00"
279
+ }
280
+ ```
281
+
282
+ ## API Endpoints
283
+
284
+ - `GET /api/operator/{address_or_id}` - Get operator rewards data
285
+ - Query param: `?detailed=true` for validator status and APY
286
+ - `GET /api/operators` - List all operators with rewards
287
+ - `GET /api/health` - Health check
288
+
289
+ ## Understanding APY Metrics
290
+
291
+ The dashboard shows three APY metrics when using the `--detailed` flag:
292
+
293
+ | Metric | What It Means |
294
+ |--------|---------------|
295
+ | **Reward APY** | Your earnings from CSM fee distributions, based on your validators' performance |
296
+ | **Bond APY** | Automatic growth of your stETH bond from protocol rebasing (same for all operators) |
297
+ | **NET APY** | Total return = Reward APY + Bond APY |
298
+
299
+ ### How APY is Calculated
300
+
301
+ **Reward APY** is calculated from actual reward distribution data published by Lido. Every ~28 days, Lido calculates how much each operator earned and publishes a "distribution frame" to IPFS (a decentralized file storage network). The dashboard fetches all these historical frames to calculate both 28-day and lifetime APY.
302
+
303
+ - **28-Day APY**: Based on the most recent ~28 days of reward distributions
304
+ - **Lifetime APY**: Based on all periods where you earned rewards (excludes ramp-up periods with no rewards to avoid misleadingly low numbers)
305
+
306
+ **Bond APY** represents the stETH rebase rate—the automatic growth of your bond due to Ethereum staking rewards. This rate is set by the Lido protocol and applies equally to all operators. The dashboard shows the current 7-day average rate from Lido's API.
307
+
308
+ > **Note**: Bond APY shows the current stETH rate for both 28-Day and Lifetime columns, as historical rates aren't readily available.
309
+
310
+ ### Why You Might Want an Etherscan API Key
311
+
312
+ The actual reward data lives on IPFS and is always accessible. However, to *discover* which IPFS files exist, the dashboard needs to find historical `DistributionLogUpdated` events on the blockchain. This can be done in several ways:
313
+
314
+ | Method | Description |
315
+ |--------|-------------|
316
+ | **With Etherscan API key** | Most reliable. Queries Etherscan directly for complete, up-to-date distribution history. |
317
+ | **Without API key** | Uses a built-in list of known distributions. Works fine but may be slightly behind if new distributions happened recently. |
318
+
319
+ **How to get one (free):**
320
+ 1. Go to [etherscan.io/apis](https://etherscan.io/apis)
321
+ 2. Create a free account
322
+ 3. Generate an API key
323
+ 4. Add to your `.env` file: `ETHERSCAN_API_KEY=your_key_here`
324
+
325
+ The free tier allows 5 calls/second, which is plenty for this dashboard.
326
+
327
+ ## Data Sources
328
+
329
+ - **On-chain contracts**: CSModule, CSAccounting, CSFeeDistributor, stETH
330
+ - **Rewards tree**: https://github.com/lidofinance/csm-rewards (updates hourly)
331
+ - **Beacon chain**: beaconcha.in API (for validator status)
332
+ - **Lido API**: stETH APR data (for bond APY calculations)
333
+ - **IPFS**: Historical reward distribution logs (cached locally after first fetch)
334
+
335
+ ## Contract Addresses (Mainnet)
336
+
337
+ - CSModule: `0xdA7dE2ECdDfccC6c3AF10108Db212ACBBf9EA83F`
338
+ - CSAccounting: `0x4d72BFF1BeaC69925F8Bd12526a39BAAb069e5Da`
339
+ - CSFeeDistributor: `0xD99CC66fEC647E68294C6477B40fC7E0F6F618D0`
340
+ - stETH: `0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84`
341
+
342
+ ## Development
343
+
344
+ ```bash
345
+ # Install dev dependencies
346
+ pip install -e ".[dev]"
347
+
348
+ # Run tests
349
+ pytest
350
+ ```
351
+
352
+ ## License
353
+
354
+ MIT
@@ -0,0 +1,27 @@
1
+ src/__init__.py,sha256=Bfqpjo9Q1XaV8DNqkf1sADzWg2ACpfZWSGLtahZE3iU,35
2
+ src/main.py,sha256=tj7C09FVBGBVyjKYwmElpX5M92xfydDm8RJ6-MSFdMk,951
3
+ src/cli/__init__.py,sha256=mgHAwomqzAhOHJnlWrWtCguhGzhDWlkCvkzKsfoFsds,35
4
+ src/cli/commands.py,sha256=kSioEDzBf85MKEEWb_wq9DbRUyEtQYnHPJ9dxi-nPvk,23929
5
+ src/core/__init__.py,sha256=ZDHZojANK1ZFpn5lQROERTo97MYQFAxqA9APvs7ruEQ,57
6
+ src/core/config.py,sha256=UD4-LVHdeQeT6n9BtLXh2zZcXfX0-ZhrMVZx93E2BGk,1429
7
+ src/core/contracts.py,sha256=BjPrywRZd6qQfT9HMtuI0cUIxAuouoUATuxGpDVT4KM,541
8
+ src/core/types.py,sha256=dzTdZiOOzxwj4oh0ZLEWqb4jbVsA0TVm6Rqkod7yUMg,4551
9
+ src/data/__init__.py,sha256=DItA8aEp8Lbr0uFlJVppMaTtVEEznoA1hkRpH-vfHhk,57
10
+ src/data/beacon.py,sha256=9oaR7TO2WcP_D3jVTzcd9WE6NbF2WnqQDW_y5M8GsZ0,13511
11
+ src/data/cache.py,sha256=w1iv4rM-FVgFlaSNYdQA3CfqyhZo9-gqbZwKmzKY0Ps,2134
12
+ src/data/etherscan.py,sha256=mkd4KB-4JUvY_aVVqUH119GLS--_qivmeRKR70ivQkk,2832
13
+ src/data/ipfs_logs.py,sha256=IV_eTyktO3DaiTsXgU7huzo51I60OVo8ne9G_yvRdIk,9192
14
+ src/data/known_cids.py,sha256=onwTTNvAv4h0-3LZgLhqMlKzuNH2VhBqQGZ9fm8GyoE,1705
15
+ src/data/lido_api.py,sha256=WuVrqVOT7trxGgZX4Kavg7k9DyKyXIa_aSc_7XVLU2Y,1026
16
+ src/data/onchain.py,sha256=l9xQxKoXhmr0TKguba1L423_o9mdTLoeDhegMpa3ZgY,9710
17
+ src/data/rewards_tree.py,sha256=a-MO14b4COjOvy59FPd0jaf1dkgidlqCQKAFDinwRJU,1894
18
+ src/data/strikes.py,sha256=9iSW7Xm2W0rqySAJn5IwqCCKf-ef2XazC7tYHgz9REk,7480
19
+ src/services/__init__.py,sha256=MC7blFLAMazErCWuyYXvS6sO3uZm1z_RUOtnlIK0kSo,38
20
+ src/services/operator_service.py,sha256=Y6rXYdJzv7V3Nix99iiyC7NcDRfShdvDTcRtXbp_oTQ,13015
21
+ src/web/__init__.py,sha256=iI2c5xxXmzsNxIetm0P2qE3uVsT-ClsMfzn620r5YTU,40
22
+ src/web/app.py,sha256=qEIB05J0sKEeZkfHkJwotltsL-d2j1KTDS56cQl2_IU,32129
23
+ src/web/routes.py,sha256=z0cmH4mA3IxlHYQ-8FFYQrXCRVsi3PvUG_8ZWLixfwg,6204
24
+ csm_dashboard-0.2.0.dist-info/METADATA,sha256=fEsfIq2oOP6SA2aSCefK21P0Q-OUj9G5GgvdY6I-h8s,10003
25
+ csm_dashboard-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
26
+ csm_dashboard-0.2.0.dist-info/entry_points.txt,sha256=P1Ul8ALIPBwDlVlXqTPuzJ64xxRpIJsYW8U73Tyjgtg,37
27
+ csm_dashboard-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ csm = src.main:app
src/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """Lido CSM Operator Dashboard."""
src/cli/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """CLI module - Typer commands."""