Skip to content

Buy orders with same sell buy token#4274

Open
ashleychandy wants to merge 4 commits intocowprotocol:mainfrom
ashleychandy:buy-orders-with-same-sell-buy-token
Open

Buy orders with same sell buy token#4274
ashleychandy wants to merge 4 commits intocowprotocol:mainfrom
ashleychandy:buy-orders-with-same-sell-buy-token

Conversation

@ashleychandy
Copy link
Copy Markdown
Contributor

@ashleychandy ashleychandy commented Mar 18, 2026

Description

Enable sell=buy handling for native-equivalent trades by treating native wrapped token to ETH marker as same-token during order validation.
This is needed because the conversion path already exists downstream, but validation previously rejected these orders early.

Changes

  • Updated same-token validation logic to consider native wrapped token sell + ETH marker buy as same-token for policy evaluation.
  • Preserved existing policy behavior: allow-sell permits Sell orders, while Buy orders remain rejected.
  • Added unit test coverage for native-equivalent same-token cases under both disallow and allow-sell behavior.
  • Added e2e coverage for:
  • native-equivalent Sell quote/order success
  • native-equivalent Buy quote rejection under allow-sell policy

How to test

  1. cargo nextest run -p shared pre_validate_err pre_validate_same_tokens_allow_sell
  2. cargo nextest run -p e2e local_node_native_same_token_sell_with_eth_buy_marker local_node_native_same_token_buy_with_eth_buy_marker_rejected --test-threads 1 --run-ignored ignored-only --failure-output final

Related Issues

Fixes #4053

@ashleychandy ashleychandy requested a review from a team as a code owner March 18, 2026 17:31
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

No critical issues found.

@github-actions
Copy link
Copy Markdown

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 Mar 26, 2026
@m-sz
Copy link
Copy Markdown
Contributor

m-sz commented Mar 30, 2026

Hello @ashleychandy, thank You for Your contribution. I will review it thoroughly and we will either work together to ensure a smooth review or I might take over it to incorporate into a PR I am already working on. Will reach back to You tomorrow.

@github-actions github-actions bot removed the stale label Mar 31, 2026
… same token validation

Add tests for same sell and buy token validation in order processing
@ashleychandy ashleychandy force-pushed the buy-orders-with-same-sell-buy-token branch from fafce0b to 029fc4b Compare March 31, 2026 09:12
@ashleychandy
Copy link
Copy Markdown
Contributor Author

Hey @m-sz,
Thanks for taking a look, I appreciate it.

I’ve just pushed a small refactor to the validate_same_sell_and_buy_token logic along with some additional test coverage to make the behavior clearer and easier to reason about.

Happy to iterate based on your feedback, or if it fits better with your ongoing PR, I’m also fine with you incorporating the changes there. Just let me know how you’d prefer to proceed.

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.

chore:support native token with same sell and buy token

2 participants