Skip to content

Conversation

@squadgazzz
Copy link
Contributor

Description

Fetching COW AMM token balances takes a lot of time on base due to a high number of AMMs. In order to speed things up a bit, it is suggested to use FuturesUnordered, which is a better approach than FuturesOrdered, which is used by futures_util::future::join_all when the number of futures exceeds 30.

How to test

Staging

Copilot AI review requested due to automatic review settings November 25, 2025 20:47
@squadgazzz squadgazzz requested a review from a team as a code owner November 25, 2025 20:47
@squadgazzz squadgazzz changed the title Use FuturesUnordered when fetching COW AMM balances Use FuturesUnordered when fetching COW AMM balances Nov 25, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the performance of COW AMM balance fetching on Base by replacing join_all (which uses FuturesOrdered for >30 futures) with FuturesUnordered. This change allows futures to complete in any order, improving concurrency when checking a high number of AMMs for zero token balances.

Key changes:

  • Replaced join_all with FuturesUnordered for concurrent balance checking
  • Refactored async closure to use async move block for better ownership handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fafk fafk added this pull request to the merge queue Nov 26, 2025
Merged via the queue into main with commit 1ad7431 Nov 26, 2025
18 checks passed
@fafk fafk deleted the improve-amm-zero-balance-task branch November 26, 2025 11:42
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants