Skip to content

feat: fetch gasless transactions for BatchSell quotes#8805

Open
micaelae wants to merge 13 commits into
mainfrom
swaps4444-batch-trades
Open

feat: fetch gasless transactions for BatchSell quotes#8805
micaelae wants to merge 13 commits into
mainfrom
swaps4444-batch-trades

Conversation

@micaelae
Copy link
Copy Markdown
Member

@micaelae micaelae commented May 14, 2026

Explanation

Implements the updateBatchSellTrades handler which calls the obtainGaslessBatch to estimate network fees for BatchSell quotes. Clients will need to call the handler whenever the selectBatchQuotes selector's recommended quotes change

A new selector selectBatchSellTrades has also been added, which returns whether a batch is submittable, and the totalNetworkFee provided by the obtainGaslessBatch endpoint and its converted values

References

Fixes https://consensyssoftware.atlassian.net/browse/SWAPS-4444

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Adds a new async fetch path and state for BatchSell gasless trade/fee data, including abort/error handling and new API response validation. Risk is moderate because it changes quote-related state shape and moves totalNetworkFee for batch sells to a new selector/endpoint.

Overview
Adds BatchSell gasless trade/fee fetching via BridgeController:updateBatchSellTrades, calling the bridge API POST /obtainGaslessBatch and storing results in new state fields batchSellTrades and batchSellTradesLoadingStatus (with abort-on-new-fetch/reset and stale-data clearing on new quote requests).

Introduces selectBatchSellTrades to surface batch submittability and a computed totalNetworkFee (with currency conversions); breaking: removes totalNetworkFee from selectBatchSellQuotes.

Extends types/validators to model and validate the new response (BatchSellTradesResponse, fee schema, tx type, gas limit fields) and updates tests/snapshots accordingly; also removes some unnecessary Hex type assertions in bridge-status-controller and transaction-pay-controller.

Reviewed by Cursor Bugbot for commit 28e4c4c. Bugbot is set up for automated code reviews on this repo. Configure here.

@micaelae micaelae force-pushed the swaps4444-batch-trades branch from 812aa2e to c01f799 Compare May 14, 2026 00:46
@micaelae micaelae marked this pull request as ready for review May 14, 2026 01:04
@micaelae micaelae requested a review from a team as a code owner May 14, 2026 01:04
@micaelae micaelae temporarily deployed to default-branch May 14, 2026 01:05 — with GitHub Actions Inactive
@micaelae micaelae requested a review from a team as a code owner May 14, 2026 01:06
Comment thread packages/bridge-controller/src/bridge-controller.ts
Comment thread packages/bridge-controller/src/bridge-controller.ts
@micaelae micaelae requested a review from a team as a code owner May 15, 2026 19:16
@micaelae micaelae enabled auto-merge May 15, 2026 19:50
Comment thread packages/bridge-controller/src/bridge-controller.ts
@micaelae micaelae disabled auto-merge May 15, 2026 19:58
@micaelae micaelae enabled auto-merge May 15, 2026 20:00
GeorgeGkas
GeorgeGkas previously approved these changes May 15, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 28e4c4c. Configure here.

selectExchangeRateByAssetId(
state,
state.batchSellTrades?.fee.asset?.assetId,
),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing optional chaining on fee causes runtime crash

Medium Severity

The selectBatchSellFees input selectors access state.batchSellTrades?.fee.amount, state.batchSellTrades?.fee.asset, and state.batchSellTrades?.fee.asset?.assetId without optional chaining after fee. The BatchSellTradesResponseSchema defines fee as optional(...), so when batchSellTrades is non-null but fee is undefined, these expressions throw a TypeError because .amount / .asset is accessed on undefined. The combiner's truthiness check doesn't help since the crash occurs in the input selectors before the combiner runs.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 28e4c4c. Configure here.

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