0x Version 2

High Level Overview


## What's new in 0x v2 * Generalized Asset Types * New Signature Types * Order Matching * Transaction Signing * Bulk Cancellation
## Asset Types
## ERC20 * Fungible Tokens * Only Token Standard for 0x v1 * Examples * WETH * ZRX * DAI * MBGN
## ERC721 * Non-Fungible Tokens * New Standard supported by 0x v2 * Examples * Crypto Kitties * Trading Card Games
## Asset Data * 0x v1 identified assets by token address: * `0xdde19c145c1ee51b48f7a28e8df125da0cc440be`
## Asset Data * 0x v2 identifies assets by "asset data": * `0xf47261b0000000000000000000000000dde19c145c1ee51b48f7a28e8df125da0cc440be` | offset | length | description | |--------|----------|---------------------------------------------| | 0 | 4 bytes | Asset proxy identifier (`f47261b`) | | 16 | 20 bytes | Token Address (`dde19c145c1ee51b48f7a...`) | | 36 | - | Asset-specific information |
## Asset Proxy * One asset proxy for each asset type * Users give asset proxy permission to move assets * New asset proxy can be added to exchange * Could add asset types without exchange upgrade
## Signatures * Cryptographic proof that a trade is authorized

0x v1 Signatures (EthSign)


  • Some clients prefix message, others don't

EIP-712 Signatures

## Presign * Users can make a contract call to assert that an order is signed * Allows contracts as makers * Not gas efficient
## Wallet Signatures * Signer must be a contract implementing: `isValidSignature(hash, sig)` * Exchange calls contract to verify * Hard to manage as a Relayer * Must validate signatures via EVM * Signature validity may change without notice
## Validator Signatures * Signer designates a validator contract on exchange * Validator must be a contract implementing: `isValidSignature(hash, signer, sig)` * Exchange calls contract to verify * Slightly easier to manage as a Relayer * Validator whitelist * Emit events when signature validity changes
## Signature Notes * OpenRelay supports EthSign and EIP712s * Plans to support presign and validator whitelist * No plans to support wallet signatures * Contract only verifies signatures once
## Order Matching * 0x v1: * Batch fill order A, use proceeds to fill order B * Take spread as profit * Matcher must have initial funds to fill A
## Order Matching * 0x v2: * `matchOrders(orderA, orderB)` * `orderA.maker` is `orderB.taker`, vice versa * Matcher takes spread as profit * Matcher requires no initial funds
## Transaction Signing * 0x v1: * Taker must call contract functions directly * `fillOrder()` * `batchFillOrders()`
## Transaction Signing * 0x v2: * Taker can sign function call data * Separate Ethereum account can submit transaction to the chain * Orders can constrain transaction sender
## Cancellations * 0x v1: * Each order must be cancelled explicitly * Partial cancellations allowed * Gas heavy * Puts onus of tracking orders on maker
## Cancellations * 0x v2: * Each order can be cancelled explicitly * Cancellation is binary * Cancel orders where `order.salt < epoch` * Best practice: `order.salt = now()` * Can cancel all old orders in one transaction, even if you've forgotten them
## Conclusion * Lots of new protocol capabilities * Tooling is still catching up * ERC721 support * EIP-712 signing * Validator contracts * Version 2.1 in 3-6 months * More gas efficient * Possibly new APIs * Same order schema
## Next Time * Open to suggestions * ERC721 Deep Dive * Explore New Widgets