feat: Filter gainer/upcoming assets#4227
Conversation
Conditionally hides the Upcoming section when all assets have vague launch dates (e.g., "soon", "H1 2024", "2024"). The section only displays when at least one asset has a specific date including month, quarter, or day. When hidden, New and Top Gainers sections expand to fill the space with a cleaner 2-column grid layout. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds three new filters to the top gainers query: - Require minimum $10k liquidity in pools - Exclude stablecoins from top gainers - Exclude alloy variants (show only canonical assets) This ensures top gainers shows only meaningful price movements on liquid assets. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
4 Skipped Deployments
|
|
Should be ok, but before marking as ready, testing during:
|
|
DYM is a top gainer and DYM.dym is filtered from the overall display. Also concerns about speed of loading. |
Extends the minimum liquidity filter from the top gainers highlights to the assets table's top gainers category view. This ensures consistent filtering across all top gainers displays. Changes: - Add minLiquidity parameter to mapGetMarketAssets function - Pass minLiquidity through getMarketAssets query - Apply minLiquidity: 1000 when topGainers category is selected in assets table Note: Liquidity represents total liquidity across all pools for the asset. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Forces onlyVerified: true when topGainers category is selected to match the swap page behavior. Also updates comment to reflect correct $1k threshold. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
WalkthroughNew optional filters—excludeVariants, excludeStablecoins, and minLiquidity—are added to market asset queries. The backend mapGetMarketAssets function implements variant and stablecoin filtering logic and updates liquidity thresholds. The tRPC assets endpoint extends its input schema and propagates these filters. The frontend applies specific filter combinations (all three enabled with minLiquidity=1000) for the topGainers category and adds conditional rendering for upcoming assets with specific launch dates. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/trpc/src/assets.ts (1)
604-660: Consider reusingmapGetMarketAssetsto reduce code duplication.The filtering logic in
getTopGainerAssets(stablecoin exclusion, variant exclusion, liquidity threshold) duplicates what's now available inmapGetMarketAssets. Consider refactoring to:const marketAssets = await mapGetMarketAssets({ ...ctx, onlyVerified: true, excludeVariants: true, excludeStablecoins: true, minLiquidity: 1000, }); const qualifyingAssets = marketAssets.filter( (asset) => asset.priceChange24h !== undefined ); return sort(qualifyingAssets, "priceChange24h").slice(0, topN);This would:
- Reduce code duplication
- Benefit from
getMarketAsset's caching- Ensure consistent filtering behavior
However, I understand there may be performance considerations (fetching all assets vs. a subset). If the current approach is intentional for optimization, a comment explaining the trade-off would be helpful.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/server/src/queries/complex/assets/market.ts(1 hunks)packages/trpc/src/assets.ts(6 hunks)packages/web/components/assets/highlights-categories.tsx(3 hunks)packages/web/components/table/asset-info.tsx(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: JohnnyWyles
Repo: osmosis-labs/osmosis-frontend PR: 4171
File: packages/web/components/pages/asset-info-page/pools.tsx:21-0
Timestamp: 2025-10-08T14:01:51.343Z
Learning: In packages/web/components/pages/asset-info-page/pools.tsx, the poolTypesFilter intentionally excludes only "cosmwasm-transmuter" by default, not all CosmWasm pool types, because alloyed pools should remain visible to users.
📚 Learning: 2025-10-08T14:01:51.343Z
Learnt from: JohnnyWyles
Repo: osmosis-labs/osmosis-frontend PR: 4171
File: packages/web/components/pages/asset-info-page/pools.tsx:21-0
Timestamp: 2025-10-08T14:01:51.343Z
Learning: In packages/web/components/pages/asset-info-page/pools.tsx, the poolTypesFilter intentionally excludes only "cosmwasm-transmuter" by default, not all CosmWasm pool types, because alloyed pools should remain visible to users.
Applied to files:
packages/server/src/queries/complex/assets/market.tspackages/trpc/src/assets.tspackages/web/components/table/asset-info.tsx
📚 Learning: 2024-11-05T08:46:24.743Z
Learnt from: greg-nagy
Repo: osmosis-labs/osmosis-frontend PR: 3913
File: packages/trpc/src/assets.ts:444-446
Timestamp: 2024-11-05T08:46:24.743Z
Learning: In `packages/trpc/src/assets.ts`, within the `getUserDustAssets` procedure, a prior filter ensures that `usdValue` is defined and valid, so additional error handling for `usdValue` may not be necessary in subsequent operations.
Applied to files:
packages/trpc/src/assets.ts
📚 Learning: 2024-11-05T08:46:24.743Z
Learnt from: greg-nagy
Repo: osmosis-labs/osmosis-frontend PR: 3913
File: packages/trpc/src/assets.ts:444-446
Timestamp: 2024-11-05T08:46:24.743Z
Learning: In the codebase, it's acceptable for errors to propagate to the client from the `getUserDustAssets` procedure in `packages/trpc/src/assets.ts`, so adding try-catch blocks for handling potential price fetching errors is not required.
Applied to files:
packages/trpc/src/assets.ts
🧬 Code graph analysis (1)
packages/server/src/queries/complex/assets/market.ts (2)
packages/types/src/asset-types.ts (1)
AssetList(6-10)packages/server/src/queries/complex/assets/index.ts (2)
AssetFilter(21-21)getAssets(81-90)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: preview-swap-usdc-tests
- GitHub Check: preview-pools-and-select-pair-tests
- GitHub Check: preview-portfolio-trx-tests
- GitHub Check: Summary
🔇 Additional comments (12)
packages/web/components/assets/highlights-categories.tsx (4)
41-79: Well-structured date validation with good coverage.The helper function cleanly handles the different date format cases. A few observations:
Line 68:
mayappears twice in the regex pattern - once inapril|may|juneand it would naturally be captured, but this is fine.Consider whether dates with just a day number (e.g., "22nd" or "15") without month context should be handled. Currently they'd return
false, which seems correct.The half-year regex on line 57 (
/^h[12]\s*\d{4}$/i) correctly handles "H1 2024" but won't match "H1/2024" or "H12024" (no space). The\s*makes the space optional, so "H12024" actually would match - this is good.
103-108: LGTM - Clean filtering logic.The filtering correctly derives qualifying assets and the boolean flag. Note that during loading (
isTopUpcomingAssetsLoading === true),hasQualifyingUpcomingAssetswill befalse, so the Upcoming section won't show a skeleton loader if ultimately there are no qualifying assets. This is acceptable UX behavior.
113-120: Grid layout adjustments look correct.The conditional classes properly handle both states - 2-column when Upcoming is hidden and 3-column when shown. The inline comments clarify the intent well.
140-148: Conditional rendering is correct.Since
hasQualifyingUpcomingAssetsrequires!isTopUpcomingAssetsLoading, theisLoadingprop passed toAssetHighlightswill always befalsewhen this section renders. The skeleton loader logic insideAssetHighlightswon't trigger, which is appropriate since we've already confirmed qualifying assets exist.packages/web/components/table/asset-info.tsx (2)
198-208: Verify theminLiquiditythreshold value.The PR description states "Only show assets with significant liquidity (> 10k)" but the code uses
minLiquidity: 1000(1k). This discrepancy should be clarified:
- If 10k is intended: change to
minLiquidity: 10000- If 1k is correct: update the PR description
Also note that
getTopGainerAssetsinassets.ts(line 657) uses1000for the highlights section, so these should be consistent with the intended threshold.
198-201: LGTM - Verified assets logic is correct.For
topGainers, forcingonlyVerified: trueensures the filtered list only contains verified assets, which aligns with the PR's filtering goals.packages/server/src/queries/complex/assets/market.ts (3)
128-137: LGTM - Liquidity filtering logic is sound.The dual-path logic correctly handles:
- When
minLiquidityis provided: filters to assets with liquidity >= threshold- When
minLiquidityis undefined: requires positive liquidity (maintains existing behavior)Assets without liquidity data (
undefined) default toDec(0)and are correctly filtered out in both cases.
98-107: LGTM - Variant filtering logic is correct.The filter keeps:
- Assets without a
variantGroupKey(not part of a variant group)- Canonical assets where
variantGroupKey === coinMinimalDenomThis correctly excludes non-canonical variants like "DYM.dym" while keeping "DYM".
109-122: Verify coinMinimalDenom consistency between asset sources to ensure stablecoin filtering works correctly.The stablecoin category lookup builds a map from
params.assetListsusingasset.coinMinimalDenomas the key, then filters againstassets(fromgetAssets) using the samecoinMinimalDenom. If these two sources use different denom formats or have aliasing issues (e.g., one uses canonical denoms while the other uses IBC denoms), stablecoins from the unmatched denoms will not be filtered as expected. Verify thatasset.coinMinimalDenomis consistently formatted across bothparams.assetListsand theassetsarray before relying on this lookup.packages/trpc/src/assets.ts (3)
269-271: LGTM - Schema extensions are correct.The new optional fields are properly typed and will flow through to the downstream functions.
650-660: LGTM - Liquidity filtering is correctly implemented.The filtering logic properly handles:
- Missing
priceChange24hdata- Missing or undefined liquidity
- Threshold comparison using
DecThe
slice(0, topN)after sorting ensures only the top N gainers are returned.
618-634: No action needed. The fullAssetMap lookup will consistently find matches because bothgetAssets()andfullAssetMaporiginate from the samectx.assetListssource, andcoinMinimalDenomvalues are never transformed during filtering.Likely an incorrect or invalid review comment.
|
@JohnnyWyles I noticed it removes alloys as well as variants? Is the alloyed asset (non-variant) removal intended too? Update: nevermind, I think it's due to the liquidity being under 10k If this is the case, then it looks good to me |
In this case it is that it also removes Unverified assets from the list, something that was the case for the mini-display under the swap tool already. Dropped the liquidity requirement to 1k btw, just wasn't reflected in the PR description. This is because it is not pool liquidity but directional liquidity available. |
What is the purpose of the change:
Hide upcoming assets section when only vague launch dates exist.
Filter the top gainers to:
Linear Task
https://linear.app/osmosis/issue/FE-1283/filter-top-gainers
https://linear.app/osmosis/issue/FE-1466/hide-upcoming-assets-when-no-assets-have-a-date
Testing and Verifying