Same token policy buy support#4463
Conversation
There was a problem hiding this comment.
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.
supporting buy orders for sell=buy
067da91 to
ba4efbd
Compare
Co-authored-by: José Duarte <15343819+jmg-duarte@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
MartinquaXD
left a comment
There was a problem hiding this comment.
Tests look good. So in practice no logic change was needed. We just needed to lift the limitation that buy orders are not supported.
Description
Adds buy-side support for orders whose buy token equals the sell token (part of
#3963) via a new
SameTokensPolicy::Allowvariant.AllowSellonly permittedsell orders, so buy same-token quotes were rejected at validation.
This only adds the capability and test coverage — the default policy stays
Disallowand shipped configs keepAllowSell, so there is no productionbehavior change until a config opts into
allow.Changes
SameTokensPolicy::Allowvariant and handle it in order validation.Allowvalidation and for the same-tokenout_amountcorrection in the trade verifier, which buy quotes can now reach.
How to test