-
-
Notifications
You must be signed in to change notification settings - Fork 368
feat: add dapp swap comparison button #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| feeBips, | ||
| ethAmountDisplay: ethAmountInput || DEFAULT_ETH_AMOUNT, | ||
| feePercentageDisplay: | ||
| feePercentageInput || DEFAULT_FEE_PERCENTAGE.toString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: UI shows invalid input; uses defaults for tx
The display values (ethAmountDisplay and feePercentageDisplay) can show invalid user input even though the actual transaction will use default values. When a user enters invalid input (e.g., "abc" for ETH amount or "200" for fee percentage), the display will show the invalid input, but getConfigValues() will use the default values for the actual transaction due to parseEthAmount()/parseFeePercentage() returning null for invalid input. This creates a mismatch between what the UI displays and what transaction will actually be sent.
| ethers.utils.parseEther(DEFAULT_ETH_AMOUNT).toHexString(); | ||
|
|
||
| const feeBips = | ||
| parseFeePercentage(feePercentageInput) || DEFAULT_FEE_PERCENTAGE * 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Zero-fee input misinterpreted as fifty percent
When a user enters 0 for the fee percentage, parseFeePercentage returns 0, which is falsy in JavaScript. The || operator then incorrectly falls back to DEFAULT_FEE_PERCENTAGE * 100 (5000 basis points), causing a 0% fee input to be treated as 50%. This prevents users from setting a zero fee for testing.
seaona
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good! Just added a small comment but non blocking
| <div class="card full-width"> | ||
| <div class="card-body"> | ||
| <h4 class="card-title"> | ||
| Swap Comparison (High Fee Test - Mainnet only) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
138ec5f
|
|
||
| document.addEventListener('newChainIdInt', function (e) { | ||
| swapButton.disabled = e.detail.chainIdInt !== 1; | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice addition 🙌

Note
Adds a configurable ETH→USDC swap comparison UI that builds/sends Universal Router calldata, enables only on mainnet, and is integrated into the transactions section.
swapComparisonComponentto compare an ETH→USDC swap with configurable fee (amount, fee %, recipient), status, and tx hash display.newChainIdInt,globalConnectionChange, anddisableAndClearevents.executecalldata using V4 actions (SWAP_EXACT_IN_SINGLE,SETTLE_ALL,TAKE_PORTION,TAKE_ALL) with ethers encoding and input validation.eth_sendTransactiontoUNIVERSAL_ROUTERwith user-specified ETH value.components/transactions/index.jsand render insrc/index.jstransactions row.newChainIdIntinhandleNewChainto drive component enablement.Written by Cursor Bugbot for commit 138ec5f. This will update automatically on new commits. Configure here.