41 Commits

Author SHA1 Message Date
Steve Marx
012fff46f6
add permissionless transformer deployer (#55)
* add permissionless transformer deployer
2020-11-27 18:21:49 -05:00
Steve Marx
88d7e73eba
remove calldata signing (#51) 2020-11-25 16:55:12 -05:00
Steve Marx
ad337271d3
Miscellaneous fixes to RFQ origin registration (#48)
* Contracts can no longer call registerAllowedRfqOrigins()
* registerAllowedRfqOrigins() is now plural, registers an array of
addresses
2020-11-25 14:08:15 -05:00
Steve Marx
e2ee3414ea
limit order metatransactions (#44) 2020-11-24 13:39:40 -05:00
Lawrence Forman
ab698cec14
EP: misc fixes (#38)
* `@0x/contracts-zero-ex`: Fix NativeOrdersFeature order hash cancellation not emitting proper maker.
`@0x/contracts-zero-ex`: Revert to original (deployed) ZeroEx/EP proxy implementation. Optimized one is now at `ZeroExOptimized.sol`.
`@0x/contracts-zero-ex`: Add gas limits to first `transferFrom()` call in `LibTokenSpender` and `UniswapFeature`.

* `@0x/contracts-zero-ex`: Update changelog

* disable `no-empty-blocks` solidity linter rule

* `@0x/contracts-zero-ex`: Use bloom filters of greedy tokens in token transfer logic
`@0x/contracts-zero-ex`: Turn `LibTokenSpender` into `FixinTokenSpender`.
`@0x/contracts-zero-ex`: Misc renames for consistency.

* `@0x/contracts-zero-ex`: Export `GREEDY_TOKENS` list

* rebase and update changelog

* `@0x/contracts-zero-ex`: Change bloom filter hash algo based on discussions

* `@0x/contracts-zero-ex`: Fix changelog

* update orders docs

* `@0x/contracts-zero-ex`: revert if allowance call fails in uniswap feature

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-23 12:59:02 -05:00
Lawrence Forman
561b60a24d
EP Native Orders (#27)
* `@0x/contracts-zero-ex`: add limit orders feature
`@0x/contracts-utils`: add `uint128` functions to `LibSafeMathV06`

* `@0x/contract-addresses`: Update ganache snapshot addresses

* `@0x/contracts-zero-ex`: Mask EIP712 struct hash values.

* `@0x/contracts-zero-ex`: Add more limit order tests

* `@0x/contracts-zero-ex`: Fix typos

* `@0x/contracts-zero-ex`: Compute fee collector address after protocol fee zero check.

* `@0x/contracts-zero-ex`: Remove WETH payment logic from fee collector fixin

* `@0x/contracts-zero-ex`: Convert all ETH to WETH in `FeeCollector`.

* `@0x/contracts-zero-ex`: Address review feedback

* `@0x/contracts-zero-ex`: Export more utils

* `@0x/contracts-zero-ex`: Rename `LimitOrdersFeatures`, `LibLimitOrders`, etc. into `*NativeOrders*`.
`@0x/contracts-zero-ex`: Emit `protocolFeePaid` in native order fill events.
`@0x/contracts-zero-ex`: Refactor to get around stack limits.
`@0x/contracts-zero-ex`: Use different storage mappings for RFQ and limit order pair cancellations.

* `@0x/contracts-zero-ex`: Add `getProtocolFeeMultiplier()` and `transferProtocolFeesForPools()` to `NativeOrdersFeature`.

* `@0x/contracts-zero-ex`: Fix broken tests

* update orders docs

* `@0x/contracts-zero-ex`: Add more tests to `NativeOrdersFeature`

* rebuild after rebase

* `@0x/contract-addresses`: Fix changelog booboo

* `@0x/contracts-zero-ex`: Add method selectors output to generated artifacts

* `@0x/contracts-zero-ex`: Add maker address to order cancel events.
`@0x/contracts-zreo-ex`: Remove `UpTo` suffix from order pair cancellation functions.
`@0x/contracts-zreo-ex`: Address misc review comments.

* `@0x/contracts-zero-ex`: More SafeMath in native orders

* update orders docs

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-17 15:39:40 -05:00
mzhu25
7403c0255a
Feature/liquidity provider sandbox (#16)
* Update liquidity provider feature to use sandbox

* add support for liquidity provider feature in the exchange proxy swap quote consumer

* Move to off-chain liquidity provider registry

* Update ILiquidityProvider interface

* Remove some unused artifacts and wrappers

* Consolidate ILiquidityProvider

* prettier

* lint

* Address PR feedback

* Add failover to sandbox

* Add test for failover behavior in LiquidityProviderSandbox

* Update changelogs

* Emit events for the new LiquidityProvider scenarios

* Fix swap quote consumer bug

* post-rebase fixes

* `@0x/contracts-zero-ex`: bump feature versions

* Add default field to TokenAdjacencyGraph

* update addresses

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-13 12:22:21 -08:00
Lawrence Forman
48e7a391c8
Deploy new FQT (#28)
* `@0x/contracts-zero-ex`: Change `ProtocolFeeUnfunded` event in FQT
`@0x/contracts-zero-ex`: Use new PLP interface in FQT.

* `@0x/contract-addresses`: Deploy new FQT

* fix failing FQT test

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-02 21:47:25 -05:00
Lawrence Forman
f4709ed1cb
EP: Add LibSignature library (#21)
* `@0x/contracts-zero-ex`: Add `LibSignature` library

* `@0x/contracts-zero-ex`: Update package.json scripts

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-10-29 17:47:17 -04:00
Steve Marx
9816019bc5
add protocol fees fixin (#2) 2020-10-28 17:10:59 -04:00
Jacob Evans
99f5be8378
chore: [asset swapper] sampler Solidity 0.6 + Bridge addresses in AS (#4)
* Refactor excess interfaces

* Compiles on 0.6

* Refactored into try/catch

* Rebase and Refactored to v06

* Handle invalid registry in LP

* Update packages/asset-swapper/contracts/src/LiquidityProviderSampler.sol

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>

* chore: [asset-swapper] Move Bridge Addresses and Gas schedule

* curve->pool

* lint

* Refactor to fix module load order

* Move FEE Schedule

* rollup: Swerve/Sushi/SnowSwap/DODO (#7)

* rollup: Swerve/Sushi

* DODO Rollup + Snowswap Swerve

* hardcode addresses temporarily

* rebase

* rename to SUSHISWAP_ROUTER

* CHANGELOGs

* CHANGELOGs

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
2020-10-27 15:16:09 +10:00
Steve Marx
861871134b
add LibTokenSpender and convert to using that (#3)
add LibTokenSpender and convert to using that

This skips the allowance target. Allowances are instead just set on the
exchange proxy itself. There is a fallback, though, to try spending from
the allowance target if the original transfer fails.
2020-10-23 10:45:46 -04:00
Jacob Evans
7698f21517
feat: [asset-swapper] Shell 🐚 (#2722)
* feat: [asset-swapper] Shell

* Deployed and Changelogs

* Glue up the deployed address

* Glue for FQT rollup
2020-10-06 15:55:51 +10:00
Michael Zhu
1c15ecacb0 add tests for LiquidityProviderFeature 2020-10-05 10:09:06 -07:00
Michael Zhu
78e3cd39d1 @0x/contracts-zero-ex: Add LiquidityProviderFeature contracts 2020-10-05 09:43:19 -07:00
Lawrence Forman
f84b375cde
UniswapFeature (#2703)
* Minimal Uniswap accessor.

* Add comments

* Safe math

* mainnet gas benchmark

* Assembler Uniswap

* Selectors and addresses

* Fix bugs in ABI encoders

* Typo

* AsmUniswap test

* Fix wantAmount computation

* Golfing

* Bypass AllowanceTarget

* Generalized asm uniswapper

* Implement ordering

* Fix pair computation

* #6 Golfing Iron

* Remove 'to' argument (saves 377 gas)

* New contract api

* `@0x/contracts-zero-ex`: Add `UniswapFeature`

* `@0x/contract-artifacts`: Regenerate artifacts

* `@0x/contract-wrappers`: Regenerate wrappers

* `@0x/asset-swapper`: Add Uniswap VIP support.
`@0x/asset-swapper`: Add `includeSources` support.

* `@0x/contracts-zero-ex`: Fix misleading comments in `UniswapFeature`.
`@0x/asset-swapper`: Fix linter errors.

* `@0x/asset-swapper`: Fix source filter bugs.

* `@0x/contracts-zero-ex`: `UniswapFeature`: Reduce calldata size for AllowanceTarget call
`@0x/asset-swapper`: Fix failing test.

* `@0x/contracts-zero-ex`: Fix ETH buy tokens not being normalized to WETH.

* `@0x/asset-swapper`: Fix multi-hop weirdness with source filters.

* `@0x/asset-swapper`: Fix failing test.

* `@0x/asset-swapper`: Really fix that broken AS test.

* `@0x/asset-swapper`: use filter objects instead of source array for valid buy and sell sources/

* `@0x/asset-swapper`: Move some source filtering logic into the sampler operations.

* `@0x/contracts-zero-ex`: Address PR feedback

* `@0x/contracts-zero-ex`: Fix feature version bug.

* `@0x/asset-swapper`: Did I actually fix AS tests this time? Who knows.

Co-authored-by: Remco Bloemen <remco@0x.org>
Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-09-23 16:27:48 +10:00
Lawrence Forman
889b58a914 @0x/contracts-zero-ex: Add RFQT taker enforcement to FQT.
`@0x/contracts-zero-ex`: Remove redundant event from `BridgeAdapter`.
`@0x/contracts-zero-ex`: Treat all calldata as signed if quote signer is not in `TransformERC20Feature`.

`@0x/contracts-zero-ex`: Update bridge adapters
2020-09-02 15:58:38 -04:00
Lawrence Forman
1d6aef5cd6 @0x/contracts-zero-ex: Remove UniswapFeature
`@0x/contracts-zero-ex`: Fix broken tests.
2020-09-01 16:05:14 -04:00
Lawrence Forman
2636384ead Merge remote-tracking branch 'origin/feat/exchange-proxy/post-cd-audit' into fix/ep/meta-transactions 2020-09-01 09:48:17 -04:00
Lawrence Forman
9cda9f69cd @0x/contracts-zero-ex: Add reentrancy guard to mtx functions
`@0x/contracts-zero-ex`: Add refund mechanism to mtxs
`@0x/contracts-zero-ex`: Pass sender to transfomers.
`@0x/contracts-zero-ex`: Refund protocol fees to `refundReceiver` in FQT.
`@0x/utils`: Add EP flavor of `IllegalReentrancyError`
`@0x/order-utils`: Add `refundReceiver` to FQT transform data.
`@0x/asset-swapper`: Add `refundReceiver` support to EP swap quote consumer.
2020-09-01 09:40:58 -04:00
Jacob Evans
7e8b56eef4
feat: mStable + FQT Rollup (#2662)
* feat: mStable

* deploy and CHANGELOG

* `@0x/contracts-utils`: Add more testnet addresses.

* `@0x/contract-addresses`: Deply Mstable on testnets

* `@0x/contract-addresses`: Remove testnet deployments of mStable :-)

* move `erc20-bridge-sampler` into `asset-swapper`
remove `DevUtils` dependency from sampler contract.

* `@0x/asset-swapper`: Add ERC20BridgeSampler support for validating orders in maker fees denominated in non-maker assets.
`@0x/asset-swapper`: Add tests for `NativeOrderSampler`.

* `@0x/asset-swapper`: Return `0` sample if native order asset data is unsupported.

* `@0x/asset-swapper`: Fix failing test.

* feat: ExchangeProxy FQT fruit rollup (#2645)

* feat: Optimize Bridges in ExchangeProxy

* compile and most work

* work around to trust the delecall contract

* force allowances

* Update Kyber/Eth2Dai bridges

* Remove memory state where not required

* cleanup

* Combine Bridges into one adapter

* mixins

* refactor out ZeroExBridge

* move out interface

* comment out hacks

* update migrations

* remove simbot hacks

* AdapterAddresses and mStable

* Share constructor arg

* fix migration

* Remove whitespace

* `@0x/contracts-zero-ex`: BridgeAdapter -- revert if bridge address is 0.

* `@0x/contract-addresses`: Deploy FQT.

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Lawrence Forman <lawrence@0xproject.com>

* update ganache contract addresses

* fix: asset-swapper empty batch call (#2669)

* update ganache contract addresses

* fix: asset-swapper prevent empty sampler batch call

* add sampler to migrations

* change migrations version

* Use contract-wrappers and artifacts

* remove extra data

* remove deps, set sampler to NULL_ADDRESS

* all the exports

* noop sell rate too

* update ganache contract addresses

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
2020-08-20 08:18:44 +10:00
Lawrence Forman
71700e69af @0x/zero-ex: Address CD post-audit feedback.
Add `LogMetadataTransformer`.
2020-08-19 13:52:32 -04:00
Lawrence Forman
5dd686f22f @0x/contracts-zero-ex: Add reentrancy guard to mtx functions
`@0x/contracts-zero-ex`: Add refund mechanism to mtxs
`@0x/contracts-zero-ex`: Pass sender to transfomers.
`@0x/contracts-zero-ex`: Refund protocol fees to `refundReceiver` in FQT.
`@0x/utils`: Add EP flavor of `IllegalReentrancyError`
`@0x/order-utils`: Add `refundReceiver` to FQT transform data.
`@0x/asset-swapper`: Add `refundReceiver` support to EP swap quote consumer.
2020-08-06 22:28:35 -04:00
Lawrence Forman
07a681c77e @0x/contracts-zero-ex: Add IZeroEx contract. 2020-07-22 22:59:46 -04:00
Lawrence Forman
5f5a158060 @0x/contracts-zero-ex: Update TransformERC20 and MetaTransactions to handle signed calldata. 2020-07-22 22:18:39 -04:00
Lawrence Forman
e8106f04b5 @0x/contracts-zero-ex: Address review feedback. 2020-07-10 02:36:25 -04:00
Lawrence Forman
297ff10c14 @0x/contracts-zero-ex: add SignatureValidator and MetaTransactions features. 2020-07-10 02:36:00 -04:00
Jacob Evans
406d2cefc5
feat: ExchangeProxy FillQuoteTransformer bridge direct (#2608)
* Detect Bridge orders and fill direct

* Mark as external for try/catch

* Initial tests

* discuss: Continue if protocol fee insufficient

* Emit ProtocolFeeUnfunded

* put the clamps on taker balance

* feat: GST free and optimize

* fix: low level GST free call

* fix: review feedback

* remove unused return struct
2020-07-07 07:37:26 +10:00
Lawrence Forman
5707993995 @0x/contracts-zero-ex: Add AffiliateFeeTransformer. 2020-06-08 21:33:26 -04:00
Lawrence Forman
87ed0071c4 @0x/contracts-zero-ex: Make TransformerDeployer boring. 2020-06-08 15:30:56 -04:00
Lawrence Forman
a7ce72cae0 @0x/contracts-zero-ex: Rebase against development 2020-05-28 11:56:59 -04:00
Lawrence Forman
28402ff7d8 @0x/contracts-zero-ex: Add self-destructing to transformers 2020-05-28 11:56:59 -04:00
Lawrence Forman
c610dd96f5 @0x/contracts-zero-ex: Rebase, returning nonces in transform(). 2020-05-28 11:56:59 -04:00
Lawrence Forman
2ba3818b65 @0x/contracts-zero-ex: Introduce transformer contracts. 2020-05-28 11:56:59 -04:00
Lawrence Forman
c911c3352c @0x/contracts-zero-ex: Make TokenSpender's puppet contract a distinct contract type and rename getTokenSpenderPuppet() to getAllowanceTarget() 2020-05-28 11:56:58 -04:00
Lawrence Forman
2fce332ed7
ZeroEx: TransformERC20, TokenSpender (#2545)
* `@0x/contracts-utils`: Convert more 0.6 contracts

* `@0x/contracts-erc20`: Add solidity 0.6 contracts.

* `@0x/utils`: Add new `ZeroExRevertErrors` revert types

* `@0x/contracts-zero-ex`: Introduce the `TransformERC20` feature.

* `@0x/subproviders`: Update ganache-core.
`@0x/web3-wrapper`: Update ganache-core.

* `@0x/contracts-zero-ex`: Make `TokenSpender`'s puppet contract a distinct contract type and rename `getTokenSpenderPuppet()` to `getAllowanceTarget()`

* `@0x/zero-ex`: Rebase and use "slot" instead of "offset" language in storage buckets.

* `@0x/web3-wrapper`: Add `getAccountNonceAsync()` to `Web3Wrapper`

* `@0x/contracts-zero-ex`: Revamp TransformERC20.

* `@0x/contracts-zero-ex`: Remove `payable` from `IERC20Transformer.transform()` and disable hex capitalization linter rule because of prettier conflicts.

* `@0x/contracts-zero-ex`: Use `immutable` owner in `Puppet` instead of `Ownable`.

* `@x/utils`: Address review feedback.

* `@0x/contracts-zero-ex`: Address review feedback.

* `@0x/contracts-utils`: Address review feedback.

* `@0x/contracts-zero-ex`: Return deployment nonce in `transform()`.

* `@0x/contracts-zero-ex`: Finish returning deployment nonce in `transform()`.

* `@0x/contracts-zero-ex`: Fix doc-gen bug.

* `@0x/contracts-zero-ex`: Address review comments.

* `@0x/utils`: Add `NegativeTransformERC20OutputERror`

* `@0x/contracts-zero-ex`: Revert if the taker's output amount decreases.

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-05-20 22:47:21 -04:00
Lawrence Forman
f2e16dfb21 @0x/contracts-zero-ex: Switch rich revert style.
`@0x/contracts-zero-ex`: Merge `FixinOwnable` -> `FixinCommon`.
2020-04-29 13:01:19 -04:00
Lawrence Forman
0042e42160 @0x/contracts-zero-ex: Merge Migrate into Ownable 2020-04-24 01:06:44 -04:00
Lawrence Forman
4446ac1ca3 @0x/contracts-zero-ex: Use (scaled) enums for storage IDs 2020-04-21 22:29:46 -04:00
Lawrence Forman
12f2250ab5 @0x/contracts-zero-ex: bootstrap() is now a temporary feature, registered in the ZeroEx constructor.
`@0x/contracts-zero-ex`: `bootstrap()` de-registers itself and self-destructs once it's called.
`@0x/contracts-zero-ex`: `bootstrap()` now takes arbitrary call data, but the callee is fixed in an immutable.
`@0x/contracts-zero-ex`: `bootstrap()` caller is fixed in an immutable.
`@0x/contracts-zero-ex`: `bootstrap()` only calls a single target.
`@0x/contracts-zero-ex`: Renamed `BasicMigration` to `InitialMigration`.
`@0x/contracts-zero-ex`: `InitialMigration` is now the bootstrap target and multiplexes to the initial features.
`@0x/contracts-zero-ex`: Add `Migrate` feature and tests.
`@0x/contracts-zero-ex`: Re-organize contract locatins (remove `interfaces` folder).
2020-04-21 22:29:46 -04:00
Lawrence Forman
c11d661b39 @0x/contracts-zero-ex`: Create ZeroEx (proxy) contracts 2020-04-21 22:29:46 -04:00