Skip to content
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

Optimized Uniswap V3 settlement #88

Closed
dekz opened this issue May 25, 2021 · 1 comment
Closed

Optimized Uniswap V3 settlement #88

dekz opened this issue May 25, 2021 · 1 comment
Labels
status: implemented Proposed changes have been implemented (and deployed, if smart contract) type: core

Comments

@dekz
Copy link
Member

dekz commented May 25, 2021

Summary

This ZEIP proposes to optimize the the integration of Uniswap V3 during settlement, lowering the cost for a significant number of trades.

As Uniswap V3 is gaining significant volume, it is optimal for our users to access this liquidity source for the lowest cost possible.

The proposal also includes removing a deprecated feature known as the allowance target failover in FixinTokenSpender.

Type:

CORE

Motivation

This ZEIP integrates a number of features around Uniswap V3 to reduce the overall cost of using this source within 0x contracts.

In the 0x architecture, trades can either be executed inside or outside of a sandbox. When new liquidity sources are added they are added in a manner in which they execute inside of the sandbox. During settlement, the sandbox is transferred the tokens and has no access to any allowances, so no user funds can ever be at risk. This comes at the cost of additional gas cost overhead.

In order to optimize specific liquidity sources we implement a Feature which executes in an environment which may have access to user allowances. As such we take the utmost care when implementing a new Feature into the 0x protocol.

We propose to optimize the cost of Uniswap V3 settlement, lowering the costs for a large number of trades. There are two changes proposed in this ZEIP, firstly adding UniswapV3Feature to the ExchangeProxy as well as adding support for Uniswap v3 on MultiplexFeature.

The UniswapV3Feature is a gas-optimized contract allowing more efficient settlement of Uniswap V3 trades. The settlement cost when using the UniswapV3Feature is expected to be cheaper than using Uniswap V3 directly. This allows us to offer better prices through the 0x API using 0x contracts. This feature is used when the trade is entirely Uniswap V3.

Adding Uniswap V3 support in the MultiPlexFeature allows for Uniswap V3 execution to be mixed with other supported sources. For example, this allows cheap execution of a split between Uniswap V3 and 0x Request for Quote.

The proposal also includes removing a deprecated feature known as the allowance target failover in FixinTokenSpender.

Implementation

UniswapV3Feature: 0xProject/protocol#237
MultiPlex Changes: 0xProject/protocol#237

Costs

path gas cost (new) gas cost (old)
ETH->USDC 136615 272556
USDC->ETH 106248 239026
WETH->USDC 99272 243708
USDC->WETH 89648 239115

Designated team: 0x Labs

Notes

The change will be spot-checked by Consensys Diligence

@dekz dekz added the status: implemented Proposed changes have been implemented (and deployed, if smart contract) label Jul 8, 2021
@mintcloud
Copy link
Contributor

voted on https://0x.org/zrx/vote/zeip-88 and deployed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: implemented Proposed changes have been implemented (and deployed, if smart contract) type: core
Projects
None yet
Development

No branches or pull requests

2 participants