defi

Keeping Bungee Bridge quotes current

Refresh the quote immediately before building the transaction. A route is a price estimate tied to changing liquidity and bridge conditions, so your app should keep the displayed output and the transaction it builds in sync.

What can make a quote stale?

A cross-chain route can combine a source-chain swap, a bridge transfer, and a destination-chain swap. Each part affects the estimated output; token prices, available liquidity, and execution costs can change while a user reviews the route.

For example, an illustrative quote might send 100 USDC from Ethereum and estimate 98.70 USDC on Polygon after swaps and costs. If a refreshed quote estimates 98.35 USDC, update the amount shown and ask the user to review it before building. Do not show 98.70 while quietly building from the newer route.

When route selection is still the open question, see how Bungee Bridge routes compare for the selection detail. This post focuses on keeping that choice current through transaction construction. The official Bungee app can also serve as a reference for comparing cross-chain transfers.

How should an integrator refresh and build?

Use the quote response that matches the user’s latest choices as the input to transaction construction. In the Socket API, that generally means requesting a quote, then passing the chosen route to the build-transaction endpoint; the route can include intermediate swaps as well as the bridge.

  1. Requote when intent changes. Fetch a new quote if the user changes the source amount, either token, either chain, or the recipient. Send token amounts in raw units: for a six-decimal token, 100 USDC is 100,000,000.
  2. Present the complete route. Show the estimated destination amount and any relevant source-side requirements before the user commits. Treat the estimate as conditional, not as a guaranteed arrival amount.
  3. Build from the selected response. Immediately before building, use the latest quote for the same inputs and pass its route data to the build endpoint. If the route cannot be built, quote again and present the new estimate for review.
  4. Check approval and submit. For an ERC-20, verify whether the required spender has allowance; if not, the wallet may need to approve before submitting the bridge transaction. Then have the user sign and submit on the source chain.
  5. Track the transfer separately. Once submitted, use the source transaction details with the bridge-status endpoint to follow cross-chain progress. A confirmed source transaction does not by itself mean the destination transfer is complete.

What edge case should the interface handle?

A quote can remain valid for the original amount while becoming wrong for the user’s actual intent. For instance, if the user edits 100 USDC to 120 USDC after seeing a route, reusing the old route may fail during build or produce a transaction that does not match the amount they reviewed.

Keep the quote inputs alongside the route in application state and compare them before building. In practice, I invalidate on any input change and refresh again at confirmation; I do not rely on a fixed quote lifetime unless the API explicitly provides one.

Practical tip: make the confirmation summary come from the same refreshed route object that you pass to transaction construction.