Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(TokenClient): multicall balance & allowance queries #1496

Merged
merged 9 commits into from
May 14, 2024

Conversation

pxrl
Copy link
Contributor

@pxrl pxrl commented May 8, 2024

TokenClient update is occasionally observed to hang for 10s of seconds. It's a surprisingly RPC-intensive method because it issues a parallel RPC query for each supported token on a chain. This doesn't scale well with each new chain or token that's added, so bundle the queries into a multicall. The legacy implementation is retained for chains that don't support multicall3, which is nominally just hardhat in test.

To simplify this change, split out the HubPool BondToken query from the regular update() call. The BondToken part is so specific that it could optionally be pulled out of the TokenClient entirely.

TokenClient update is occasionally observed to hang for 10s of seconds.
It's a surprisingly RPC-intensive method because it issues a parallel
RPC query for each supported token on a chain. This doesn't scale well
with each new chain or token that's added, so bundle the queries into a
multicall. The legacy implementation is retained for chains that don't
support multicall3, which is nominally just hardhat in test.
src/clients/TokenClient.ts Outdated Show resolved Hide resolved
src/clients/TokenClient.ts Outdated Show resolved Hide resolved
src/clients/TokenClient.ts Outdated Show resolved Hide resolved
@pxrl
Copy link
Contributor Author

pxrl commented May 10, 2024

I've factored out the multicall3 aggregate() call to the SDK. The corresponding PR is here: across-protocol/sdk#644. This PR is now subject to that going in and a new SDK being produced.

@pxrl pxrl marked this pull request as ready for review May 14, 2024 11:39
Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

One potential code reuse suggestion otherwise lgtm

src/clients/TokenClient.ts Show resolved Hide resolved
@pxrl pxrl merged commit ed32ed2 into master May 14, 2024
4 checks passed
@pxrl pxrl deleted the pxrl/tokenClientMulticall branch May 14, 2024 18:15
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