Repository navigation
Add edge-case coverage and harden pool TVL, fee APR, query defaults, and network accessors - #1271
Merged
Mimah97 merged 5 commits intoOct 16, 2026
Conversation
…or the zero-liqui Closes Vatix-Protocol#1188
…non-finite inputs Closes Vatix-Protocol#1189
…th no defaults, s Closes Vatix-Protocol#1190
…workRpcUrl have n Closes Vatix-Protocol#1191
…0-1191 # Conflicts: # apps/api/src/stats/pool-tvl.spec.ts # apps/api/src/stats/pool-tvl.ts
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
Add edge-case coverage and harden pool TVL, fee APR, query defaults, and network accessors
What was solved
#1188 — apps/api: pool-tvl computation has no test for the zero-liquidity and missing-price branches
Extend
apps/api/src/stats/pool-tvl.spec.tswith tests covering zero-liquidity pools, missing USD price on one token, missing USD price on both tokens, and a mixed valid/invalid aggregate; ifpool-tvl.tscurrently yields NaN/Infinity or throws on those inputs, make it return 0 (or skip the pool) and document the choice in the function JSDoc.Addressed:
apps/api/src/stats/pool-tvl.spec.ts#1189 — apps/web: formatFeeApr accepts negative and non-finite inputs inconsistently
Add a vitest test file for apps/web/lib/fee-apr.ts covering NaN, Infinity, -Infinity, negative numbers, 0, valid numeric strings, and non-numeric strings, and fix formatFeeApr so empty/whitespace strings return 'N/A' instead of 0.00%.
Addressed:
#1190 — apps/web: Providers creates a QueryClient with no defaults, so failed queries retry forever
Update apps/web/app/providers.tsx to construct the QueryClient from an exported
queryClientDefaultsobject with explicit query defaults: a retry function that returns false for 4xx errors (inspecting error.status or the shape from apps/web/lib/api-fetch.ts) and a bounded retry count otherwise, a sensible staleTime, and refetchOnWindowFocus disabled. Add a test under apps/web/tests/ asserting the retry behavior for 4xx vs other errors and that refetchOnWindowFocus is false.Addressed:
export const queryClientDefaults) instead ofnew QueryClient()with no options.#1191 — packages/config: getNetworkPassphrase/getNetworkRpcUrl have no tests for unknown network input
Make the unknown-network contract explicit and consistent across the four config accessors (getNetworkPassphrase, getNetworkRpcUrl, getNetworkHorizonUrl, getExplorerTxUrl) by throwing a descriptive typed Error naming the offending value, keeping isStellarNetwork as the single narrowing source of truth, and extend the existing networks test file to assert behaviour for '', 'unknown', a wrong-cased known network ('TESTNET'), and a valid preset for each accessor. Public surface in packages/config/src/index.ts stays unchanged.
Addressed:
Changes
apps/web/lib/fee-apr.ts(modify)apps/web/lib/api-fetch.ts(modify)apps/api/src/stats/pool-tvl.ts(modify)apps/web/lib/fee-apr.test.ts(modify)apps/web/__tests__/providers.test.tsx(create)apps/api/src/stats/pool-tvl.spec.ts(modify)apps/web/app/providers.tsx(modify)packages/config/src/networks.ts(modify)packages/config/src/__tests__/networks.test.ts(modify)Approach
Issues
Closes #1188
Closes #1189
Closes #1190
Closes #1191