Skip to content

Conversation

@glitch003
Copy link
Collaborator

Payment docs are broken due to a problem calculating usage percentage. this PR also includes a few other docs fixes

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a broken usage percentage calculation in the payment documentation snippets and adds clarification to the staking rewards documentation.

Key Changes:

  • Refactored the usage percentage calculation to properly handle edge cases (when avgPrice ≤ basePrice or avgPrice ≥ maxPrice)
  • Added explicit conditional logic to avoid division errors and ensure calculated usage stays within 0-100% range
  • Added specific dollar amount ($1,500 in LITKEY tokens) to the baseline reward description in staking documentation

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
docs/snippets/PriceProvider.jsx Improved usage percentage calculation logic with better edge case handling and added debug logging
docs/node-ops/staking-and-delegation.mdx Clarified baseline reward amount by adding specific $1,500 value

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 279 to 286
// Debug: log values to understand why calculation might fail
console.log('Usage calculation:', {
nodePrices: nodePriceData.map(n => n.price.toString()),
avgPrice: avgPrice.toString(),
basePrice: basePrice.toString(),
maxPrice: maxPrice.toString(),
avgVsBase: avgPrice.lt(basePrice) ? 'avg < base' : avgPrice.eq(basePrice) ? 'avg = base' : 'avg > base',
});
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statement should be removed before merging to production. This will pollute the browser console for end users viewing the documentation.

Copilot uses AI. Check for mistakes.
calculatedUsage = Math.max(0, Math.min(100, calculatedUsage));
}
}
console.log('Calculated usage:', calculatedUsage);
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statement should be removed before merging to production. This will pollute the browser console for end users viewing the documentation.

Suggested change
console.log('Calculated usage:', calculatedUsage);

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Chris Cassano <1285652+glitch003@users.noreply.github.com>
@glitch003 glitch003 merged commit ea2eafd into naga Dec 19, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants