mzhu25 c1177416f5
[Final] ERC721 and ERC1155 Orders (#429)
* add LibERC721Order.sol

* Add ERC721 interface to vendor/

* Add ERC721OrdersFeature interface

* Storage lib for ERC721 orders feature

* Implement basic functionality for ERC721 orders (buy, sell, cancel, etc)

* Add isValidERC721OrderSignature to interface

* implement onERC721Received

* Implement batchBuyERC721s

* left/right orders -> sell/buy orders

* Add missing @return comments

* Implement matching functions

* Use SafeMath where necessary

* add rich errors for ERC721OrdersFeature

* Add comments

* Add presign support for ERC721 orders

* Cancel using just the order nonce

* Add IERC721OrdersFeature to IZeroEx

* Add taker callback

* Assembly optimizations in LibERC721Order

* Add ERC721Orders TS class

* create zero-ex/contracts/test/integration/ and tokens/ directories

* TestMintableERC721Token

* tmp

* address feedback from original PR (#391)

* address feedback from original PR

* Update contracts/zero-ex/contracts/src/features/ERC721OrdersFeature.sol

Co-authored-by: Kim Persson <kimpers@users.noreply.github.com>

* address review feedback and improve order parameter naming

* Add batchCancel function

* Emit order fields in preSign

* Fix tests

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Kim Persson <kimpers@users.noreply.github.com>
Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>

* Remove revertIfIncomplete from batchMatch

* Sanity check maker address in preSign

* ERC1155OrdersFeature contracts

* Commence refactor, abstract base contract

* ERC721OrdersFeature inherits from NFTOrders

* Refactor ERC1155OrdersFeature to inherit from NFTOrders

* Fix order hashing

* Fix ERC721OrdersFeature tests

* Typos

* Remove maker address from preSigned mapping

* disable dex sampler tests

* Refactor TS tooling

* Address PR feedback

* Rearrange event fields to better align with struct fields

* Update comments

* update AbiEncoder.create params

* Add ERC1155Order to protocol-utils

* Add ERC1155OrdersFeeature tests

* Bump package versions and regenerate contract wrappers

* Add ERC165Feature

* NFT orders: address audit findings (#417)

* CVF-1: use pragma solidity ^0.6 instead of ^0.6.5

* CVF-11: fix inaccurate comment

* CVF-16: Enable taker callbacks for batchBuyERC1155s

* CVF-17: use internal call if revertIfIncomplete is true

* CVF-21: avoid duplicate SLOAD

* CVF-23: merge if statements

* CVF-24: Reorder status checks to be consistent with ERC721OrdersFeature

* CVF-25: Update unclear comment (canonical hash -> EIP-712 hash)

* CVF-31: Document keys of orderState mapping

* CVF-45: DRY up fees/properties hashing

* CVF-47, CVF-50, CVF-57: calculate properties.length once; hash propertyStructHashArray in-place using assembly

* CVF-56: More descriptive names for assembly variables

* CVF-71: Update confusing comment about rounding in _payFees

* CVF-72: Move ETH assertions outside of loop in _payFees

* CVF-74: Move property validation loop to else branch

* CVF-82: Update inaccurate comment

* CVF-86: Enable taker callbacks for batchBuyERC721s

* CVF-87: use internal call if revertIfIncomplete is true

* CVF-89: Perform token mismatch checks before stateful operations

* CVF-90, CVF-91: Defer ERC20 token mismatch check

* CVF-93: Add inline comments for _payFees parameters in matchERC721Orders

* CVF-94: Fix comment (Step 7 -> Step 5)

* CVF-98: Use binary & operator instead of mod

* CVF-99: Update unclear comment (canonical hash -> EIP-712 hash)

* CVF-65, CVF-66, CVF-67: Copy params.ethAvailable into local variable; check that ethSpent does not exceed ethAvailable; remove ethAvailable < erc20FillAmount check

* CVF-52, CVF-55, CVF-59: calculate fees.length once; hash feeStructHashArray in-place using assembly

* CVF-14, CVF-32: OrderState struct; separate storage mapping for 1155 cancellations so orders can be cancelled by nonce

* Update changelogs, IZeroEx artifact/wrapper

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Kim Persson <kimpers@users.noreply.github.com>
2022-02-22 10:00:22 -08:00
2022-02-11 22:53:49 +10:00
2018-02-05 10:25:05 -08:00
2020-10-20 20:53:39 -04:00
2021-01-26 09:33:14 -08:00
2021-06-02 14:21:14 +10:00
2020-10-20 20:53:39 -04:00
2020-10-20 20:53:39 -04:00
2020-10-20 20:53:39 -04:00
2020-10-20 20:53:39 -04:00
2021-08-18 10:33:47 +10:00
2018-10-18 14:08:26 +01:00


0x is an open protocol that facilitates trustless, low friction exchange of Ethereum-based assets. For more information on how it works, check out the 0x protocol specification.

This repository is a monorepo including the 0x protocol smart contracts and numerous developer tools. Each public sub-package is independently published to NPM.

CircleCI Coverage Status Discord License

Packages

Visit our developer portal for a comprehensive list of core & community maintained packages. All packages maintained with this monorepo are listed below.

Solidity Packages

These packages are all under development. See /contracts/README.md for a list of deployed packages.

Package Version Description
@0x/contracts-zero-ex npm The contracts used for settling trades within the protocol
@0x/contracts-erc20 npm Implementations of various ERC20 tokens
@0x/contracts-test-utils npm TypeScript/Javascript shared utilities used for testing contracts
@0x/contracts-utils npm Generic libraries and utilities used throughout all of the contracts

TypeScript/Javascript Packages

0x-specific packages

Package Version Description
@0x/asset-swapper npm Package used to find and create aggregated swaps
@0x/protocol-utils npm A set of utilities for generating, parsing, signing and validating 0x orders
@0x/contract-addresses npm A tiny utility library for getting known deployed contract addresses for a particular network.
@0x/contract-wrappers npm JS/TS wrappers for interacting with the 0x smart contracts
@0x/migrations npm Migration tool for deploying 0x smart contracts on private testnets
@0x/contract-artifacts npm 0x smart contract compilation artifacts

Usage

Node version 6.x or 8.x is required.

Most of the packages require additional typings for external dependencies. You can include those by prepending the @0x/typescript-typings package to your typeRoots config.

"typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"],

Contributing

We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.

Read our contribution guidelines.

Install dependencies

Make sure you are using Yarn v1.9.4. To install using brew:

brew install yarn@1.9.4

Then install dependencies

yarn install

Build

To build all packages:

yarn build

To build a specific package:

PKG=@0x/asset-swapper yarn build

To build all contracts packages:

yarn build:contracts

Watch

To re-build all packages on change:

yarn watch

To watch a specific package and all it's dependent packages:

PKG=[NPM_PACKAGE_NAME] yarn watch

e.g
PKG=@0x/asset-swapper yarn watch

Clean

Clean all packages:

yarn clean

Clean a specific package

PKG=@0x/asset-swapper yarn clean

Rebuild

To re-build (clean & build) all packages:

yarn rebuild

To re-build (clean & build) a specific package & it's deps:

PKG=@0x/asset-swapper yarn rebuild

Lint

Lint all packages:

yarn lint

Lint a specific package:

PKG=@0x/asset-swapper yarn lint

Run Tests

Run all tests:

yarn test

Run a specific package's test:

PKG=@0x/asset-swapper yarn test

Run all contracts packages tests:

yarn test:contracts
Description
protocol for MEV related stuff
Readme 166 MiB
Languages
TypeScript 59.4%
Solidity 31.6%
MDX 9%