Skip to content

fix(swapper): buffer BobGateway EVM gas limit and raise default slippage - #12428

Merged
kaladinlight merged 3 commits into
developfrom
fix/bob-gateway-evm-gas-buffer-slippage
Jun 15, 2026
Merged

fix(swapper): buffer BobGateway EVM gas limit and raise default slippage#12428
kaladinlight merged 3 commits into
developfrom
fix/bob-gateway-evm-gas-buffer-slippage

Conversation

@kaladinlight

@kaladinlight kaladinlight commented Jun 15, 2026

Copy link
Copy Markdown
Member

Description

Two small, focused fixes for the BOB Gateway swapper:

  1. Buffer the EVM broadcast gas limit by 20%getUnsignedEvmTransaction now pads the gas limit of the tx we actually sign/broadcast by 1.2×. This reduces the risk of out-of-gas reverts on the final tx, since the quote-time gas estimate can under-estimate actual execution.

    • The buffer is applied only to the broadcast gas limit (a ceiling). The displayed network fee (getEvmTransactionFees) is intentionally left unbuffered so quote fee comparisons stay honest, and unused gas is refunded — so the fee actually paid by the user is unaffected.
    • Consistent with the existing ~20% gas-limit buffer pattern used elsewhere (e.g. 0x/ZRX swapper).
  2. Raise BOB Gateway default slippage to 3% (0.005 → 0.03) — aligns with the higher default already used for other bridge-style swappers where off-chain quote estimates can drift.

Issue (if applicable)

closes #

Risk

Low-to-moderate. Touches the on-chain EVM transaction for BOB Gateway sells (gas limit only — no change to to/value/data), plus a default slippage tolerance bump.

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

BOB Gateway swapper only (EVM → BOB / EVM sells, and EVM→BTC offramp). Gas-limit padding affects every BOB Gateway EVM broadcast tx; slippage change affects BOB Gateway quotes.

Testing

Engineering

  • Initiate a BOB Gateway EVM sell and inspect the unsigned tx — confirm gasLimit is ~1.2× the raw estimate, while the network fee shown in the trade input is unchanged (uses the unbuffered estimate).
  • Confirm a BOB Gateway quote now defaults to 3% slippage tolerance.

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

N/A

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Increased default slippage tolerance for BobGateway swapper to improve transaction stability.
    • Enhanced gas limit calculation for BobGateway EVM transactions with additional padding for improved reliability.

kaladinlight and others added 2 commits June 15, 2026 10:31
Pad only the gas limit of the broadcast tx (a ceiling) to reduce the risk
of out-of-gas reverts. The displayed network fee (getEvmTransactionFees) is
left unbuffered, and unused gas is refunded, so the fee actually paid is
unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kaladinlight
kaladinlight requested a review from a team as a code owner June 15, 2026 16:47
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Two numeric parameter adjustments for the BobGateway swapper: the default slippage decimal percentage is raised from '0.005' to '0.03', and getUnsignedEvmTransaction now computes a padded gas limit (feeData.gasLimit × 1.2) via bnOrZero and passes it explicitly to adapter.buildCustomApiTx.

Changes

BobGateway Parameter Adjustments

Layer / File(s) Summary
Default slippage constant
packages/swapper/src/constants.ts
BobGateway's entry in getDefaultSlippageDecimalPercentageForSwapper is updated from '0.005' to '0.03'.
Gas limit 1.2× padding
packages/swapper/src/swappers/BobGatewaySwapper/endpoints.ts
bnOrZero is imported and getUnsignedEvmTransaction multiplies feeData.gasLimit by 1.2, forwarding the result as an explicit gasLimit to adapter.buildCustomApiTx.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐇 A slippage so small made the bunny fret,
So we bumped it up — no regrets yet!
The gas was too tight, transactions would fail,
We padded by 1.2 — now swaps shall prevail!
Hop on, BobGateway, smooth is the trail! 🌿

🚥 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 concisely summarizes both main changes: buffering the BobGateway EVM gas limit by 20% and raising the default slippage tolerance, which are the primary modifications in the changeset.
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/bob-gateway-evm-gas-buffer-slippage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@packages/swapper/src/swappers/BobGatewaySwapper/endpoints.ts`:
- Around line 100-102: The gasLimit calculation in the file uses toFixed(0)
which performs standard rounding and can round down, potentially undermining the
intended 20% padding buffer. Replace the toFixed(0) rounding with an explicit
ceiling operation (using a method like Math.ceil or equivalent BigNumber ceiling
method) to ensure the padded gas limit is always rounded up and never falls
below the computed 1.2x multiplier result.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 98331311-0229-4a19-9cf3-34de14837464

📥 Commits

Reviewing files that changed from the base of the PR and between 3ff114f and 7628c01.

📒 Files selected for processing (2)
  • packages/swapper/src/constants.ts
  • packages/swapper/src/swappers/BobGatewaySwapper/endpoints.ts

Comment thread packages/swapper/src/swappers/BobGatewaySwapper/endpoints.ts
@kaladinlight
kaladinlight enabled auto-merge (squash) June 15, 2026 16:54
@kaladinlight
kaladinlight merged commit 93f4088 into develop Jun 15, 2026
4 checks passed
@kaladinlight
kaladinlight deleted the fix/bob-gateway-evm-gas-buffer-slippage branch June 15, 2026 17:06
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