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

Allow batch 0x transaction execution #36

Closed
abandeali1 opened this issue May 2, 2019 · 0 comments
Closed

Allow batch 0x transaction execution #36

abandeali1 opened this issue May 2, 2019 · 0 comments
Labels
status: implemented Proposed changes have been implemented (and deployed, if smart contract) type: core

Comments

@abandeali1
Copy link
Member

abandeali1 commented May 2, 2019

Preamble

ZEIP: 36
Title: Allow batch 0x transaction execution
Author: 0x Core Team
Type: Standard Track
Category: Core
Status: Final
Created: 2019-10-29

Discussion: #36

Summary

The Exchange contract currently only allows for a single 0x transaction to be executed atomically. This proposal would add the ability to atomically execute a batch of transactions by calling a single function.

Motivation

There are niche use cases for composing custom a custom series of Exchange function calls. One example:

  1. A maker places a buy order on market A
  2. A sell order appears on market B that would satisfy the maker's buy order
  3. The maker would like to atomically fill the sell order and cancel the buy order, rather than executing the transactions asynchronously and risking that only one of the transactions is successful.

Specification

A naive solution is extremely simple to implement and adds no additional attack surface:

/// @dev Executes a batch of Exchange method calls in the context of signer(s).
/// @param transactions Array of 0x transactions containing salt, signerAddress, and data.
/// @param signatures Array of proofs that transactions have been signed by signer(s).
/// @return Array containing ABI encoded return data for each of the underlying Exchange function calls.
function batchExecuteTransactions(
    ZeroExTransaction[] memory transactions,
    bytes[] memory signatures
)
    public
    returns (bytes[] memory)
{
    uint256 length = transactions.length;
    bytes[] memory returnData = new bytes[](length);
    for (uint256 i = 0; i != length; i++) {
        returnData[i] = _executeTransaction(transactions[i], signatures[i]);
    }
    return returnData;
}

It would be useful if the return data of each transaction could be passed into and processed by the next transaction, but this would be extremely complex to implement (and is potentially infeasible).

Copyright

Copyright and related rights waived via CC0.

@abandeali1 abandeali1 added 3.0 and removed 3.0 labels May 3, 2019
@dekz dekz modified the milestone: V3 development Jun 21, 2019
@dekz dekz mentioned this issue Oct 21, 2019
@hysz hysz mentioned this issue Nov 8, 2019
@mintcloud mintcloud added status: implemented Proposed changes have been implemented (and deployed, if smart contract) type: core and removed 3.0 labels Apr 10, 2020
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

3 participants