0xProject / ZEIPs

0x Improvement Proposals
Apache License 2.0
91 stars 15 forks source link

MultiplexFeature and BatchFillNativeOrdersFeature #83

Closed mintcloud closed 3 years ago

mintcloud commented 3 years ago

Summary

This ZEIP proposes to integrate two features to 0x V4: MultiplexFeature and BatchFillNativeOrdersFeature.

Type:

CORE

Motivation

This ZEIP proposes to integrate two new features –– MultiplexFeature and BatchFillNativeOrdersFeature –– to the core protocol.

MultiplexFeature makes it easier for 0x API to take advantage of the RFQ order gas savings introduced in 0x V4. In order to guarantee low revert rates on RFQ liquidity, 0x API typically appends "fallback orders" that would be able to fulfill the swap in case an RFQ order expires (or otherwise reverts). This requires the swap to go through the TransformERC20Feature and its associated pipeline of smart contracts, which adds gas overhead and makes the overall price less competitive. With this change, it will be possible to add fallback liquidity without going through the aforementioned pipeline, instead leveraging more gas-efficient routes such as directly trading with Uniswap or Sushiswap. In practice, this should result in more competitive RFQ liquidity in 0x API-powered applications.

BatchFillNativeOrders will introduce functions to fill multiple V4 limit or RFQ orders in a single function call. This feature has been requested by VolleyFire to more efficiently fill smaller limit orders created by 0x integrators. This should improve the execution of smaller limit orders created from Matcha and other 0x limit order integrators. In addition, some smart contract integrations may find these functions convenient.

The two changes are bundled in one ZEIP since they will be spot-audited together, as they also involve similar parts of the codebase.

Specification

Comprehensive specifications are hosted here https://protocol.0x.org/

Implementation

It is proposed to deploy and register MultiplexFeature and BatchFillNativeOrdersFeature in the ZeroEx proxy contract, taking advantage of the upgradability introduced with 0x v4. No change is required for 0x API integrators or market makers. When the governance vote is completed, assuming a positive outcome, the change will be introduced with a timelock period of 48 hours.

Designated team: 0x Labs

Notes

The change will be spot-checked by Consensys Diligence

mintcloud commented 3 years ago

PR reference https://github.com/0xProject/protocol/pull/140