Skip to content

Skip balance check for flashloan orders#4278

Open
felixjff wants to merge 1 commit intocowprotocol:mainfrom
felixjff:feat/flashloan-skip-balance-check
Open

Skip balance check for flashloan orders#4278
felixjff wants to merge 1 commit intocowprotocol:mainfrom
felixjff:feat/flashloan-skip-balance-check

Conversation

@felixjff
Copy link
Copy Markdown

Summary

  • Flashloan orders get their sell tokens from the flashloan at settlement time, so they should not be filtered out due to insufficient user balance
  • Removes the restriction that flashloan orders must have the settlement contract as receiver
  • Flashloan orders now bypass balance allocation entirely, similar to CoW AMM orders

Flashloan orders get their sell tokens from the flashloan at settlement
time, so they should not be filtered out due to insufficient user
balance. Previously, flashloan orders were also required to have the
settlement contract as receiver, which is unnecessarily restrictive.
@felixjff felixjff requested a review from a team as a code owner March 20, 2026 03:05
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the handling of flashloan orders to bypass user balance checks and removes the restriction on the order's receiver. The implementation is correct for cases where application data is available. However, I've identified a high-severity logic error where flashloan orders may be incorrectly dropped if their application data fails to be fetched, which undermines the goal of this change.

@jmg-duarte
Copy link
Copy Markdown
Contributor

What is the motivation for this PR?

@felixjff
Copy link
Copy Markdown
Author

@jmg-duarte currently the Driver is filtering flashloan orders that don't have the settlement contract as receiver. I've noticed several flashloan orders have different receiver addresses (see example).

The constraint to only allow orders that have the settlement contract as receiver address seems outdated.

Could you explain what the logic behind that is? Why is the Driver allowing only flashloan orders through that have the settlement contract as receiver?

Copy link
Copy Markdown
Contributor

@jmg-duarte jmg-duarte left a comment

Choose a reason for hiding this comment

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

About the motivation, I miscommunicated.

Please update the PR description to include the reasoning behind the change, thanks in advance!

app_data: Arc<HashMap<order::app_data::AppDataHash, Arc<app_data::ValidatedAppData>>>,
cow_amm_orders: Arc<Vec<Order>>,
settlement_contract: &eth::Address,
_settlement_contract: &eth::Address,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove this parameter and update other call sites

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

This pull request has been marked as stale because it has been inactive a while. Please update this pull request or it will be automatically closed.

@github-actions github-actions bot added the stale label Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants