feat(bridge): withdrawal fee estimates — request/confirm/cancel flow#403
Open
heyolaniran wants to merge 8 commits into
Open
feat(bridge): withdrawal fee estimates — request/confirm/cancel flow#403heyolaniran wants to merge 8 commits into
heyolaniran wants to merge 8 commits into
Conversation
Introduce developerFeePercent and withdrawalFeeEstimate settings (bridge fixed fee, gas limit, RPC URL, and fallbacks) for customer fee breakdown on Bridge withdrawals.
Add flash fee, Bridge rail fee (0.6%), and buffered Ethereum gas estimates, plus presenter helpers for pending vs receipt amounts.
Store flash, Bridge, gas, and total customer fee estimates on pending withdrawals and refresh them when reusing an existing pending request.
Resolve and persist fee estimates on request, map Bridge transfer receipt fees on initiate, improve Ibex balance error mapping, and pass developer_fee_percent when creating virtual accounts.
Expose flashFeeNotice copy explaining Flash, Bridge, and gas buffer components while totals remain estimates until Bridge settles.
Add estimated fee breakdown, subtotal/final amounts, receipt fees, and flashFeeNotice on BridgeWithdrawal for request and query paths.
Add a 3-step Bruno collection and extend existing withdrawal requests with fee field assertions and local env defaults.
- replay.spec.ts: spread jest.requireActual('@config') so getFeesConfig
survives the partial @config mock
- index.spec.ts: mock updateWithdrawalFeeEstimates in the dedup test so
stale clearAllMocks() impl doesn't bleed in from a prior test
- return-shapes.spec.ts: toEqual → toMatchObject for getWithdrawals shape
check, now that presentBridgeWithdrawal emits fee fields
- client-usd-wallet.spec.ts: spread jest.requireActual('ibex-client') so
IbexUrls survives the partial ibex-client mock
islandbitcoin
requested changes
Jun 12, 2026
Contributor
There was a problem hiding this comment.
Do we need to keep this file in the commit history?
Contributor
There was a problem hiding this comment.
Remove all the Bruno files so the PR has less noise
Contributor
There was a problem hiding this comment.
we should never check in an API key, not even a sandbox one. Remove this and purge it from commit history
| bridgeFixedFeePercent: { type: "number", default: 0.6 }, | ||
| usdtTransferGasLimit: { type: "integer", default: 65000 }, | ||
| gasPriceBufferMultiplier: { type: "number", default: 1.5 }, | ||
| ethereumGasRpcUrl: { type: "string", default: "https://cloudflare-eth.com" }, |
Contributor
There was a problem hiding this comment.
depending on only one URL for gas fees is a bottleneck. At a minimum we should be getting multiple sources and using an average, or getting the gas fee estimate from Bridge directly
| amount, | ||
| gasMarket, | ||
| config = getWithdrawalFeeEstimateConfig(), | ||
| developerFeePercent = BridgeConfig.developerFeePercent ?? 2, |
Contributor
There was a problem hiding this comment.
should this still be here? his a hardcoded default of 2 the right answer?
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
getFeesConfig/IbexUrls, staleclearAllMocksmock bleed,toEqual→toMatchObjectfor shape tests that now include fee fields)Test plan
yarn test:unit --testPathPattern="bridge"— all bridge unit tests passyarn test:unit --testPathPattern="ibex/client-usd-wallet"— ibex client test passesyarn test:unit— full unit suite green