Skip to content

Conversation

@0xAlunara
Copy link
Collaborator

The following PR reasons about the existing store + fetching infrastructure. In the future, we will replace it with hooks + queries, but for now:

  1. The dex global slice calls await state.pools.fetchPools(config, curveApi, poolIds, failedFetching24hOldVprice) during hydration

  2. fetchPools fetches all pool user balances with the following snippet:

    const partialTokens = await tokens.setTokensMapper(curve, partialPoolDatas)
    
    if (curve.signerAddress) {
      void userBalances.fetchUserBalancesByTokens(config, curve, partialTokens)
    }

    Therefore, during hydration all tokens balances are being fetched already.

  3. In addition, inside the useAutoRefresh of the dex layout, we have:

    usePageVisibleInterval(() => {
      if (curveApi) {
        void fetchPoolsVolumeTvl(curveApi)
    
        if (curveApi.signerAddress) {
          void fetchAllStoredBalances(config, curveApi)
        }
      }
    }, REFRESH_INTERVAL['5m'])

    Therefore, all user balances already get periodically updated and hence we can remove:

    useEffect(() => {
      void updateTokenList(config, isReady ? curve : null, tokensMapper)
      // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [config, isReady, tokensMapperStr, curve?.signerAddress])

    from the quick swap page, which gets triggered each time you switch tabs in the browser.

    In addition, user balances are also being fetched already when updating the quick swap form by setFormValues with:

    if (curve.signerAddress)
      await sliceState.fetchUserBalances(config, curve, searchedParams.fromAddress, searchedParams.toAddress)

    Which means the form will use the latest balances anyway

@vercel
Copy link

vercel bot commented Dec 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
curve-dapp Ready Ready Preview, Comment Dec 20, 2025 2:10pm
curve-dapp-storybook Ready Ready Preview, Comment Dec 20, 2025 2:10pm

@0xAlunara 0xAlunara merged commit 9758f22 into main Dec 22, 2025
16 checks passed
@0xAlunara 0xAlunara deleted the refactor/remove-unnecessary-token-balance-fetching-on-quickswap branch December 22, 2025 13:11
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.

4 participants