Skip to content

Conversation

@0xAlunara
Copy link
Collaborator

@0xAlunara 0xAlunara commented Dec 11, 2025

To keep the PR small, the goal here is not to replace the Zustand stores & mapper just yet. The goal here is to only replace the actual balance fetching with wagmi core functionality. This allows using the useTokenBalance query everywhere, as it'll be fetching from the same (Tanstack) cache as whenever fetchTokenBalance is called by the stores, without actually relying on data from the store. In other words, it makes removing the stores for balances and tokens later easier.

This means that useTokenBalance has been refactored such that it uses getNativeBalanceQueryOptions and getERC20QueryContracts factory functions that can be re-used for the imperative fetchTokenBalance function (with a staleTime of 0 to ensure freshness as the stores expect).

After some checking I'm fairly confident that all native gas tokens use ethAddress as their token address in the Curve eco. This means we no longer need the token symbol to check if a token is a native gas token or not. This is good news, because we don't always have token symbols at hand, we often have merely the address at our disposal.

In the end I would've loved to use queryFactory, but it's not really suitable when using wagmi actions. You want to make proper use of its internal Tanstack logic when using both native wagmi hooks and a queryClient. For example, we don't really have any say in whatever queryKey it's using internally. Perhaps we could make a wagmiQueryFactory later, but that's some serious refactoring that I'm not willing to do now. And I'm not sure if that's even worthwhile.

Additional reading material if you question the method on how I've implemented fetchQuery.

@vercel
Copy link

vercel bot commented Dec 11, 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 16, 2025 8:30pm
curve-dapp-storybook Ready Ready Preview, Comment Dec 16, 2025 8:30pm

Copy link
Collaborator

@0xPearce 0xPearce left a comment

Choose a reason for hiding this comment

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

Not sure why but my USDC balance isn't showing up in the Preview, but does locally

localhost Preview
Image Image

0xPearce
0xPearce previously approved these changes Dec 12, 2025
OnlyJousting
OnlyJousting previously approved these changes Dec 15, 2025
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.

5 participants