Skip to content

Quote swaps the wallet cannot pay for - #519

Open
j0ntz wants to merge 2 commits into
masterfrom
jon/ignore-balances-for-quoting
Open

j0ntz wants to merge 2 commits into
masterfrom
jon/ignore-balances-for-quoting

Conversation

@j0ntz

@j0ntz j0ntz commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none (the new fields are declared locally until EdgeApp/edge-core-js#750 publishes)

Description

Asana task

Quotes a swap the wallet cannot pay for when the request opts in with allowInsufficientFunds. Users can then compare rates before moving funds into Edge.

The first commit splits makeSwapPluginQuote into helpers with no behavior change. The second adds the behavior:

  • Without the flag, an InsufficientFundsError from the wallet still rejects the quote as it does on master.
  • With the flag, the helper retries the spend with skipChecks to price the network fee. If the engine still refuses, it reads the fee from the error, and falls back to zero when neither source has one.
  • The resulting quote carries insufficientFunds and its approve always throws the shortfall. It can never broadcast.

Plugins with their own balance gates or a transaction sent before the swap (lifi, xrpDex, token approvals on uni-v2 forks and Rango) are unchanged. They still throw when short and drop out of the results, because letting them through could produce an unflagged quote that broadcasts a transaction doomed to fail.

The new fields are declared locally in src/swap/types.ts, which keeps this PR passing CI against the published core.

j0ntz added 2 commits October 31, 2026 18:51
No behavior change. The transaction build, the saved-action read, and the
fee total move out of makeSwapPluginQuote so another quote path can share them.
When a request sets allowInsufficientFunds and the order fails only on funds,
the shared quote helper now returns a quote carrying the shortfall. It tries a
build without balance checks for a real fee, then falls back to the fee on the
error. The quote's approve always throws, so nothing unpaid reaches the network.

Plugins that check the balance themselves or need an approval transaction first
keep throwing and drop out of the results.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-01T02:37:59.253890Z
We couldn’t complete this review. Comment @codex review to try again.
64acd72 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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