Skip to content

Fix OKX approval sync before follow-up transactions#402

Draft
Seranged wants to merge 1 commit into
developmentfrom
fix/okx-approval-block-wait
Draft

Fix OKX approval sync before follow-up transactions#402
Seranged wants to merge 1 commit into
developmentfrom
fix/okx-approval-block-wait

Conversation

@Seranged

@Seranged Seranged commented May 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace OKX's fixed post-approval delay with a receipt/block-aware wait
  • wait for two blocks after approval plus a five-second floor before the next wallet prompt
  • keep the wait bounded so RPC or OKX lag cannot hang the operation flow indefinitely

Why

OKX can open the follow-up transaction review before its asset-change simulation sees the freshly confirmed approval. In that state it may show "Unable to decode asset changes" and disable confirmation. Waiting past the approval receipt block gives OKX more time to validate allowance state before the final tx prompt.

Test plan

  • npx eslint composables/useEulerOperations/execution.ts
  • npm run typecheck
  • manual OKX extension test: Permit2 approval waits until approval block + 2 before opening the deposit prompt

Summary by CodeRabbit

  • Bug Fixes
    • Improved transaction confirmation handling for OKX wallet users with more efficient blockchain-based confirmation waiting instead of fixed delays.

Review Change Stack

@railway-app

railway-app Bot commented May 10, 2026

Copy link
Copy Markdown

🚅 Deployed to the euler-lite-pr-402 environment in euler-lite

Service Status Web Updated (UTC)
production-master-branch ✅ Success (View Logs) Web May 10, 2026 at 2:36 pm

@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Post-approval timing for OKX wallet transactions is refactored from a fixed delay to a block-based confirmation strategy. OKX detection is performed once per execution instead of per approval step. New timing constants, a sleep helper, and a block confirmation polling function enable concurrent minimum-delay and block-confirmation waiting after each approval step.

Changes

OKX Post-Approval Block Confirmation Timing

Layer / File(s) Summary
Timing Constants
composables/useEulerOperations/execution.ts
New constants define block count to wait (BLOCKS_TO_WAIT), minimum wall-clock delay (MIN_DELAY_MS), total timeout (TIMEOUT_MS), and poll interval (POLL_INTERVAL_MS) for OKX post-approval confirmation.
Helper Functions
composables/useEulerOperations/execution.ts
sleep(ms) utility provides Promise-based delays. waitForPostApprovalConfirmations(receipt) polls getBlockNumber() until target block is reached, with timeout enforcement and error/timeout warning logs.
Integration: Detection & Approval Handling
composables/useEulerOperations/execution.ts
OKX wallet detection (usesOkxWallet) is computed once at the start of executeTxPlan. Approval-step handling concurrently waits for minimum delay and block confirmations when OKX is detected and a receipt is available, replacing the previous per-step fixed delay.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • euler-xyz/euler-lite#294: Both PRs modify composables/useEulerOperations/execution.ts to improve OKX wallet post-approval timing—the earlier PR adds a fixed 3-second delay, while this PR replaces it with block-confirmation polling and consolidates OKX detection.

Suggested reviewers

  • kasperpawlowski

Poem

🐰 Blocks tick faster than clocks do stay,
OKX waits the blockchain's way,
No more delays of fixed design—
Confirmations polled in perfect time,
One check at start, then swift delight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing OKX approval synchronization timing before follow-up transactions, which matches the primary objective of replacing fixed delays with block-based confirmation waits.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/okx-approval-block-wait

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@composables/useEulerOperations/execution.ts`:
- Around line 10-13: The hard 15000ms cap (OKX_POST_APPROVE_BLOCK_TIMEOUT_MS)
can expire before approvalBlock + OKX_POST_APPROVE_CONFIRMATION_BLOCKS on slow
chains; replace the fixed cap with a dynamic timeout computed from an estimated
block time (e.g., estimatedBlockTimeMs * OKX_POST_APPROVE_CONFIRMATION_BLOCKS)
plus a small buffer, or fetch recent block timestamps from the provider to
calculate a runtime block-time and use max(dynamicTimeout, a sensible minimum
like 15s) when polling (the poll loop that uses OKX_POST_APPROVE_MIN_DELAY_MS,
OKX_POST_APPROVE_BLOCK_POLL_MS, and OKX_POST_APPROVE_BLOCK_TIMEOUT_MS should
instead use this dynamicTimeout); alternatively expose the timeout as
configurable so environments with ~12s blocks can increase it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: euler-xyz/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ff3319e1-b4c2-46bc-a798-b14a669e1b33

📥 Commits

Reviewing files that changed from the base of the PR and between 33b7417 and 76aeca4.

📒 Files selected for processing (1)
  • composables/useEulerOperations/execution.ts

Comment thread composables/useEulerOperations/execution.ts
@Seranged Seranged marked this pull request as draft May 11, 2026 12:36
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.

1 participant