Skip to content

fix(place-orders): two-call refresh + SELL recovery test#31

Merged
suhailkakar merged 1 commit into
mainfrom
suhail/post-then-recover-allowance
May 20, 2026
Merged

fix(place-orders): two-call refresh + SELL recovery test#31
suhailkakar merged 1 commit into
mainfrom
suhail/post-then-recover-allowance

Conversation

@suhailkakar
Copy link
Copy Markdown
Member

@suhailkakar suhailkakar commented May 20, 2026

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 retry POST /order when the API rejects with an allowance/balance 400 error: it checks current spender allowance, submits the appropriate approval (approve_erc20 for BUY, approve_erc1155_for_all for SELL), performs a two-call allowance refresh (/balance-allowance/update then /balance-allowance), and retries once.

Removes the previous preflight ensure_order_allowance check during signing, refactors allowance helpers to expose fetch_current_*_allowance utilities (including side/token-specific queries), and updates/expands unit tests to cover BUY/SELL recovery behavior and confirm create_*_order no longer hits allowance endpoints.

Reviewed by Cursor Bugbot for commit eb59ae8. Bugbot is set up for automated code reviews on this repo. Configure here.

@suhailkakar suhailkakar merged commit 7be2171 into main May 20, 2026
7 checks passed
@suhailkakar suhailkakar deleted the suhail/post-then-recover-allowance branch May 20, 2026 17:04
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.

2 participants