Cointime

Download App
iOS & Android

Uniswap Labs Has Released Two New Smart Contracts

Today, Uniswap Labs has released two new smart contracts:

Permit2 allows token approvals to be shared and managed across different applications creating a more unified, cost-efficient, and safer UX.

Universal Router unifies ERC20 and NFT swapping into a single swap router. Integrated with Permit2, users can swap multiple tokens and NFTs in one swap while saving on gas fees.

We originally conceived Permit2 and Universal Router to improve our own products, optimizing gas costs, simplifying user transaction flows, and strengthening security. As we ideated, we realized that other applications could greatly benefit from integrating these contracts. Uniswap is committed to building public infrastructure that pushes crypto forward, which is why we designed these contracts to be used by the entire developer ecosystem, including extensive documentation, SDKs, and a two-week bug bounty.

Permit2 - Efficient, consistent, and secure approvals

Permit2 is a token approval contract that can safely share and manage token approvals across different smart contracts. As more projects integrate with Permit2, we can standardize token approvals across all applications. In turn, Permit2 will improve the user experience by reducing transaction costs while improving smart contract security.

Originally defined in EIP-20, the canonical token approve method suffered from a couple of weaknesses:

Users had to send an approval transaction for each new application they wanted to use. This led to a confusing UX where users might be asked to send multiple transactions before using an application, wasting gas and time.

For convenience's sake, applications asked users to approve the maximum allowance, giving applications access to a wallet’s entire token balance for an indefinite amount of time. Though Uniswap has never suffered from an exploit, infinite approvals can be hacked to steal user tokens. (PSA to revoke active allowances.)

EIP-2612 iterated on token approvals. Users could interact with application contracts without requiring prior approval by appending a signed permit message to their transaction. While EIP-2612 made token approves safer with granular allowance approvals, tokens launched before EIP-2612 did not support the permit function and not all newer tokens have adopted it.

How Permit2 improves UX

Permit2 further iterates on the token approval mechanism by introducing signature-based approvals and transfers for any ERC20 token, regardless of EIP-2612 support. Permit2 also comes with a host of exciting features that unlock more secure token approval options and enable a more consistent user experience across any integrating application. The full list of features can be found in our docs, but notably:

Permits for any token. Applications can have a single transaction flow by sending a signature along with the transaction data for any token, including those not supporting a native permit method.

Expiring approvals. Approvals can be time-bound, removing security concerns around hanging approvals on a wallet’s entire token balance. Revoking approvals do not necessarily have to be a new transaction.

Signature-based transfers. Users can bypass setting allowances entirely by releasing tokens to a permissioned spender through a one-time signature.

Batch approvals and transfers. Users can set approvals on multiple tokens or execute multiple transfers with one transaction.

Batch revoking allowances. Remove allowances on any number of tokens and spenders in one transaction.

Integrate Permit2

Permit2 is a non-upgradable, unowned, and open-source contract that has been deployed to the same address across Ethereum, Optimism, Arbitrum, Polygon, and Celo. To start integrating, see the developer docs and SDK.

As part of our robust smart contract development standards, we’ve also launched a bug bounty program for the Permit2 contracts.

Currently, Permit2 only supports ERC20 tokens. Uniswap Labs will be releasing a version for NFTs in the near future.

Universal Router - Unified token and NFT swaps

We’ve integrated Permit2 into another exciting contract we’re releasing. The Universal Router is Uniswap’s next-generation router that unifies token and NFT trades into a highly flexible, gas-optimized, secure, and extensible swap router. The Universal Router significantly improves product and user experience, which is why it will become the default swap router for all Uniswap swaps in the near future.

Swap routers take in defined parameters (e.g. swap route, maximum slippage, and swap recipient) and execute swaps against your desired venues (e.g. Uniswap pools, NFT marketplaces). Swap routers are optimized to find the lowest prices and execute them at the lowest gas cost.

However, current swap routers suffer from two inefficiencies:

Existing swap routers typically only support either NFTs or ERC20 tokens. Trades that involve both currently require multiple transactions. For example, buying an NFT with an ERC20 token would require two separate transactions. First, a swap from DAI to ETH, and then the final swap from ETH to NFT.

Because swap routers are responsible for transferring user tokens, users must approve every token on first use, making them costly to upgrade. This is especially problematic for aggregator swap routers as contracts must be redeployed each time a new protocol is supported.

How Universal Router unifies swaps

With the Universal Router, users can execute multiple token swaps on Uniswap V2 & V3, and buy NFTs from multiple marketplaces all in one transaction. For example, envision a swap that

Uses three different input tokens

Swaps on Uniswap V2 and V3 using a split route

Performs an ETH to WETH wrap

Buys an NFT on OpenSea

This entire flow can be executed as a single transaction.

