Skip to content

fix(bridge): estimate at USDC precision instead of 2 decimals - #42

Open
mrnetwork0001 wants to merge 1 commit into
circlefin:masterfrom
mrnetwork0001:fix/bridge-estimate-usdc-precision
Open

fix(bridge): estimate at USDC precision instead of 2 decimals#42
mrnetwork0001 wants to merge 1 commit into
circlefin:masterfrom
mrnetwork0001:fix/bridge-estimate-usdc-precision

Conversation

@mrnetwork0001

Copy link
Copy Markdown

app/api/bridge/estimate/route.ts formats the amount for App Kit with toFixed(2):

// App Kit expects amount in human-readable decimal format
const amountString = amountNum.toFixed(2);

But USDC has 6 decimals, and app/api/bridge/rebalance/route.ts executes the transfer at full precision:

const bridgeAmountString = (amountNum + estimatedBridgeFee).toFixed(6);

Two consequences:

The quote prices a different amount than the transfer. 12.3456 USDC is estimated as 12.35, then bridged as 12.3456 + fee.

Sub-cent amounts are estimated as zero. components/dialogs/use-bridge-fee-estimates.ts fires an estimate for any parseFloat(amount) > 0, so 0.001 USDC 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.

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.
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