Skip to content

Same token policy buy support#4463

Merged
extrawurst merged 7 commits into
mainfrom
same-token-policy-buy-support
Jun 3, 2026
Merged

Same token policy buy support#4463
extrawurst merged 7 commits into
mainfrom
same-token-policy-buy-support

Conversation

@extrawurst
Copy link
Copy Markdown
Contributor

@extrawurst extrawurst commented Jun 2, 2026

Description

Adds buy-side support for orders whose buy token equals the sell token (part of
#3963) via a new SameTokensPolicy::Allow variant. AllowSell only permitted
sell orders, so buy same-token quotes were rejected at validation.

This only adds the capability and test coverage — the default policy stays
Disallow and shipped configs keep AllowSell, so there is no production
behavior change until a config opts into allow.

Changes

  • Add the SameTokensPolicy::Allow variant and handle it in order validation.
  • Add a buy-side e2e test settling a same-token (WETH→ETH) order end to end.
  • Add unit coverage for Allow validation and for the same-token out_amount
    correction in the trade verifier, which buy quotes can now reach.

How to test

cargo nextest run -p shared -p configs -p price-estimation
cargo nextest run -p e2e local_node --run-ignored ignored-only --test-threads 1 --failure-output final

@extrawurst extrawurst requested a review from a team as a code owner June 2, 2026 15:40
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 implements buy-side support for same sell and buy token orders under the SameTokensPolicy::Allow policy. It updates the order validation logic, refactors the trade verifier's post-processing to support this verification, and adds corresponding unit and end-to-end tests. The feedback highlights a misleading comment in the newly added end-to-end test that describes a successful quote submission as an expected failure point, which should be updated or removed.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/e2e/tests/e2e/submission.rs Outdated
@extrawurst extrawurst force-pushed the same-token-policy-buy-support branch from 067da91 to ba4efbd Compare June 2, 2026 15:52
@extrawurst extrawurst changed the base branch from e2e-tests-in-devcontainer to main June 2, 2026 15:52
Comment thread crates/e2e/tests/e2e/submission.rs Outdated
Comment thread crates/e2e/tests/e2e/submission.rs Outdated
Comment thread crates/price-estimation/src/trade_verifier.rs Outdated
Comment thread crates/shared/src/order_validation.rs Outdated
Comment thread crates/price-estimation/src/trade_verifier.rs Outdated
extrawurst and others added 2 commits June 2, 2026 18:08
Co-authored-by: José Duarte <15343819+jmg-duarte@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@squadgazzz squadgazzz left a comment

Choose a reason for hiding this comment

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

LGTM, good tests 👍

Copy link
Copy Markdown
Contributor

@MartinquaXD MartinquaXD left a comment

Choose a reason for hiding this comment

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

Tests look good. So in practice no logic change was needed. We just needed to lift the limitation that buy orders are not supported.

Comment thread crates/shared/src/order_validation.rs
@extrawurst extrawurst added this pull request to the merge queue Jun 3, 2026
Merged via the queue into main with commit 1b74cd7 Jun 3, 2026
20 checks passed
@extrawurst extrawurst deleted the same-token-policy-buy-support branch June 3, 2026 13:15
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 3, 2026
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