fix(bridge): estimate at USDC precision instead of 2 decimals - #42
Open
mrnetwork0001 wants to merge 1 commit into
Open
fix(bridge): estimate at USDC precision instead of 2 decimals#42mrnetwork0001 wants to merge 1 commit into
mrnetwork0001 wants to merge 1 commit into
Conversation
The estimate route formats the amount with toFixed(2), but USDC has 6 decimals
and app/api/bridge/rebalance/route.ts executes the transfer with toFixed(6).
Two consequences:
- 12.3456 USDC is quoted as 12.35 but bridged as 12.3456 + fee, so the fee
estimate prices a different amount than the transfer.
- Any amount below 0.005 USDC is quoted as "0.00".
Aligns the estimate with the precision the rebalance already uses.
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.
app/api/bridge/estimate/route.tsformats the amount for App Kit withtoFixed(2):But USDC has 6 decimals, and
app/api/bridge/rebalance/route.tsexecutes the transfer at full precision:Two consequences:
The quote prices a different amount than the transfer.
12.3456USDC is estimated as12.35, then bridged as12.3456 + fee.Sub-cent amounts are estimated as zero.
components/dialogs/use-bridge-fee-estimates.tsfires an estimate for anyparseFloat(amount) > 0, so0.001USDC reaches the route and is sent to App Kit as"0.00".This changes the estimate to
toFixed(6), matching the precision the rebalance route already uses, so the quote is priced for the amount actually transferred.One-line change plus a comment explaining why the precision matters.