Skip to content

fix(ethereum): check the allowance when the spender appears at prepare - #521

Merged
chybisov merged 7 commits into
mainfrom
fix/ethereum-recheck-allowance-after-prepare
Oct 21, 2026
Merged

chybisov merged 7 commits into
mainfrom
fix/ethereum-recheck-allowance-after-prepare

Conversation

@Kayanski

@Kayanski Kayanski commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Which Linear task is linked to this PR?

None yet. Follow-up to JUM-1642 (Relay routes asking users to approve the wrong spender).

Why was it implemented this way?

Some providers, like Relay, only know the ERC-20 spender once /stepTransaction runs. The allowance tasks run before that, so today the backend has to guess the spender, and a wrong guess makes the transaction revert.

Now the backend can leave estimate.approvalAddress empty at routing time and set it in /stepTransaction. A new EthereumCheckAllowanceAfterPrepareTask runs after PrepareTransaction, but only when the spender was empty before prepare and is set after it. It reuses the existing allowance tasks (and adds the approval to the batch in batched mode).

Nothing changes for steps that already have a spender, native permits, Permit2, or steps that skip approval.

Rollout: only send an empty spender to clients on this SDK version. Older versions skip the approval and the transaction reverts.

Visual showcase (Screenshots or Videos)

New approvalAddressAtPrepare.flow.spec.ts covers: approve needed, allowance already enough, batched, spender moved by the re-quote (unchanged), and no spender at all. Without the new task, the first three fail.

Checklist before requesting a review

  • I have performed a self-review and testing of my code.
  • This pull request is focused and addresses a single problem.
  • If this PR modifies the SDK API or adds new features that require documentation, I have updated the documentation in the public-docs repository. (No public API change.)

🤖 Generated with Claude Code

…epare

/stepTransaction can move estimate.approvalAddress after the allowance
tasks approved the routing-time spender (Relay only knows the spender
once it builds the executable transaction). The transaction then went out
against a spender with no allowance and reverted.

A new task after PrepareTransaction reads the allowance for the new
spender and resets/sets it only if it falls short. In batched it drops
the approval queued for the old spender.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 79f4854

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@lifi/sdk-provider-ethereum Patch
@lifi/sdk-provider-tron Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle size

✅ No significant changes. Every check is within budget.

@lifi/sdk

Import Base PR Change Budget used
⚪ createClient + getQuote 4.31 kB 4.31 kB — ▰▰▰▰▰▰▰▱▱▱ 72%
⚪ all exports 16.0 kB 16.0 kB — ▰▰▰▰▰▰▰▰▱▱ 80%
⚪ CJS (no tree-shaking) 19.4 kB 19.4 kB — ▰▰▰▰▰▰▰▰▱▱ 81%

Providers

Import Base PR Change Budget used
⚪ ethereum (+ viem) 96.9 kB 96.8 kB 🔻 −0.07 kB (−0.1%) ▰▰▰▰▰▰▰▰▱▱ 84%
⚪ solana 28.3 kB 28.3 kB — ▰▰▰▰▰▰▰▰▱▱ 83%
⚪ bitcoin 68.1 kB 68.1 kB — ▰▰▰▰▰▰▰▰▱▱ 83%
⚪ sui 98.2 kB 98.2 kB — ▰▰▰▰▰▰▰▰▰▱ 89%
⚪ tron 213.1 kB 213.2 kB 🔺 +0.11 kB (+0.1%) ▰▰▰▰▰▰▰▰▰▱ 92%
⚪ stellar 122.9 kB 122.9 kB — ▰▰▰▰▰▰▰▰▱▱ 83%
⚪ zcash 6.45 kB 6.45 kB — ▰▰▰▰▰▰▰▰▱▱ 81%

Full integration

Import Base PR Change Budget used
⚪ createClient + all providers 588.2 kB 587.9 kB 🔻 −0.38 kB (−0.1%) ▰▰▰▰▰▰▰▰▰▱ 87%
How to read this
  • Sizes are minified + brotli, measured with size-limit the way an app bundles the import: tree-shaken, with all dependencies included except the ones in the check's ignore list (packages the app already has, such as peers).
  • Code behind a dynamic import() is counted too, unless the check's name says otherwise.
  • 🟠 / 🟢 mark a change of at least 512 B and at least 1% or 5.00 kB. 🔴 means the check is over its budget.
  • Budgets live in .size-limit.json. The base commit is measured with the same checks as the PR.

79f4854 merged into 6e0e588 · workflow run

…repare

Narrow the post-prepare allowance task to a step that had no
estimate.approvalAddress before prepare and gets one from /stepTransaction.
A step that already had a spender behaves as before, even if the re-quote
moves it. This lets a provider leave the spender empty at routing time
instead of guessing, so the user never approves a wrong contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kayanski Kayanski changed the title fix(ethereum): check the allowance again when the spender moves at prepare fix(ethereum): check the allowance when the spender appears at prepare Oct 15, 2026
@Kayanski
Kayanski marked this pull request as ready for review October 15, 2026 12:02
@Kayanski
Kayanski requested a review from chybisov October 15, 2026 12:04
Kayanski and others added 4 commits October 15, 2026 14:22
Mirror the Ethereum post-prepare allowance task for Tron. A TRC-20 step
that had no estimate.approvalAddress before prepare and gets one from
/stepTransaction now reads the allowance for it and approves only if it
falls short, before the transaction is signed. Relay on Tron only knows
its depository spender once it builds the executable transaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…it2 chain

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kayanski Kayanski added the release-preview Publish a 0.0.0-preview-<sha> build of this PR to npm label Oct 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Preview published under the preview dist-tag.

Install the exact version(s) — @preview moves with the newest preview across PRs:

npm i @lifi/sdk-provider-ethereum@0.0.0-preview-069261a2
npm i @lifi/sdk-provider-tron@0.0.0-preview-069261a2

@github-actions github-actions Bot removed the release-preview Publish a 0.0.0-preview-<sha> build of this PR to npm label Oct 16, 2026
@chybisov
chybisov merged commit 7d9a726 into main Oct 21, 2026
6 checks passed
@chybisov
chybisov deleted the fix/ethereum-recheck-allowance-after-prepare branch October 21, 2026 09:18
@github-actions github-actions Bot mentioned this pull request Oct 21, 2026
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