Uniswap / interface

🦄 Open source interfaces for the Uniswap protocol
https://app.uniswap.org
GNU General Public License v3.0
4.93k stars 5k forks source link

Add network parameter to uniswap URLs #1893

Closed rahul-kothari closed 2 years ago

rahul-kothari commented 3 years ago

Is your feature request related to a problem? Please describe. I am working for the EF's Devcon ticketing team. We use uniswap as a way for users to pay for the tickets. And this devcon we are also integrating some L2 networks.

We basically create a uniswap URL and let user's pay through that. So for example: https://uniswap.exchange/send?exactField=output&exactAmount={exact_amount}&outputCurrency={output_currency}&recipient={recipient_address}

Except this always defaults to Ethereum mainnet. So say, I wanted to do this on Rinkeby testnet or optimism, because there is no network parameter, the website defaults to ETH Mainnet and reports that the tokens are unrecognised. The user would have to then manually connect their wallet to the right network to see the tokens. This isn't just poor UX for the user but also potentially dangerous. The non-sophisticated user wouldn't even realise what went wrong and may end up paying on the wrong network.

Describe the solution you'd like The URL to have a network/chainId parameter (default = 1). So if a chainId is provided, then the UI should default to the appropriate network (instead of currently assuming it is always eth mainnet).

https://uniswap.exchange/send?exactField=output&exactAmount={exact_amount}&outputCurrency={output_currency}&recipient={recipient_address}&chainId=3

This would be super helpful for when uniswap scales to other L2s.

Additional context image https://app.uniswap.org/#/swap?exactAmount=3500&outputCurrency=ETH&inputCurrency=0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735recipient=0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735&exactField=output

^ Convert DAI to ETH on Rinkeby testnet. However to a user, it would seem like there is nothing wrong here and end up paying on the wrong network.

willhennessy commented 3 years ago

Hi Rahul, thanks for the suggestion! @JFrankfurt are we able to change the network on command like this? I thought metamask imposes some limits

rahul-kothari commented 3 years ago

Any update on changing the URL? More useful now that uniswap is on optimism mainnet

willhennessy commented 3 years ago

Agreed, but we have a bunch of other tasks for L2 as well so we haven't had a chance to start yet sorry!

On Fri, Jul 16, 2021, 1:28 PM Rahul Kothari @.***> wrote:

Any update on changing the URL? More useful now that uniswap is on optimism mainnet

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Uniswap/uniswap-interface/issues/1893#issuecomment-881604329, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJT5WPFKNLYBACKWHRP33DTYBTZ5ANCNFSM47DJY7SA .

moodysalem commented 3 years ago

one thing we can do to alleviate the trickiness is have the network that the app is connected to be completely separate from the wallet

this will help with the dropdown as well

so we would always be using infura/network connector regardless of what wallet is connected, and only send signing requests to the wallet connector

will cost us more infura requests for metamask users

the app would be linkable with a network id, and that would just start the app with a particular network selected

one unknown--what to do when the user is connected to a different network when they want to send the transaction? need to disable buttons everywhere, lots of edge cases

moodysalem commented 3 years ago

one unknown--what to do when the user is connected to a different network when they want to send the transaction? need to disable buttons everywhere, lots of edge cases

another complication is that we need to fetch some data from mainnet always (e.g. token list ens urls, logo ens urls), so switching the network connector chain id will be a little difficult without breaking those things. we may want a app network connector, an always-mainnet network connector, and the wallet network connector to be three separate providers