Skip to content

fix(pay): deduplicate wrapped-token ops to prevent double-unwrap revert#108

Open
jeremie-olivier wants to merge 1 commit into
devfrom
fix/split-payment-double-unwrap
Open

fix(pay): deduplicate wrapped-token ops to prevent double-unwrap revert#108
jeremie-olivier wants to merge 1 commit into
devfrom
fix/split-payment-double-unwrap

Conversation

@jeremie-olivier

Copy link
Copy Markdown

Summary

  • Replaces the broken simulatedBalances approach (pathfinder ignored the LiftERC20 address as the token field, so both legs still planned identical unwraps)
  • Adds deduplicateWrappedOps post-processing on the merged tx batch:
    • Keeps one unwrap(uint256) per LiftERC20 contract, skipping duplicates
    • Collects all wrap(address,uint256,uint8) rewraps grouped by (hub + avatar)
    • Defers all rewraps to end of batch (after both transfers)
    • Merges duplicate rewraps: rewrap_merged = rewrap_1 + rewrap_2 - unwrap = X - A - B
  • Both legs are built concurrently again (no more sequential dependency)

Result tx order: [unwrap, transfer_foundation, transfer_expert, rewrap_merged]

Test plan

  • Book a session with expert share > 0% in the Circles playground
  • Confirm the tx batch has exactly one de0e9a3e unwrap (not two)
  • Confirm the payment executes without UserOperation reverted with reason: 0x
  • Confirm both legs (foundation + expert) receive correct amounts on-chain

🤖 Generated with Claude Code

Both payment legs planned identical unwrap(uint256) calls on the same
LiftERC20 contract. The second unwrap reverted with 0x because the
balance was already consumed by the first.

Replace simulatedBalances approach (pathfinder ignored wrong token field)
with post-processing deduplication: keep one unwrap per contract, collect
all rewraps per (hub, avatar) group, defer them to end of batch, and
merge amounts as rewrap_1 + rewrap_2 - unwrap = X - A - B.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gnosis-box

gnosis-box Bot commented May 25, 2026

Copy link
Copy Markdown

The preview deployment for gnosis-box/-t-h-p-for--good:-dev-z8o0444888o4o0ks88kk40k4 is ready. 🟢

Open Preview | Open Build Logs | Open Application Logs

Last updated at: 2026-05-25 01:17:59 CET

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