Skip to content

feat: colocate pools' active data in usePool()#10265

Merged
gomesalexandre merged 9 commits intodevelopfrom
feat_react_table_things
Aug 13, 2025
Merged

feat: colocate pools' active data in usePool()#10265
gomesalexandre merged 9 commits intodevelopfrom
feat_react_table_things

Conversation

@gomesalexandre
Copy link
Contributor

@gomesalexandre gomesalexandre commented Aug 12, 2025

Description

Makes it so that usePools() now return active data (isTradingActive / isTradingActiveLoading / isLpDepositEnabled) for later use in sorting, vs. currently being fetched by each row.

Issue (if applicable)

Risk

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Testing

  • LP Available Pools tags should show no regressions
  • LP Available Pools sorting should show no regressions

Engineering

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

https://jam.dev/c/f4394434-a9fe-4709-b9ca-63725d5a6897

Summary by CodeRabbit

  • New Features

    • Pool list now uses per-pool trading and deposit flags so availability, statuses, and APY display are more accurate.
    • Per-pool loading indicators provide smoother, more granular loading behavior.
  • Refactor

    • Consolidated status logic to rely on per-pool signals and upstream status data, simplifying UI state handling.
  • Bug Fixes

    • More reliable detection of disabled deposits and halted trading, reducing incorrect availability indicators and skeletons.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 12, 2025

📝 Walkthrough

Walkthrough

Introduces a reusable isLpDepositEnabled utility, extends Pool with per-pool status fields, and updates pool fetching to query Thorchain inbound addresses and MIMIR to compute per-pool isTradingActive and isLpDepositEnabled. AvailablePools now renders using these per-pool fields and loading flags.

Changes

