fix(place-orders): two-call refresh + SELL recovery test#31
Merged
Conversation
cesarenaldi
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Medium Risk
Changes the order placement flow to conditionally submit on-chain approval transactions and retry the order on specific 400 rejections, which can affect trading behavior and trigger side effects (approvals/relayer calls). Test coverage is added, but the logic depends on matching a backend error string and new side-effect endpoints.
Overview
Adds
post_order_with_allowance_recovery(async + sync) to retryPOST /orderwhen the API rejects with an allowance/balance 400 error: it checks current spender allowance, submits the appropriate approval (approve_erc20for BUY,approve_erc1155_for_allfor SELL), performs a two-call allowance refresh (/balance-allowance/updatethen/balance-allowance), and retries once.Removes the previous preflight
ensure_order_allowancecheck during signing, refactors allowance helpers to exposefetch_current_*_allowanceutilities (including side/token-specific queries), and updates/expands unit tests to cover BUY/SELL recovery behavior and confirmcreate_*_orderno longer hits allowance endpoints.Reviewed by Cursor Bugbot for commit eb59ae8. Bugbot is set up for automated code reviews on this repo. Configure here.