fix(checkout): price gas units before using them as a balance requirement - #2956
Merged
allan-almeida-imtbl merged 2 commits intoSep 30, 2026
Merged
Conversation
…ment gasCalculator summed the estimateGas results, which are gas units, and returned the sum as a wei amount for the native balance check. 200,000 gas became 200,000 wei, so the gas half of the affordability check could never fail and a wallet holding only the item price passed, then failed at submission with an out-of-funds error. The units are now multiplied by the current gas price, the same price the caller-supplied gas-limit branch already used, before they become a requirement. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
View your CI Pipeline Execution ↗ for commit 4903e74
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
… Passport wallets Now that the gas requirement is priced correctly it would ask a Passport wallet to hold native IMX for gas the relayer prices and collects instead. buy still runs Smart Checkout for Passport so the item price is checked and top-up routes offered, but passes no transaction or gas limit, which skips the gas requirement. sell already skipped Smart Checkout entirely for Passport; buy cannot, because buying needs funds. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ermyas
approved these changes
Sep 30, 2026
allan-almeida-imtbl
deleted the
allanalmeida/bloc-683-gas-calculator-units
branch
September 30, 2026 00:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Smart Checkout's gas affordability check has never been able to fail: it compares gas units against a wei balance. The gas estimate is now priced at the current gas price before it becomes a balance requirement.
Linear: BLOC-683 (parent BLOC-678, Fee model vector, zkEVM → OP Stack migration).
The bug, by example
A wallet holding 1.001 IMX buys a 1.0 IMX item. The purchase needs one approval plus the fulfilment. The node estimates 50,000 + 150,000 = 200,000 gas units, and the gas price is 10 gwei.
Today the check passes, the widget proceeds to signing, and the transaction is rejected at submission with an out-of-funds error. Smart Checkout never gets the chance to route the user to a top-up. The gas figure it adds is ten billion times too small to change the outcome, so in effect the check only tests the item price.
With this change the same wallet is told it is 0.001 IMX short and offered the insufficient-funds routes (on-ramp / swap) before anything is signed.
Detail and impact of the change
Fixed
gasCalculator(packages/checkout/sdk/src/smartCheckout/gas/gasCalculator.ts) summed theestimateGasresults for the approvals and the fulfilment transaction and returned that sum as a nativeItemRequirementwithisFee: true.estimateGasanswers in gas units. The sum is now multiplied bygetGasPriceInWei(feeData), fetched once alongside the estimates. The caller-supplied gas-limit branch (TransactionOrGasType.GAS) already did this multiplication; both branches now use the one price. If the node returns no usable fee data the calculator returnsnull(no gas requirement), which is what the gas-limit branch already did in that case.Changed
Visible to integrators using external wallets: a wallet that cannot cover gas now fails the affordability check and gets the insufficient-funds routes instead of a submission failure, and the routes' top-up amounts include real gas.
Passport wallets (review feedback). A Passport wallet does not pay gas from its native balance; the relayer prices and collects the fee. With the requirement now correctly sized,
buywould have asked a Passport user holding 50 USDC and no IMX to top up 0.002 IMX for gas they are never charged.buynow runs Smart Checkout for Passport without a transaction or gas limit, which skips only the gas requirement: the item-price check and the top-up routes stay. This differs fromsell, which skips Smart Checkout entirely for Passport, because listing needs no funds and buying does. Test added: a Passport provider reachessmartCheckoutwithundefinedas the gas argument.Anything else worth calling out?
🤖 Generated with Claude Code