Cohort / File(s) Summary
Thorchain LP deposit enablement utility
src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx
Adds isLpDepositEnabled({ mimir, assetId }) returning `boolean
AvailablePools status rendering
src/pages/ThorChainLP/AvailablePools.tsx
Replaces global hook-based status checks with per-pool fields (isTradingActive, isLpDepositEnabled, isTradingActiveLoading); updates status useMemo, loading condition, and removes unused imports.
Pool type extensions
src/pages/ThorChainLP/queries/hooks/usePool.ts
Extends exported Pool type with optional isTradingActive?, isTradingActiveLoading?, and isLpDepositEnabled?.
Pools query augmentation
src/pages/ThorChainLP/queries/hooks/usePools.ts
Adds Thorchain inbound-address query and MIMIR integration; maps pools to compute and attach isTradingActive, isTradingActiveLoading, and isLpDepositEnabled; adjusts query options and return shape.

Sequence Diagram(s)

sequenceDiagram
  participant UI as AvailablePools
  participant Pools as usePools
  participant Midgard as Midgard API
  participant Inbound as Thorchain Inbound API
  participant Mimir as Thorchain MIMIR

  UI->>Pools: request pools
  Pools->>Midgard: fetch pools list
  Midgard-->>Pools: pools
  Pools->>Inbound: fetch inbound addresses (Thorchain)
  Inbound-->>Pools: inbound addresses
  Pools->>Mimir: fetch MIMIR (Thorchain)
  Mimir-->>Pools: mimir flags
  Pools->>Pools: compute isTradingActive per pool
  Pools->>Pools: compute isLpDepositEnabled per pool
  Pools-->>UI: pools with status & loading flags
  UI->>UI: render using per-pool fields
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Suggested labels

high risk

Suggested reviewers

  • kaladinlight
  • premiumjibles

Poem

I hop through mimir, sniff each gate,
I check the pools — am I too late?
Flags and inbounds, one by one,
Deposits open, trading run.
A rabbit nods: the checks are done. 🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat_react_table_things

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gomesalexandre gomesalexandre changed the title [skip ci] wip: pools sorting push non-active pools to the bottom of the list feat: colocate pools' active data in usePool() Aug 13, 2025
@gomesalexandre gomesalexandre marked this pull request as ready for review August 13, 2025 10:54
@gomesalexandre gomesalexandre requested a review from a team as a code owner August 13, 2025 10:54
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (1)
src/pages/ThorChainLP/AvailablePools.tsx (1)

90-94: Consider handling undefined states explicitly

The default case returns a subtle color with APY, but this might be reached when pool.isTradingActive is undefined (still loading). Consider whether this is the intended behavior.

Consider explicitly handling the loading state:

               case pool.isTradingActive === true && pool.status === 'staged':
                 return {
                   color: 'yellow.500',
                   element: <Text translation='common.staged' />,
                 }
+              case pool.isTradingActive === undefined:
+                return {
+                  color: 'text.subtle',
+                  element: <Text translation='common.loading' />,
+                }
               default:
                 return {
                   color: 'text.subtle',
                   element: <Amount.Percent value={pool.annualPercentageRate} suffix='APY' />,
                 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21c85b7 and 34a6e4e.

📒 Files selected for processing (4)
  • src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx (1 hunks)
  • src/pages/ThorChainLP/AvailablePools.tsx (4 hunks)
  • src/pages/ThorChainLP/queries/hooks/usePool.ts (1 hunks)
  • src/pages/ThorChainLP/queries/hooks/usePools.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/error-handling.mdc)

**/*.{ts,tsx}: ALWAYS use Result<T, E> pattern for error handling in swappers and APIs
ALWAYS use Ok() and Err() from @sniptt/monads for monadic error handling
ALWAYS use custom error classes from @shapeshiftoss/errors
ALWAYS provide meaningful error codes for internationalization
ALWAYS include relevant details in error objects
ALWAYS wrap async operations in try-catch blocks
ALWAYS use AsyncResultOf utility for converting promises to Results
ALWAYS provide fallback error handling
ALWAYS use timeoutMonadic for API calls
ALWAYS provide appropriate timeout values for API calls
ALWAYS handle timeout errors gracefully
ALWAYS validate inputs before processing
ALWAYS provide clear validation error messages
ALWAYS use early returns for validation failures
ALWAYS log errors for debugging
ALWAYS use structured logging for errors
ALWAYS include relevant context in error logs
Throwing errors instead of using monadic patterns is an anti-pattern
Missing try-catch blocks for async operations is an anti-pattern
Generic error messages without context are an anti-pattern
Not handling specific error types is an anti-pattern
Missing timeout handling is an anti-pattern
No input validation is an anti-pattern
Poor error logging is an anti-pattern
Using any for error types is an anti-pattern
Missing error codes for internationalization is an anti-pattern
No fallback error handling is an anti-pattern
Console.error without structured logging is an anti-pattern

**/*.{ts,tsx}: ALWAYS use camelCase for variables, functions, and methods
ALWAYS use descriptive names that explain the purpose for variables and functions
ALWAYS use verb prefixes for functions that perform actions
ALWAYS use PascalCase for types, interfaces, and enums
ALWAYS use descriptive names that indicate the structure for types, interfaces, and enums
ALWAYS use suffixes like Props, State, Config, Type when appropriate for types and interfaces
ALWAYS use UPPER_SNAKE_CASE for constants and configuration values
ALWAYS use d...

Files:

  • src/pages/ThorChainLP/queries/hooks/usePool.ts
  • src/pages/ThorChainLP/queries/hooks/usePools.ts
  • src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx
  • src/pages/ThorChainLP/AvailablePools.tsx
**/*

📄 CodeRabbit Inference Engine (.cursor/rules/naming-conventions.mdc)

**/*: ALWAYS use appropriate file extensions
Flag files without kebab-case

Files:

  • src/pages/ThorChainLP/queries/hooks/usePool.ts
  • src/pages/ThorChainLP/queries/hooks/usePools.ts
  • src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx
  • src/pages/ThorChainLP/AvailablePools.tsx
**/use*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/naming-conventions.mdc)

**/use*.{ts,tsx}: ALWAYS use use prefix for custom hooks
ALWAYS use descriptive names that indicate the hook's purpose
ALWAYS use camelCase after the use prefix for custom hooks

Files:

  • src/pages/ThorChainLP/queries/hooks/usePool.ts
  • src/pages/ThorChainLP/queries/hooks/usePools.ts
  • src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/react-best-practices.mdc)

USE Redux only for global state shared across multiple places

Files:

  • src/pages/ThorChainLP/queries/hooks/usePool.ts
  • src/pages/ThorChainLP/queries/hooks/usePools.ts
  • src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx
  • src/pages/ThorChainLP/AvailablePools.tsx
**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/error-handling.mdc)

**/*.tsx: ALWAYS wrap components in error boundaries
ALWAYS provide user-friendly fallback components in error boundaries
ALWAYS log errors for debugging in error boundaries
ALWAYS use useErrorToast hook for displaying errors
ALWAYS provide translated error messages in error toasts
ALWAYS handle different error types appropriately in error toasts
Missing error boundaries in React components is an anti-pattern

**/*.tsx: ALWAYS use PascalCase for React component names
ALWAYS use descriptive names that indicate the component's purpose
ALWAYS match the component name to the file name
Flag components without PascalCase
Flag default exports for components

Files:

  • src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx
  • src/pages/ThorChainLP/AvailablePools.tsx
**/*.{tsx,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/react-best-practices.mdc)

**/*.{tsx,jsx}: ALWAYS use useMemo for expensive computations, object/array creations, and filtered data
ALWAYS use useMemo for derived values and computed properties
ALWAYS use useMemo for conditional values and simple transformations
ALWAYS use useCallback for event handlers and functions passed as props
ALWAYS use useCallback for any function that could be passed as a prop or dependency
ALWAYS include all dependencies in useEffect, useMemo, useCallback dependency arrays
NEVER use // eslint-disable-next-line react-hooks/exhaustive-deps unless absolutely necessary
ALWAYS explain why dependencies are excluded if using eslint disable
ALWAYS use named exports for components
NEVER use default exports for components
KEEP component files under 200 lines when possible
BREAK DOWN large components into smaller, reusable pieces
EXTRACT complex logic into custom hooks
USE local state for component-level state
LIFT state up when needed across multiple components
USE Context for avoiding prop drilling
ALWAYS wrap components in error boundaries for production
ALWAYS handle async errors properly
ALWAYS provide user-friendly error messages
ALWAYS use virtualization for lists with 100+ items
ALWAYS implement proper key props for list items
ALWAYS lazy load heavy components
ALWAYS use React.lazy for code splitting
Components receiving props are wrapped with memo

Files:

  • src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx
  • src/pages/ThorChainLP/AvailablePools.tsx
🧠 Learnings (1)
📓 Common learnings
Learnt from: gomesalexandre
PR: shapeshift/web#10206
File: src/config.ts:127-128
Timestamp: 2025-08-07T11:20:44.614Z
Learning: gomesalexandre prefers required environment variables without default values in the config file (src/config.ts). They want explicit configuration and fail-fast behavior when environment variables are missing, rather than having fallback defaults.
Learnt from: gomesalexandre
PR: shapeshift/web#10206
File: src/lib/moralis.ts:47-85
Timestamp: 2025-08-07T11:22:16.983Z
Learning: gomesalexandre prefers console.error over structured logging for Moralis API integration debugging, as they find it more conventional and prefer to examine XHR requests directly rather than rely on structured logs for troubleshooting.
🧬 Code Graph Analysis (2)
src/pages/ThorChainLP/queries/hooks/usePools.ts (8)
src/react-queries/queries/thornode.ts (1)
  • getInboundAddressesQuery (72-88)
packages/swapper/src/thorchain-utils/index.ts (1)
  • getChainIdBySwapper (40-49)
src/lib/utils/thorchain/hooks/useThorchainMimir.ts (1)
  • useThorchainMimir (15-28)
packages/caip/src/constants.ts (1)
  • thorchainChainId (71-71)
src/pages/ThorChainLP/queries/hooks/usePool.ts (1)
  • Pool (20-28)
packages/swapper/src/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.ts (1)
  • thorPoolAssetIdToAssetId (10-11)
src/react-queries/selectors/index.ts (2)
  • selectInboundAddressData (18-28)
  • selectIsTradingActive (30-73)
src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx (1)
  • isLpDepositEnabled (8-32)
src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx (5)
src/lib/utils/thorchain/types.ts (1)
  • ThorchainMimir (9-209)
packages/caip/src/assetId/assetId.ts (1)
  • AssetId (17-17)
packages/caip/src/constants.ts (2)
  • thorchainAssetId (49-49)
  • thorchainChainId (71-71)
packages/swapper/src/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.ts (1)
  • assetIdToThorPoolAssetId (13-14)
src/lib/utils/thorchain/hooks/useThorchainMimir.ts (1)
  • useThorchainMimir (15-28)
🔇 Additional comments (4)
src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx (1)

25-25: The script didn’t surface how poolAssetId is later used or validated against known Thorchain asset IDs, nor any tests demonstrating the expected dot/dash placement. To confirm the correct transformation (first dash only vs. all dashes) we need to see:

  • How poolAssetId is matched or looked up (e.g. in an enabled‐pools map).
  • Any existing normalization logic (e.g. in assetIdToThorPoolAssetIdMap).

Could you please share the surrounding lines in src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx—specifically how poolAssetId is consumed—or add tests/logs showing lookup failures for multi-dash IDs?

src/pages/ThorChainLP/queries/hooks/usePool.ts (1)

24-28: Good addition of pool status fields

The addition of isTradingActive, isTradingActiveLoading, and isLpDepositEnabled fields to the Pool type properly supports the colocation of pool status data as intended by the PR.

src/pages/ThorChainLP/AvailablePools.tsx (1)

63-96: Clean refactor to use pool-level status data

The switch to using pool.isLpDepositEnabled and pool.isTradingActive successfully eliminates the need for external hooks and improves performance by colocating the data fetching. The status logic is now cleaner and more maintainable.

src/pages/ThorChainLP/queries/hooks/usePools.ts (1)

132-143: Good implementation of LP deposit status

The implementation correctly integrates the new isLpDepositEnabled function to compute per-pool deposit status, which aligns well with the PR's objective of colocating pool data.

Copy link
Collaborator

@NeOMakinG NeOMakinG left a comment

Choose a reason for hiding this comment

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

Seems like working as expected, happy with that
image

@gomesalexandre gomesalexandre enabled auto-merge (squash) August 13, 2025 13:49
@gomesalexandre gomesalexandre merged commit de173e2 into develop Aug 13, 2025
3 of 4 checks passed
@gomesalexandre gomesalexandre deleted the feat_react_table_things branch August 13, 2025 13:57
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0e5936 and 1be3591.

📒 Files selected for processing (1)
  • src/pages/ThorChainLP/queries/hooks/usePools.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/error-handling.mdc)

**/*.{ts,tsx}: ALWAYS use Result<T, E> pattern for error handling in swappers and APIs
ALWAYS use Ok() and Err() from @sniptt/monads for monadic error handling
ALWAYS use custom error classes from @shapeshiftoss/errors
ALWAYS provide meaningful error codes for internationalization
ALWAYS include relevant details in error objects
ALWAYS wrap async operations in try-catch blocks
ALWAYS use AsyncResultOf utility for converting promises to Results
ALWAYS provide fallback error handling
ALWAYS use timeoutMonadic for API calls
ALWAYS provide appropriate timeout values for API calls
ALWAYS handle timeout errors gracefully
ALWAYS validate inputs before processing
ALWAYS provide clear validation error messages
ALWAYS use early returns for validation failures
ALWAYS log errors for debugging
ALWAYS use structured logging for errors
ALWAYS include relevant context in error logs
Throwing errors instead of using monadic patterns is an anti-pattern
Missing try-catch blocks for async operations is an anti-pattern
Generic error messages without context are an anti-pattern
Not handling specific error types is an anti-pattern
Missing timeout handling is an anti-pattern
No input validation is an anti-pattern
Poor error logging is an anti-pattern
Using any for error types is an anti-pattern
Missing error codes for internationalization is an anti-pattern
No fallback error handling is an anti-pattern
Console.error without structured logging is an anti-pattern

**/*.{ts,tsx}: ALWAYS use camelCase for variables, functions, and methods
ALWAYS use descriptive names that explain the purpose for variables and functions
ALWAYS use verb prefixes for functions that perform actions
ALWAYS use PascalCase for types, interfaces, and enums
ALWAYS use descriptive names that indicate the structure for types, interfaces, and enums
ALWAYS use suffixes like Props, State, Config, Type when appropriate for types and interfaces
ALWAYS use UPPER_SNAKE_CASE for constants and configuration values
ALWAYS use d...

Files:

  • src/pages/ThorChainLP/queries/hooks/usePools.ts
**/*

📄 CodeRabbit Inference Engine (.cursor/rules/naming-conventions.mdc)

**/*: ALWAYS use appropriate file extensions
Flag files without kebab-case

Files:

  • src/pages/ThorChainLP/queries/hooks/usePools.ts
**/use*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/naming-conventions.mdc)

**/use*.{ts,tsx}: ALWAYS use use prefix for custom hooks
ALWAYS use descriptive names that indicate the hook's purpose
ALWAYS use camelCase after the use prefix for custom hooks

Files:

  • src/pages/ThorChainLP/queries/hooks/usePools.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/react-best-practices.mdc)

USE Redux only for global state shared across multiple places

Files:

  • src/pages/ThorChainLP/queries/hooks/usePools.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: gomesalexandre
PR: shapeshift/web#10206
File: src/config.ts:127-128
Timestamp: 2025-08-07T11:20:44.614Z
Learning: gomesalexandre prefers required environment variables without default values in the config file (src/config.ts). They want explicit configuration and fail-fast behavior when environment variables are missing, rather than having fallback defaults.
Learnt from: gomesalexandre
PR: shapeshift/web#10206
File: src/lib/moralis.ts:47-85
Timestamp: 2025-08-07T11:22:16.983Z
Learning: gomesalexandre prefers console.error over structured logging for Moralis API integration debugging, as they find it more conventional and prefer to examine XHR requests directly rather than rely on structured logs for troubleshooting.
📚 Learning: 2025-08-13T13:45:25.710Z
Learnt from: gomesalexandre
PR: shapeshift/web#10265
File: src/pages/ThorChainLP/queries/hooks/usePools.ts:93-0
Timestamp: 2025-08-13T13:45:25.710Z
Learning: In the ShapeShift web app, inbound addresses data for Thorchain pools requires aggressive caching settings (staleTime: 0, gcTime: 0, refetchInterval: 60_000) to ensure trading status and LP deposit availability are always current. This is intentional business-critical behavior, not a performance issue to be optimized.

Applied to files:

  • src/pages/ThorChainLP/queries/hooks/usePools.ts
📚 Learning: 2025-08-07T11:22:16.983Z
Learnt from: gomesalexandre
PR: shapeshift/web#10206
File: src/lib/moralis.ts:47-85
Timestamp: 2025-08-07T11:22:16.983Z
Learning: gomesalexandre prefers console.error over structured logging for Moralis API integration debugging, as they find it more conventional and prefer to examine XHR requests directly rather than rely on structured logs for troubleshooting.

Applied to files:

  • src/pages/ThorChainLP/queries/hooks/usePools.ts
🧬 Code Graph Analysis (1)
src/pages/ThorChainLP/queries/hooks/usePools.ts (8)
src/react-queries/queries/thornode.ts (1)
  • getInboundAddressesQuery (72-88)
packages/swapper/src/thorchain-utils/index.ts (1)
  • getChainIdBySwapper (40-49)
src/lib/utils/thorchain/hooks/useThorchainMimir.ts (1)
  • useThorchainMimir (15-28)
packages/caip/src/constants.ts (1)
  • thorchainChainId (71-71)
src/pages/ThorChainLP/queries/hooks/usePool.ts (1)
  • Pool (20-28)
packages/swapper/src/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers.ts (1)
  • thorPoolAssetIdToAssetId (10-11)
src/react-queries/selectors/index.ts (2)
  • selectInboundAddressData (18-28)
  • selectIsTradingActive (30-73)
src/lib/utils/thorchain/hooks/useIsThorchainLpDepositEnabled.tsx (1)
  • isLpDepositEnabled (8-32)
⏰ 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). (1)
  • GitHub Check: Call / Static
🔇 Additional comments (2)
src/pages/ThorChainLP/queries/hooks/usePools.ts (2)

93-103: Aggressive refetch config acknowledged and appropriate here

The always-stale + 60s refetch strategy for inbound addresses is intentional for real-time trading/LP status. Looks good given business requirements.


132-145: LGTM: No silent drops when Mimir is unavailable

Early-returning poolsWithActiveData when mimir is missing avoids silently dropping pools. Solid improvement for predictability.


export type { Pool } from './usePool'

export const usePools = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add an explicit return type for usePools

Project guidelines require explicit return types. This also documents the hook’s contract.

-import { useQueries, useQuery } from '@tanstack/react-query'
+import { useQueries, useQuery, type UseQueryResult } from '@tanstack/react-query'
-export const usePools = () => {
+export const usePools = (): UseQueryResult<Pool[]> => {

Also applies to: 4-4

🤖 Prompt for AI Agents
In src/pages/ThorChainLP/queries/hooks/usePools.ts around line 22 (and also
applies to lines 4-4), the usePools hook is missing an explicit return type;
update the function signature to include a concrete return type that reflects
the hook's contract (for example the specific data/result shape, or a React
Query return type like ReturnType<typeof useQuery> or Promise/Array of Pool
items as appropriate), and import or define any required types; ensure the
exported usePools signature explicitly declares that return type.

Comment on lines +105 to +107
const { data: mimir } = useThorchainMimir({
chainId: thorchainChainId,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Include Mimir loading state to avoid false “inactive” during initial load

selectIsTradingActive returns false for native fee assets until mimir is available. Without including mimir’s loading state, rows can briefly show “inactive” instead of “loading”.

-  const { data: mimir } = useThorchainMimir({
+  const { data: mimir, isLoading: isMimirLoading } = useThorchainMimir({
     chainId: thorchainChainId,
   })
-      acc.push({ ...pool, isTradingActive, isTradingActiveLoading: isInboundAddressesDataLoading })
+      acc.push({
+        ...pool,
+        isTradingActive,
+        isTradingActiveLoading: isInboundAddressesDataLoading || isMimirLoading,
+      })

Also applies to: 124-126

Comment on lines +112 to +114
const assetId = thorPoolAssetIdToAssetId(pool.asset)
if (!assetId) return acc

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use pool.assetId instead of recomputing it; remove now-unneeded import

Pool already carries a non-optional assetId. Re-deriving it risks mismatches and unnecessary failures. This also lets you drop thorPoolAssetIdToAssetId from imports.

-import { getChainIdBySwapper, SwapperName, thorPoolAssetIdToAssetId } from '@shapeshiftoss/swapper'
+import { getChainIdBySwapper, SwapperName } from '@shapeshiftoss/swapper'
-      const assetId = thorPoolAssetIdToAssetId(pool.asset)
-      if (!assetId) return acc
+      const { assetId } = pool
-      const assetId = thorPoolAssetIdToAssetId(pool.asset)
-      if (!assetId) return acc
+      const { assetId } = pool

Also applies to: 136-138, 3-3

🤖 Prompt for AI Agents
In src/pages/ThorChainLP/queries/hooks/usePools.ts around lines 112-114 (and
likewise update 136-138 and the import at line 3), the code recomputes an
assetId via thorPoolAssetIdToAssetId(pool.asset) and guards on its falsiness;
instead use the existing pool.assetId property directly (e.g. const assetId =
pool.assetId) and remove the now-unneeded thorPoolAssetIdToAssetId import from
the top of the file so you no longer recompute or guard on a derived value.

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