The Universal Router is integrated with Permit2, meaning that users approve with Permit2 and pass their signature through to the Universal Router, abstracting the token approval flow from the router contracts. Developers can deploy new versions of the Universal Router without requiring users to send a separate approval transaction each time. This allows the Universal Router - or any integrated contract - to remain immutable, while also allowing new features to be added in the future.

Integrate Universal Router

The Universal Router is a non-upgradable, unowned, and open-source contract that has been deployed across Ethereum, Optimism, Arbitrum, Polygon, and Celo. To start integrating, see the SDK.

Similarly to Permit2, we are running a bug bounty program to keep Uniswap contracts to the highest security standards.

Comments

All Comments

Recommended for you

  • First Windows PCs with NVIDIA Chips Expected to Debut Next Week

    On May 30, Axios reported that sources indicate NVIDIA is set to enter the personal computer market, with the first Windows PCs featuring its chips as the main processors expected to be unveiled next week. NVIDIA and Microsoft will showcase their collaborative results and the initial PCs equipped with these chips at two major industry events: Computex in Taipei and the Microsoft Build Developer Conference. Sources suggest that PCs with NVIDIA chips are likely to appear in Microsoft's Surface brand as well as products from other manufacturers, including Dell. Microsoft is also expected to launch software that will allow users to more easily run AI agents locally on Windows PCs.

  • This Week, US Spot Bitcoin ETFs Experience Net Outflows of $1.4156 Billion

    On May 30, according to Farside monitoring, US spot Bitcoin ETFs experienced cumulative net outflows of $1.4156 billion this week. This includes: IBIT with net outflows of $966.3 million; GBTC with net outflows of $172 million; FBTC with net outflows of $169.1 million; BITB with net outflows of $46.3 million; ARKB with net outflows of $24.7 million; MSBT with net outflows of $1 million; and Grayscale BTC with net outflows of $33 million.

  • US Oil Giant Predicts Higher Oil Prices This Summer

    On May 30, according to CCTV Finance, during a conference hosted by investment firm Bernstein, Chevron CEO Mike Wirth stated that due to the situation in Iran, global crude oil inventories are continuously declining, and oil prices are likely to rise in the next two months. The Financial Times reported that Wirth's remarks reflect widespread concerns: even if the conflicting parties reach a ceasefire agreement, the negative impact of the conflict on energy prices will persist for months. Additionally, CNN reported on the 28th that due to the ongoing geopolitical conflicts in the Middle East, the U.S. Strategic Petroleum Reserve is declining at a rare pace not seen in recent years, and commercial crude oil inventories are also at low levels.

  • S&P 500 Index Set for Rare Nine-Week Winning Streak

    On May 29, hopes that a ceasefire agreement could bring an end to the Middle East conflict have propelled the U.S. stock market towards a rare weekly winning streak record, with a surge in artificial intelligence trading also boosting the market. The S&P 500 index has rebounded nearly 20% from the lows triggered by the war and is poised for its ninth consecutive week of gains, marking the longest winning streak since December 2023. Such a rare occurrence has only happened a few times since 1985. On Friday, the index edged higher, hovering near record highs.

  • Grayscale to Introduce $115 Million HYPE Token Seed Funding for Hyperliquid Staking ETF

    On May 29, Finance Feeds reported that Grayscale is in talks with Hyper Holdings Global LP to sell shares of its proposed Hyperliquid ETF in exchange for approximately 2 million HYPE tokens, valued at about $115 million at current prices, to serve as seed capital before the fund's listing. At the same time, Grayscale has renamed the product to 'Grayscale Hyperliquid Staking ETF', which is set to be listed on NASDAQ under the ticker HYPG. The new staking feature distinguishes it from a traditional spot ETF that solely tracks token prices.

  • BTC Falls Below $73,000

    Market data shows that BTC has fallen below $73,000, currently priced at $72,999.33, with a 24-hour decline of 0.4%. The market is experiencing significant volatility, so please ensure proper risk management.

  • Spot Gold Reaches $4,550/oz, Up 1.20% for the Day

    Spot gold has reached $4,550 per ounce, rising 1.20% for the day.

  • S&P 500 Technology Sector Hits Record High, Up 1.7%

    On May 29, it was reported that the S&P 500 technology sector has reached a historic high, currently up 1.7%.

  • U.S. Stock Indices Open Slightly Higher; Dell Rises Over 30%

    On May 29, U.S. stocks opened with the three major indices slightly higher, with the Dow Jones up 0.18%, the S&P 500 up 0.09%, and the Nasdaq up 0.16%. Dell (DELL.N) surged over 30% as its first-quarter earnings exceeded expectations. Stocks of AI server manufacturers also rose, with Super Micro Computer (SMCI.O) up over 7% and HP (HPQ.N) up over 6%.

  • Musk Denies Reports of SpaceX Lowering IPO Valuation Target to At Least $1.8 Trillion

    On May 29, Musk denied reports that SpaceX had lowered its IPO valuation target to at least $1.8 trillion. (Jin Shi)