Skip to content

Commit 343e334

Browse files
authored
fix: correct est epochs paid calculation in shreds list (#312)
## Summary - Fix estimated epochs paid being 100x too high in `shreds list` - Price from `fetch_device_prices` is in whole USDC, not centi-USDC — divisor should be 1,000,000 not 10,000 - Fix misleading doc comment on `fetch_device_prices`
1 parent 39fccac commit 343e334

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

  • crates/solana-cli/src/command/shreds

crates/solana-cli/src/command/shreds/list.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,9 @@ impl ListCommand {
202202
let balance = escrow_balances.get(seat_key).copied().unwrap_or(0);
203203
let escrow_usdc = format!("{:.2}", balance as f64 / 1_000_000.0);
204204
let price = device_prices.get(device_key).copied().unwrap_or(0);
205-
// balance is micro-USDC (1 USDC = 1_000_000), price is centi-USDC
206-
// (1 USDC = 100); divide balance by 10_000 to align units.
205+
// balance is micro-USDC (1 USDC = 1_000_000), price is whole USDC.
207206
let est_epochs_paid = if price > 0 {
208-
format!("~{}", balance / 10_000 / price)
207+
format!("~{}", balance / (price * 1_000_000))
209208
} else {
210209
"N/A".to_string()
211210
};
@@ -236,7 +235,7 @@ impl ListCommand {
236235
}
237236
}
238237

239-
/// Fetch the current epoch price (base + premium, in micro-USDC) for each device.
238+
/// Fetch the current epoch price (base + premium, in whole USDC) for each device.
240239
async fn fetch_device_prices(
241240
connection: &SolanaConnection,
242241
device_keys: &[Pubkey],

0 commit comments

Comments
 (0)