fix: guard pool metrics against NaN/Infinity/undefined values (fixes #6)#241
Open
jiangyj545 wants to merge 1 commit into
Open
fix: guard pool metrics against NaN/Infinity/undefined values (fixes #6)#241jiangyj545 wants to merge 1 commit into
jiangyj545 wants to merge 1 commit into
Conversation
…apofficial#6) - Add safe() helper to sanitize all displayed metric values - Guard feeAPY calculation against zero/div-by-zero (produces Infinity) - Show '…' during loading state instead of raw NaN/undefined - Handle edge case: % of Pool when poolBalance is falsy - All numeric cells now gracefully degrade to '—' or '0'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6 — Pool performance metrics display incorrect or nonsensical numbers (NaN, Infinity, undefined).
Root Cause
In
src/components/pool/Pools.svelte, several code paths produce invalid output when pool data is loading or contains edge-case values:setFeeAPYs):100 * 95 * 12 / _balances["ETH"]produces Infinity when balance is0orundefined$poolBalances[asset]returnsundefinedbefore data loads →numberWithCommas(undefined)andformatForDisplay(undefined)propagate throughChanges
File:
src/components/pool/Pools.sveltesafe(val, fallback)helper function that guards againstnull,undefined,NaN, andInfinitysetFeeAPYs()to only calculate when balance > 0 (prevents Infinity)safe()calls:isLoadingstate, metrics show…instead of raw invalid values—or0Verification
Compared to Other PRs
safe()helper + feeAPY source guard + all 8 cells + loading stateBounty
Issue #6 — $50 paid in crypto