Compare commits

...

466 Commits

Author SHA1 Message Date
xianny
b5eb1c9ee8 Publish
- @0x/contracts-asset-proxy@3.4.0
 - @0x/contracts-broker@1.1.6
 - @0x/contracts-coordinator@3.1.7
 - @0x/contracts-dev-utils@1.3.5
 - @0x/contracts-erc1155@2.1.7
 - @0x/contracts-erc20-bridge-sampler@1.7.0
 - @0x/contracts-erc20@3.2.1
 - @0x/contracts-erc721@3.1.7
 - @0x/contracts-exchange-forwarder@4.2.7
 - @0x/contracts-exchange-libs@4.3.7
 - @0x/contracts-exchange@3.2.7
 - @0x/contracts-extensions@6.2.1
 - @0x/contracts-integrations@2.6.0
 - @0x/contracts-multisig@4.1.7
 - @0x/contracts-staking@2.0.14
 - @0x/contracts-test-utils@5.3.4
 - @0x/contracts-utils@4.5.1
 - @0x/contracts-zero-ex@0.2.0
 - 0x.js@9.2.0
 - @0x/abi-gen@5.3.1
 - @0x/assert@3.0.9
 - @0x/asset-swapper@4.6.0
 - @0x/base-contract@6.2.3
 - @0x/connect@6.0.9
 - @0x/contract-addresses@4.11.0
 - @0x/contract-artifacts@3.7.1
 - @0x/contract-wrappers-test@12.2.16
 - @0x/contract-wrappers@13.8.0
 - @0x/contracts-gen@2.0.10
 - @0x/dev-utils@3.3.0
 - ethereum-types@3.2.0
 - @0x/instant@1.0.53
 - @0x/json-schemas@5.1.0
 - @0x/migrations@6.4.0
 - @0x/monorepo-scripts@1.0.54
 - @0x/order-utils@10.3.0
 - @0x/orderbook@2.2.7
 - @0x/sol-compiler@4.1.1
 - @0x/sol-coverage@4.0.10
 - @0x/sol-doc@3.1.8
 - @0x/sol-profiler@4.1.0
 - @0x/sol-resolver@3.1.0
 - @0x/sol-trace@3.0.10
 - @0x/sol-tracing-utils@7.1.0
 - @0x/sra-spec@3.0.9
 - @0x/subproviders@6.1.1
 - @0x/tslint-config@4.1.0
 - @0x/types@3.2.0
 - @0x/typescript-typings@5.1.1
 - @0x/utils@5.5.1
 - @0x/web3-wrapper@7.2.0
2020-07-14 21:48:14 -07:00
xianny
9d3755db36 Updated CHANGELOGS & MD docs 2020-07-14 21:47:59 -07:00
Jacob Evans
762e0aec2d fix: Update to use KNP getExpectedRateAfterFee (#2629)
* Update to use KNP getExpectedRateAfterFee

* hack: use overrides instead of forking in ganache

* fix: added some tests using overrides

* override sampler

* Overrides in bridge_sampler_mainnet_test

* use getContracts to fake out tests

* chore: supply devUtils address

* feat: specify the call override by default

* CHANGELOGs

* export SamplerOverrides

* fix package.json

* fix: after rebase
2020-07-15 14:05:57 +10:00
mzhu25
ff9c9241d8 BalancerBridge (#2613)
* Add BalancerBridge and Sampler functions

* Update sampler artifacts/wrappers

* Add Balancer support to AssetSwapper + related refactoring

* Make use of GraphQL instead of sampler

* "fix" build and add mainnet BalancerBridge tests

* address some comments

* add balancer cache and fix DexSampler tests

* lint

* wip: tests for balancer sampler ops

* Fix market operation utils test

* balancer unit tests

* Return a buy quote of 0 if the buy amount exceeds the Balancer pool's balance

* Dynamic fee estimation

* Update contract addresses, export BalancerBridge wrapper

* Update changelogs

* Fix bugs discovered via simbot

* Fix issues in balancer_utils

* override `BigNumber.config` in configured_bignumber.ts

* Special case Balancer subops in  too

* Address some more comments

* Address Balancer performance issue

* Performance improvements

* Address comment

* Fix tests

Co-authored-by: xianny <xianny@gmail.com>
2020-07-14 19:18:50 -07:00
Lawrence Forman
18bc701e8b Merge pull request #2610 from 0xProject/feat/zero-ex/meta-transactions
EP: MetaTransactions
2020-07-10 11:12:58 -04:00
Lawrence Forman
a47795fd3f @0x/contract-wrappers-test: Increase test timeout. 2020-07-10 03:05:56 -04:00
Lawrence Forman
a55e8b268c @0x/contracts-zero-ex: Fix linter errors. 2020-07-10 02:36:25 -04:00
Lawrence Forman
e8106f04b5 @0x/contracts-zero-ex: Address review feedback. 2020-07-10 02:36:25 -04:00
Lawrence Forman
bdc1dbf08a @0x/order-utils: Address review feedback. 2020-07-10 02:36:25 -04:00
Lawrence Forman
06eeb2088b @0x/types: Address review feedback. 2020-07-10 02:36:25 -04:00
Lawrence Forman
7da9ec2c75 @0x/contract-addresses: Update ganache snapshot addresses for the Exchange Proxy. 2020-07-10 02:36:24 -04:00
Lawrence Forman
297ff10c14 @0x/contracts-zero-ex: add SignatureValidator and MetaTransactions features. 2020-07-10 02:36:00 -04:00
Lawrence Forman
1305f4314d @0x/0x.js: Export ExchangeProxyMetaTransaction and SignedExchangeProxyMetaTransaction 2020-07-10 02:36:00 -04:00
Lawrence Forman
55474c0599 @0x/types: Add ExchangeProxyMetaTransactionHash(). 2020-07-10 02:36:00 -04:00
Lawrence Forman
687c79ae81 @0x/utils: Add more revert errors to ZeroExRevertErrors 2020-07-10 02:36:00 -04:00
Lawrence Forman
829a353b14 @0x/order-utils: Add getOrderHash(), getExchangeTransactionHash(), getExchangeProxyTransactionHash() 2020-07-10 02:36:00 -04:00
Lawrence Forman
aced474dc5 Merge pull request #2628 from 0xProject/fix/dfb-redeploy-kovan-07-10-20
Redeploy DFB on kovan.
2020-07-10 02:35:37 -04:00
Lawrence Forman
7c08d5f198 etheereum-types: Touch this package to fix publish. 2020-07-10 01:53:02 -04:00
Lawrence Forman
c546787994 @0x/contract-addresses: Redeploy DFB on kovan.
`@0x/contracts-utils`: Reorganize `DeploymentConstants` addresses.
2020-07-10 01:29:28 -04:00
Lawrence Forman
7967a8416c Merge pull request #2625 from 0xProject/feat/deploy-new-fqt-2608
Deploy FQT from #2608
2020-07-07 16:05:04 -04:00
Lawrence Forman
9164cff234 @0x/contract-addresses: Deploy FQT from PR 2608 2020-07-07 01:10:16 -04:00
Lawrence Forman
017f98e87e Merge pull request #2616 from 0xProject/fix/dfb-revert
Fix DFB instability
2020-07-07 01:08:51 -04:00
Lawrence Forman
f33d8670aa @0x/contract-addresses: Update DFB addresses. 2020-07-07 01:07:44 -04:00
Lawrence Forman
845a42e73a @0x/asset-proxy: Fix DFB instability 2020-07-07 01:06:46 -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
41cdbc0ec4 Merge pull request #2622 from 0xProject/migration/exchange-proxy/affiliate-fee-transformer-initial
Deploy AffiliateFeeTransformer
2020-07-02 23:40:35 -04:00
Lawrence Forman
c6ec261c5c @0x/asset-swapper: Fix failing test. 2020-07-02 21:45:39 -04:00
Lawrence Forman
a2db1a3275 @0x/migrations: Add affiliateFeeTransformer and exchangeProxyFlashWallet to ganache snapshot migration. 2020-07-02 21:45:39 -04:00
Lawrence Forman
1e8f2f0e83 @0x/contract-addresses: Add affiliateFeeTransformer and exchangeProxyFlashWallet addresses. 2020-07-02 16:04:33 -04:00
Lawrence Forman
8491abe142 @0x/contracts-zero-ex: Export AffiliateFeeTransformer. 2020-07-02 16:04:33 -04:00
Lawrence Forman
d4302538bf Merge pull request #2620 from 0xProject/feat/contract-wrappers/geth-call-support
geth eth_call support.
2020-07-02 11:48:35 -04:00
Lawrence Forman
c34e3765ef @0x/dev-utils: Export GethCallOverrides type 2020-07-02 01:57:01 -04:00
Lawrence Forman
1f86bc06ef @0x/web3-wrapper: Export GethCallOverrides and GethCallOverridesRPC. 2020-07-02 01:56:33 -04:00
Lawrence Forman
7e892fac2d @0x/asset-swapper: Increase test timeout for slow CI 2020-07-02 00:33:23 -04:00
Lawrence Forman
23789b0692 @0x/contract-wrappers: Export GethCallOverrides. 2020-07-01 22:33:52 -04:00
Lawrence Forman
89adbe4127 0x.js: Export GethCallOverrides. 2020-07-01 21:08:25 -04:00
Lawrence Forman
11940fb98e @0x/json-schemas: Rename CallData.value -> CallData.balance and make it `wholeNumberSchema type.'
`@0x/web3-wrapper`: Only supply overrides to eth_call RPC if provided.
2020-07-01 20:43:33 -04:00
Lawrence Forman
13ae335811 0x/ethereum-types: Add geth eth_call types.
`0x/json-schemas`: Add geth eth_call properties to `CallData`.
`@0x/web3-wrapper`: Add geth geth eth_call support.
2020-07-01 15:54:49 -04:00
Lawrence Forman
b2dc6ad2fa @0x/asset-swapper: "Fix" forwarder buys of low decimal tokens. (#2618)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-07-01 20:30:12 +10:00
Jacob Evans
85ca926fd0 feat: asset-swapper singleton gas price oracle (#2619) 2020-07-01 18:43:47 +10:00
Jacob Evans
676698a59b fix: asset-swapper ethgasstation url option (#2617)
* fix: asset-swapper order-utils version

* fix: asset-swapper specify ethgasstation url as option

* default to real EGS

* fix: bad package.json
2020-07-01 13:47:34 +10:00
Lawrence Forman
22408ecd58 @0x/asset-swapper: Fix best/worst case asset amount calculations. (#2615)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Jacob Evans <jacob@dekz.net>
2020-06-30 17:58:06 +10:00
Jacob Evans
d36acc7ec7 fix: asset-swapper EthGasStation proxy url (#2614) 2020-06-30 17:41:52 +10:00
Lawrence Forman
a5a68acfec Add Exchange Proxy to Ganache snapshot (#2612)
* `@0x/contracts-zero-ex`: Expose migration tools.

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

* `@0x/migrations`: Add Exchange Proxy migration
2020-06-25 13:52:01 +10:00
Jacob Evans
7431651666 fix: package.json from publish (#2611) 2020-06-24 15:44:42 +10:00
Jacob Evans
4f91bfd907 Updated CHANGELOGS & MD docs 2020-06-24 14:12:56 +10:00
mzhu25
8d2086870b Merge pull request #2607 from 0xProject/fix/sol-profiler-returns
Fix sol-profiler bugs
2020-06-22 14:35:52 -07:00
Daniel Pyrathon
1511ef1a98 Merge pull request #2609 from 0xProject/feature/quote-requestor-strings
Quote Requestor Fix:  BigNumbers to Strings
2020-06-19 15:40:58 -07:00
Daniel Pyrathon
4e030ce1e8 remove legacy taker request 2020-06-19 15:07:39 -07:00
Steve Klebanoff
2507ad274b remove BigNumbers from expectedParams 2020-06-19 14:42:45 -07:00
Steve Klebanoff
fb1c149eb9 another comment 2020-06-19 13:43:27 -07:00
Steve Klebanoff
d4662f428a change BNs to strings 2020-06-19 13:29:19 -07:00
F. Eugene Aumson
73c779c13a Merge pull request #2582 from 0xProject/feat/asset-swapper/use-quote-server
asset-swapper: Use @0x/quote-server, not local typedefs; and adapt to renamed taker request parameters
2020-06-19 13:05:10 -04:00
F. Eugene Aumson
b8cc164af1 asset-s: rm refs to quoteExpiry for RFQT tests
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2582#discussion_r441836846
2020-06-17 17:29:35 -04:00
Michael Zhu
64a391b5f8 Update changelogs 2020-06-17 12:23:49 -07:00
Michael Zhu
21a202dd16 Fix sol-profiler bugs 2020-06-17 12:08:29 -07:00
F. Eugene Aumson
187dd2fdc3 asset-swapper: Prune dead code 2020-06-17 14:56:39 -04:00
F. Eugene Aumson
c18f3f0b33 asset-s: use RFQT-specific types in MarketOpUtils 2020-06-17 14:56:04 -04:00
F. Eugene Aumson
7162935028 asset-s: use RFQT-specific types in MarketOpUtils 2020-06-17 10:39:48 -04:00
Lawrence Forman
9215a73b6c Merge pull request #2604 from 0xProject/feat/order-utils/transformer-encoders
order-utils: ERC20 Transformer utils
2020-06-17 09:32:43 -04:00
Lawrence Forman
edd840794c @0x/asset-swapper: Fix linter errors. 2020-06-17 02:12:32 -04:00
Lawrence Forman
c30a6eb1aa @0x/contracts-zero-ex: Fix linter errors. 2020-06-17 01:23:08 -04:00
Lawrence Forman
233642af29 @0x/asset-swapper: Remove dependency on contracts-zero-ex. 2020-06-17 01:23:08 -04:00
Lawrence Forman
7dffd0a03e @0x/contracts-zero-ex: Use transformer utils from order-utils. 2020-06-17 01:23:08 -04:00
Lawrence Forman
f7bc3ff49d @0x/order-utils: Add ERC20 Transformer utils and export useful constants. 2020-06-17 01:23:08 -04:00
Lawrence Forman
53aabe3cdb Merge pull request #2605 from 0xProject/feat/zero-ex/transform-erc20-make-creatTransformWallet-onlyOwner
Flip `TransformERC20.createTransformWallet()` to `onlyOwner`
2020-06-17 01:17:43 -04:00
Lawrence Forman
09b8d7cfc9 @0x/contracts-zero-ex: Flip TransformERC20.createTransformWallet() to onlyOwner. 2020-06-16 18:07:03 -04:00
F. Eugene Aumson
1512afc7e6 CI: persist test-publish npm logs as Artifacts 2020-06-16 17:33:30 -04:00
F. Eugene Aumson
dde0c76112 Merge branch 'development' into feat/asset-swapper/use-quote-server 2020-06-16 10:26:56 -04:00
Xianny
f14b6f2ba2 Fix/erc20 sampler/uniswap v2 buys (#2603)
* `@0x/contracts-erc20-bridge-sampler`: Fix `sampleBuysFromUniswapV2()`

* fix uniswapV2 buys

* redeploy ERC20BridgeSampler to fix Uniswap buys

* fix changelog, move artifact to correct dir

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
2020-06-12 15:54:19 -07:00
Lawrence Forman
4fced276c4 Merge pull request #2591 from 0xProject/feat/asset-swapper/exchange-proxy-support
asset-swapper: Exchange Proxy support
2020-06-12 01:52:07 -04:00
Lawrence Forman
7590471d62 @0x/migrations: Add uniswapV2Bridge entry that was lost in rebase. 2020-06-12 00:40:37 -04:00
Lawrence Forman
0b6bcf6739 @0x/asset-swapper: Fix linter errors. 2020-06-11 23:59:54 -04:00
Lawrence Forman
3a5ce86ed9 @0x/sol-compiler: Fix CompilerOptions schema.
`@0x/contract-addresses`: Add `exchangeProxyGovernor`.
`@0x/contract-addresses`: Add deployed EP addresses.
`@0x/migrations`: Add `exchangeProxyGovernor`.
2020-06-11 23:59:24 -04:00
Lawrence Forman
7b298939e2 @0x/asset-swapper: Guess deployment nonce from transformer address.
`@0x/asset-swapper`: Fix ETH not being passed as the token to `transformERC20()`.
2020-06-11 23:53:18 -04:00
Lawrence Forman
f1f6aa7d80 Switch to using deployment nonce instead of transformer addresses. 2020-06-11 23:53:18 -04:00
Lawrence Forman
7ce7dd7252 @0x/asset-swapper: Address review feedback 2020-06-11 23:53:16 -04:00
Lawrence Forman
01aa556ede @0x/abi-gen: Update python wrappers generation to work with leading underscores in identifiers.' 2020-06-11 23:52:59 -04:00
Lawrence Forman
48ad39c1c7 @0x/asset-swapper: Add ExchangeProxySwapQuoteConsumer. 2020-06-11 23:52:56 -04:00
Lawrence Forman
9cab034448 @0x/migrations: Use new ContractAddresses type. 2020-06-11 23:52:39 -04:00
Lawrence Forman
0d7a22634c @0x/contract-addresses: Add exchange proxy address placeholders. 2020-06-11 23:51:45 -04:00
Lawrence Forman
3e3bc5c06d @0x/contract-artifacts: Add ITransformERC20 artifact.
`@0x/contract-wrappers`: Add `ITransformERC20Contract`.
2020-06-11 23:50:25 -04:00
Lawrence Forman
2a81e468c7 @0x/contracts-zero-ex: Add transformer decoders 2020-06-11 23:49:52 -04:00
Lawrence Forman
0ba67a363e @0x/instant: Pin asset-swapper version. 2020-06-11 23:49:52 -04:00
Lawrence Forman
deae846864 @0x/contracts-broker: Fix broken tests. 2020-06-11 23:49:52 -04:00
Lawrence Forman
3a0d48ad77 Run broker tests on CI 2020-06-11 23:49:52 -04:00
Jacob Evans
81d4803b4d fix: UniswapV2 path order (#2601) 2020-06-12 13:26:56 +10:00
mzhu25
e936c7c507 Merge pull request #2593 from 0xProject/feature/multibridge/asset-swapper
Add MultiBridge support to AssetSwapper
2020-06-11 14:26:32 -07:00
F. Eugene Aumson
ad868af96e asset-swapper: use RFQT-specific response types
@0x/quote-server was recently updated to offer RFQT- and RFQM-specific
types, in addition to abstracted types.  Since everything here is RFQT
specific, usage has been changed to use those specific types.

Addresses review comments
https://github.com/0xProject/0x-monorepo/pull/2582#discussion_r437623138
and
https://github.com/0xProject/0x-monorepo/pull/2582#discussion_r437625305
2020-06-11 15:57:49 -04:00
Michael Zhu
cd14a45414 Update sampler artifacts/wrappers 2020-06-11 12:47:54 -07:00
F. Eugene Aumson
f7cd7110ea asset-s: Remove erroneous addition of API key
It was added due to the introduction of the use of the TakerRequest type
from @0x/quote-server, as it's included in that structure.  However,
that structure is primarily used within the quote server as the output
of parameter parsing, and that parsing routine transforms the API key
HEADER from the request into the TakerRequest type.  In short, the API
key is input as a header, not a parameter.

Addresses review comment
https://github.com/0xProject/0x-monorepo/pull/2582#discussion_r437624647
2020-06-11 14:17:45 -04:00
Michael Zhu
44262bf747 MultiBridge support in AssetSwapper 2020-06-11 11:14:48 -07:00
Xianny
0fbbabe208 Add Uniswap V2 support to @0x/asset-swapper (#2599)
* add uniswapV2

* update changelogs

* remove unused import

* add tests for Uniswap V2 ETH

* rename UniswapV2 and UniswapV2Eth

* use correct token address path

* update contract addresses after deploy
2020-06-11 10:23:50 -07:00
Lawrence Forman
b39189fde3 Merge pull request #2594 from 0xProject/feat/contracts-zero-ex/AffiliateFeeTransformer
Exchange Proxy: AffiliateFeeTransformer
2020-06-08 22:24:17 -04:00
Lawrence Forman
18fc1d78f4 @0x/contracts-zero-ex: Rebase 2020-06-08 21:34:09 -04:00
Lawrence Forman
d44a91d10b @0x/contracts-zero-ex: Address review feedback. 2020-06-08 21:33:27 -04:00
Lawrence Forman
5e9829b2d8 @0x/contracts-zero-ex: Add AffiliateFeeTransformer tests. 2020-06-08 21:33:27 -04:00
Lawrence Forman
2176deae36 @0x/contracts-zero-ex: Rebase 2020-06-08 21:33:27 -04:00
Lawrence Forman
7c5035aa39 @0x/contracts-zero-ex: Use array of structs in AffiliateFeeTransformer data. 2020-06-08 21:33:27 -04:00
Lawrence Forman
5707993995 @0x/contracts-zero-ex: Add AffiliateFeeTransformer. 2020-06-08 21:33:26 -04:00
Lawrence Forman
f81697527c Merge pull request #2592 from 0xProject/feat/zero-ex/transformer-deployer
Exchange Proxy: TransformerDeployer
2020-06-08 20:30:09 -04:00
Lawrence Forman
967eff4c58 Merge pull request #2597 from 0xProject/fix/zero-ex/transform-erc20-audit
Exchange Proxy: Address audit feedback (2)
2020-06-08 20:29:27 -04:00
F. Eugene Aumson
d5d07dd34e Merge branch 'development' into feat/asset-swapper/use-quote-server 2020-06-08 19:15:07 -04:00
F. Eugene Aumson
b91cc3781d asset-swapper: Use newer @0x/quote-server 2020-06-08 18:07:59 -04:00
Lawrence Forman
87ed0071c4 @0x/contracts-zero-ex: Make TransformerDeployer boring. 2020-06-08 15:30:56 -04:00
Lawrence Forman
0fed48630c @0x/contracts-zero-ex: Add TransformDeployer contract. 2020-06-08 15:30:56 -04:00
Lawrence Forman
7b3e7c98ac @0x/contracts-zero-ex: Add missing docstrings + fix compilation errors. 2020-06-08 15:28:27 -04:00
Lawrence Forman
09f44b0375 Update changelogs 2020-06-08 15:28:27 -04:00
Lawrence Forman
ebfa62637e @0x/contracts-zero-ex: Address audit feedback. 2020-06-08 15:28:27 -04:00
Lawrence Forman
cb2cc05cac @0x/contracts-erc20: Update LibERC20TokenV06 comments. 2020-06-08 15:28:27 -04:00
Lawrence Forman
f9c9131d81 @0x/contracts-utils: Update V06 contracts to get around 0.6.9 docstring errors 2020-06-08 15:28:27 -04:00
Lawrence Forman
1be9a1cbc7 @0x/utils: Update ZeroExRevertErrors. 2020-06-08 15:28:27 -04:00
F. Eugene Aumson
b7fda8ecf0 Merge pull request #2598 from 0xProject/fix/py-ci-mypy-0.780
Python: pin mypy to <= 0.770
2020-06-08 12:27:30 -04:00
F. Eugene Aumson
db16392821 Python: pin mypy to <= 0.770
See also https://github.com/python/mypy/issues/8953
2020-06-08 11:51:38 -04:00
Xianny
7127f541c3 UniswapV2Bridge (#2590)
* implement UniswapV2 Bridge

* More tests for UniswapV2Bridge

* cleanup and remove ERC20BridgeSampler changes

* enable multihop; address review comments

* solidity 0.6.9 doesnt allow devdoc for public storage vars

* codestyle improvements
2020-06-05 11:56:52 -07:00
Lawrence Forman
32793cc008 Merge pull request #2595 from 0xProject/feat/erc20-bridge-sampler/uniswapv2-tests
Add Uniswap V2 to ERC20BridgeSampler
2020-06-04 12:14:07 -04:00
xianny
fbaf55cb25 update @0x/contract-artifacts and @0x/contract-wrappers 2020-06-03 13:45:35 -07:00
xianny
b8d51fc4e8 rename contract to UniswapV2Router01
https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/UniswapV2Router01.sol
2020-06-03 12:08:08 -07:00
Lawrence Forman
0c6e05d220 Merge pull request #2576 from 0xProject/feat/contracts-zero-ex/0x-api-erc20-transformers
ZeroEx: ERC20 Transformers
2020-06-03 14:09:20 -04:00
Lawrence Forman
4066c17a0f @0x/contracts-erc20-bridge-sampler: Add UniswapV2. 2020-06-03 14:01:09 -04:00
Lawrence Forman
429f2bb8dd @0x/contracts-utils: Add UniswapV2 to DeploymentConstants. 2020-06-03 13:57:59 -04:00
Lawrence Forman
112f4fc4f0 @0x/contracts-zero-ex: Address review comments. 2020-06-02 22:01:22 -04:00
Lawrence Forman
ecfbd6280f @0x/contracts-zero-ex: Address review feedback. 2020-05-28 11:56:59 -04:00
Lawrence Forman
bf84409839 @0x/utils: Update InvalidTransformDataError. 2020-05-28 11:56:59 -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
e1d213d1a3 @0x/utils: Add more transformer revert errors. 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
0e1a5a375a @0x/contracts-test-utils: Add msg param to assertIntegerRoughlyEquals 2020-05-28 11:56:59 -04:00
Lawrence Forman
cfc3daeb65 @0x/utils: Add ERC20 transformer revert errors. 2020-05-28 11:56:59 -04:00
Lawrence Forman
6359f1950e @0x/contracts-zero-ex: Address review feedback. 2020-05-28 11:56:59 -04:00
Lawrence Forman
d2f581853d @x/utils: Address review feedback. 2020-05-28 11:56:59 -04:00
Lawrence Forman
030cb285da @0x/contracts-zero-ex: Use immutable owner in Puppet instead of Ownable. 2020-05-28 11:56:59 -04:00
Lawrence Forman
af45409959 @0x/contracts-zero-ex: Revamp TransformERC20. 2020-05-28 11:56:59 -04:00
Lawrence Forman
d9a9bc35e3 @0x/zero-ex: Rebase and use "slot" instead of "offset" language in storage buckets. 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
654abbac25 @0x/contracts-zero-ex: Introduce the TransformERC20 feature. 2020-05-28 11:56:58 -04:00
Lawrence Forman
46d5f42c9d @0x/utils: Add new ZeroExRevertErrors revert types 2020-05-28 11:56:58 -04:00
Lawrence Forman
1509da1215 @0x/contracts-utils: Convert more 0.6 contracts 2020-05-28 11:56:58 -04:00
F. Eugene Aumson
98a99d96aa Merge pull request #2588 from 0xProject/feuGeneA-patch-4
asset-swapper: For RFQ, don't log error status code if there isn't one
2020-05-27 19:31:43 -04:00
F. Eugene Aumson
d62d81af17 Update quote_requestor.ts 2020-05-27 14:19:24 -04:00
Lawrence Forman
dba67eb927 asset-swapper: Increase timeout for tests. (#2587)
* `@0x/asset-swapper`: Increase timeout for tests.

* Update packages/asset-swapper/CHANGELOG.json

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

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Kim Persson <kimpers@users.noreply.github.com>
2020-05-27 09:51:20 -04:00
Lawrence Forman
548c30d6a0 ZeroEx: Audit Fixes (#2586)
* `@0x/utils`: Remove unused revert error.

* `@0x/contracts-zero-ex`: Address audit feedback.
2020-05-26 20:57:55 -04:00
F. Eugene Aumson
1b8b9186a8 asset-swapper: Fix test-publish 2020-05-26 18:46:19 -04:00
F. Eugene Aumson
a8cfcfb371 Fix test-publish CI failure 2020-05-26 15:24:43 -04:00
F. Eugene Aumson
f7a414bc29 asset-s/RFQ: adapt to renamed TakerRequest fields 2020-05-26 15:24:42 -04:00
F. Eugene Aumson
e05cd1d66b asset-s/QuoteRequestor: use TakerRequest type 2020-05-26 15:24:38 -04:00
F. Eugene Aumson
511cd90c44 Merge pull request #2585 from 0xProject/fix/asset-swapper/rfqt-error-status-logging
asset-s/QuoteRequestor: fix statusCode logging
2020-05-21 18:43:04 -04:00
F. Eugene Aumson
8fb2d8da88 asset-s/QuoteRequestor: fix statusCode logging 2020-05-21 16:37:37 -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
Francesco Agosti
b23f1eb145 Merge pull request #2583 from 0xProject/feat/estimated-gas-token-refund
Expose fills object in asset-swapper quote orders
2020-05-20 14:56:49 -07:00
fragosti
f694072b5a Run prettier 2020-05-20 14:20:54 -07:00
fragosti
10de266e0f Remove unused variable SignedOrderWithFillableAmounts 2020-05-20 13:13:01 -07:00
fragosti
71811ed04f Remove unused variable 2020-05-20 12:53:58 -07:00
fragosti
e9638ef95e Add to changelog 2020-05-20 12:52:35 -07:00
fragosti
5226bb5596 Expose fills in asset-swapper quote 2020-05-20 12:50:15 -07:00
F. Eugene Aumson
b9984b6df4 asset-swapper: fix bug: bad maker response throws
Formerly, a maker sending back a non-JSON was causing an exception to be
thrown.
2020-05-15 01:20:30 -04:00
F. Eugene Aumson
9c11835fee asset-s: use @0x/quote-server, not local typedefs 2020-05-15 01:20:29 -04:00
F. Eugene Aumson
d9e13d6b99 Merge pull request #2581 from 0xProject/fix/asset-swapper/rfqt-logging
asset-swapper: Improve logging for 0x API consumption
2020-05-11 19:13:07 -04:00
F. Eugene Aumson
dede076835 asset-s/QuoteRequestor: clarify axios error type
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2581#discussion_r423337773
2020-05-11 18:34:32 -04:00
F. Eugene Aumson
c929782e0d asset-swapper/RFQT: Log params sent to maker
* Include in RFQ-T info log entry the query parameters that were sent to
the maker.

* Re-organize log entry
    * Rename top-level field from rfqtMakerResponse to
    rfqtMakerInteraction.
    * Create separate `request` and `response` sub-objects.

* Rename field `latency` to `latencyMs`.
2020-05-11 18:01:06 -04:00
F. Eugene Aumson
a43c7e36f8 asset-swapper/RFQT: log maker response metadata 2020-05-11 17:40:19 -04:00
F. Eugene Aumson
b95cec9c32 asset-swapper: fix bug: RFQ-T info log was broken 2020-05-11 17:39:30 -04:00
F. Eugene Aumson
9a7d9abe3c asset-swapper: consolidate RFQ-T usage of Axios 2020-05-11 13:52:42 -04:00
F. Eugene Aumson
c77b620453 asset-swapper: Improve RFQ-T logging for 0x API
* Change QuoteRequestor logger parameters to conform to pino logging
library, duplicating (one of) their LogFunction prototype interfaces for
our purposes here.  With this, every log emission now includes BOTH a
human-readable message AND a JSON object.  Also, this pattern has been
applied to both the error logger and the info logger.

* Do better handling of Axios errors when logging them.  Before we were
(a) logging errors in a separate log entry than the message that
explains it, and (b) dumping the whole error object to the log entry,
which was resulting in an object so massive that pino/Kibana was
splitting it into 3 separate entries.  Now, we (a) follow the pattern
described in the previous bullet, which puts the error object and the
human readable message into the same log entry, and (b) we check to see
if an error object is Axios-specific, and if so then we use the
AxiosError.toJSON() method to strip out the irrelevant properties.

* Log a uniform maker response metric, with maker endpoint URL, status
code, and latency, for both successful cases and erroneous ones.
(Before, we were only doing this for successful cases.)
2020-05-11 13:38:37 -04:00
Lawrence Forman
b348084e2a @0x/zero-ex: Always offset storage bucket ID by 1. (#2579)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-05-08 20:13:45 -04:00
F. Eugene Aumson
ff1811ef90 Merge pull request #2574 from 0xProject/rfqt-follow-ups
asset-swapper: RFQ-T follow ups
2020-05-07 17:44:02 -04:00
F. Eugene Aumson
39cf4a7576 Ran prettier...on development code! wtf?
Maybe something weird happened in the merge conflict resolution? Though
I didn't see anything in particular.
2020-05-07 01:39:22 -04:00
F. Eugene Aumson
21b67625a6 Merge branch 'development' into rfqt-follow-ups 2020-05-07 01:07:41 -04:00
Jacob Evans
fb0311e675 feat: ERC20BridgeSampler Unlock Kyber collisions (#2575)
* feat: ERC20BridgeSampler Unlock Kyber collisions

* Updated fallback strategy

* Address comments

* Eth2Dai hop sampler

* Update packages/asset-swapper/src/utils/market_operation_utils/index.ts

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

* Set DFB expiry to 2hr

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
2020-05-07 07:56:03 +10:00
F. Eugene Aumson
8a14b4afff asset-swapper: clarify comment
This comment recently got moved from one context to another.  In the old
context, the whole comment made sense, but in the new context it needed
paring down.
2020-05-06 13:24:20 -04:00
F. Eugene Aumson
e42701599a asset-s/RFQT: log each maker resp. time, not agg.
Log each maker's individual response times, rather than logging them in
aggregate.

Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2574#discussion_r419769846
2020-05-06 13:23:35 -04:00
F. Eugene Aumson
352b1b43f2 asset-s: restore type safety to rfqt.skipBuyReq's
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2574#discussion_r420465928
2020-05-06 13:16:23 -04:00
F. Eugene Aumson
2922ebd095 asset-s/test: stop unnecessarily priming mock
Addresses review comment 93bdaba8ee (r419774170)
2020-05-05 17:17:47 -04:00
F. Eugene Aumson
a9e72085dd asset-s: fix bug handling RFQ-T skipBuyRequest
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2574#discussion_r419772045
2020-05-05 17:17:47 -04:00
F. Eugene Aumson
ed3d194c90 asset-s: ignore case verifying RFQT taker address
Do case INsensitive comparison when verifying that RFQ-T firm quote
contains the requested taker address.

This commit also introduces some changes around the RfqtRequestOpts
parameter.  Without these changes, there were errors (tsc or tslint?
can't remember) about takerAddress being possibly undefined.

Rather than asserting it yet again (which we're already doing via
assertTakerAddressOrThrow()), I decided to change the RfqtRequestOpts
param to be required, not optional.  Coincidentally, this brings the
requestRfqtFirmQuotesAsync() interface into alignment with the
requestRfqtIndicativeQuotesAsync() one, which already requires the
options parameter.

Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2574#discussion_r419770087
2020-05-05 17:17:46 -04:00
F. Eugene Aumson
125c53827b asset-s: check RFQ expiry more canonically
For firm quotes, re-use orderCalculationUtils.willOrderExpire(), just
like utils.order_prune_utils.

For indicative quotes, duplicate the logic used in that
willOrderExpire() function, since it can't be re-used for an indicative
quote (it's not a full Order object), and since the logic is very
minimal.

Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2574#discussion_r419768395
2020-05-05 17:16:48 -04:00
F. Eugene Aumson
38781807cd asset-s: simplify test util usage 2020-05-05 12:53:31 -04:00
F. Eugene Aumson
c046943269 asset-s: fix bug: expiry is BigNumber, not string 2020-05-05 12:43:41 -04:00
Lawrence Forman
fe36cd86bb Merge pull request #2573 from 0xProject/fix/contracts-zero-ex/initial-migration-self-destruct
ZeroEx: InitialMigration Race Condition/Self-destruct
2020-04-30 15:02:16 -04:00
F. Eugene Aumson
401410089c asset-s/QuoteRequestor: info log Objects, not strs
In the QuoteRequestor class, when _infoLogger() is used, log objects
directly, rather than stringifying them first.  This changes the 0x API
log rendering from

{"level":"info","time":1588209135290,"pid":13022,"hostname":"precision5510","msg":"{\"aggregatedRfqtLatencyMs\":4}","v":1}

to

{"level":"info","time":1588224481908,"pid":3637,"hostname":"precision5510","aggregatedRfqtLatencyMs":2,"v":1}

This facilitates parsing of these logs by Kibana.
2020-04-30 01:32:06 -04:00
F. Eugene Aumson
fa23337519 asset-swapper: Ran prettier 2020-04-29 17:50:16 -04:00
F. Eugene Aumson
ae5421f76e asset-s: Use expiryBufferMs to filter RFQ-T quotes 2020-04-29 17:24:51 -04:00
F. Eugene Aumson
a2e2b429d5 asset-s: exclude RFQ-T orders w/ bad takerAddress 2020-04-29 17:24:42 -04:00
F. Eugene Aumson
ac852b23b3 asset-s: allow disabling of buy req's for RFQ-T 2020-04-29 17:23:16 -04:00
F. Eugene Aumson
e12389a002 asset-s: don't ignore default SwapQuoter RFQT opts 2020-04-29 17:23:16 -04:00
F. Eugene Aumson
da18e42d2a asset-s: Fix prettier command to match monorepo's 2020-04-29 17:23:15 -04:00
F. Eugene Aumson
93bdaba8ee asset-s: skip RFQT makers not supporting reqd pair
Skip querying an RFQ-T maker for a quote when the requested asset pair
isn't supported by that maker.
2020-04-29 17:23:10 -04:00
F. Eugene Aumson
4cb08a61d5 asset-s: RFQT info logger; log maker response time 2020-04-29 17:22:59 -04:00
Lawrence Forman
133692ca92 @0x/contract-wrappers-test: Increase test timeout for CI 2020-04-29 17:11:00 -04:00
F. Eugene Aumson
4bcc4b3cf8 asset-s: relay expiration time in indicative quote 2020-04-29 15:45:35 -04:00
F. Eugene Aumson
4eb20ca4b6 asset-s/QuoteRequestor: use constructor assignment 2020-04-29 15:45:35 -04:00
Lawrence Forman
69f7343be5 @0x/contracts-zero-ex: Lock the caller of InitialMigration.deploy() and actually self-destruct. 2020-04-29 14:26:55 -04:00
F. Eugene Aumson
19b28a58d6 Merge pull request #2544 from 0xProject/fix/pyfail-dupe-docstrings
Python: unpin Sphinx dependency, clean up warnings
2020-04-29 13:53:18 -04:00
Lawrence Forman
3c33a93b9c Merge pull request #2572 from 0xProject/feat/contracts-zero-ex/syntactic-sugar-1
ZeroEx: Switch rich revert style.
2020-04-29 13:52:39 -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
F. Eugene Aumson
0f689e8051 Merge pull request #2571 from 0xProject/fix/pylint-upgrade
Python: adapt to latest version of pylint
2020-04-29 12:15:31 -04:00
F. Eugene Aumson
5b44e6ef64 Python: adapt to latest version of pylint 2020-04-29 10:10:18 -04:00
Lawrence Forman
49e4ade66f Merge pull request #2570 from 0xProject/fix/redeploy-sampler-on-kovan
`@0x/contract-addresses`: Redeploy sampler on kovan
2020-04-28 17:33:02 -04:00
Lawrence Forman
3bae27d039 @0x/contract-addresses: Redeploy sampler on kovan 2020-04-28 15:05:51 -04:00
Lawrence Forman
a77f0c606d Merge pull request #2569 from 0xProject/feat/contracts-zero-ex/iownable-compat
ZeroEx: IOwnable(V06) compatibility
2020-04-28 14:29:33 -04:00
Lawrence Forman
f1de64dcaf @0x/contracts-zero-ex: Make Ownable feature conform to IOwnable. 2020-04-28 12:16:30 -04:00
Lawrence Forman
feb672c3cd @0x/contracts-utils: Make IOwnableV06 conform to IOwnable. 2020-04-28 12:16:11 -04:00
mzhu25
a90b463a7d Merge pull request #2567 from 0xProject/fix/instanceof-array-isArray
instanceof Array -> Array.isArray
2020-04-28 01:03:02 -07:00
Jacob Evans
5f5f25c978 fix: contract-addresses ERC20BridgeSampler (#2568)
* fix: contract-addresses ERC20BridgeSampler

* CHANGELOG
2020-04-28 17:48:32 +10:00
Michael Zhu
351ea8bc1c instanceof Array -> Array.isArray 2020-04-27 18:28:56 -07:00
Jacob Evans
b34edcbf87 [asset-swapper] clip native fill data (#2565)
* [asset-swapper] clip native fill data

* Test for createFillPaths

* CHANGELOG
2020-04-25 08:44:48 +10:00
Alex Towle
160519e1fe Merge pull request #2566 from 0xProject/fix/dangling-promises-asset-swapper
[asset-swapper] Fixed dangling promises
2020-04-24 16:53:30 -05:00
Alex Towle
44d626e12e Changed style 2020-04-24 13:31:47 -05:00
Alex Towle
efb9dc51c9 Fix linting error 2020-04-24 13:07:15 -05:00
Alex Towle
deb51434fd Fixed dangling promises 2020-04-24 12:44:05 -05:00
Lawrence Forman
501070bfb0 Merge pull request #2564 from 0xProject/feat/contracts-zero-ex/consolidate-bootstrap-features
ZeroEx: Merge Migrate and Ownable Features
2020-04-24 01:43:04 -04:00
Lawrence Forman
712958d8c8 @0x/asset-swapper: Fix sporadically failing quote simulation tests. 2020-04-24 01:07:16 -04:00
Lawrence Forman
4d8d944fe5 @0x/contracts-utils: Update package.json 2020-04-24 01:06:44 -04:00
Lawrence Forman
0042e42160 @0x/contracts-zero-ex: Merge Migrate into Ownable 2020-04-24 01:06:44 -04:00
Lawrence Forman
85509ea251 @0x/utils: ZeroExRevertErrors.Migrate -> ZeroExRevertErrors.Ownable 2020-04-24 01:06:44 -04:00
Jacob Evans
6063854d06 Add Curve sUSD (#2563) 2020-04-24 07:06:36 +10:00
F. Eugene Aumson
456f8a90b1 Merge pull request #2562 from 0xProject/feature/rfqt-warning-logger
asset-swapper: support RFQ-T logger callback
2020-04-23 01:48:43 -04:00
F. Eugene Aumson
980246d07a asset-swapper: use lambda not .bind() 2020-04-23 01:11:15 -04:00
F. Eugene Aumson
141c30b173 asset-swapper: remove debug logging 2020-04-23 01:08:26 -04:00
F. Eugene Aumson
22f9b03fce asset-swapper: Remove superfluous conditional 2020-04-23 01:07:57 -04:00
Lawrence Forman
be2db504b9 Merge pull request #2561 from 0xProject/feat/contracts-zero-ex/unused-storage-id
ZeroEx: Add `Unused` to `StorageId` enum
2020-04-23 00:23:35 -04:00
Jacob Evans
cac6f5234f Collapse on-chain sources into DexForwarderBridge (#2560)
* Collapse on-chain sources into DexForwarderBridge

* Fix tests. CHANGELOG
2020-04-23 13:12:46 +10:00
F. Eugene Aumson
eb6b32b6ee asset-swapper: support RFQ-T logger callback
For use in integrations that have specific log formats to adhere to.
2020-04-22 20:59:17 -04:00
F. Eugene Aumson
07acc9529e Merge pull request #2555 from 0xProject/rfq-t-indicative
asset-swapper: RFQ-T indicative quotes
2020-04-22 16:34:02 -04:00
Lawrence Forman
f7f0152573 @0x/contracts-zero-ex: Add Unused to StorageId enum 2020-04-22 16:06:49 -04:00
F. Eugene Aumson
153533f1d5 Fix bug in prior revision: wrong asset data
I tried to get fancy back in 5effc6ec90.
I changed something more than the single refactor targetted by the
commit, and it broke things!  This reverts part of that commit,
restoring clean runs of 0x API tests.
2020-04-22 11:58:09 -04:00
F. Eugene Aumson
11622c586a asset-s: Add RfqtRequestOpts.isIndicative 2020-04-22 11:58:09 -04:00
Lawrence Forman
7396bb508a Merge pull request #2540 from 0xProject/feat/contracts/zero-ex
ZeroEx: Universal proxy
2020-04-21 23:37:35 -04:00
Lawrence Forman
7df6530f3a @0x/contracrts-zero-ex: Address more review comments. 2020-04-21 22:29:46 -04:00
Lawrence Forman
80787456fa @0x/contracts-zero-ex: Fix comments. 2020-04-21 22:29:46 -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
220039ab00 @0x/contracts-zero-ex: Allow any call target to bootstrap(). 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
0c33aa16a1 @0x/utils: Add more ZeroEx rich reverts.
`@0x/utils: Display revert error payload in stack traces.
2020-04-21 22:29:46 -04:00
Lawrence Forman
72908b02fe @0x/contracts-zero-ex: Address review feedback.
`@0x/contracts-zero-ex`: Add target implementation address to `rollback()`.
`@0x/contracts-zero-ex`: Add storage ID uniqueness test.
`@0x/contracts-zero-ex`: Add rollback history querying functions to `SimpleFunctionRegistry`.
2020-04-21 22:29:46 -04:00
Lawrence Forman
223aa04424 @0x/utils: Change SimpleFunctionRegistry NoRollbackHistoryError to NotInRollbackHistoryError. 2020-04-21 22:29:46 -04:00
Lawrence Forman
e53248cca6 @0x/sol-compiler: Address review feedback. 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
Lawrence Forman
4212a08337 @0x/contracts-utils: Add solidity 0.6 contracts 2020-04-21 22:29:46 -04:00
Lawrence Forman
c0553fa9eb Add @0x/contracts-zero-ex project to monorepo.
Tweak circleci config to avoid running out of memory.
2020-04-21 22:29:46 -04:00
Lawrence Forman
7f26fafed7 @0x/utils: ZeroExRevertErrors. 2020-04-21 22:29:46 -04:00
Lawrence Forman
3e9309c003 @0x/sol-compiler: Strip receive functions from 0.6 ABI output 2020-04-21 22:29:46 -04:00
Lawrence Forman
1017707475 ethereum-types: Update MethodAbi definition for solidity 0.6 2020-04-21 22:29:46 -04:00
F. Eugene Aumson
e8ff5da209 asset-swapper: update CHANGELOG 2020-04-21 01:49:28 -04:00
F. Eugene Aumson
03ed3ac1b0 Merge branch 'development' into rfq-t-indicative 2020-04-21 00:50:50 -04:00
F. Eugene Aumson
2c97208e74 asset-s: simplify type with ?, not |undefined
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2555#discussion_r411081841
2020-04-21 00:49:30 -04:00
Jacob Evans
a458e81f8d ERC20BridgeSampler: Additional Buy support (#2551)
* ERC20BridgeSampler: Sample Curve Buy

* Fake Buy Kyber/PLP

* Deploy mainnet

* Add Kyber rates for buy tests

* CHANGELOGs

* Provide maxIterations and targetSlippage as options

* Cleanup ERC20BridgeSampler for re-use

* Redeploy Mainnet Kovan

* Feedback fixes

* Handle OOG/revert 0s

* Redeploy Mainnet refactor
2020-04-21 13:26:12 +10:00
F. Eugene Aumson
83289bc801 asset-s: consider falsey takerAddress as absent
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2555#discussion_r411543876
2020-04-20 22:56:44 -04:00
F. Eugene Aumson
ba2ac6a7b5 asset-s: Clarify indicative quote enablement
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2555#discussion_r411498729
2020-04-20 22:56:44 -04:00
F. Eugene Aumson
245b6da577 asset-s: Require RfqtRequestOpts.intentOnFilling
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2555#discussion_r411083497
2020-04-20 22:56:44 -04:00
F. Eugene Aumson
8875f924b0 asset-s: test requestRfqtIndicativeQuotesAsync 2020-04-20 22:56:44 -04:00
F. Eugene Aumson
ad7868ebe1 asset-s: clean up order faking for indicative RFQT
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2555#discussion_r411545804
2020-04-20 22:56:44 -04:00
F. Eugene Aumson
5effc6ec90 asset-swapper: extract method
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2555#discussion_r411514718
2020-04-20 22:56:43 -04:00
F. Eugene Aumson
4cc9ceabd2 asset-swapper: Rm unused ERC20BridgeSource.Rfqt
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2555#discussion_r410517580
2020-04-20 22:56:43 -04:00
F. Eugene Aumson
464c918134 asset-swapper: test RFQT indicative quote handling 2020-04-20 22:56:43 -04:00
F. Eugene Aumson
2456adcb68 asset-swapper: validate RFQT indicative quotes
Validate that the responses returned from maker endpoints both conform
to expected JSON schema data types and also have the expected asset
data, per the taker's request.
2020-04-20 22:56:43 -04:00
F. Eugene Aumson
45bc967f30 asset-swapper: Differentiate RFQT warning messages 2020-04-17 02:34:36 -04:00
F. Eugene Aumson
d6d4d29257 asset-swapper: RFQ-T indicative quotes
These changes have been exercised via mocha tests in the 0x-api repo.

Not sure why I had to add GetMarketOrdersRfqtOpts to the package
exports.  `yarn test:generate_docs:circleci` said:

$ node ./packages/monorepo-scripts/lib/doc_generate.js --package @0x/asset-swapper
GENERATE_DOCS: Generating Typedoc JSON for @0x/asset-swapper...
GENERATE_DOCS: Generating Typedoc Markdown for @0x/asset-swapper...
GENERATE_DOCS: Modifying Markdown To Exclude Unexported Items...
Error: @0x/asset-swapper package needs to export:
GetMarketOrdersRfqtOpts
From it's index.ts. If any are from external dependencies, then add them to the EXTERNAL_TYPE_MAP.
    at DocGenerateUtils._lookForMissingReferenceExportsThrowIfExists (/root/repo/packages/monorepo-scripts/lib/utils/doc_generate_utils.js:288:19)
    at DocGenerateUtils.<anonymous> (/root/repo/packages/monorepo-scripts/lib/utils/doc_generate_utils.js:255:34)
    at step (/root/repo/packages/monorepo-scripts/lib/utils/doc_generate_utils.js:32:23)
    at Object.next (/root/repo/packages/monorepo-scripts/lib/utils/doc_generate_utils.js:13:53)
    at fulfilled (/root/repo/packages/monorepo-scripts/lib/utils/doc_generate_utils.js:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
2020-04-17 02:34:36 -04:00
F. Eugene Aumson
33fdfdc8c0 asset-swapper: Extract method inferQueryParams
For use in upcoming implementation of indicative quotes.
2020-04-17 01:18:46 -04:00
F. Eugene Aumson
80c8712b2a asset-swapper: Rm unused field in SwapQuoterOpts 2020-04-17 01:18:28 -04:00
F. Eugene Aumson
957e3eb93c asset-swapper: Restructure RFQ-T request options
There's one subtlety here: apiKey has been moved to be within the rfqt
namespace, after talking to Fabio and discovering that he only needs to
re-use the API key in 0x API, not in asset-swapper.
2020-04-17 01:18:07 -04:00
F. Eugene Aumson
110e1afa8e Merge pull request #2541 from 0xProject/rfq-t
asset-swapper: RFQ-T firm quotes
2020-04-15 15:24:48 -04:00
F. Eugene Aumson
1da8f68871 migrations: Add independent yarn prettier script 2020-04-15 14:17:03 -04:00
F. Eugene Aumson
513ddb4cca Merge branch 'development' into rfq-t 2020-04-15 11:12:30 -04:00
F. Eugene Aumson
3bdfcb8542 Update {asset-s,migrat,contract-ad}* CHANGELOGs 2020-04-15 01:47:13 -04:00
F. Eugene Aumson
aee758eca2 Fix bug: Stop ignoring default SwapQuoteRequestOps
SwapQuoter._getSwapQuoteAsync() was merging defaults into the options
sent into SwapQuoteCalculator.calculateMarket{Buy,Sell}SwapQuoteAsync(),
but it was using the unmerged options function parameter for the RFQ-T
options and also for the gas price option.
2020-04-15 01:47:01 -04:00
Steve Klebanoff
47ef7fffce RFQ-T: validate assetData & add more tests (#2552)
* test for returning a 200 with invalid data, and additonal logging for that case

* Ensure RFQ-T response has asset data we expect

* validate signed order schema

* give more descriptive variable names and test an unsigned order

* takeout unused var
2020-04-15 00:11:37 -04:00
F. Eugene Aumson
58d6256607 Bug fix: RFQ-T orders werent going through sorting 2020-04-13 12:53:08 -04:00
F. Eugene Aumson
b854fcdb72 Remove an unnecessary type annotation 2020-04-13 12:53:08 -04:00
F. Eugene Aumson
27ca75d94f Clarify parallelization of orderbook & RFQT
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r406955099
2020-04-13 12:53:08 -04:00
F. Eugene Aumson
bb15f78af0 Validate maker endpoint responses with JSON Schema
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r406957115
2020-04-13 12:53:08 -04:00
F. Eugene Aumson
ccc9e18132 Type Axios response with undefined, not void
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r406956436
2020-04-13 12:53:08 -04:00
F. Eugene Aumson
d55108ab60 Eliminate unnecessary else
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405906319
2020-04-13 12:53:07 -04:00
Steve Klebanoff
84adbcb683 asset-swapper: Mockable axios for QuoteRequestor (#2549)
* Mockable axios for QuoteRequestor

* Move RFQT Mocker to src

* move MockedRfqtFirmQuoteResponse into types file

* fix import
2020-04-10 23:09:56 -04:00
F. Eugene Aumson
0cb5e4553b Await Axios response so we don't circumvent catch
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r406604110
2020-04-10 15:34:06 -04:00
F. Eugene Aumson
264407b707 In Opts types, REQUIRE rfqt SUB-options
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r406505994
2020-04-09 21:58:22 -04:00
F. Eugene Aumson
eb5ec58453 Add yarn prettier script, & call it from lint 2020-04-09 21:58:22 -04:00
F. Eugene Aumson
39c2a757be Promote a closure to a function
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405953107
2020-04-09 18:39:46 -04:00
F. Eugene Aumson
8cdc05f582 Promote max maker response time to a global option 2020-04-09 17:21:36 -04:00
F. Eugene Aumson
5f4778c852 Don't throw when RFQ-T client isn't whitelisted
Addresses review comments
https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405964457
and
https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r406040453
2020-04-09 17:21:35 -04:00
F. Eugene Aumson
70add44fc1 Push RFQ-T opts to SwapQuoterReqOpts subnamespace
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405969509
2020-04-09 17:21:35 -04:00
F. Eugene Aumson
fa617d2e9d Demote public member to private
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405963834
2020-04-09 17:21:35 -04:00
F. Eugene Aumson
3c795d365d Demote instance member to just constructor a arg
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405963779
2020-04-09 17:21:35 -04:00
F. Eugene Aumson
93872ad7a3 Push RFQ-T opts to own SwapQuoterOpts subnamespace
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405963240
2020-04-09 17:21:35 -04:00
F. Eugene Aumson
227676c150 Remove unused intentOnFilling method parameter
Addresses review comments
https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405952889
and
https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r406048104
2020-04-09 17:21:35 -04:00
F. Eugene Aumson
5f23833b43 rm unused SwapQuoteRequestOpts key enableRfqt
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r406043111
2020-04-09 17:21:35 -04:00
F. Eugene Aumson
121d51b414 Use try...catch instead of Promise.catch()
Addresses review comments
https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405953735
and
https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405966703
2020-04-09 17:21:34 -04:00
Jacob Evans
0e196a59d9 Always use DFB in asset-swapper (#2542)
* Always use DFB in asset-swapper

* Clean up
2020-04-09 15:52:15 +10:00
F. Eugene Aumson
63bfd23310 Pass QuoteRequestor via SwapQuoteOpts not ctor arg
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405900525
2020-04-09 00:29:58 -04:00
F. Eugene Aumson
aadcf8fed0 Parallelize RFQ-T with orderbook query
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405905572
2020-04-09 00:29:57 -04:00
F. Eugene Aumson
37390e03b4 Use Array.push instead of Array.concat
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405905052
2020-04-09 00:09:10 -04:00
F. Eugene Aumson
98fc780ade Use map idiom instead of for loop
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405904035
2020-04-08 23:14:06 -04:00
F. Eugene Aumson
1670b21123 Use NULL_ADDRESS instead of literal
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405901406
2020-04-08 22:56:11 -04:00
F. Eugene Aumson
5602aacbd2 mk SwapQuoterOpt rfqtTakerApiKeyWhitelist optional
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2541#discussion_r405749147
2020-04-08 22:48:21 -04:00
F. Eugene Aumson
6ddbea207f Stop using 3rd party sphinx typehints plugin
Because sphinx itself supports typehints now, and a recent update to
plugin caused it to start spewing massive amounts of warnings.
2020-04-08 14:09:50 -04:00
F. Eugene Aumson
261bced822 Fix redundant docstrings and unpin sphinx
The latest version of Sphinx (documentation generation utility) was
giving a warning (which we were configured to treat as an error) about
there being multiple docstring definitions for the same class.  This had
never been flagged before.
2020-04-08 14:09:49 -04:00
Lawrence Forman
a80d1f861c Merge pull request #2536 from 0xProject/feat/asset-swapper/DexForwarderBridge-support
asset-swapper: DFB support + refactors
2020-04-07 14:35:01 -04:00
Lawrence Forman
c541340ef5 Update CHANGELOG.json
`@0x/contract-addresses`: Redeploy `DexForwarderBridge` on Mainnet with Gas Token freeing
`@0x/contract-addresses`: Revert to older Curve Bridge (without Gas Tokens)
2020-04-07 13:41:37 -04:00
Lawrence Forman
434af0ae64 @0x/contracts-asset-proxy: Update CHANGELOG 2020-04-07 13:38:35 -04:00
Jacob Evans
c6379ca1d4 Update DexForwarderBridge address 2020-04-07 12:35:18 -04:00
Jacob Evans
cdbcada49b Authorize sender adddress 2020-04-07 12:35:18 -04:00
Jacob Evans
282930cb9b Add GST support to DFB 2020-04-07 12:35:18 -04:00
Lawrence Forman
b09c751942 @0x/asset-swapper: Remove deprecated swap_quote_calculator tests 2020-04-07 12:35:18 -04:00
Lawrence Forman
b2047b90b3 @0x/asset-proxy: Fix failing test. 2020-04-07 12:35:18 -04:00
Lawrence Forman
0c8aec30bd @0x/asset-swapper: Fix linter lies. 2020-04-07 12:35:18 -04:00
Lawrence Forman
fafaa3e69b @0x/asset-swapper: Lint and remove @0x/contracts-asset-proxy dep. 2020-04-07 12:35:18 -04:00
Lawrence Forman
d19bb3de8d @0x/asset-swapper: Run prettier 2020-04-07 12:35:18 -04:00
Lawrence Forman
481136166c @0x/asset-swapper: Remove unused Order export from index.ts. 2020-04-07 12:35:18 -04:00
Lawrence Forman
4df81a0b9e @0x/asset-swapper: add quote fill simulation tests 2020-04-07 12:35:18 -04:00
Lawrence Forman
da1e9c2d97 @0x/asset-swapper: Add DFB support + refactor swap quote calculation utils 2020-04-07 12:35:18 -04:00
F. Eugene Aumson
4b5a02c246 asset-swapper, migrations: incl. prettier in lint 2020-04-07 01:41:47 -04:00
F. Eugene Aumson
0e1572cfd7 migrations: add yarn publish:private 2020-04-07 01:41:47 -04:00
F. Eugene Aumson
343caa1ff6 migrations: Deploy ERC20BridgeSampler 2020-04-07 01:41:47 -04:00
F. Eugene Aumson
403fb3826d asset-swapper: support firm RFQ-T quote requests 2020-04-07 01:41:47 -04:00
F. Eugene Aumson
3cdccb7b4e prep asset-swapper: rename variable 2020-04-07 00:48:25 -04:00
F. Eugene Aumson
d9be78cdb4 py/contract_wrappers: Pin sphinx to prev version (#2539) 2020-04-07 00:47:45 -04:00
F. Eugene Aumson
16dc8255e1 Pin pytests to ganache snapshot 6.0.0 (#2535) 2020-04-06 20:01:54 -04:00
Lawrence Forman
2086bfff25 Merge pull request #2532 from 0xProject/feat/sol-compiler/support-0.6
sol-compiler: 0.6 support
2020-04-01 15:07:18 -04:00
Lawrence Forman
b9a68c0b8e @0x/sol-compiler: Address review feedback. 2020-04-01 14:30:17 -04:00
Lawrence Forman
74647f0e88 @0x/sol-compiler: remove fs.promises usage 2020-04-01 13:42:48 -04:00
Lawrence Forman
6e29c8bea9 @0x/sol-compiler: Make source paths in output artifacts nicer if they're within modules.
`@0x/sol-compiler`: Makea Add v0.6 solidity test.
2020-04-01 13:42:48 -04:00
Lawrence Forman
b36373ab81 @0x/sol-compiler: Insert compiler version in input artifacts. 2020-04-01 13:42:48 -04:00
Lawrence Forman
dc437aacf1 @0x/sol-compiler`: Refactor + add solidity 0.6 support 2020-04-01 13:42:48 -04:00
Lawrence Forman
e19dae9b28 @0x/typescript-typings: Add version() to SolcInstance 2020-04-01 13:42:48 -04:00
Jacob Evans
424cbd4831 Forwarder Market sell specified amount or throw (#2521)
* Forwarder Market sell specified amount or throw

* Address feedback comments

* Break if we have only protocol fee remaining

* Lint

* Update deployed addresses

* Updated artifacts and wrappers

* [asset-swapper] Forwarder throws on market sell if amount not sold (#2534)
2020-03-31 16:25:34 +10:00
Lawrence Forman
350feed993 Merge pull request #2531 from 0xProject/feat/erc20-bridge-sampler/dev-utils-as-param
ERC20BridgeSampler: Pass in `DevUtils` address as a constructor arg
2020-03-30 18:02:33 -04:00
Jacob Evans
7ca4aa0ff4 [asset-swapper] Fix getBatchMarketBuyOrdersAsync (#2533) 2020-03-31 04:21:03 +10:00
Lawrence Forman
bf00e67245 Merge pull request #2525 from 0xProject/feat/bridge/DexForwarderBridge
DexForwarderBridge
2020-03-27 17:44:47 -04:00
Lawrence Forman
c5a6e49681 update ganache forwarder address 2020-03-27 16:50:11 -04:00
Lawrence Forman
a509af2875 @0x/contract-addresses: Add dexForwarderBridge address.
`@0x/migrations`: Add `dexForwarderBridge` address field.
2020-03-27 16:40:46 -04:00
Lawrence Forman
1f789bf396 @0x/contracts-asset-proxy: Add DexForwarderBridge.executeBridgeCall() test. 2020-03-27 16:39:57 -04:00
Lawrence Forman
0ccbc7d3d2 @0x/contracts-asset-proxy: Fix typos and remove BridgeTransferFromCallFailed event from DexForwarderBridge. 2020-03-27 16:39:57 -04:00
Lawrence Forman
f3c6f26f85 @0x/contracts-asset-proxy: Fix typo in DFB tests. 2020-03-27 16:39:57 -04:00
Lawrence Forman
338c358df2 @0x/contracts-asset-proxy: Address review comments. 2020-03-27 16:39:57 -04:00
Lawrence Forman
4bdaa48303 @0x/contracts-asset-proxy: Create DexForwarderBridge bridge contract. 2020-03-27 16:39:57 -04:00
Lawrence Forman
36267746da @0x/contracts-erc20-bridge-sampler: Cache DevUtils address in getOrderFillableTakerAssetAmounts. 2020-03-26 12:11:14 -04:00
Lawrence Forman
7775541eed @0x/contracts-integrations: Update ERC20BridgeSampler tests 2020-03-26 12:09:14 -04:00
Lawrence Forman
5029be4c83 @0x/contracts-erc20-bridge-sampler: Pass in DevUtils address as a constructor parameter 2020-03-26 11:58:25 -04:00
Jacob Evans
277dbacf68 Set GSTCollector address and deploy Curve (#2530)
* Set GSTCollector address and deploy Curve

* CHANGELOGs
2020-03-26 18:26:16 +10:00
Lawrence Forman
0fdfb03f3c Merge pull request #2529 from 0xProject/fix/contract-addresses/fix-dydx-bridge-mainnet-address
Fix DydxBridge addresses.
2020-03-25 23:30:00 -04:00
Lawrence Forman
17d81bf014 @0x/contract-addresses: Fix DydxBridge mainnet/kovan address.
`@0x/contract-addresses`: Lowercase GodsUnchained/broker addresses.
2020-03-25 22:40:18 -04:00
Jacob Evans
568e9be07e Gas Tokens in Bridges (#2523)
* Gas Tokens in Bridges

* Added freesGasTokensFromCollector.

To handle the case where GST2 is being traded and the balanceOf checks become confusing

* Update CHANGELOGs
2020-03-26 11:58:28 +10:00
Lawrence Forman
99b0a95f8a Merge pull request #2526 from 0xProject/fix/asset-swapper/optimizer-fee-bugs
AssetSwapper: Fix quote optimizer fee bug
2020-03-24 09:56:09 -04:00
Lawrence Forman
0fdd31892a @0x/asset-swapper: Fix quote optimizer bug not properly accounting for fees. 2020-03-20 15:59:48 -04:00
Lawrence Forman
7a682604f9 Merge pull request #2524 from 0xProject/feat/erc20-bridge/less-ambiguous-transfer-event-args
Rename `ERC20BridgeTransfer` event args
2020-03-13 23:04:57 -04:00
Lawrence Forman
ce96e35d7d @0x/contracts-asset-proxy: Rename ERC20BridgeTransfer event args to be less ambiguous. 2020-03-13 21:00:35 -04:00
Xianny
b7fb5394a7 add gitpkg to contract-wrappers (#2520) 2020-03-13 10:10:32 -07:00
Lawrence Forman
aaa62beca7 Merge pull request #2522 from 0xProject/fix/asset-swapper/fee-schedule
`@0x/asset-swapper`: Fix fee schedule not being scaled by gas price.
2020-03-13 01:14:23 -04:00
Lawrence Forman
2b58a7242b @0x/asset-swapper: Fix changelog. 2020-03-13 00:40:19 -04:00
Lawrence Forman
5ed919df79 @0x/asset-swapper: Fix fee schedule not being scaled by gas price. 2020-03-13 00:10:04 -04:00
Lawrence Forman
baf6372179 Merge pull request #2513 from 0xProject/feat/asset-swapper/death-to-reverts
Asset-swapper: Fallback orders + refactors
2020-03-12 18:45:27 -04:00
Lawrence Forman
1a9063a55b @0x/asset-swapper: Address review comments. 2020-03-11 12:24:32 -04:00
Lawrence Forman
87999f402f @0x/asset-swapper: Sort native path fills by ADJUSTED rate. 2020-03-11 01:17:23 -04:00
Lawrence Forman
109d466260 @0x/asset-swapper: Fix double bridgeSlippage on generated orders. 2020-03-10 23:02:41 -04:00
Lawrence Forman
37597eca75 @0x/asset-swapper: Fix getPathSize() and getAdjustedPathSize() bug.
`@0x/asset-swapper`: Add `maxFallbackSlippage` option.
2020-03-10 14:25:13 -04:00
Lawrence Forman
5fd767b739 @0x/instant: Fix changelog. 2020-03-10 13:25:39 -04:00
Lawrence Forman
0e7a473116 @0x/asset-swapper: Clean up source breakdown code a bit.
`@0x/asset-swapper`: Allow Kyber conflicts in fallback path.
2020-03-10 00:05:14 -04:00
Lawrence Forman
05bf55dca8 @0x/asset-swapper: Add gasSchedule option to SwapQuoter.
`@0x/asset-swapper`: Rename `fees` `SwapQuoter` option to `feeSchedule`.
2020-03-09 22:33:33 -04:00
Lawrence Forman
cc12ad8d86 @0x/asset-swapper: Only generate fallbacks for native orders in optimal path.
`@0x/asset-swapper`: Exclude conflicting sources across both optimal and fallback paths.
2020-03-09 21:44:30 -04:00
Lawrence Forman
847a7f470c @0x/instant: Fix for changed asset-swapper configs. 2020-03-09 21:44:30 -04:00
Lawrence Forman
95bebd6d1d @0x/asset-swapper: Clean up median price calls. 2020-03-09 21:44:30 -04:00
Lawrence Forman
8179a964ea @0x/asset-swapper: Reintroduce runLimit option.
`@0x/asset-swapper`: Make native fills one single path.
`@0x/asset-swapper`: Redo the optimizer algo again to be more thorough.
`@0x/asset-swapper`: Make `getMedianSellRate()` return `1` if maker token == taker token.
2020-03-09 21:44:30 -04:00
Lawrence Forman
d0805d4bbb @0x/asset-swapper: Rebase and fix some minor bugs. 2020-03-09 21:44:29 -04:00
Lawrence Forman
f901c401b7 rebase 2020-03-09 21:44:29 -04:00
Lawrence Forman
6ccadcb928 @0x/asset-swapper: Refactor market op utils.
`@0x/asset-swapper`: add fallback orders.
`@0x/asset-swapper`: Remove `noConflicts` and `dustThreshold` options.
`@0x/asset-swapper`: Add `allowFallback` option.
2020-03-09 21:44:29 -04:00
Daniel Pyrathon
58b6c25d5c Merge pull request #2519 from 0xProject/PirosB3-patch-1
Update addresses.json
2020-03-09 10:44:44 -07:00
Daniel Pyrathon
9cbab26202 added CHANGELOG changes 2020-03-09 10:36:32 -07:00
Daniel Pyrathon
74bcb468ca Update addresses.json 2020-03-09 10:23:20 -07:00
Daniel Pyrathon
07a6ba88f4 Merge pull request #2515 from 0xProject/PirosB3-patch-1
Update CHANGELOG.json
2020-03-06 13:44:22 -08:00
Daniel Pyrathon
49dff49993 Update CHANGELOG.json 2020-03-06 12:47:18 -08:00
Daniel Pyrathon
68207aac80 Merge pull request #2505 from 0xProject/feature/plp-integration
🔂 Liquidity Provider Asset Swapper integration
2020-03-06 12:34:45 -08:00
Francesco Agosti
64652b2ff0 Merge pull request #2514 from 0xProject/feat/add-gitpkg-to-contract-addresses
Add private:publish to contract-addresses
2020-03-06 12:17:22 -08:00
Daniel Pyrathon
659e8991de Completed feedback 2020-03-06 12:02:36 -08:00
fragosti
9f495b6dc9 Add private:publish to contract-addresses 2020-03-06 11:32:08 -08:00
Daniel Pyrathon
d8498134ad Merge branch 'development' of github.com:0xProject/0x-monorepo into feature/plp-integration
# Conflicts:
#	packages/contract-addresses/addresses.json
#	packages/contract-wrappers/package.json
2020-03-06 09:59:16 -08:00
Daniel Pyrathon
17b2320b0d remove unit tests that were ported to erc20-bridge-sampler package 2020-03-06 09:53:54 -08:00
Daniel Pyrathon
36c457f483 added unit tests for the Liquidity Provider 2020-03-06 09:47:17 -08:00
Lawrence Forman
b8ec7f5e26 Merge pull request #2512 from 0xProject/fix/contracts/bridges-usdt-fix
Bridges: USDT/KNC fix + ERC20BridgeTransfer events
2020-03-05 19:41:55 -05:00
Daniel Pyrathon
dbc5c0d5d8 moved unit tests to the appropriate sections 2020-03-05 16:29:34 -08:00
Daniel Pyrathon
fa886aa849 prettify and lint 2020-03-05 16:21:15 -08:00
Daniel Pyrathon
32e1ae2b18 added unit tests to avoid regression due to variable order 2020-03-05 16:07:49 -08:00
Daniel Pyrathon
61f03b0ea2 invert maker and taker token variable 2020-03-05 16:07:10 -08:00
Lawrence Forman
c47825a820 @0x/contract-addresses: Redeploy bridges. 2020-03-05 18:39:48 -05:00
Lawrence Forman
2d7cb63c7b @0x/contracts-asset-proxy: Address review comments. 2020-03-05 18:21:38 -05:00
Lawrence Forman
c3d4c13936 @0x/contracts-erc20: Switch LibERC20Token.approveIfBelowMax() to LibERC20Token.approveIfBelow().
`@0x/contracts-asset-proxy`: Use `LibERC20Token.approveIfBelow()` for bridge approvals.
2020-03-05 18:21:38 -05:00
Lawrence Forman
3f51b9322f @0x/contracts-asset-proxy: Emit ERC20BridgeTransfer events in bridges. 2020-03-05 18:21:38 -05:00
Lawrence Forman
b604e2bd4e @0x/contracts-erc20: Add LibERC20Token.approveIfBelowMax().
`@0x/contracts-asset-proxy`: Use `LibERC20Token.approveIfBelowMax` in all DEX bridges.
2020-03-05 18:21:38 -05:00
mzhu25
bcd92473d1 Merge pull request #2511 from 0xProject/feature/extensions/max-gasprice-orders
`@0x/contracts-extensions`: Maximum gas price contract
2020-03-05 12:30:03 -08:00
Michael Zhu
6f5bf9d146 Add artifacts, wrappers, and addresses 2020-03-05 10:53:02 -08:00
Michael Zhu
490094939f Address comments 2020-03-04 22:12:48 -08:00
Daniel Pyrathon
d0d7d2772f upgrades contracts-erc20-bridge-sampler dependency 2020-03-04 14:33:43 -08:00
Daniel Pyrathon
59091896b4 Merge branch 'development' of github.com:0xProject/0x-monorepo into feature/plp-integration
# Conflicts:
#	packages/asset-swapper/package.json
#	packages/asset-swapper/src/utils/market_operation_utils/sampler.ts
#	packages/asset-swapper/src/utils/market_operation_utils/types.ts
#	packages/asset-swapper/test/market_operation_utils_test.ts
2020-03-04 14:11:17 -08:00
Daniel Pyrathon
3eb1429a25 adds possibility to exclude PLP 2020-03-04 13:50:07 -08:00
Daniel Pyrathon
bc7504c469 refresh wrappers and artifacts 2020-03-04 08:24:35 -08:00
Daniel Pyrathon
99dc4b8e07 refactor more code 2020-03-04 08:17:01 -08:00
Daniel Pyrathon
807904bb86 addressed PR comments 2020-03-04 07:59:09 -08:00
Francesco Agosti
7b8c8348f4 Merge pull request #2502 from 0xProject/feat/gitpkg-asset-swapper
Install gitpkg in asset-swapper
2020-03-04 07:30:22 -08:00
Michael Zhu
9c5ac26170 Update changelog 2020-03-03 17:30:53 -08:00
Michael Zhu
5db065644c Add tooling and unit tests 2020-03-03 17:30:53 -08:00
Alex Towle
0cc3a99169 Merge pull request #2504 from 0xProject/feature/better_resolver_errors
Update resolver errors to include parent filename
2020-03-03 16:56:26 -08:00
Michael Zhu
2b1545145b MaximumGasPrice contract 2020-03-03 15:39:45 -08:00
Daniel Pyrathon
49b7c9c8a4 update sampler address 2020-03-03 14:02:15 -08:00
fragosti
114119f7c8 Build before publish 2020-03-03 13:45:25 -08:00
fragosti
b4ef866c10 Update gitpkg to use fork 2020-03-03 13:27:43 -08:00
Jacob Evans
15f75a08d5 Publish
- @0x/contracts-asset-proxy@3.2.5
 - @0x/contracts-broker@1.1.4
 - @0x/contracts-coordinator@3.1.5
 - @0x/contracts-dev-utils@1.3.3
 - @0x/contracts-erc1155@2.1.5
 - @0x/contracts-erc20-bridge-sampler@1.5.1
 - @0x/contracts-erc20@3.1.5
 - @0x/contracts-erc721@3.1.5
 - @0x/contracts-exchange-forwarder@4.2.5
 - @0x/contracts-exchange-libs@4.3.5
 - @0x/contracts-exchange@3.2.5
 - @0x/contracts-extensions@6.1.5
 - @0x/contracts-integrations@2.5.1
 - @0x/contracts-multisig@4.1.5
 - @0x/contracts-staking@2.0.12
 - @0x/contracts-test-utils@5.3.2
 - @0x/contracts-utils@4.4.3
 - 0x.js@9.1.5
 - @0x/asset-swapper@4.4.0
 - @0x/contract-addresses@4.9.0
 - @0x/contract-wrappers-test@12.2.13
 - @0x/contract-wrappers@13.6.3
 - @0x/instant@1.0.50
 - @0x/migrations@6.2.4
 - @0x/order-utils@10.2.4
 - @0x/orderbook@2.2.5
2020-03-03 18:26:46 +11:00
Jacob Evans
29f9c5473d Updated CHANGELOGS & MD docs 2020-03-03 18:26:14 +11:00
Jacob Evans
ea1528aea6 [asset-swapper] Add latest BUSD Curve (#2506)
* [asset-swapper] Add latest BUSD Curve

* Update Compound Curve
2020-03-03 17:53:35 +11:00
Daniel Pyrathon
18ce19a84d refactored imports 2020-03-02 11:03:11 -08:00
Daniel Pyrathon
b0fd78d68d added linting to the contracts 2020-03-02 10:48:52 -08:00
Daniel Pyrathon
8186d6277e fixed a bug with imports 2020-03-02 10:16:40 -08:00
Daniel Pyrathon
599af2b1a9 factored out interfaces in types.ts 2020-03-02 10:12:51 -08:00
Daniel Pyrathon
82de5adbe9 refactored sampler operations into a single external file 2020-03-02 10:06:43 -08:00
Daniel Pyrathon
82b0f85258 transformed the new artifacts 2020-03-02 10:01:06 -08:00
David Sun
cded58c30d Merge pull request #2491 from 0xProject/fix/instant/support-erc721
[FIX] Instant + Asset-swapper support for ERC721
2020-03-01 14:57:18 -05:00
David Sun
da17b49b81 added changelog 2020-03-01 13:54:14 -05:00
David Sun
4728cdfa7c added changelog 2020-03-01 13:36:56 -05:00
Alex Towle
d97b30dcee Improve error message for nested errors 2020-02-28 17:11:30 -08:00
Daniel Pyrathon
fa8e8ad52d Update artifacts after rename 2020-02-28 17:09:48 -08:00
Daniel Pyrathon
7495ac8111 performed a rename 2020-02-28 16:54:05 -08:00
Daniel Pyrathon
08619e2c06 re-generate ERC20BridgeSampler artifacts 2020-02-28 15:59:46 -08:00
Daniel Pyrathon
5d4bbd5b37 Merge branch 'development' of github.com:0xProject/0x-monorepo into feature/plp-integration
# Conflicts:
#	packages/asset-swapper/package.json
2020-02-28 15:50:34 -08:00
Daniel Pyrathon
9d2aef5006 Added linting and prettifying 2020-02-28 12:36:47 -08:00
Daniel Pyrathon
bcc3e5ebb0 refactor tests, and add more tests 2020-02-28 12:28:09 -08:00
Daniel Pyrathon
e5df51a83a tidy up tests, add other tests 2020-02-28 12:12:58 -08:00
David Sun
97fb843f01 prettier 2020-02-28 14:03:54 -05:00
David Sun
8afb044877 address feedback 2020-02-28 13:15:50 -05:00
David Sun
7f869868c9 prettier + lint 2020-02-28 13:13:46 -05:00
David Sun
31275228ac patch asset-swapper to support ERC721 2020-02-28 13:13:18 -05:00
Daniel Pyrathon
7181be8768 added more unit tests, reinforced existing tests, added more implementation 2020-02-28 10:02:18 -08:00
Lawrence Forman
3b446e887a Merge pull request #2503 from 0xProject/feat/deploy-erc20-bridge-sampler
Redeploy `ERC20BridgeSampler`
2020-02-28 12:01:06 -05:00
Lawrence Forman
431196c391 @0x/contract-addresses: Redeploy ERC20BridgeSampler. 2020-02-28 01:18:24 -05:00
Daniel Pyrathon
9608d8fb46 added more unit tests for PLP DEX sampling 2020-02-27 16:03:44 -08:00
mzhu25
d574ca1628 Merge pull request #2501 from 0xProject/fix/bridge-sampler/get-liquidity-provider-from-registry
Fix getLiquidityProviderFromRegistry
2020-02-27 14:09:28 -08:00
Daniel Pyrathon
8be60e2ff5 initial unit tests for DEX sampler 2020-02-27 14:00:08 -08:00
Daniel Pyrathon
3c0fd540b1 generated wrappers for ERC20 sampler 2020-02-27 13:53:52 -08:00
fragosti
23a7dc9a8a Install gitpkg in asset-swapper 2020-02-27 13:51:28 -08:00
Michael Zhu
f97e6892b6 Fix getLiquidityProviderFromRegistry 2020-02-27 13:39:03 -08:00
Jacob Evans
7742901e5c Publish
- @0x/contracts-asset-proxy@3.2.4
 - @0x/contracts-broker@1.1.3
 - @0x/contracts-coordinator@3.1.4
 - @0x/contracts-dev-utils@1.3.2
 - @0x/contracts-erc1155@2.1.4
 - @0x/contracts-erc20-bridge-sampler@1.5.0
 - @0x/contracts-erc20@3.1.4
 - @0x/contracts-erc721@3.1.4
 - @0x/contracts-exchange-forwarder@4.2.4
 - @0x/contracts-exchange-libs@4.3.4
 - @0x/contracts-exchange@3.2.4
 - @0x/contracts-extensions@6.1.4
 - @0x/contracts-integrations@2.5.0
 - @0x/contracts-multisig@4.1.4
 - @0x/contracts-staking@2.0.11
 - @0x/contracts-test-utils@5.3.1
 - @0x/contracts-utils@4.4.2
 - 0x.js@9.1.4
 - @0x/asset-swapper@4.3.2
 - @0x/contract-addresses@4.8.0
 - @0x/contract-wrappers-test@12.2.12
 - @0x/contract-wrappers@13.6.2
 - @0x/instant@1.0.49
 - @0x/migrations@6.2.3
 - @0x/order-utils@10.2.3
 - @0x/orderbook@2.2.4
2020-02-28 08:13:33 +11:00
Jacob Evans
de68cb25d0 Updated CHANGELOGS & MD docs 2020-02-28 08:13:09 +11:00
Daniel Pyrathon
77d7afe505 created DummyPLPRegistry and DummyPLP + generated wrappers for these new contracts and their respective interfaces 2020-02-27 12:52:13 -08:00
Daniel Pyrathon
68fb6c2c27 Merge pull request #2499 from 0xProject/feature/erc20-bridge-sampler/liquidity-provider-registry
`@0x/contracts-erc20-bridge-sampler`: LiquidityProviderRegistry
2020-02-27 12:37:10 -08:00
Michael Zhu
a47c031ad1 Catch reverts when calling registry 2020-02-27 11:23:25 -08:00
Michael Zhu
817049456c Get liquidity provider from registry in the sampler 2020-02-27 11:05:56 -08:00
Lawrence Forman
e1a061789f Merge pull request #2500 from 0xProject/fix/asset-swapper/native-order-prune
[asset-swapper] Fix native fill prune
2020-02-27 13:38:49 -05:00
Jacob Evans
28573ba772 [asset-swapper] Fix native fill prune 2020-02-27 16:42:20 +11:00
David Sun
880b9413f6 Merge pull request #2492 from 0xProject/fix/instant/constant-polling
[Fix] Instant call destroyAsync on unmount
2020-02-26 19:36:48 -05:00
mzhu25
9a7c4b21a9 @0x/contracts-erc20-bridge-sampler: Generic liquidity provider sampling (#2487)
* Add methods to Sampler contract to plug into generic on-chain liquidity provider
2020-02-26 11:54:48 -08:00
mzhu25
ac56038eca Add Broker, GodsUnchainedValidator, ChainlinkStopLimit to ContractAddresses interface (#2498) 2020-02-26 11:54:32 -08:00
Lawrence Forman
4dd2fb6903 Merge pull request #2478 from 0xProject/feat/contracts/integrations/chai-bridge-benchmarks
`@0x/contracts-integrations`: Add `ChaiBridge` and `DydxBridge` gas b…
2020-02-26 14:17:15 -05:00
Lawrence Forman
0baec61f06 @0x/contracts/integrations: Update wallets and add comments with last run gas costs to benchmarks. 2020-02-26 12:57:03 -05:00
Lawrence Forman
d4751788d1 @0x/contracts-integrations: Add ChaiBridge and DydxBridge gas benchmark tests. 2020-02-26 11:29:44 -05:00
Lawrence Forman
ae68c061d1 @0x/asset-proxy: Add more functions to IDydx.
`@0x/dev-utils`: Fix all the weird dydx base unit madness.
2020-02-26 11:29:26 -05:00
Lawrence Forman
b0387245f0 @0x/contracts-utils: Roll back additions to LibFractions.
`@0x/contracts-dev-utils`: Add `D18` library for working with base-10, 18-digit decimals.
`@0x/contracts-dev-utils`: Use `D18` library instead of `LibFractions` in `LibDydxBalance`.
2020-02-26 11:29:16 -05:00
Lawrence Forman
c2d06a4a23 Cherry pick dydx validation from #2456 2020-02-26 11:29:02 -05:00
Lawrence Forman
270108abb7 Cherry pick DevUtils refactor code from #2456 2020-02-26 11:26:57 -05:00
Lawrence Forman
e76c33232d Cherry-pick changes from feat/dev-utils/dydx-bridge-validation 2020-02-26 11:26:57 -05:00
Jacob Evans
58ff2dc492 Publish
- @0x/contracts-asset-proxy@3.2.3
 - @0x/contracts-broker@1.1.2
 - @0x/contracts-coordinator@3.1.3
 - @0x/contracts-dev-utils@1.3.1
 - @0x/contracts-erc1155@2.1.3
 - @0x/contracts-erc20-bridge-sampler@1.4.2
 - @0x/contracts-erc20@3.1.3
 - @0x/contracts-erc721@3.1.3
 - @0x/contracts-exchange-forwarder@4.2.3
 - @0x/contracts-exchange-libs@4.3.3
 - @0x/contracts-exchange@3.2.3
 - @0x/contracts-extensions@6.1.3
 - @0x/contracts-integrations@2.4.2
 - @0x/contracts-multisig@4.1.3
 - @0x/contracts-staking@2.0.10
 - @0x/contracts-utils@4.4.1
 - 0x.js@9.1.3
 - @0x/abi-gen@5.2.2
 - @0x/asset-swapper@4.3.1
 - @0x/contract-wrappers-test@12.2.11
 - @0x/instant@1.0.48
 - @0x/migrations@6.2.2
 - @0x/orderbook@2.2.3
 - @0x/sol-doc@3.1.6
2020-02-26 11:34:29 +11:00
Jacob Evans
13c45a0e96 Updated CHANGELOGS & MD docs 2020-02-26 11:34:00 +11:00
henrynguyen5
90cb86911a Update resolver errors to include parent filename 2020-02-25 18:40:45 -05:00
Jacob Evans
be7b1a1bd4 Include bin in npm publish (#2496)
* Include bin in npm publish

* Include bin in files

* Update CHANGELOG

* Changelog
2020-02-26 10:12:52 +11:00
Amir Bandeali
132a3c6705 Merge pull request #2495 from 0xProject/feat/defaults-should-save-standard-input
Update boilerplate
2020-02-25 10:56:26 -08:00
Amir
5e73257557 Set shouldSaveStandardInput to true in all compiler.json files 2020-02-25 10:04:19 -08:00
Amir
e83346fbbb Do not prettify Solidity 2020-02-25 10:04:19 -08:00
David Sun
f56839ec6b call destroyAsync on unmount 2020-02-24 12:24:07 -05:00
529 changed files with 39558 additions and 6188 deletions

View File

@@ -38,17 +38,7 @@ jobs:
path: ~/repo/packages/abi-gen/test-cli/output
- store_artifacts:
path: ~/repo/packages/contract-wrappers/generated_docs
test-contracts-ganache:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-extensions @0x/contracts-asset-proxy @0x/contracts-exchange @0x/contracts-exchange-forwarder @0x/contracts-coordinator @0x/contracts-staking
test-exchange-ganache-3.0:
test-exchange-ganache:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
@@ -58,7 +48,7 @@ jobs:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-exchange
test-integrations-ganache-3.0:
test-integrations-ganache:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
@@ -68,7 +58,7 @@ jobs:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-integrations
test-contracts-rest-ganache-3.0:
test-contracts-staking-ganache:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
@@ -77,11 +67,17 @@ jobs:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-asset-proxy @0x/contracts-exchange-forwarder @0x/contracts-staking @0x/contracts-coordinator @0x/contracts-erc20-bridge-sampler
# TODO(dorothy-zbornak): Re-enable after updating this package for
# 3.0. At that time, also remove exclusion from monorepo
# package.json's test script.
# - run: yarn wsrun test:circleci @0x/contracts-extensions
- run: yarn wsrun test:circleci @0x/contracts-staking
test-contracts-rest-ganache:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-asset-proxy @0x/contracts-exchange-forwarder @0x/contracts-coordinator @0x/contracts-erc20-bridge-sampler @0x/contracts-broker @0x/contracts-zero-ex
test-publish:
resource_class: medium+
docker:
@@ -95,6 +91,8 @@ jobs:
- run:
command: yarn test:publish:circleci
no_output_timeout: 1800
- store_artifacts:
path: ~/.npm/_logs
test-doc-generation:
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
@@ -194,6 +192,8 @@ jobs:
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
- image: 0xorg/ganache-cli:6.0.0
environment:
VERSION: '6.0.0'
- image: 0xorg/mesh:0xV3
environment:
ETHEREUM_RPC_URL: 'http://localhost:8545'
@@ -417,13 +417,16 @@ workflows:
main:
jobs:
- build
- test-exchange-ganache-3.0:
- test-exchange-ganache:
requires:
- build
- test-integrations-ganache-3.0:
- test-integrations-ganache:
requires:
- build
- test-contracts-rest-ganache-3.0:
- test-contracts-staking-ganache:
requires:
- build
- test-contracts-rest-ganache:
requires:
- build
- test-rest:
@@ -440,8 +443,9 @@ workflows:
- build
- submit-coverage:
requires:
- test-contracts-rest-ganache-3.0
- test-exchange-ganache-3.0
- test-contracts-rest-ganache
- test-contracts-staking-ganache
- test-exchange-ganache
- test-rest
- static-tests
- test-python:

4
.gitignore vendored
View File

@@ -111,6 +111,8 @@ contracts/exchange-forwarder/generated-artifacts/
contracts/exchange-forwarder/test/generated-artifacts/
contracts/dev-utils/generated-artifacts/
contracts/dev-utils/test/generated-artifacts/
contracts/zero-ex/generated-artifacts/
contracts/zero-ex/test/generated-artifacts/
packages/sol-tracing-utils/test/fixtures/artifacts/
python-packages/contract_artifacts/src/zero_ex/contract_artifacts/artifacts/
@@ -165,6 +167,8 @@ contracts/exchange-forwarder/generated-wrappers/
contracts/exchange-forwarder/test/generated-wrappers/
contracts/dev-utils/generated-wrappers/
contracts/dev-utils/test/generated-wrappers/
contracts/zero-ex/generated-wrappers/
contracts/zero-ex/test/generated-wrappers/
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/*/__init__.py
# solc-bin in sol-compiler

View File

@@ -64,6 +64,10 @@ lib
/contracts/dev-utils/test/generated-wrappers
/contracts/dev-utils/generated-artifacts
/contracts/dev-utils/test/generated-artifacts
/contracts/zero-ex/generated-wrappers
/contracts/zero-ex/test/generated-wrappers
/contracts/zero-ex/generated-artifacts
/contracts/zero-ex/test/generated-artifacts
/contracts/staking/build/
/contracts/coordinator/build/
/contracts/exchange/build/
@@ -91,3 +95,4 @@ packages/abi-gen/test-cli/fixtures/artifacts/AbiGenDummy.json
packages/abi-gen/test-cli/fixtures/artifacts/LibDummy.json
packages/abi-gen/test-cli/fixtures/artifacts/TestLibDummy.json
packages/*/docs
*.sol

View File

@@ -1,4 +1,79 @@
[
{
"version": "3.4.0",
"changes": [
{
"note": "Fix instability with DFB.",
"pr": 2616
},
{
"note": "Add `BalancerBridge`",
"pr": 2613
}
],
"timestamp": 1594788383
},
{
"version": "3.3.0",
"changes": [
{
"note": "Use `LibERC20Token.approveIfBelow()` in DEX bridges for for approvals.",
"pr": 2512
},
{
"note": "Emit `ERC20BridgeTransfer` events in bridges.",
"pr": 2512
},
{
"note": "Change names of `ERC20BridgeTransfer` args to be less ambiguous.",
"pr": 2524
},
{
"note": "Added `MixinGasToken` allowing Gas Tokens to be freed",
"pr": 2523
},
{
"note": "Add `DexForwaderBridge` bridge contract.",
"pr": 2525
},
{
"note": "Add `UniswapV2Bridge` bridge contract.",
"pr": 2590
},
{
"note": "Add Gas Token freeing to `DexForwarderBridge` contract.",
"pr": 2536
}
],
"timestamp": 1592969527
},
{
"timestamp": 1583220306,
"version": "3.2.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582837861,
"version": "3.2.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582677073,
"version": "3.2.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582623685,
"version": "3.2.2",
@@ -42,7 +117,7 @@
},
{
"note": "Add `setOperators()` to `IDydx`",
"pr": "TODO"
"pr": 2462
}
],
"timestamp": 1581204851

View File

@@ -5,6 +5,33 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.4.0 - _July 15, 2020_
* Fix instability with DFB. (#2616)
* Add `BalancerBridge` (#2613)
## v3.3.0 - _June 24, 2020_
* Use `LibERC20Token.approveIfBelow()` in DEX bridges for for approvals. (#2512)
* Emit `ERC20BridgeTransfer` events in bridges. (#2512)
* Change names of `ERC20BridgeTransfer` args to be less ambiguous. (#2524)
* Added `MixinGasToken` allowing Gas Tokens to be freed (#2523)
* Add `DexForwaderBridge` bridge contract. (#2525)
* Add `UniswapV2Bridge` bridge contract. (#2590)
* Add Gas Token freeing to `DexForwarderBridge` contract. (#2536)
## v3.2.5 - _March 3, 2020_
* Dependencies updated
## v3.2.4 - _February 27, 2020_
* Dependencies updated
## v3.2.3 - _February 26, 2020_
* Dependencies updated
## v3.2.2 - _February 25, 2020_
* Dependencies updated
@@ -20,7 +47,7 @@ CHANGELOG
* Fix broken tests. (#2462)
* Remove dependency on `@0x/contracts-dev-utils` (#2462)
* Add asset data decoding functions (#2462)
* Add `setOperators()` to `IDydx` (#TODO)
* Add `setOperators()` to `IDydx` (#2462)
## v3.1.3 - _February 6, 2020_

View File

@@ -3,6 +3,7 @@
"contractsDir": "./contracts",
"useDockerisedSolc": false,
"isOfflineMode": false,
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": {

View File

@@ -0,0 +1,103 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/IBalancerPool.sol";
contract BalancerBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
/// token encoded in the bridge data, then transfers the bought
/// tokens to `to`.
/// @param toTokenAddress The token to buy and transfer to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded addresses of the "from" token and Balancer pool.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// Decode the bridge data.
(address fromTokenAddress, address poolAddress) = abi.decode(
bridgeData,
(address, address)
);
require(toTokenAddress != fromTokenAddress, "BalancerBridge/INVALID_PAIR");
uint256 fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
LibERC20Token.approveIfBelow(fromTokenAddress, poolAddress, fromTokenBalance);
// Sell all of this contract's `fromTokenAddress` token balance.
(uint256 boughtAmount,) = IBalancerPool(poolAddress).swapExactAmountIn(
fromTokenAddress, // tokenIn
fromTokenBalance, // tokenAmountIn
toTokenAddress, // tokenOut
amount, // minAmountOut
uint256(-1) // maxPrice
);
// Transfer the converted `toToken`s to `to`.
LibERC20Token.transfer(toTokenAddress, to, boughtAmount);
emit ERC20BridgeTransfer(
fromTokenAddress,
toTokenAddress,
fromTokenBalance,
boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Magic success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -35,7 +35,7 @@ contract ChaiBridge is
/// @param from Address to transfer asset from.
/// @param to Address to transfer asset to.
/// @param amount Amount of asset to transfer.
/// @return success The magic bytes `0x37708e9b` if successful.
/// @return success The magic bytes `0xdc1600f3` if successful.
function bridgeTransferFrom(
address /* tokenAddress */,
address from,

View File

@@ -26,6 +26,7 @@ import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/ICurve.sol";
import "./MixinGasToken.sol";
// solhint-disable not-rely-on-time
@@ -33,54 +34,64 @@ import "../interfaces/ICurve.sol";
contract CurveBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
DeploymentConstants,
MixinGasToken
{
struct CurveBridgeData {
address curveAddress;
int128 fromCoinIdx;
int128 toCoinIdx;
int128 version;
}
/// @dev Callback for `ICurve`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the opposing asset
/// (DAI, USDC) to the Curve contract, then transfers the bought
/// tokens to `to`.
/// @param toTokenAddress The token to give to `to` (i.e DAI, USDC, USDT).
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoeded "from" token address.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address /* from */,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
freesGasTokensFromCollector
returns (bytes4 success)
{
// Decode the bridge data to get the Curve metadata.
(address curveAddress, int128 fromCoinIdx, int128 toCoinIdx, int128 version) = abi.decode(bridgeData, (address, int128, int128, int128));
ICurve exchange = ICurve(curveAddress);
CurveBridgeData memory data = abi.decode(bridgeData, (CurveBridgeData));
address fromTokenAddress = exchange.underlying_coins(fromCoinIdx);
address fromTokenAddress = ICurve(data.curveAddress).underlying_coins(data.fromCoinIdx);
require(toTokenAddress != fromTokenAddress, "CurveBridge/INVALID_PAIR");
uint256 fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
LibERC20Token.approve(fromTokenAddress, address(exchange), uint256(-1));
LibERC20Token.approveIfBelow(fromTokenAddress, data.curveAddress, fromTokenBalance);
// Try to sell all of this contract's `fromTokenAddress` token balance.
if (version == 0) {
exchange.exchange_underlying(
fromCoinIdx,
toCoinIdx,
if (data.version == 0) {
ICurve(data.curveAddress).exchange_underlying(
data.fromCoinIdx,
data.toCoinIdx,
// dx
IERC20Token(fromTokenAddress).balanceOf(address(this)),
fromTokenBalance,
// min dy
amount,
// expires
block.timestamp + 1
);
} else {
exchange.exchange_underlying(
fromCoinIdx,
toCoinIdx,
ICurve(data.curveAddress).exchange_underlying(
data.fromCoinIdx,
data.toCoinIdx,
// dx
IERC20Token(fromTokenAddress).balanceOf(address(this)),
fromTokenBalance,
// min dy
amount
);
@@ -89,6 +100,15 @@ contract CurveBridge is
uint256 toTokenBalance = IERC20Token(toTokenAddress).balanceOf(address(this));
// Transfer the converted `toToken`s to `to`.
LibERC20Token.transfer(toTokenAddress, to, toTokenBalance);
emit ERC20BridgeTransfer(
fromTokenAddress,
toTokenAddress,
fromTokenBalance,
toTokenBalance,
from,
to
);
return BRIDGE_SUCCESS;
}

View File

@@ -0,0 +1,200 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
import "../interfaces/IERC20Bridge.sol";
import "./MixinGasToken.sol";
// solhint-disable space-after-comma, indent
contract DexForwarderBridge is
IERC20Bridge,
IWallet,
DeploymentConstants,
MixinGasToken
{
using LibSafeMath for uint256;
/// @dev Data needed to reconstruct a bridge call.
struct BridgeCall {
address target;
uint256 inputTokenAmount;
uint256 outputTokenAmount;
bytes bridgeData;
}
/// @dev Intermediate state variables used by `bridgeTransferFrom()`, in
/// struct form to get around stack limits.
struct TransferFromState {
address inputToken;
uint256 initialInputTokenBalance;
uint256 callInputTokenAmount;
uint256 callOutputTokenAmount;
uint256 totalInputTokenSold;
BridgeCall[] calls;
}
/// @dev Spends this contract's entire balance of input tokens by forwarding
/// them to other bridges. Reverts if the entire balance is not spent.
/// @param outputToken The token being bought.
/// @param to The recipient of the bought tokens.
/// @param bridgeData The abi-encoded input token address.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address outputToken,
address /* from */,
address to,
uint256 /* amount */,
bytes calldata bridgeData
)
external
freesGasTokensFromCollector
returns (bytes4 success)
{
require(
msg.sender == _getERC20BridgeProxyAddress(),
"DexForwarderBridge/SENDER_NOT_AUTHORIZED"
);
TransferFromState memory state;
(
state.inputToken,
state.calls
) = abi.decode(bridgeData, (address, BridgeCall[]));
state.initialInputTokenBalance =
IERC20Token(state.inputToken).balanceOf(address(this));
for (uint256 i = 0; i < state.calls.length; ++i) {
// Stop if the we've sold all our input tokens.
if (state.totalInputTokenSold >= state.initialInputTokenBalance) {
break;
}
// Compute token amounts.
state.callInputTokenAmount = LibSafeMath.min256(
state.calls[i].inputTokenAmount,
state.initialInputTokenBalance.safeSub(state.totalInputTokenSold)
);
state.callOutputTokenAmount = LibMath.getPartialAmountFloor(
state.callInputTokenAmount,
state.calls[i].inputTokenAmount,
state.calls[i].outputTokenAmount
);
// Execute the call in a new context so we can recoup transferred
// funds by reverting.
(bool didSucceed, ) = address(this)
.call(abi.encodeWithSelector(
this.executeBridgeCall.selector,
state.calls[i].target,
to,
state.inputToken,
outputToken,
state.callInputTokenAmount,
state.callOutputTokenAmount,
state.calls[i].bridgeData
));
if (didSucceed) {
// Increase the amount of tokens sold.
state.totalInputTokenSold = state.totalInputTokenSold.safeAdd(
state.callInputTokenAmount
);
}
}
// Always succeed.
return BRIDGE_SUCCESS;
}
/// @dev Transfers `inputToken` token to a bridge contract then calls
/// its `bridgeTransferFrom()`. This is executed in separate context
/// so we can revert the transfer on error. This can only be called
// by this contract itself.
/// @param bridge The bridge contract.
/// @param to The recipient of `outputToken` tokens.
/// @param inputToken The input token.
/// @param outputToken The output token.
/// @param inputTokenAmount The amount of input tokens to transfer to `bridge`.
/// @param outputTokenAmount The amount of expected output tokens to be sent
/// to `to` by `bridge`.
function executeBridgeCall(
address bridge,
address to,
address inputToken,
address outputToken,
uint256 inputTokenAmount,
uint256 outputTokenAmount,
bytes calldata bridgeData
)
external
{
// Must be called through `bridgeTransferFrom()`.
require(msg.sender == address(this), "DexForwarderBridge/ONLY_SELF");
// `bridge` must not be this contract.
require(bridge != address(this));
// Get the starting balance of output tokens for `to`.
uint256 initialRecipientBalance = IERC20Token(outputToken).balanceOf(to);
// Transfer input tokens to the bridge.
LibERC20Token.transfer(inputToken, bridge, inputTokenAmount);
// Call the bridge.
(bool didSucceed, bytes memory resultData) =
bridge.call(abi.encodeWithSelector(
IERC20Bridge(0).bridgeTransferFrom.selector,
outputToken,
bridge,
to,
outputTokenAmount,
bridgeData
));
// Revert if the call failed or not enough tokens were bought.
// This will also undo the token transfer.
require(
didSucceed
&& resultData.length == 32
&& LibBytes.readBytes32(resultData, 0) == bytes32(BRIDGE_SUCCESS)
&& IERC20Token(outputToken).balanceOf(to).safeSub(initialRecipientBalance) >= outputTokenAmount
);
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Magic success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -50,7 +50,7 @@ contract DydxBridge is
/// @param encodedBridgeData An abi-encoded `BridgeData` struct.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address,
address, /* toTokenAddress */
address from,
address to,
uint256 amount,
@@ -81,6 +81,7 @@ contract DydxBridge is
// Run operation. This will revert on failure.
IDydx(_getDydxAddress()).operate(accounts, actions);
return BRIDGE_SUCCESS;
}

View File

@@ -38,13 +38,14 @@ contract Eth2DaiBridge is
/// (DAI or WETH) to the Eth2Dai contract, then transfers the bought
/// tokens to `to`.
/// @param toTokenAddress The token to give to `to` (either DAI or WETH).
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoeded "from" token address.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address /* from */,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
@@ -56,18 +57,28 @@ contract Eth2DaiBridge is
(address fromTokenAddress) = abi.decode(bridgeData, (address));
IEth2Dai exchange = IEth2Dai(_getEth2DaiAddress());
uint256 fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
LibERC20Token.approve(fromTokenAddress, address(exchange), uint256(-1));
LibERC20Token.approveIfBelow(fromTokenAddress, address(exchange), fromTokenBalance);
// Try to sell all of this contract's `fromTokenAddress` token balance.
uint256 boughtAmount = exchange.sellAllAmount(
fromTokenAddress,
IERC20Token(fromTokenAddress).balanceOf(address(this)),
fromTokenBalance,
toTokenAddress,
amount
);
// Transfer the converted `toToken`s to `to`.
LibERC20Token.transfer(toTokenAddress, to, boughtAmount);
emit ERC20BridgeTransfer(
fromTokenAddress,
toTokenAddress,
fromTokenBalance,
boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}

View File

@@ -66,13 +66,14 @@ contract KyberBridge is
/// to the `KyberNetworkProxy` contract, then transfers the bought
/// tokens to `to`.
/// @param toTokenAddress The token to give to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoeded "from" token address.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address /* from */,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
@@ -109,7 +110,11 @@ contract KyberBridge is
} else if (state.fromTokenAddress != address(state.weth)) {
// If the input token is not WETH, grant an allowance to the exchange
// to spend them.
LibERC20Token.approve(state.fromTokenAddress, address(state.kyber), uint256(-1));
LibERC20Token.approveIfBelow(
state.fromTokenAddress,
address(state.kyber),
state.fromTokenBalance
);
} else {
// If the input token is WETH, unwrap it and attach it to the call.
state.fromTokenAddress = KYBER_ETH_ADDRESS;
@@ -143,6 +148,15 @@ contract KyberBridge is
state.weth.deposit.value(boughtAmount)();
state.weth.transfer(to, boughtAmount);
}
emit ERC20BridgeTransfer(
state.fromTokenAddress == KYBER_ETH_ADDRESS ? address(state.weth) : state.fromTokenAddress,
toTokenAddress,
state.fromTokenBalance,
boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}

View File

@@ -0,0 +1,55 @@
/*
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.16;
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IGasToken.sol";
contract MixinGasToken is
DeploymentConstants
{
/// @dev Frees gas tokens based on the amount of gas consumed in the function
modifier freesGasTokens {
uint256 gasBefore = gasleft();
_;
IGasToken gst = IGasToken(_getGstAddress());
if (address(gst) != address(0)) {
// (gasUsed + FREE_BASE) / (2 * REIMBURSE - FREE_TOKEN)
// 14154 24000 6870
uint256 value = (gasBefore - gasleft() + 14154) / 41130;
gst.freeUpTo(value);
}
}
/// @dev Frees gas tokens using the balance of `from`. Amount freed is based
/// on the gas consumed in the function
modifier freesGasTokensFromCollector() {
uint256 gasBefore = gasleft();
_;
IGasToken gst = IGasToken(_getGstAddress());
if (address(gst) != address(0)) {
// (gasUsed + FREE_BASE) / (2 * REIMBURSE - FREE_TOKEN)
// 14154 24000 6870
uint256 value = (gasBefore - gasleft() + 14154) / 41130;
gst.freeFromUpTo(_getGstCollectorAddress(), value);
}
}
}

View File

@@ -38,10 +38,11 @@ contract UniswapBridge is
{
// Struct to hold `bridgeTransferFrom()` local variables in memory and to avoid
// stack overflows.
struct WithdrawToState {
struct TransferState {
IUniswapExchange exchange;
uint256 fromTokenBalance;
IEtherToken weth;
uint256 boughtAmount;
}
// solhint-disable no-empty-blocks
@@ -55,13 +56,14 @@ contract UniswapBridge is
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
/// token encoded in the bridge data.
/// @param toTokenAddress The token to buy and transfer to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded "from" token address.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address /* from */,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
@@ -70,7 +72,7 @@ contract UniswapBridge is
returns (bytes4 success)
{
// State memory object to avoid stack overflows.
WithdrawToState memory state;
TransferState memory state;
// Decode the bridge data to get the `fromTokenAddress`.
(address fromTokenAddress) = abi.decode(bridgeData, (address));
@@ -96,7 +98,7 @@ contract UniswapBridge is
state.weth.withdraw(state.fromTokenBalance);
// Buy as much of `toTokenAddress` token with ETH as possible and
// transfer it to `to`.
state.exchange.ethToTokenTransferInput.value(state.fromTokenBalance)(
state.boughtAmount = state.exchange.ethToTokenTransferInput.value(state.fromTokenBalance)(
// Minimum buy amount.
amount,
// Expires after this block.
@@ -108,9 +110,9 @@ contract UniswapBridge is
// Convert from a token to WETH.
} else if (toTokenAddress == address(state.weth)) {
// Grant the exchange an allowance.
_grantExchangeAllowance(state.exchange, fromTokenAddress);
_grantExchangeAllowance(state.exchange, fromTokenAddress, state.fromTokenBalance);
// Buy as much ETH with `fromTokenAddress` token as possible.
uint256 ethBought = state.exchange.tokenToEthSwapInput(
state.boughtAmount = state.exchange.tokenToEthSwapInput(
// Sell all tokens we hold.
state.fromTokenBalance,
// Minimum buy amount.
@@ -119,17 +121,17 @@ contract UniswapBridge is
block.timestamp
);
// Wrap the ETH.
state.weth.deposit.value(ethBought)();
state.weth.deposit.value(state.boughtAmount)();
// Transfer the WETH to `to`.
IEtherToken(toTokenAddress).transfer(to, ethBought);
IEtherToken(toTokenAddress).transfer(to, state.boughtAmount);
// Convert from one token to another.
} else {
// Grant the exchange an allowance.
_grantExchangeAllowance(state.exchange, fromTokenAddress);
_grantExchangeAllowance(state.exchange, fromTokenAddress, state.fromTokenBalance);
// Buy as much `toTokenAddress` token with `fromTokenAddress` token
// and transfer it to `to`.
state.exchange.tokenToTokenTransferInput(
state.boughtAmount = state.exchange.tokenToTokenTransferInput(
// Sell all tokens we hold.
state.fromTokenBalance,
// Minimum buy amount.
@@ -144,6 +146,15 @@ contract UniswapBridge is
toTokenAddress
);
}
emit ERC20BridgeTransfer(
fromTokenAddress,
toTokenAddress,
state.fromTokenBalance,
state.boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}
@@ -165,10 +176,19 @@ contract UniswapBridge is
/// on behalf of this contract.
/// @param exchange The Uniswap token exchange.
/// @param tokenAddress The token address for the exchange.
function _grantExchangeAllowance(IUniswapExchange exchange, address tokenAddress)
/// @param minimumAllowance The minimum necessary allowance.
function _grantExchangeAllowance(
IUniswapExchange exchange,
address tokenAddress,
uint256 minimumAllowance
)
private
{
LibERC20Token.approve(tokenAddress, address(exchange), uint256(-1));
LibERC20Token.approveIfBelow(
tokenAddress,
address(exchange),
minimumAllowance
);
}
/// @dev Retrieves the uniswap exchange for a given token pair.

View File

@@ -0,0 +1,135 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IUniswapV2Router01.sol";
import "../interfaces/IERC20Bridge.sol";
// solhint-disable space-after-comma
// solhint-disable not-rely-on-time
contract UniswapV2Bridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
struct TransferState {
address[] path;
uint256 fromTokenBalance;
}
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
/// token encoded in the bridge data.
/// @param toTokenAddress The token to buy and transfer to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded path of token addresses. Last element must be toTokenAddress
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// hold variables to get around stack depth limitations
TransferState memory state;
// Decode the bridge data to get the `fromTokenAddress`.
// solhint-disable indent
state.path = abi.decode(bridgeData, (address[]));
// solhint-enable indent
require(state.path.length >= 2, "UniswapV2Bridge/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
require(state.path[state.path.length - 1] == toTokenAddress, "UniswapV2Bridge/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN");
// Just transfer the tokens if they're the same.
if (state.path[0] == toTokenAddress) {
LibERC20Token.transfer(state.path[0], to, amount);
return BRIDGE_SUCCESS;
}
// Get our balance of `fromTokenAddress` token.
state.fromTokenBalance = IERC20Token(state.path[0]).balanceOf(address(this));
// Grant the Uniswap router an allowance.
LibERC20Token.approveIfBelow(
state.path[0],
_getUniswapV2Router01Address(),
state.fromTokenBalance
);
// Buy as much `toTokenAddress` token with `fromTokenAddress` token
// and transfer it to `to`.
IUniswapV2Router01 router = IUniswapV2Router01(_getUniswapV2Router01Address());
uint[] memory amounts = router.swapExactTokensForTokens(
// Sell all tokens we hold.
state.fromTokenBalance,
// Minimum buy amount.
amount,
// Convert `fromTokenAddress` to `toTokenAddress`.
state.path,
// Recipient is `to`.
to,
// Expires after this block.
block.timestamp
);
emit ERC20BridgeTransfer(
// input token
state.path[0],
// output token
toTokenAddress,
// input token amount
state.fromTokenBalance,
// output token amount
amounts[amounts.length - 1],
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -0,0 +1,39 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
interface IBalancerPool {
/// @dev Sell `tokenAmountIn` of `tokenIn` and receive `tokenOut`.
/// @param tokenIn The token being sold
/// @param tokenAmountIn The amount of `tokenIn` to sell.
/// @param tokenOut The token being bought.
/// @param minAmountOut The minimum amount of `tokenOut` to buy.
/// @param maxPrice The maximum value for `spotPriceAfter`.
/// @return tokenAmountOut The amount of `tokenOut` bought.
/// @return spotPriceAfter The new marginal spot price of the given
/// token pair for this pool.
function swapExactAmountIn(
address tokenIn,
uint tokenAmountIn,
address tokenOut,
uint minAmountOut,
uint maxPrice
) external returns (uint tokenAmountOut, uint spotPriceAfter);
}

View File

@@ -65,7 +65,6 @@ interface ICurve {
returns (uint256 dy);
/// @dev Get the amount of `fromToken` by buying `buyAmount` of `toToken`
/// This function exists on later versions of Curve (USDC/DAI/USDT)
/// @param i The token index being sold.
/// @param j The token index being bought.
/// @param buyAmount The amount of token being bought.

View File

@@ -21,16 +21,32 @@ pragma solidity ^0.5.9;
contract IERC20Bridge {
// @dev Result of a successful bridge call.
/// @dev Result of a successful bridge call.
bytes4 constant internal BRIDGE_SUCCESS = 0xdc1600f3;
/// @dev Emitted when a trade occurs.
/// @param inputToken The token the bridge is converting from.
/// @param outputToken The token the bridge is converting to.
/// @param inputTokenAmount Amount of input token.
/// @param outputTokenAmount Amount of output token.
/// @param from The `from` address in `bridgeTransferFrom()`
/// @param to The `to` address in `bridgeTransferFrom()`
event ERC20BridgeTransfer(
address inputToken,
address outputToken,
uint256 inputTokenAmount,
uint256 outputTokenAmount,
address from,
address to
);
/// @dev Transfers `amount` of the ERC20 `tokenAddress` from `from` to `to`.
/// @param tokenAddress The address of the ERC20 token to transfer.
/// @param from Address to transfer asset from.
/// @param to Address to transfer asset to.
/// @param amount Amount of asset to transfer.
/// @param bridgeData Arbitrary asset data needed by the bridge contract.
/// @return success The magic bytes `0x37708e9b` if successful.
/// @return success The magic bytes `0xdc1600f3` if successful.
function bridgeTransferFrom(
address tokenAddress,
address from,

View File

@@ -0,0 +1,40 @@
/*
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.15;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
contract IGasToken is IERC20Token {
/// @dev Frees up to `value` sub-tokens
/// @param value The amount of tokens to free
/// @return How many tokens were freed
function freeUpTo(uint256 value) external returns (uint256 freed);
/// @dev Frees up to `value` sub-tokens owned by `from`
/// @param from The owner of tokens to spend
/// @param value The amount of tokens to free
/// @return How many tokens were freed
function freeFromUpTo(address from, uint256 value) external returns (uint256 freed);
/// @dev Mints `value` amount of tokens
/// @param value The amount of tokens to mint
function mint(uint256 value) external;
}

View File

@@ -0,0 +1,40 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
interface IUniswapV2Router01 {
/// @dev Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path.
/// The first element of path is the input token, the last is the output token, and any intermediate elements represent
/// intermediate pairs to trade through (if, for example, a direct pair does not exist).
/// @param amountIn The amount of input tokens to send.
/// @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.
/// @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
/// @param to Recipient of the output tokens.
/// @param deadline Unix timestamp after which the transaction will revert.
/// @return amounts The input token amount and all subsequent output token amounts.
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
}

View File

@@ -0,0 +1,244 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
import "../src/bridges/DexForwarderBridge.sol";
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
interface ITestDexForwarderBridge {
event BridgeTransferFromCalled(
address caller,
uint256 inputTokenBalance,
address inputToken,
address outputToken,
address from,
address to,
uint256 amount
);
event TokenTransferCalled(
address from,
address to,
uint256 amount
);
function emitBridgeTransferFromCalled(
address caller,
uint256 inputTokenBalance,
address inputToken,
address outputToken,
address from,
address to,
uint256 amount
) external;
function emitTokenTransferCalled(
address from,
address to,
uint256 amount
) external;
}
interface ITestDexForwarderBridgeTestToken {
function transfer(address to, uint256 amount)
external
returns (bool);
function mint(address to, uint256 amount)
external;
function balanceOf(address owner) external view returns (uint256);
}
contract TestDexForwarderBridgeTestBridge {
bytes4 private _returnCode;
string private _revertError;
uint256 private _transferAmount;
ITestDexForwarderBridge private _testContract;
constructor(bytes4 returnCode, string memory revertError) public {
_testContract = ITestDexForwarderBridge(msg.sender);
_returnCode = returnCode;
_revertError = revertError;
}
function setTransferAmount(uint256 amount) external {
_transferAmount = amount;
}
function bridgeTransferFrom(
address outputToken,
address from,
address to,
uint256 amount,
bytes memory bridgeData
)
public
returns (bytes4 success)
{
if (bytes(_revertError).length != 0) {
revert(_revertError);
}
address inputToken = abi.decode(bridgeData, (address));
_testContract.emitBridgeTransferFromCalled(
msg.sender,
ITestDexForwarderBridgeTestToken(inputToken).balanceOf(address(this)),
inputToken,
outputToken,
from,
to,
amount
);
ITestDexForwarderBridgeTestToken(outputToken).mint(to, _transferAmount);
return _returnCode;
}
}
contract TestDexForwarderBridgeTestToken {
using LibSafeMath for uint256;
mapping(address => uint256) public balanceOf;
ITestDexForwarderBridge private _testContract;
constructor() public {
_testContract = ITestDexForwarderBridge(msg.sender);
}
function transfer(address to, uint256 amount)
external
returns (bool)
{
balanceOf[msg.sender] = balanceOf[msg.sender].safeSub(amount);
balanceOf[to] = balanceOf[to].safeAdd(amount);
_testContract.emitTokenTransferCalled(msg.sender, to, amount);
return true;
}
function mint(address owner, uint256 amount)
external
{
balanceOf[owner] = balanceOf[owner].safeAdd(amount);
}
function setBalance(address owner, uint256 amount)
external
{
balanceOf[owner] = amount;
}
}
contract TestDexForwarderBridge is
ITestDexForwarderBridge,
DexForwarderBridge
{
address private AUTHORIZED_ADDRESS; // solhint-disable-line var-name-mixedcase
function setAuthorized(address authorized)
public
{
AUTHORIZED_ADDRESS = authorized;
}
function createBridge(
bytes4 returnCode,
string memory revertError
)
public
returns (address bridge)
{
return address(new TestDexForwarderBridgeTestBridge(returnCode, revertError));
}
function createToken() public returns (address token) {
return address(new TestDexForwarderBridgeTestToken());
}
function setTokenBalance(address token, address owner, uint256 amount) public {
TestDexForwarderBridgeTestToken(token).setBalance(owner, amount);
}
function setBridgeTransferAmount(address bridge, uint256 amount) public {
TestDexForwarderBridgeTestBridge(bridge).setTransferAmount(amount);
}
function emitBridgeTransferFromCalled(
address caller,
uint256 inputTokenBalance,
address inputToken,
address outputToken,
address from,
address to,
uint256 amount
)
public
{
emit BridgeTransferFromCalled(
caller,
inputTokenBalance,
inputToken,
outputToken,
from,
to,
amount
);
}
function emitTokenTransferCalled(
address from,
address to,
uint256 amount
)
public
{
emit TokenTransferCalled(
from,
to,
amount
);
}
function balanceOf(address token, address owner) public view returns (uint256) {
return TestDexForwarderBridgeTestToken(token).balanceOf(owner);
}
function _getGstAddress()
internal
view
returns (address gst)
{
return address(0);
}
function _getERC20BridgeProxyAddress()
internal
view
returns (address erc20BridgeProxyAddress)
{
return AUTHORIZED_ADDRESS;
}
}

View File

@@ -110,6 +110,10 @@ contract TestToken {
return true;
}
function allowance(address, address) external view returns (uint256) {
return 0;
}
/// @dev Retrieve the balance for `owner`.
function balanceOf(address owner)
external

View File

@@ -110,6 +110,10 @@ contract TestToken {
return _testContract.wethDeposit.value(msg.value)(msg.sender);
}
function allowance(address, address) external view returns (uint256) {
return 0;
}
function balanceOf(address owner)
external
view

View File

@@ -224,6 +224,10 @@ contract TestToken {
TestEventsRaiser(msg.sender).raiseWethWithdraw(amount);
}
function allowance(address, address) external view returns (uint256) {
return 0;
}
/// @dev Retrieve the balance for `owner`.
function balanceOf(address owner)
external

View File

@@ -0,0 +1,253 @@
/*
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
import "../src/bridges/UniswapV2Bridge.sol";
import "../src/interfaces/IUniswapV2Router01.sol";
contract TestEventsRaiser {
event TokenTransfer(
address token,
address from,
address to,
uint256 amount
);
event TokenApprove(
address spender,
uint256 allowance
);
event SwapExactTokensForTokensInput(
uint amountIn,
uint amountOutMin,
address toTokenAddress,
address to,
uint deadline
);
function raiseTokenTransfer(
address from,
address to,
uint256 amount
)
external
{
emit TokenTransfer(
msg.sender,
from,
to,
amount
);
}
function raiseTokenApprove(address spender, uint256 allowance) external {
emit TokenApprove(spender, allowance);
}
function raiseSwapExactTokensForTokensInput(
uint amountIn,
uint amountOutMin,
address toTokenAddress,
address to,
uint deadline
) external
{
emit SwapExactTokensForTokensInput(
amountIn,
amountOutMin,
toTokenAddress,
to,
deadline
);
}
}
/// @dev A minimalist ERC20 token.
contract TestToken {
using LibSafeMath for uint256;
mapping (address => uint256) public balances;
string private _nextRevertReason;
/// @dev Set the balance for `owner`.
function setBalance(address owner, uint256 balance)
external
payable
{
balances[owner] = balance;
}
/// @dev Just emits a TokenTransfer event on the caller
function transfer(address to, uint256 amount)
external
returns (bool)
{
TestEventsRaiser(msg.sender).raiseTokenTransfer(msg.sender, to, amount);
return true;
}
/// @dev Just emits a TokenApprove event on the caller
function approve(address spender, uint256 allowance)
external
returns (bool)
{
TestEventsRaiser(msg.sender).raiseTokenApprove(spender, allowance);
return true;
}
function allowance(address, address) external view returns (uint256) {
return 0;
}
/// @dev Retrieve the balance for `owner`.
function balanceOf(address owner)
external
view
returns (uint256)
{
return balances[owner];
}
}
/// @dev Mock the UniswapV2Router01 contract
contract TestRouter is
IUniswapV2Router01
{
string private _nextRevertReason;
/// @dev Set the revert reason for `swapExactTokensForTokens`.
function setRevertReason(string calldata reason)
external
{
_nextRevertReason = reason;
}
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts)
{
_revertIfReasonExists();
amounts = new uint[](path.length);
amounts[0] = amountIn;
amounts[amounts.length - 1] = amountOutMin;
TestEventsRaiser(msg.sender).raiseSwapExactTokensForTokensInput(
// tokens sold
amountIn,
// tokens bought
amountOutMin,
// output token (toTokenAddress)
path[path.length - 1],
// recipient
to,
// deadline
deadline
);
}
function _revertIfReasonExists()
private
view
{
if (bytes(_nextRevertReason).length != 0) {
revert(_nextRevertReason);
}
}
}
/// @dev UniswapV2Bridge overridden to mock tokens and Uniswap router
contract TestUniswapV2Bridge is
UniswapV2Bridge,
TestEventsRaiser
{
// Token address to TestToken instance.
mapping (address => TestToken) private _testTokens;
// TestRouter instance.
TestRouter private _testRouter;
constructor() public {
_testRouter = new TestRouter();
}
function setRouterRevertReason(string calldata revertReason)
external
{
_testRouter.setRevertReason(revertReason);
}
/// @dev Sets the balance of this contract for an existing token.
/// The wei attached will be the balance.
function setTokenBalance(address tokenAddress, uint256 balance)
external
{
TestToken token = _testTokens[tokenAddress];
token.setBalance(address(this), balance);
}
/// @dev Create a new token
/// @param tokenAddress The token address. If zero, one will be created.
function createToken(
address tokenAddress
)
external
returns (TestToken token)
{
token = TestToken(tokenAddress);
if (tokenAddress == address(0)) {
token = new TestToken();
}
_testTokens[address(token)] = token;
return token;
}
function getRouterAddress()
external
view
returns (address)
{
return address(_testRouter);
}
function _getUniswapV2Router01Address()
internal
view
returns (address)
{
return address(_testRouter);
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-asset-proxy",
"version": "3.2.2",
"version": "3.4.0",
"engines": {
"node": ">=6.12"
},
@@ -38,7 +38,7 @@
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"abis": "./test/generated-artifacts/@(ChaiBridge|CurveBridge|DydxBridge|ERC1155Proxy|ERC20BridgeProxy|ERC20Proxy|ERC721Proxy|Eth2DaiBridge|IAssetData|IAssetProxy|IAssetProxyDispatcher|IAuthorizable|IChai|ICurve|IDydx|IDydxBridge|IERC20Bridge|IEth2Dai|IKyberNetworkProxy|IUniswapExchange|IUniswapExchangeFactory|KyberBridge|MixinAssetProxyDispatcher|MixinAuthorizable|MultiAssetProxy|Ownable|StaticCallProxy|TestChaiBridge|TestDydxBridge|TestERC20Bridge|TestEth2DaiBridge|TestKyberBridge|TestStaticCallTarget|TestUniswapBridge|UniswapBridge).json",
"abis": "./test/generated-artifacts/@(BalancerBridge|ChaiBridge|CurveBridge|DexForwarderBridge|DydxBridge|ERC1155Proxy|ERC20BridgeProxy|ERC20Proxy|ERC721Proxy|Eth2DaiBridge|IAssetData|IAssetProxy|IAssetProxyDispatcher|IAuthorizable|IBalancerPool|IChai|ICurve|IDydx|IDydxBridge|IERC20Bridge|IEth2Dai|IGasToken|IKyberNetworkProxy|IUniswapExchange|IUniswapExchangeFactory|IUniswapV2Router01|KyberBridge|MixinAssetProxyDispatcher|MixinAuthorizable|MixinGasToken|MultiAssetProxy|Ownable|StaticCallProxy|TestChaiBridge|TestDexForwarderBridge|TestDydxBridge|TestERC20Bridge|TestEth2DaiBridge|TestKyberBridge|TestStaticCallTarget|TestUniswapBridge|TestUniswapV2Bridge|UniswapBridge|UniswapV2Bridge).json",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
},
"repository": {
@@ -51,14 +51,15 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.2.1",
"@0x/contracts-gen": "^2.0.8",
"@0x/contracts-test-utils": "^5.3.0",
"@0x/contracts-utils": "^4.4.0",
"@0x/dev-utils": "^3.2.1",
"@0x/sol-compiler": "^4.0.8",
"@0x/abi-gen": "^5.3.1",
"@0x/contract-wrappers": "^13.8.0",
"@0x/contracts-gen": "^2.0.10",
"@0x/contracts-test-utils": "^5.3.4",
"@0x/contracts-utils": "^4.5.1",
"@0x/dev-utils": "^3.3.0",
"@0x/sol-compiler": "^4.1.1",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/tslint-config": "^4.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
@@ -78,20 +79,21 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.1",
"@0x/contracts-erc1155": "^2.1.2",
"@0x/contracts-erc20": "^3.1.2",
"@0x/contracts-erc721": "^3.1.2",
"@0x/contracts-exchange-libs": "^4.3.2",
"@0x/order-utils": "^10.2.2",
"@0x/types": "^3.1.2",
"@0x/typescript-typings": "^5.0.2",
"@0x/utils": "^5.4.1",
"@0x/web3-wrapper": "^7.0.7",
"ethereum-types": "^3.1.0",
"@0x/base-contract": "^6.2.3",
"@0x/contracts-erc1155": "^2.1.7",
"@0x/contracts-erc20": "^3.2.1",
"@0x/contracts-erc721": "^3.1.7",
"@0x/contracts-exchange-libs": "^4.3.7",
"@0x/order-utils": "^10.3.0",
"@0x/types": "^3.2.0",
"@0x/typescript-typings": "^5.1.1",
"@0x/utils": "^5.5.1",
"@0x/web3-wrapper": "^7.2.0",
"ethereum-types": "^3.2.0",
"lodash": "^4.17.11"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}

View File

@@ -5,8 +5,10 @@
*/
import { ContractArtifact } from 'ethereum-types';
import * as BalancerBridge from '../generated-artifacts/BalancerBridge.json';
import * as ChaiBridge from '../generated-artifacts/ChaiBridge.json';
import * as CurveBridge from '../generated-artifacts/CurveBridge.json';
import * as DexForwarderBridge from '../generated-artifacts/DexForwarderBridge.json';
import * as DydxBridge from '../generated-artifacts/DydxBridge.json';
import * as ERC1155Proxy from '../generated-artifacts/ERC1155Proxy.json';
import * as ERC20BridgeProxy from '../generated-artifacts/ERC20BridgeProxy.json';
@@ -17,29 +19,36 @@ import * as IAssetData from '../generated-artifacts/IAssetData.json';
import * as IAssetProxy from '../generated-artifacts/IAssetProxy.json';
import * as IAssetProxyDispatcher from '../generated-artifacts/IAssetProxyDispatcher.json';
import * as IAuthorizable from '../generated-artifacts/IAuthorizable.json';
import * as IBalancerPool from '../generated-artifacts/IBalancerPool.json';
import * as IChai from '../generated-artifacts/IChai.json';
import * as ICurve from '../generated-artifacts/ICurve.json';
import * as IDydx from '../generated-artifacts/IDydx.json';
import * as IDydxBridge from '../generated-artifacts/IDydxBridge.json';
import * as IERC20Bridge from '../generated-artifacts/IERC20Bridge.json';
import * as IEth2Dai from '../generated-artifacts/IEth2Dai.json';
import * as IGasToken from '../generated-artifacts/IGasToken.json';
import * as IKyberNetworkProxy from '../generated-artifacts/IKyberNetworkProxy.json';
import * as IUniswapExchange from '../generated-artifacts/IUniswapExchange.json';
import * as IUniswapExchangeFactory from '../generated-artifacts/IUniswapExchangeFactory.json';
import * as IUniswapV2Router01 from '../generated-artifacts/IUniswapV2Router01.json';
import * as KyberBridge from '../generated-artifacts/KyberBridge.json';
import * as MixinAssetProxyDispatcher from '../generated-artifacts/MixinAssetProxyDispatcher.json';
import * as MixinAuthorizable from '../generated-artifacts/MixinAuthorizable.json';
import * as MixinGasToken from '../generated-artifacts/MixinGasToken.json';
import * as MultiAssetProxy from '../generated-artifacts/MultiAssetProxy.json';
import * as Ownable from '../generated-artifacts/Ownable.json';
import * as StaticCallProxy from '../generated-artifacts/StaticCallProxy.json';
import * as TestChaiBridge from '../generated-artifacts/TestChaiBridge.json';
import * as TestDexForwarderBridge from '../generated-artifacts/TestDexForwarderBridge.json';
import * as TestDydxBridge from '../generated-artifacts/TestDydxBridge.json';
import * as TestERC20Bridge from '../generated-artifacts/TestERC20Bridge.json';
import * as TestEth2DaiBridge from '../generated-artifacts/TestEth2DaiBridge.json';
import * as TestKyberBridge from '../generated-artifacts/TestKyberBridge.json';
import * as TestStaticCallTarget from '../generated-artifacts/TestStaticCallTarget.json';
import * as TestUniswapBridge from '../generated-artifacts/TestUniswapBridge.json';
import * as TestUniswapV2Bridge from '../generated-artifacts/TestUniswapV2Bridge.json';
import * as UniswapBridge from '../generated-artifacts/UniswapBridge.json';
import * as UniswapV2Bridge from '../generated-artifacts/UniswapV2Bridge.json';
export const artifacts = {
MixinAssetProxyDispatcher: MixinAssetProxyDispatcher as ContractArtifact,
MixinAuthorizable: MixinAuthorizable as ContractArtifact,
@@ -50,30 +59,39 @@ export const artifacts = {
ERC721Proxy: ERC721Proxy as ContractArtifact,
MultiAssetProxy: MultiAssetProxy as ContractArtifact,
StaticCallProxy: StaticCallProxy as ContractArtifact,
BalancerBridge: BalancerBridge as ContractArtifact,
ChaiBridge: ChaiBridge as ContractArtifact,
CurveBridge: CurveBridge as ContractArtifact,
DexForwarderBridge: DexForwarderBridge as ContractArtifact,
DydxBridge: DydxBridge as ContractArtifact,
Eth2DaiBridge: Eth2DaiBridge as ContractArtifact,
KyberBridge: KyberBridge as ContractArtifact,
MixinGasToken: MixinGasToken as ContractArtifact,
UniswapBridge: UniswapBridge as ContractArtifact,
UniswapV2Bridge: UniswapV2Bridge as ContractArtifact,
IAssetData: IAssetData as ContractArtifact,
IAssetProxy: IAssetProxy as ContractArtifact,
IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact,
IAuthorizable: IAuthorizable as ContractArtifact,
IBalancerPool: IBalancerPool as ContractArtifact,
IChai: IChai as ContractArtifact,
ICurve: ICurve as ContractArtifact,
IDydx: IDydx as ContractArtifact,
IDydxBridge: IDydxBridge as ContractArtifact,
IERC20Bridge: IERC20Bridge as ContractArtifact,
IEth2Dai: IEth2Dai as ContractArtifact,
IGasToken: IGasToken as ContractArtifact,
IKyberNetworkProxy: IKyberNetworkProxy as ContractArtifact,
IUniswapExchange: IUniswapExchange as ContractArtifact,
IUniswapExchangeFactory: IUniswapExchangeFactory as ContractArtifact,
IUniswapV2Router01: IUniswapV2Router01 as ContractArtifact,
TestChaiBridge: TestChaiBridge as ContractArtifact,
TestDexForwarderBridge: TestDexForwarderBridge as ContractArtifact,
TestDydxBridge: TestDydxBridge as ContractArtifact,
TestERC20Bridge: TestERC20Bridge as ContractArtifact,
TestEth2DaiBridge: TestEth2DaiBridge as ContractArtifact,
TestKyberBridge: TestKyberBridge as ContractArtifact,
TestStaticCallTarget: TestStaticCallTarget as ContractArtifact,
TestUniswapBridge: TestUniswapBridge as ContractArtifact,
TestUniswapV2Bridge: TestUniswapV2Bridge as ContractArtifact,
};

View File

@@ -0,0 +1,27 @@
import { AbiEncoder, BigNumber } from '@0x/utils';
export interface DexForwarderBridgeCall {
target: string;
inputTokenAmount: BigNumber;
outputTokenAmount: BigNumber;
bridgeData: string;
}
export interface DexForwaderBridgeData {
inputToken: string;
calls: DexForwarderBridgeCall[];
}
export const dexForwarderBridgeDataEncoder = AbiEncoder.create([
{ name: 'inputToken', type: 'address' },
{
name: 'calls',
type: 'tuple[]',
components: [
{ name: 'target', type: 'address' },
{ name: 'inputTokenAmount', type: 'uint256' },
{ name: 'outputTokenAmount', type: 'uint256' },
{ name: 'bridgeData', type: 'bytes' },
],
},
]);

View File

@@ -1,5 +1,6 @@
export { artifacts } from './artifacts';
export {
BalancerBridgeContract,
ChaiBridgeContract,
ERC1155ProxyContract,
ERC20BridgeProxyContract,
@@ -88,3 +89,4 @@ export {
} from './asset_data';
export * from './dydx_bridge_encoder';
export * from './dex_forwarder_bridge';

View File

@@ -3,8 +3,10 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../generated-wrappers/balancer_bridge';
export * from '../generated-wrappers/chai_bridge';
export * from '../generated-wrappers/curve_bridge';
export * from '../generated-wrappers/dex_forwarder_bridge';
export * from '../generated-wrappers/dydx_bridge';
export * from '../generated-wrappers/erc1155_proxy';
export * from '../generated-wrappers/erc20_bridge_proxy';
@@ -15,26 +17,33 @@ export * from '../generated-wrappers/i_asset_data';
export * from '../generated-wrappers/i_asset_proxy';
export * from '../generated-wrappers/i_asset_proxy_dispatcher';
export * from '../generated-wrappers/i_authorizable';
export * from '../generated-wrappers/i_balancer_pool';
export * from '../generated-wrappers/i_chai';
export * from '../generated-wrappers/i_curve';
export * from '../generated-wrappers/i_dydx';
export * from '../generated-wrappers/i_dydx_bridge';
export * from '../generated-wrappers/i_erc20_bridge';
export * from '../generated-wrappers/i_eth2_dai';
export * from '../generated-wrappers/i_gas_token';
export * from '../generated-wrappers/i_kyber_network_proxy';
export * from '../generated-wrappers/i_uniswap_exchange';
export * from '../generated-wrappers/i_uniswap_exchange_factory';
export * from '../generated-wrappers/i_uniswap_v2_router01';
export * from '../generated-wrappers/kyber_bridge';
export * from '../generated-wrappers/mixin_asset_proxy_dispatcher';
export * from '../generated-wrappers/mixin_authorizable';
export * from '../generated-wrappers/mixin_gas_token';
export * from '../generated-wrappers/multi_asset_proxy';
export * from '../generated-wrappers/ownable';
export * from '../generated-wrappers/static_call_proxy';
export * from '../generated-wrappers/test_chai_bridge';
export * from '../generated-wrappers/test_dex_forwarder_bridge';
export * from '../generated-wrappers/test_dydx_bridge';
export * from '../generated-wrappers/test_erc20_bridge';
export * from '../generated-wrappers/test_eth2_dai_bridge';
export * from '../generated-wrappers/test_kyber_bridge';
export * from '../generated-wrappers/test_static_call_target';
export * from '../generated-wrappers/test_uniswap_bridge';
export * from '../generated-wrappers/test_uniswap_v2_bridge';
export * from '../generated-wrappers/uniswap_bridge';
export * from '../generated-wrappers/uniswap_v2_bridge';

View File

@@ -5,8 +5,10 @@
*/
import { ContractArtifact } from 'ethereum-types';
import * as BalancerBridge from '../test/generated-artifacts/BalancerBridge.json';
import * as ChaiBridge from '../test/generated-artifacts/ChaiBridge.json';
import * as CurveBridge from '../test/generated-artifacts/CurveBridge.json';
import * as DexForwarderBridge from '../test/generated-artifacts/DexForwarderBridge.json';
import * as DydxBridge from '../test/generated-artifacts/DydxBridge.json';
import * as ERC1155Proxy from '../test/generated-artifacts/ERC1155Proxy.json';
import * as ERC20BridgeProxy from '../test/generated-artifacts/ERC20BridgeProxy.json';
@@ -17,29 +19,36 @@ import * as IAssetData from '../test/generated-artifacts/IAssetData.json';
import * as IAssetProxy from '../test/generated-artifacts/IAssetProxy.json';
import * as IAssetProxyDispatcher from '../test/generated-artifacts/IAssetProxyDispatcher.json';
import * as IAuthorizable from '../test/generated-artifacts/IAuthorizable.json';
import * as IBalancerPool from '../test/generated-artifacts/IBalancerPool.json';
import * as IChai from '../test/generated-artifacts/IChai.json';
import * as ICurve from '../test/generated-artifacts/ICurve.json';
import * as IDydx from '../test/generated-artifacts/IDydx.json';
import * as IDydxBridge from '../test/generated-artifacts/IDydxBridge.json';
import * as IERC20Bridge from '../test/generated-artifacts/IERC20Bridge.json';
import * as IEth2Dai from '../test/generated-artifacts/IEth2Dai.json';
import * as IGasToken from '../test/generated-artifacts/IGasToken.json';
import * as IKyberNetworkProxy from '../test/generated-artifacts/IKyberNetworkProxy.json';
import * as IUniswapExchange from '../test/generated-artifacts/IUniswapExchange.json';
import * as IUniswapExchangeFactory from '../test/generated-artifacts/IUniswapExchangeFactory.json';
import * as IUniswapV2Router01 from '../test/generated-artifacts/IUniswapV2Router01.json';
import * as KyberBridge from '../test/generated-artifacts/KyberBridge.json';
import * as MixinAssetProxyDispatcher from '../test/generated-artifacts/MixinAssetProxyDispatcher.json';
import * as MixinAuthorizable from '../test/generated-artifacts/MixinAuthorizable.json';
import * as MixinGasToken from '../test/generated-artifacts/MixinGasToken.json';
import * as MultiAssetProxy from '../test/generated-artifacts/MultiAssetProxy.json';
import * as Ownable from '../test/generated-artifacts/Ownable.json';
import * as StaticCallProxy from '../test/generated-artifacts/StaticCallProxy.json';
import * as TestChaiBridge from '../test/generated-artifacts/TestChaiBridge.json';
import * as TestDexForwarderBridge from '../test/generated-artifacts/TestDexForwarderBridge.json';
import * as TestDydxBridge from '../test/generated-artifacts/TestDydxBridge.json';
import * as TestERC20Bridge from '../test/generated-artifacts/TestERC20Bridge.json';
import * as TestEth2DaiBridge from '../test/generated-artifacts/TestEth2DaiBridge.json';
import * as TestKyberBridge from '../test/generated-artifacts/TestKyberBridge.json';
import * as TestStaticCallTarget from '../test/generated-artifacts/TestStaticCallTarget.json';
import * as TestUniswapBridge from '../test/generated-artifacts/TestUniswapBridge.json';
import * as TestUniswapV2Bridge from '../test/generated-artifacts/TestUniswapV2Bridge.json';
import * as UniswapBridge from '../test/generated-artifacts/UniswapBridge.json';
import * as UniswapV2Bridge from '../test/generated-artifacts/UniswapV2Bridge.json';
export const artifacts = {
MixinAssetProxyDispatcher: MixinAssetProxyDispatcher as ContractArtifact,
MixinAuthorizable: MixinAuthorizable as ContractArtifact,
@@ -50,30 +59,39 @@ export const artifacts = {
ERC721Proxy: ERC721Proxy as ContractArtifact,
MultiAssetProxy: MultiAssetProxy as ContractArtifact,
StaticCallProxy: StaticCallProxy as ContractArtifact,
BalancerBridge: BalancerBridge as ContractArtifact,
ChaiBridge: ChaiBridge as ContractArtifact,
CurveBridge: CurveBridge as ContractArtifact,
DexForwarderBridge: DexForwarderBridge as ContractArtifact,
DydxBridge: DydxBridge as ContractArtifact,
Eth2DaiBridge: Eth2DaiBridge as ContractArtifact,
KyberBridge: KyberBridge as ContractArtifact,
MixinGasToken: MixinGasToken as ContractArtifact,
UniswapBridge: UniswapBridge as ContractArtifact,
UniswapV2Bridge: UniswapV2Bridge as ContractArtifact,
IAssetData: IAssetData as ContractArtifact,
IAssetProxy: IAssetProxy as ContractArtifact,
IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact,
IAuthorizable: IAuthorizable as ContractArtifact,
IBalancerPool: IBalancerPool as ContractArtifact,
IChai: IChai as ContractArtifact,
ICurve: ICurve as ContractArtifact,
IDydx: IDydx as ContractArtifact,
IDydxBridge: IDydxBridge as ContractArtifact,
IERC20Bridge: IERC20Bridge as ContractArtifact,
IEth2Dai: IEth2Dai as ContractArtifact,
IGasToken: IGasToken as ContractArtifact,
IKyberNetworkProxy: IKyberNetworkProxy as ContractArtifact,
IUniswapExchange: IUniswapExchange as ContractArtifact,
IUniswapExchangeFactory: IUniswapExchangeFactory as ContractArtifact,
IUniswapV2Router01: IUniswapV2Router01 as ContractArtifact,
TestChaiBridge: TestChaiBridge as ContractArtifact,
TestDexForwarderBridge: TestDexForwarderBridge as ContractArtifact,
TestDydxBridge: TestDydxBridge as ContractArtifact,
TestERC20Bridge: TestERC20Bridge as ContractArtifact,
TestEth2DaiBridge: TestEth2DaiBridge as ContractArtifact,
TestKyberBridge: TestKyberBridge as ContractArtifact,
TestStaticCallTarget: TestStaticCallTarget as ContractArtifact,
TestUniswapBridge: TestUniswapBridge as ContractArtifact,
TestUniswapV2Bridge: TestUniswapV2Bridge as ContractArtifact,
};

View File

@@ -0,0 +1,354 @@
import { ContractTxFunctionObj } from '@0x/contract-wrappers';
import {
blockchainTests,
constants,
expect,
filterLogsToArguments,
getRandomInteger,
randomAddress,
shortZip,
} from '@0x/contracts-test-utils';
import { BigNumber, hexUtils, NULL_ADDRESS } from '@0x/utils';
import { DecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { DexForwarderBridgeCall, dexForwarderBridgeDataEncoder } from '../src/dex_forwarder_bridge';
import { artifacts } from './artifacts';
import {
TestDexForwarderBridgeBridgeTransferFromCalledEventArgs as BtfCalledEventArgs,
TestDexForwarderBridgeContract,
TestDexForwarderBridgeEvents as TestEvents,
} from './wrappers';
const { ZERO_AMOUNT } = constants;
blockchainTests.resets('DexForwarderBridge unit tests', env => {
let testContract: TestDexForwarderBridgeContract;
let inputToken: string;
let outputToken: string;
const BRIDGE_SUCCESS = '0xdc1600f3';
const BRIDGE_FAILURE = '0xffffffff';
const BRIDGE_REVERT_ERROR = 'oopsie';
const NOT_AUTHORIZED_REVERT = 'DexForwarderBridge/SENDER_NOT_AUTHORIZED';
const DEFAULTS = {
toAddress: randomAddress(),
};
before(async () => {
testContract = await TestDexForwarderBridgeContract.deployFrom0xArtifactAsync(
artifacts.TestDexForwarderBridge,
env.provider,
env.txDefaults,
artifacts,
);
// Create test tokens.
[inputToken, outputToken] = [
await callAndTransactAsync(testContract.createToken()),
await callAndTransactAsync(testContract.createToken()),
];
await callAndTransactAsync(testContract.setAuthorized(env.txDefaults.from as string));
});
async function callAndTransactAsync<TResult>(fnCall: ContractTxFunctionObj<TResult>): Promise<TResult> {
const result = await fnCall.callAsync();
await fnCall.awaitTransactionSuccessAsync({}, { shouldValidate: false });
return result;
}
function getRandomBridgeCall(
bridgeAddress: string,
fields: Partial<DexForwarderBridgeCall> = {},
): DexForwarderBridgeCall {
return {
target: bridgeAddress,
inputTokenAmount: getRandomInteger(1, '100e18'),
outputTokenAmount: getRandomInteger(1, '100e18'),
bridgeData: hexUtils.leftPad(inputToken),
...fields,
};
}
describe('bridgeTransferFrom()', () => {
let goodBridgeCalls: DexForwarderBridgeCall[];
let revertingBridgeCall: DexForwarderBridgeCall;
let failingBridgeCall: DexForwarderBridgeCall;
let allBridgeCalls: DexForwarderBridgeCall[];
let totalFillableOutputAmount: BigNumber;
let totalFillableInputAmount: BigNumber;
let recipientOutputBalance: BigNumber;
beforeEach(async () => {
goodBridgeCalls = [];
for (let i = 0; i < 4; ++i) {
goodBridgeCalls.push(await createBridgeCallAsync({ returnCode: BRIDGE_SUCCESS }));
}
revertingBridgeCall = await createBridgeCallAsync({ revertError: BRIDGE_REVERT_ERROR });
failingBridgeCall = await createBridgeCallAsync({ returnCode: BRIDGE_FAILURE });
allBridgeCalls = _.shuffle([failingBridgeCall, revertingBridgeCall, ...goodBridgeCalls]);
totalFillableInputAmount = BigNumber.sum(...goodBridgeCalls.map(c => c.inputTokenAmount));
totalFillableOutputAmount = BigNumber.sum(...goodBridgeCalls.map(c => c.outputTokenAmount));
// Grant the taker some output tokens.
await testContract.setTokenBalance(
outputToken,
DEFAULTS.toAddress,
(recipientOutputBalance = getRandomInteger(1, '100e18')),
);
});
async function setForwarderInputBalanceAsync(amount: BigNumber): Promise<void> {
await testContract
.setTokenBalance(inputToken, testContract.address, amount)
.awaitTransactionSuccessAsync({}, { shouldValidate: false });
}
async function createBridgeCallAsync(
opts: Partial<{
returnCode: string;
revertError: string;
callFields: Partial<DexForwarderBridgeCall>;
outputFillAmount: BigNumber;
}>,
): Promise<DexForwarderBridgeCall> {
const { returnCode, revertError, callFields, outputFillAmount } = {
returnCode: BRIDGE_SUCCESS,
revertError: '',
...opts,
};
const bridge = await callAndTransactAsync(testContract.createBridge(returnCode, revertError));
const call = getRandomBridgeCall(bridge, callFields);
await testContract
.setBridgeTransferAmount(call.target, outputFillAmount || call.outputTokenAmount)
.awaitTransactionSuccessAsync({}, { shouldValidate: false });
return call;
}
async function callBridgeTransferFromAsync(opts: {
bridgeData: string;
sellAmount?: BigNumber;
buyAmount?: BigNumber;
}): Promise<DecodedLogs> {
// Fund the forwarder with input tokens to sell.
await setForwarderInputBalanceAsync(opts.sellAmount || totalFillableInputAmount);
const call = testContract.bridgeTransferFrom(
outputToken,
testContract.address,
DEFAULTS.toAddress,
opts.buyAmount || totalFillableOutputAmount,
opts.bridgeData,
);
const returnCode = await call.callAsync();
if (returnCode !== BRIDGE_SUCCESS) {
throw new Error('Expected BRIDGE_SUCCESS');
}
const receipt = await call.awaitTransactionSuccessAsync({}, { shouldValidate: false });
// tslint:disable-next-line: no-unnecessary-type-assertion
return receipt.logs as DecodedLogs;
}
it('succeeds with no bridge calls and no input balance', async () => {
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls: [],
});
await callBridgeTransferFromAsync({ bridgeData, sellAmount: ZERO_AMOUNT });
});
it('succeeds with bridge calls and no input balance', async () => {
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls: allBridgeCalls,
});
await callBridgeTransferFromAsync({ bridgeData, sellAmount: ZERO_AMOUNT });
});
it('succeeds with no bridge calls and an input balance', async () => {
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls: [],
});
await callBridgeTransferFromAsync({
bridgeData,
sellAmount: new BigNumber(1),
});
});
it('succeeds if entire input token balance is not consumed', async () => {
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls: allBridgeCalls,
});
await callBridgeTransferFromAsync({
bridgeData,
sellAmount: totalFillableInputAmount.plus(1),
});
});
it('fails if not authorized', async () => {
const calls = goodBridgeCalls.slice(0, 1);
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls,
});
await callAndTransactAsync(testContract.setAuthorized(NULL_ADDRESS));
return expect(callBridgeTransferFromAsync({ bridgeData, sellAmount: new BigNumber(1) })).to.revertWith(
NOT_AUTHORIZED_REVERT,
);
});
it('succeeds with one bridge call', async () => {
const calls = goodBridgeCalls.slice(0, 1);
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls,
});
await callBridgeTransferFromAsync({ bridgeData, sellAmount: calls[0].inputTokenAmount });
});
it('succeeds with many bridge calls', async () => {
const calls = goodBridgeCalls;
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls,
});
await callBridgeTransferFromAsync({ bridgeData });
});
it('swallows a failing bridge call', async () => {
const calls = _.shuffle([...goodBridgeCalls, failingBridgeCall]);
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls,
});
await callBridgeTransferFromAsync({ bridgeData });
});
it('consumes input tokens for output tokens', async () => {
const calls = allBridgeCalls;
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls,
});
await callBridgeTransferFromAsync({ bridgeData });
const currentBridgeInputBalance = await testContract
.balanceOf(inputToken, testContract.address)
.callAsync();
expect(currentBridgeInputBalance).to.bignumber.eq(0);
const currentRecipientOutputBalance = await testContract
.balanceOf(outputToken, DEFAULTS.toAddress)
.callAsync();
expect(currentRecipientOutputBalance).to.bignumber.eq(totalFillableOutputAmount);
});
it("transfers only up to each call's input amount to each bridge", async () => {
const calls = goodBridgeCalls;
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls,
});
const logs = await callBridgeTransferFromAsync({ bridgeData });
const btfs = filterLogsToArguments<BtfCalledEventArgs>(logs, TestEvents.BridgeTransferFromCalled);
for (const [call, btf] of shortZip(goodBridgeCalls, btfs)) {
expect(btf.inputTokenBalance).to.bignumber.eq(call.inputTokenAmount);
}
});
it('transfers only up to outstanding sell amount to each bridge', async () => {
// Prepend an extra bridge call.
const calls = [
await createBridgeCallAsync({
callFields: {
inputTokenAmount: new BigNumber(1),
outputTokenAmount: new BigNumber(1),
},
}),
...goodBridgeCalls,
];
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls,
});
const logs = await callBridgeTransferFromAsync({ bridgeData });
const btfs = filterLogsToArguments<BtfCalledEventArgs>(logs, TestEvents.BridgeTransferFromCalled);
expect(btfs).to.be.length(goodBridgeCalls.length + 1);
// The last call will receive 1 less token.
const lastCall = calls.slice(-1)[0];
const lastBtf = btfs.slice(-1)[0];
expect(lastBtf.inputTokenBalance).to.bignumber.eq(lastCall.inputTokenAmount.minus(1));
});
it('recoups funds from a bridge that fails', async () => {
// Prepend a call that will take the whole input amount but will
// fail.
const badCall = await createBridgeCallAsync({
callFields: { inputTokenAmount: totalFillableInputAmount },
returnCode: BRIDGE_FAILURE,
});
const calls = [badCall, ...goodBridgeCalls];
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls,
});
const logs = await callBridgeTransferFromAsync({ bridgeData });
const btfs = filterLogsToArguments<BtfCalledEventArgs>(logs, TestEvents.BridgeTransferFromCalled);
expect(btfs).to.be.length(goodBridgeCalls.length);
});
it('recoups funds from a bridge that reverts', async () => {
// Prepend a call that will take the whole input amount but will
// revert.
const badCall = await createBridgeCallAsync({
callFields: { inputTokenAmount: totalFillableInputAmount },
revertError: BRIDGE_REVERT_ERROR,
});
const calls = [badCall, ...goodBridgeCalls];
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls,
});
const logs = await callBridgeTransferFromAsync({ bridgeData });
const btfs = filterLogsToArguments<BtfCalledEventArgs>(logs, TestEvents.BridgeTransferFromCalled);
expect(btfs).to.be.length(goodBridgeCalls.length);
});
it('recoups funds from a bridge that under-pays', async () => {
// Prepend a call that will take the whole input amount but will
// underpay the output amount..
const badCall = await createBridgeCallAsync({
callFields: {
inputTokenAmount: totalFillableInputAmount,
outputTokenAmount: new BigNumber(2),
},
outputFillAmount: new BigNumber(1),
});
const calls = [badCall, ...goodBridgeCalls];
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls,
});
const logs = await callBridgeTransferFromAsync({ bridgeData });
const btfs = filterLogsToArguments<BtfCalledEventArgs>(logs, TestEvents.BridgeTransferFromCalled);
expect(btfs).to.be.length(goodBridgeCalls.length);
});
});
describe('executeBridgeCall()', () => {
it('cannot be called externally', async () => {
return expect(
testContract
.executeBridgeCall(
randomAddress(),
randomAddress(),
randomAddress(),
randomAddress(),
new BigNumber(1),
new BigNumber(1),
constants.NULL_BYTES,
)
.callAsync(),
).to.revertWith('DexForwarderBridge/ONLY_SELF');
});
});
});

View File

@@ -0,0 +1,216 @@
import {
blockchainTests,
constants,
expect,
filterLogsToArguments,
getRandomInteger,
randomAddress,
} from '@0x/contracts-test-utils';
import { AssetProxyId } from '@0x/types';
import { AbiEncoder, BigNumber, hexUtils } from '@0x/utils';
import { DecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import {
TestUniswapV2BridgeContract,
TestUniswapV2BridgeEvents as ContractEvents,
TestUniswapV2BridgeSwapExactTokensForTokensInputEventArgs as SwapExactTokensForTokensArgs,
TestUniswapV2BridgeTokenApproveEventArgs as TokenApproveArgs,
TestUniswapV2BridgeTokenTransferEventArgs as TokenTransferArgs,
} from './wrappers';
blockchainTests.resets('UniswapV2 unit tests', env => {
const FROM_TOKEN_DECIMALS = 6;
const TO_TOKEN_DECIMALS = 18;
const FROM_TOKEN_BASE = new BigNumber(10).pow(FROM_TOKEN_DECIMALS);
const TO_TOKEN_BASE = new BigNumber(10).pow(TO_TOKEN_DECIMALS);
let testContract: TestUniswapV2BridgeContract;
before(async () => {
testContract = await TestUniswapV2BridgeContract.deployFrom0xArtifactAsync(
artifacts.TestUniswapV2Bridge,
env.provider,
env.txDefaults,
artifacts,
);
});
describe('isValidSignature()', () => {
it('returns success bytes', async () => {
const LEGACY_WALLET_MAGIC_VALUE = '0xb0671381';
const result = await testContract
.isValidSignature(hexUtils.random(), hexUtils.random(_.random(0, 32)))
.callAsync();
expect(result).to.eq(LEGACY_WALLET_MAGIC_VALUE);
});
});
describe('bridgeTransferFrom()', () => {
interface TransferFromOpts {
tokenAddressesPath: string[];
toAddress: string;
// Amount to pass into `bridgeTransferFrom()`
amount: BigNumber;
// Token balance of the bridge.
fromTokenBalance: BigNumber;
// Router reverts with this reason
routerRevertReason: string;
}
interface TransferFromResult {
opts: TransferFromOpts;
result: string;
logs: DecodedLogs;
blocktime: number;
}
function createTransferFromOpts(opts?: Partial<TransferFromOpts>): TransferFromOpts {
const amount = getRandomInteger(1, TO_TOKEN_BASE.times(100));
return {
tokenAddressesPath: Array(2).fill(constants.NULL_ADDRESS),
amount,
toAddress: randomAddress(),
fromTokenBalance: getRandomInteger(1, FROM_TOKEN_BASE.times(100)),
routerRevertReason: '',
...opts,
};
}
const bridgeDataEncoder = AbiEncoder.create('(address[])');
async function transferFromAsync(opts?: Partial<TransferFromOpts>): Promise<TransferFromResult> {
const _opts = createTransferFromOpts(opts);
for (let i = 0; i < _opts.tokenAddressesPath.length; i++) {
const createFromTokenFn = testContract.createToken(_opts.tokenAddressesPath[i]);
_opts.tokenAddressesPath[i] = await createFromTokenFn.callAsync();
await createFromTokenFn.awaitTransactionSuccessAsync();
}
// Set the token balance for the token we're converting from.
await testContract
.setTokenBalance(_opts.tokenAddressesPath[0], _opts.fromTokenBalance)
.awaitTransactionSuccessAsync();
// Set revert reason for the router.
await testContract.setRouterRevertReason(_opts.routerRevertReason).awaitTransactionSuccessAsync();
// Call bridgeTransferFrom().
const bridgeTransferFromFn = testContract.bridgeTransferFrom(
// Output token
_opts.tokenAddressesPath[_opts.tokenAddressesPath.length - 1],
// Random maker address.
randomAddress(),
// Recipient address.
_opts.toAddress,
// Transfer amount.
_opts.amount,
// ABI-encode the input token address as the bridge data. // FIXME
bridgeDataEncoder.encode([_opts.tokenAddressesPath]),
);
const result = await bridgeTransferFromFn.callAsync();
const receipt = await bridgeTransferFromFn.awaitTransactionSuccessAsync();
return {
opts: _opts,
result,
logs: (receipt.logs as any) as DecodedLogs,
blocktime: await env.web3Wrapper.getBlockTimestampAsync(receipt.blockNumber),
};
}
it('returns magic bytes on success', async () => {
const { result } = await transferFromAsync();
expect(result).to.eq(AssetProxyId.ERC20Bridge);
});
it('performs transfer when both tokens are the same', async () => {
const createTokenFn = testContract.createToken(constants.NULL_ADDRESS);
const tokenAddress = await createTokenFn.callAsync();
await createTokenFn.awaitTransactionSuccessAsync();
const { opts, result, logs } = await transferFromAsync({
tokenAddressesPath: [tokenAddress, tokenAddress],
});
expect(result).to.eq(AssetProxyId.ERC20Bridge, 'asset proxy id');
const transfers = filterLogsToArguments<TokenTransferArgs>(logs, ContractEvents.TokenTransfer);
expect(transfers.length).to.eq(1);
expect(transfers[0].token).to.eq(tokenAddress, 'input token address');
expect(transfers[0].from).to.eq(testContract.address);
expect(transfers[0].to).to.eq(opts.toAddress, 'recipient address');
expect(transfers[0].amount).to.bignumber.eq(opts.amount, 'amount');
});
describe('token -> token', async () => {
it('calls UniswapV2Router01.swapExactTokensForTokens()', async () => {
const { opts, result, logs, blocktime } = await transferFromAsync();
expect(result).to.eq(AssetProxyId.ERC20Bridge, 'asset proxy id');
const transfers = filterLogsToArguments<SwapExactTokensForTokensArgs>(
logs,
ContractEvents.SwapExactTokensForTokensInput,
);
expect(transfers.length).to.eq(1);
expect(transfers[0].toTokenAddress).to.eq(
opts.tokenAddressesPath[opts.tokenAddressesPath.length - 1],
'output token address',
);
expect(transfers[0].to).to.eq(opts.toAddress, 'recipient address');
expect(transfers[0].amountIn).to.bignumber.eq(opts.fromTokenBalance, 'input token amount');
expect(transfers[0].amountOutMin).to.bignumber.eq(opts.amount, 'output token amount');
expect(transfers[0].deadline).to.bignumber.eq(blocktime, 'deadline');
});
it('sets allowance for "from" token', async () => {
const { logs } = await transferFromAsync();
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
const routerAddress = await testContract.getRouterAddress().callAsync();
expect(approvals.length).to.eq(1);
expect(approvals[0].spender).to.eq(routerAddress);
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
});
it('sets allowance for "from" token on subsequent calls', async () => {
const { opts } = await transferFromAsync();
const { logs } = await transferFromAsync(opts);
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
const routerAddress = await testContract.getRouterAddress().callAsync();
expect(approvals.length).to.eq(1);
expect(approvals[0].spender).to.eq(routerAddress);
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
});
it('fails if the router fails', async () => {
const revertReason = 'FOOBAR';
const tx = transferFromAsync({
routerRevertReason: revertReason,
});
return expect(tx).to.eventually.be.rejectedWith(revertReason);
});
});
describe('token -> token -> token', async () => {
it('calls UniswapV2Router01.swapExactTokensForTokens()', async () => {
const { opts, result, logs, blocktime } = await transferFromAsync({
tokenAddressesPath: Array(3).fill(constants.NULL_ADDRESS),
});
expect(result).to.eq(AssetProxyId.ERC20Bridge, 'asset proxy id');
const transfers = filterLogsToArguments<SwapExactTokensForTokensArgs>(
logs,
ContractEvents.SwapExactTokensForTokensInput,
);
expect(transfers.length).to.eq(1);
expect(transfers[0].toTokenAddress).to.eq(
opts.tokenAddressesPath[opts.tokenAddressesPath.length - 1],
'output token address',
);
expect(transfers[0].to).to.eq(opts.toAddress, 'recipient address');
expect(transfers[0].amountIn).to.bignumber.eq(opts.fromTokenBalance, 'input token amount');
expect(transfers[0].amountOutMin).to.bignumber.eq(opts.amount, 'output token amount');
expect(transfers[0].deadline).to.bignumber.eq(blocktime, 'deadline');
});
});
});
});

View File

@@ -3,8 +3,10 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../test/generated-wrappers/balancer_bridge';
export * from '../test/generated-wrappers/chai_bridge';
export * from '../test/generated-wrappers/curve_bridge';
export * from '../test/generated-wrappers/dex_forwarder_bridge';
export * from '../test/generated-wrappers/dydx_bridge';
export * from '../test/generated-wrappers/erc1155_proxy';
export * from '../test/generated-wrappers/erc20_bridge_proxy';
@@ -15,26 +17,33 @@ export * from '../test/generated-wrappers/i_asset_data';
export * from '../test/generated-wrappers/i_asset_proxy';
export * from '../test/generated-wrappers/i_asset_proxy_dispatcher';
export * from '../test/generated-wrappers/i_authorizable';
export * from '../test/generated-wrappers/i_balancer_pool';
export * from '../test/generated-wrappers/i_chai';
export * from '../test/generated-wrappers/i_curve';
export * from '../test/generated-wrappers/i_dydx';
export * from '../test/generated-wrappers/i_dydx_bridge';
export * from '../test/generated-wrappers/i_erc20_bridge';
export * from '../test/generated-wrappers/i_eth2_dai';
export * from '../test/generated-wrappers/i_gas_token';
export * from '../test/generated-wrappers/i_kyber_network_proxy';
export * from '../test/generated-wrappers/i_uniswap_exchange';
export * from '../test/generated-wrappers/i_uniswap_exchange_factory';
export * from '../test/generated-wrappers/i_uniswap_v2_router01';
export * from '../test/generated-wrappers/kyber_bridge';
export * from '../test/generated-wrappers/mixin_asset_proxy_dispatcher';
export * from '../test/generated-wrappers/mixin_authorizable';
export * from '../test/generated-wrappers/mixin_gas_token';
export * from '../test/generated-wrappers/multi_asset_proxy';
export * from '../test/generated-wrappers/ownable';
export * from '../test/generated-wrappers/static_call_proxy';
export * from '../test/generated-wrappers/test_chai_bridge';
export * from '../test/generated-wrappers/test_dex_forwarder_bridge';
export * from '../test/generated-wrappers/test_dydx_bridge';
export * from '../test/generated-wrappers/test_erc20_bridge';
export * from '../test/generated-wrappers/test_eth2_dai_bridge';
export * from '../test/generated-wrappers/test_kyber_bridge';
export * from '../test/generated-wrappers/test_static_call_target';
export * from '../test/generated-wrappers/test_uniswap_bridge';
export * from '../test/generated-wrappers/test_uniswap_v2_bridge';
export * from '../test/generated-wrappers/uniswap_bridge';
export * from '../test/generated-wrappers/uniswap_v2_bridge';

View File

@@ -3,8 +3,10 @@
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"generated-artifacts/BalancerBridge.json",
"generated-artifacts/ChaiBridge.json",
"generated-artifacts/CurveBridge.json",
"generated-artifacts/DexForwarderBridge.json",
"generated-artifacts/DydxBridge.json",
"generated-artifacts/ERC1155Proxy.json",
"generated-artifacts/ERC20BridgeProxy.json",
@@ -15,31 +17,40 @@
"generated-artifacts/IAssetProxy.json",
"generated-artifacts/IAssetProxyDispatcher.json",
"generated-artifacts/IAuthorizable.json",
"generated-artifacts/IBalancerPool.json",
"generated-artifacts/IChai.json",
"generated-artifacts/ICurve.json",
"generated-artifacts/IDydx.json",
"generated-artifacts/IDydxBridge.json",
"generated-artifacts/IERC20Bridge.json",
"generated-artifacts/IEth2Dai.json",
"generated-artifacts/IGasToken.json",
"generated-artifacts/IKyberNetworkProxy.json",
"generated-artifacts/IUniswapExchange.json",
"generated-artifacts/IUniswapExchangeFactory.json",
"generated-artifacts/IUniswapV2Router01.json",
"generated-artifacts/KyberBridge.json",
"generated-artifacts/MixinAssetProxyDispatcher.json",
"generated-artifacts/MixinAuthorizable.json",
"generated-artifacts/MixinGasToken.json",
"generated-artifacts/MultiAssetProxy.json",
"generated-artifacts/Ownable.json",
"generated-artifacts/StaticCallProxy.json",
"generated-artifacts/TestChaiBridge.json",
"generated-artifacts/TestDexForwarderBridge.json",
"generated-artifacts/TestDydxBridge.json",
"generated-artifacts/TestERC20Bridge.json",
"generated-artifacts/TestEth2DaiBridge.json",
"generated-artifacts/TestKyberBridge.json",
"generated-artifacts/TestStaticCallTarget.json",
"generated-artifacts/TestUniswapBridge.json",
"generated-artifacts/TestUniswapV2Bridge.json",
"generated-artifacts/UniswapBridge.json",
"generated-artifacts/UniswapV2Bridge.json",
"test/generated-artifacts/BalancerBridge.json",
"test/generated-artifacts/ChaiBridge.json",
"test/generated-artifacts/CurveBridge.json",
"test/generated-artifacts/DexForwarderBridge.json",
"test/generated-artifacts/DydxBridge.json",
"test/generated-artifacts/ERC1155Proxy.json",
"test/generated-artifacts/ERC20BridgeProxy.json",
@@ -50,29 +61,36 @@
"test/generated-artifacts/IAssetProxy.json",
"test/generated-artifacts/IAssetProxyDispatcher.json",
"test/generated-artifacts/IAuthorizable.json",
"test/generated-artifacts/IBalancerPool.json",
"test/generated-artifacts/IChai.json",
"test/generated-artifacts/ICurve.json",
"test/generated-artifacts/IDydx.json",
"test/generated-artifacts/IDydxBridge.json",
"test/generated-artifacts/IERC20Bridge.json",
"test/generated-artifacts/IEth2Dai.json",
"test/generated-artifacts/IGasToken.json",
"test/generated-artifacts/IKyberNetworkProxy.json",
"test/generated-artifacts/IUniswapExchange.json",
"test/generated-artifacts/IUniswapExchangeFactory.json",
"test/generated-artifacts/IUniswapV2Router01.json",
"test/generated-artifacts/KyberBridge.json",
"test/generated-artifacts/MixinAssetProxyDispatcher.json",
"test/generated-artifacts/MixinAuthorizable.json",
"test/generated-artifacts/MixinGasToken.json",
"test/generated-artifacts/MultiAssetProxy.json",
"test/generated-artifacts/Ownable.json",
"test/generated-artifacts/StaticCallProxy.json",
"test/generated-artifacts/TestChaiBridge.json",
"test/generated-artifacts/TestDexForwarderBridge.json",
"test/generated-artifacts/TestDydxBridge.json",
"test/generated-artifacts/TestERC20Bridge.json",
"test/generated-artifacts/TestEth2DaiBridge.json",
"test/generated-artifacts/TestKyberBridge.json",
"test/generated-artifacts/TestStaticCallTarget.json",
"test/generated-artifacts/TestUniswapBridge.json",
"test/generated-artifacts/UniswapBridge.json"
"test/generated-artifacts/TestUniswapV2Bridge.json",
"test/generated-artifacts/UniswapBridge.json",
"test/generated-artifacts/UniswapV2Bridge.json"
],
"exclude": ["./deploy/solc/solc_bin"]
}

View File

@@ -1,4 +1,50 @@
[
{
"timestamp": 1594788383,
"version": "1.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.1.5",
"changes": [
{
"note": "Fix broken tests.",
"pr": 2591
}
],
"timestamp": 1592969527
},
{
"timestamp": 1583220306,
"version": "1.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582837861,
"version": "1.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582677073,
"version": "1.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582623685,
"version": "1.1.1",

View File

@@ -5,6 +5,26 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.1.6 - _July 15, 2020_
* Dependencies updated
## v1.1.5 - _June 24, 2020_
* Fix broken tests. (#2591)
## v1.1.4 - _March 3, 2020_
* Dependencies updated
## v1.1.3 - _February 27, 2020_
* Dependencies updated
## v1.1.2 - _February 26, 2020_
* Dependencies updated
## v1.1.1 - _February 25, 2020_
* Dependencies updated

View File

@@ -3,6 +3,7 @@
"contractsDir": "./contracts",
"useDockerisedSolc": false,
"isOfflineMode": false,
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": {

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-broker",
"version": "1.1.1",
"version": "1.1.6",
"engines": {
"node": ">=6.12"
},
@@ -51,20 +51,20 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.2.1",
"@0x/contracts-asset-proxy": "^3.2.2",
"@0x/contracts-erc20": "^3.1.2",
"@0x/contracts-erc721": "^3.1.2",
"@0x/contracts-exchange": "^3.2.2",
"@0x/contracts-exchange-libs": "^4.3.2",
"@0x/contracts-gen": "^2.0.8",
"@0x/contracts-test-utils": "^5.3.0",
"@0x/contracts-utils": "^4.4.0",
"@0x/sol-compiler": "^4.0.8",
"@0x/abi-gen": "^5.3.1",
"@0x/contracts-asset-proxy": "^3.4.0",
"@0x/contracts-erc20": "^3.2.1",
"@0x/contracts-erc721": "^3.1.7",
"@0x/contracts-exchange": "^3.2.7",
"@0x/contracts-exchange-libs": "^4.3.7",
"@0x/contracts-gen": "^2.0.10",
"@0x/contracts-test-utils": "^5.3.4",
"@0x/contracts-utils": "^4.5.1",
"@0x/sol-compiler": "^4.1.1",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.2",
"@0x/web3-wrapper": "^7.0.7",
"@0x/tslint-config": "^4.1.0",
"@0x/types": "^3.2.0",
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
@@ -84,13 +84,14 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.1",
"@0x/order-utils": "^10.2.2",
"@0x/typescript-typings": "^5.0.2",
"@0x/utils": "^5.4.1",
"ethereum-types": "^3.1.0"
"@0x/base-contract": "^6.2.3",
"@0x/order-utils": "^10.3.0",
"@0x/typescript-typings": "^5.1.1",
"@0x/utils": "^5.5.1",
"ethereum-types": "^3.2.0"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}

View File

@@ -44,13 +44,13 @@ blockchainTests.resets('GodsUnchainedValidator unit tests', env => {
const tokenId = getRandomInteger(0, constants.MAX_UINT256);
await godsUnchained.setTokenProperties(tokenId, proto.plus(1), quality).awaitTransactionSuccessAsync();
const tx = validator.checkBrokerAsset(tokenId, propertyData).callAsync();
expect(tx).to.revertWith('PROTO_MISMATCH');
expect(tx).to.revertWith('GodsUnchainedValidator/PROTO_MISMATCH');
});
it("reverts if assetData quality doesn't match proeprtyData", async () => {
const tokenId = getRandomInteger(0, constants.MAX_UINT256);
await godsUnchained.setTokenProperties(tokenId, proto, quality.plus(1)).awaitTransactionSuccessAsync();
const tx = validator.checkBrokerAsset(tokenId, propertyData).callAsync();
expect(tx).to.revertWith('QUALITY_MISMATCH');
expect(tx).to.revertWith('GodsUnchainedValidator/QUALITY_MISMATCH');
});
});
});

View File

@@ -1,4 +1,49 @@
[
{
"timestamp": 1594788383,
"version": "3.1.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "3.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1583220306,
"version": "3.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582837861,
"version": "3.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582677073,
"version": "3.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582623685,
"version": "3.1.2",

View File

@@ -5,6 +5,26 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.7 - _July 15, 2020_
* Dependencies updated
## v3.1.6 - _June 24, 2020_
* Dependencies updated
## v3.1.5 - _March 3, 2020_
* Dependencies updated
## v3.1.4 - _February 27, 2020_
* Dependencies updated
## v3.1.3 - _February 26, 2020_
* Dependencies updated
## v3.1.2 - _February 25, 2020_
* Dependencies updated

View File

@@ -2,6 +2,7 @@
"artifactsDir": "./test/generated-artifacts",
"contractsDir": "./contracts",
"useDockerisedSolc": false,
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": {

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-coordinator",
"version": "3.1.2",
"version": "3.1.7",
"engines": {
"node": ">=6.12"
},
@@ -52,19 +52,19 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.2.1",
"@0x/contracts-asset-proxy": "^3.2.2",
"@0x/contracts-dev-utils": "^1.3.0",
"@0x/contracts-erc20": "^3.1.2",
"@0x/contracts-exchange": "^3.2.2",
"@0x/contracts-gen": "^2.0.8",
"@0x/contracts-test-utils": "^5.3.0",
"@0x/dev-utils": "^3.2.1",
"@0x/order-utils": "^10.2.2",
"@0x/sol-compiler": "^4.0.8",
"@0x/abi-gen": "^5.3.1",
"@0x/contracts-asset-proxy": "^3.4.0",
"@0x/contracts-dev-utils": "^1.3.5",
"@0x/contracts-erc20": "^3.2.1",
"@0x/contracts-exchange": "^3.2.7",
"@0x/contracts-gen": "^2.0.10",
"@0x/contracts-test-utils": "^5.3.4",
"@0x/dev-utils": "^3.3.0",
"@0x/order-utils": "^10.3.0",
"@0x/sol-compiler": "^4.1.1",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/web3-wrapper": "^7.0.7",
"@0x/tslint-config": "^4.1.0",
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
@@ -84,18 +84,19 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/assert": "^3.0.7",
"@0x/base-contract": "^6.2.1",
"@0x/contract-addresses": "^4.7.0",
"@0x/contracts-utils": "^4.4.0",
"@0x/json-schemas": "^5.0.7",
"@0x/types": "^3.1.2",
"@0x/typescript-typings": "^5.0.2",
"@0x/utils": "^5.4.1",
"ethereum-types": "^3.1.0",
"@0x/assert": "^3.0.9",
"@0x/base-contract": "^6.2.3",
"@0x/contract-addresses": "^4.11.0",
"@0x/contracts-utils": "^4.5.1",
"@0x/json-schemas": "^5.1.0",
"@0x/types": "^3.2.0",
"@0x/typescript-typings": "^5.1.1",
"@0x/utils": "^5.5.1",
"ethereum-types": "^3.2.0",
"http-status-codes": "^1.3.2"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}

View File

@@ -1,4 +1,49 @@
[
{
"timestamp": 1594788383,
"version": "1.3.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "1.3.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1583220306,
"version": "1.3.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582837861,
"version": "1.3.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582677073,
"version": "1.3.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.3.0",
"changes": [

View File

@@ -5,6 +5,26 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.3.5 - _July 15, 2020_
* Dependencies updated
## v1.3.4 - _June 24, 2020_
* Dependencies updated
## v1.3.3 - _March 3, 2020_
* Dependencies updated
## v1.3.2 - _February 27, 2020_
* Dependencies updated
## v1.3.1 - _February 26, 2020_
* Dependencies updated
## v1.3.0 - _February 25, 2020_
* Update `DevUtils` addresses in `DeploymentConstants` (#2493)

View File

@@ -3,6 +3,7 @@
"contractsDir": "./contracts",
"useDockerisedSolc": false,
"isOfflineMode": false,
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": {

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-dev-utils",
"version": "1.3.0",
"version": "1.3.5",
"engines": {
"node": ">=6.12"
},
@@ -41,19 +41,19 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/dev-utils/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.2.1",
"@0x/assert": "^3.0.7",
"@0x/contracts-asset-proxy": "^3.2.2",
"@0x/contracts-erc20": "^3.1.2",
"@0x/contracts-gen": "^2.0.8",
"@0x/contracts-test-utils": "^5.3.0",
"@0x/sol-compiler": "^4.0.8",
"@0x/abi-gen": "^5.3.1",
"@0x/assert": "^3.0.9",
"@0x/contracts-asset-proxy": "^3.4.0",
"@0x/contracts-erc20": "^3.2.1",
"@0x/contracts-gen": "^2.0.10",
"@0x/contracts-test-utils": "^5.3.4",
"@0x/sol-compiler": "^4.1.1",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.2",
"@0x/utils": "^5.4.1",
"@0x/tslint-config": "^4.1.0",
"@0x/types": "^3.2.0",
"@0x/utils": "^5.5.1",
"@types/node": "*",
"ethereum-types": "^3.1.0",
"ethereum-types": "^3.2.0",
"ethers": "~4.0.4",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
@@ -64,9 +64,10 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.1"
"@0x/base-contract": "^6.2.3"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}

View File

@@ -1,4 +1,49 @@
[
{
"timestamp": 1594788383,
"version": "2.1.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "2.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1583220306,
"version": "2.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582837861,
"version": "2.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582677073,
"version": "2.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582623685,
"version": "2.1.2",

View File

@@ -5,6 +5,26 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.1.7 - _July 15, 2020_
* Dependencies updated
## v2.1.6 - _June 24, 2020_
* Dependencies updated
## v2.1.5 - _March 3, 2020_
* Dependencies updated
## v2.1.4 - _February 27, 2020_
* Dependencies updated
## v2.1.3 - _February 26, 2020_
* Dependencies updated
## v2.1.2 - _February 25, 2020_
* Dependencies updated

View File

@@ -3,6 +3,7 @@
"contractsDir": "./contracts",
"useDockerisedSolc": false,
"isOfflineMode": false,
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": {

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc1155",
"version": "2.1.2",
"version": "2.1.7",
"engines": {
"node": ">=6.12"
},
@@ -52,15 +52,15 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.2.1",
"@0x/contracts-gen": "^2.0.8",
"@0x/contracts-utils": "^4.4.0",
"@0x/dev-utils": "^3.2.1",
"@0x/sol-compiler": "^4.0.8",
"@0x/abi-gen": "^5.3.1",
"@0x/contracts-gen": "^2.0.10",
"@0x/contracts-utils": "^4.5.1",
"@0x/dev-utils": "^3.3.0",
"@0x/sol-compiler": "^4.1.1",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.2",
"@0x/typescript-typings": "^5.0.2",
"@0x/tslint-config": "^4.1.0",
"@0x/types": "^3.2.0",
"@0x/typescript-typings": "^5.1.1",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
@@ -68,7 +68,7 @@
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"ethereum-types": "^3.1.0",
"ethereum-types": "^3.2.0",
"make-promises-safe": "^1.1.0",
"mocha": "^6.2.0",
"npm-run-all": "^4.1.2",
@@ -80,13 +80,14 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.1",
"@0x/contracts-test-utils": "^5.3.0",
"@0x/utils": "^5.4.1",
"@0x/web3-wrapper": "^7.0.7",
"@0x/base-contract": "^6.2.3",
"@0x/contracts-test-utils": "^5.3.4",
"@0x/utils": "^5.5.1",
"@0x/web3-wrapper": "^7.2.0",
"lodash": "^4.17.11"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}

View File

@@ -1,4 +1,80 @@
[
{
"version": "1.7.0",
"changes": [
{
"note": "Pass in `DevUtils` address to required functions",
"pr": 2629
},
{
"note": "Use new Kyber Katalyst functions",
"pr": 2629
}
],
"timestamp": 1594788383
},
{
"version": "1.6.0",
"changes": [
{
"note": "Pass in `DevUtils` address as a constructor parameter",
"pr": 2531
},
{
"note": "Sample `Curve` for buy amounts",
"pr": 2551
},
{
"note": "Added `sampleBuysFromKyberNetwork`",
"pr": 2551
},
{
"note": "Use `searchBestRate` in Kyber samples. Return 0 when Uniswap/Eth2Dai reserve",
"pr": 2575
},
{
"note": "Add UniswapV2",
"pr": 2595
},
{
"note": "Sample from MultiBridge",
"pr": 2593
}
],
"timestamp": 1592969527
},
{
"timestamp": 1583220306,
"version": "1.5.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.5.0",
"changes": [
{
"note": "Add generic liquidity provider sampling",
"pr": 2487
},
{
"note": "Use liquidity provider registry in sampler",
"pr": 2499
}
],
"timestamp": 1582837861
},
{
"timestamp": 1582677073,
"version": "1.4.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582623685,
"version": "1.4.1",

View File

@@ -5,6 +5,33 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.7.0 - _July 15, 2020_
* Pass in `DevUtils` address to required functions (#2629)
* Use new Kyber Katalyst functions (#2629)
## v1.6.0 - _June 24, 2020_
* Pass in `DevUtils` address as a constructor parameter (#2531)
* Sample `Curve` for buy amounts (#2551)
* Added `sampleBuysFromKyberNetwork` (#2551)
* Use `searchBestRate` in Kyber samples. Return 0 when Uniswap/Eth2Dai reserve (#2575)
* Add UniswapV2 (#2595)
* Sample from MultiBridge (#2593)
## v1.5.1 - _March 3, 2020_
* Dependencies updated
## v1.5.0 - _February 27, 2020_
* Add generic liquidity provider sampling (#2487)
* Use liquidity provider registry in sampler (#2499)
## v1.4.2 - _February 26, 2020_
* Dependencies updated
## v1.4.1 - _February 25, 2020_
* Dependencies updated

View File

@@ -3,6 +3,7 @@
"contractsDir": "./contracts",
"useDockerisedSolc": false,
"isOfflineMode": false,
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": {

View File

@@ -0,0 +1,38 @@
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
contract DummyLiquidityProvider
{
/// @dev Quotes the amount of `makerToken` that would be obtained by
/// selling `sellAmount` of `takerToken`.
/// @param sellAmount Amount of `takerToken` to sell.
/// @return makerTokenAmount Amount of `makerToken` that would be obtained.
function getSellQuote(
address, /* takerToken */
address, /* makerToken */
uint256 sellAmount
)
external
view
returns (uint256 makerTokenAmount)
{
makerTokenAmount = sellAmount - 1;
}
/// @dev Quotes the amount of `takerToken` that would need to be sold in
/// order to obtain `buyAmount` of `makerToken`.
/// @param buyAmount Amount of `makerToken` to buy.
/// @return takerTokenAmount Amount of `takerToken` that would need to be sold.
function getBuyQuote(
address, /* takerToken */
address, /* makerToken */
uint256 buyAmount
)
external
view
returns (uint256 takerTokenAmount)
{
takerTokenAmount = buyAmount + 1;
}
}

View File

@@ -0,0 +1,44 @@
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
contract DummyLiquidityProviderRegistry
{
address private constant NULL_ADDRESS = address(0x0);
mapping (address => mapping (address => address)) internal _gAddressBook;
/// @dev Sets address of pool for a market given market (xAsset, yAsset).
/// @param xToken First asset managed by pool.
/// @param yToken Second asset managed by pool.
/// @param poolAddress Address of pool.
function setLiquidityProviderForMarket(
address xToken,
address yToken,
address poolAddress
)
external
{
_gAddressBook[xToken][yToken] = poolAddress;
_gAddressBook[yToken][xToken] = poolAddress;
}
/// @dev Returns the address of pool for a market given market (xAsset, yAsset), or reverts if pool does not exist.
/// @param xToken First asset managed by pool.
/// @param yToken Second asset managed by pool.
/// @return Address of pool.
function getLiquidityProviderForMarket(
address xToken,
address yToken
)
external
view
returns (address poolAddress)
{
poolAddress = _gAddressBook[xToken][yToken];
require(
poolAddress != NULL_ADDRESS,
"Registry/MARKET_PAIR_NOT_SET"
);
}
}

View File

@@ -24,12 +24,20 @@ import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "./IDevUtils.sol";
import "./IERC20BridgeSampler.sol";
import "./IEth2Dai.sol";
import "./IKyberNetwork.sol";
import "./IKyberNetworkProxy.sol";
import "./IKyberStorage.sol";
import "./IKyberHintHandler.sol";
import "./IUniswapExchangeQuotes.sol";
import "./ICurve.sol";
import "./ILiquidityProvider.sol";
import "./ILiquidityProviderRegistry.sol";
import "./IUniswapV2Router01.sol";
import "./IMultiBridge.sol";
contract ERC20BridgeSampler is
@@ -42,11 +50,21 @@ contract ERC20BridgeSampler is
uint256 constant internal KYBER_CALL_GAS = 1500e3; // 1.5m
/// @dev Gas limit for Uniswap calls.
uint256 constant internal UNISWAP_CALL_GAS = 150e3; // 150k
/// @dev Gas limit for UniswapV2 calls.
uint256 constant internal UNISWAPV2_CALL_GAS = 150e3; // 150k
/// @dev Base gas limit for Eth2Dai calls.
uint256 constant internal ETH2DAI_CALL_GAS = 1000e3; // 1m
/// @dev Base gas limit for Curve calls. Some Curves have multiple tokens
/// So a reasonable ceil is 150k per token. Biggest Curve has 4 tokens.
uint256 constant internal CURVE_CALL_GAS = 600e3; // 600k
/// @dev Default gas limit for liquidity provider calls.
uint256 constant internal DEFAULT_CALL_GAS = 400e3; // 400k
/// @dev The Kyber Uniswap Reserve address
address constant internal KYBER_UNISWAP_RESERVE = 0x31E085Afd48a1d6e51Cc193153d625e8f0514C7F;
/// @dev The Kyber Uniswap V2 Reserve address
address constant internal KYBER_UNISWAPV2_RESERVE = 0x10908C875D865C66f271F5d3949848971c9595C9;
/// @dev The Kyber Eth2Dai Reserve address
address constant internal KYBER_ETH2DAI_RESERVE = 0x1E158c0e93c30d24e918Ef83d1e0bE23595C3c0f;
/// @dev Call multiple public functions on this contract in a single transaction.
/// @param callDatas ABI-encoded call data for each function call.
@@ -71,11 +89,13 @@ contract ERC20BridgeSampler is
/// maker/taker asset amounts (returning 0).
/// @param orders Native orders to query.
/// @param orderSignatures Signatures for each respective order in `orders`.
/// @param devUtilsAddress Address to the DevUtils contract.
/// @return orderFillableTakerAssetAmounts How much taker asset can be filled
/// by each order in `orders`.
function getOrderFillableTakerAssetAmounts(
LibOrder.Order[] memory orders,
bytes[] memory orderSignatures
bytes[] memory orderSignatures,
address devUtilsAddress
)
public
view
@@ -92,11 +112,11 @@ contract ERC20BridgeSampler is
}
// solhint-disable indent
(bool didSucceed, bytes memory resultData) =
_getDevUtilsAddress()
devUtilsAddress
.staticcall
.gas(DEV_UTILS_CALL_GAS)
(abi.encodeWithSelector(
IDevUtils(_getDevUtilsAddress()).getOrderRelevantState.selector,
IDevUtils(devUtilsAddress).getOrderRelevantState.selector,
orders[i],
orderSignatures[i]
));
@@ -128,11 +148,13 @@ contract ERC20BridgeSampler is
/// Effectively ignores orders that have empty signatures or
/// @param orders Native orders to query.
/// @param orderSignatures Signatures for each respective order in `orders`.
/// @param devUtilsAddress Address to the DevUtils contract.
/// @return orderFillableMakerAssetAmounts How much maker asset can be filled
/// by each order in `orders`.
function getOrderFillableMakerAssetAmounts(
LibOrder.Order[] memory orders,
bytes[] memory orderSignatures
bytes[] memory orderSignatures,
address devUtilsAddress
)
public
view
@@ -140,7 +162,8 @@ contract ERC20BridgeSampler is
{
orderFillableMakerAssetAmounts = getOrderFillableTakerAssetAmounts(
orders,
orderSignatures
orderSignatures,
devUtilsAddress
);
// `orderFillableMakerAssetAmounts` now holds taker asset amounts, so
// convert them to maker asset amounts.
@@ -171,36 +194,52 @@ contract ERC20BridgeSampler is
returns (uint256[] memory makerTokenAmounts)
{
_assertValidPair(makerToken, takerToken);
address _takerToken = takerToken == _getWethAddress() ? KYBER_ETH_ADDRESS : takerToken;
address _makerToken = makerToken == _getWethAddress() ? KYBER_ETH_ADDRESS : makerToken;
uint256 takerTokenDecimals = _getTokenDecimals(takerToken);
uint256 makerTokenDecimals = _getTokenDecimals(makerToken);
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
address wethAddress = _getWethAddress();
uint256 value;
for (uint256 i = 0; i < numSamples; i++) {
(bool didSucceed, bytes memory resultData) =
_getKyberNetworkProxyAddress().staticcall.gas(KYBER_CALL_GAS)(
abi.encodeWithSelector(
IKyberNetwork(0).getExpectedRate.selector,
_takerToken,
_makerToken,
takerTokenAmounts[i]
));
uint256 rate = 0;
if (didSucceed) {
rate = abi.decode(resultData, (uint256));
if (takerToken == wethAddress || makerToken == wethAddress) {
// Direct ETH based trade
value = _sampleSellFromKyberNetwork(takerToken, makerToken, takerTokenAmounts[i]);
} else {
break;
// Hop to ETH
value = _sampleSellFromKyberNetwork(takerToken, wethAddress, takerTokenAmounts[i]);
if (value != 0) {
value = _sampleSellFromKyberNetwork(wethAddress, makerToken, value);
}
}
makerTokenAmounts[i] =
rate *
takerTokenAmounts[i] *
10 ** makerTokenDecimals /
10 ** takerTokenDecimals /
10 ** 18;
makerTokenAmounts[i] = value;
}
}
/// @dev Sample buy quotes from Kyber.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @param opts `FakeBuyOptions` specifying target slippage and max iterations.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromKyberNetwork(
address takerToken,
address makerToken,
uint256[] memory makerTokenAmounts,
FakeBuyOptions memory opts
)
public
view
returns (uint256[] memory takerTokenAmounts)
{
return _sampleApproximateBuysFromSource(
takerToken,
makerToken,
makerTokenAmounts,
opts,
this.sampleSellsFromKyberNetwork.selector,
address(0) // PLP registry address
);
}
/// @dev Sample sell quotes from Eth2Dai/Oasis.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
@@ -238,6 +277,31 @@ contract ERC20BridgeSampler is
}
}
/// @dev Sample sell quotes from Eth2Dai/Oasis using a hop to an intermediate token.
/// I.e WBTC/DAI via ETH or WBTC/ETH via DAI
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param intermediateToken Address of the token to hop to.
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromEth2DaiHop(
address takerToken,
address makerToken,
address intermediateToken,
uint256[] memory takerTokenAmounts
)
public
view
returns (uint256[] memory makerTokenAmounts)
{
if (makerToken == intermediateToken || takerToken == intermediateToken) {
return makerTokenAmounts;
}
uint256[] memory intermediateAmounts = sampleSellsFromEth2Dai(takerToken, intermediateToken, takerTokenAmounts);
makerTokenAmounts = sampleSellsFromEth2Dai(intermediateToken, makerToken, intermediateAmounts);
}
/// @dev Sample buy quotes from Eth2Dai/Oasis.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
@@ -431,6 +495,269 @@ contract ERC20BridgeSampler is
}
}
/// @dev Sample buy quotes from Curve.
/// @param curveAddress Address of the Curve contract.
/// @param fromTokenIdx Index of the taker token (what to sell).
/// @param toTokenIdx Index of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromCurve(
address curveAddress,
int128 fromTokenIdx,
int128 toTokenIdx,
uint256[] memory makerTokenAmounts
)
public
view
returns (uint256[] memory takerTokenAmounts)
{
uint256 numSamples = makerTokenAmounts.length;
takerTokenAmounts = new uint256[](numSamples);
for (uint256 i = 0; i < numSamples; i++) {
(bool didSucceed, bytes memory resultData) =
curveAddress.staticcall.gas(CURVE_CALL_GAS)(
abi.encodeWithSelector(
ICurve(0).get_dx_underlying.selector,
fromTokenIdx,
toTokenIdx,
makerTokenAmounts[i]
));
uint256 sellAmount = 0;
if (didSucceed) {
sellAmount = abi.decode(resultData, (uint256));
} else {
break;
}
takerTokenAmounts[i] = sellAmount;
}
}
/// @dev Sample sell quotes from an arbitrary on-chain liquidity provider.
/// @param registryAddress Address of the liquidity provider registry contract.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromLiquidityProviderRegistry(
address registryAddress,
address takerToken,
address makerToken,
uint256[] memory takerTokenAmounts
)
public
view
returns (uint256[] memory makerTokenAmounts)
{
// Initialize array of maker token amounts.
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
// Query registry for provider address.
address providerAddress = getLiquidityProviderFromRegistry(
registryAddress,
takerToken,
makerToken
);
// If provider doesn't exist, return all zeros.
if (providerAddress == address(0)) {
return makerTokenAmounts;
}
for (uint256 i = 0; i < numSamples; i++) {
(bool didSucceed, bytes memory resultData) =
providerAddress.staticcall.gas(DEFAULT_CALL_GAS)(
abi.encodeWithSelector(
ILiquidityProvider(0).getSellQuote.selector,
takerToken,
makerToken,
takerTokenAmounts[i]
));
uint256 buyAmount = 0;
if (didSucceed) {
buyAmount = abi.decode(resultData, (uint256));
} else {
// Exit early if the amount is too high for the liquidity provider to serve
break;
}
makerTokenAmounts[i] = buyAmount;
}
}
/// @dev Sample sell quotes from MultiBridge.
/// @param multibridge Address of the MultiBridge contract.
/// @param takerToken Address of the taker token (what to sell).
/// @param intermediateToken The address of the intermediate token to
/// use in an indirect route.
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromMultiBridge(
address multibridge,
address takerToken,
address intermediateToken,
address makerToken,
uint256[] memory takerTokenAmounts
)
public
view
returns (uint256[] memory makerTokenAmounts)
{
// Initialize array of maker token amounts.
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
// If no address provided, return all zeros.
if (multibridge == address(0)) {
return makerTokenAmounts;
}
for (uint256 i = 0; i < numSamples; i++) {
(bool didSucceed, bytes memory resultData) =
multibridge.staticcall.gas(DEFAULT_CALL_GAS)(
abi.encodeWithSelector(
IMultiBridge(0).getSellQuote.selector,
takerToken,
intermediateToken,
makerToken,
takerTokenAmounts[i]
));
uint256 buyAmount = 0;
if (didSucceed) {
buyAmount = abi.decode(resultData, (uint256));
} else {
// Exit early if the amount is too high for the liquidity provider to serve
break;
}
makerTokenAmounts[i] = buyAmount;
}
}
/// @dev Sample buy quotes from an arbitrary on-chain liquidity provider.
/// @param registryAddress Address of the liquidity provider registry contract.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @param opts `FakeBuyOptions` specifying target slippage and max iterations.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromLiquidityProviderRegistry(
address registryAddress,
address takerToken,
address makerToken,
uint256[] memory makerTokenAmounts,
FakeBuyOptions memory opts
)
public
view
returns (uint256[] memory takerTokenAmounts)
{
return _sampleApproximateBuysFromSource(
takerToken,
makerToken,
makerTokenAmounts,
opts,
this.sampleSellsFromLiquidityProviderRegistry.selector,
registryAddress
);
}
/// @dev Returns the address of a liquidity provider for the given market
/// (takerToken, makerToken), from a registry of liquidity providers.
/// Returns address(0) if no such provider exists in the registry.
/// @param takerToken Taker asset managed by liquidity provider.
/// @param makerToken Maker asset managed by liquidity provider.
/// @return providerAddress Address of the liquidity provider.
function getLiquidityProviderFromRegistry(
address registryAddress,
address takerToken,
address makerToken
)
public
view
returns (address providerAddress)
{
bytes memory callData = abi.encodeWithSelector(
ILiquidityProviderRegistry(0).getLiquidityProviderForMarket.selector,
takerToken,
makerToken
);
(bool didSucceed, bytes memory returnData) = registryAddress.staticcall(callData);
if (didSucceed && returnData.length == 32) {
return LibBytes.readAddress(returnData, 12);
}
}
/// @dev Sample sell quotes from UniswapV2.
/// @param path Token route. Should be takerToken -> makerToken
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromUniswapV2(
address[] memory path,
uint256[] memory takerTokenAmounts
)
public
view
returns (uint256[] memory makerTokenAmounts)
{
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
for (uint256 i = 0; i < numSamples; i++) {
(bool didSucceed, bytes memory resultData) =
_getUniswapV2Router01Address().staticcall.gas(UNISWAPV2_CALL_GAS)(
abi.encodeWithSelector(
IUniswapV2Router01(0).getAmountsOut.selector,
takerTokenAmounts[i],
path
));
uint256 buyAmount = 0;
if (didSucceed) {
// solhint-disable-next-line indent
buyAmount = abi.decode(resultData, (uint256[]))[path.length - 1];
} else {
break;
}
makerTokenAmounts[i] = buyAmount;
}
}
/// @dev Sample buy quotes from UniswapV2.
/// @param path Token route. Should be takerToken -> makerToken.
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromUniswapV2(
address[] memory path,
uint256[] memory makerTokenAmounts
)
public
view
returns (uint256[] memory takerTokenAmounts)
{
uint256 numSamples = makerTokenAmounts.length;
takerTokenAmounts = new uint256[](numSamples);
for (uint256 i = 0; i < numSamples; i++) {
(bool didSucceed, bytes memory resultData) =
_getUniswapV2Router01Address().staticcall.gas(UNISWAPV2_CALL_GAS)(
abi.encodeWithSelector(
IUniswapV2Router01(0).getAmountsIn.selector,
makerTokenAmounts[i],
path
));
uint256 sellAmount = 0;
if (didSucceed) {
// solhint-disable-next-line indent
sellAmount = abi.decode(resultData, (uint256[]))[0];
} else {
break;
}
takerTokenAmounts[i] = sellAmount;
}
}
/// @dev Overridable way to get token decimals.
/// @param tokenAddress Address of the token.
/// @return decimals The decimal places for the token.
@@ -496,4 +823,221 @@ contract ERC20BridgeSampler is
{
require(makerToken != takerToken, "ERC20BridgeSampler/INVALID_TOKEN_PAIR");
}
function _sampleSellForApproximateBuy(
address takerToken,
address makerToken,
uint256 takerTokenAmount,
bytes4 selector,
address plpRegistryAddress
)
private
view
returns (uint256 makerTokenAmount)
{
bytes memory callData;
uint256[] memory tmpTakerAmounts = new uint256[](1);
tmpTakerAmounts[0] = takerTokenAmount;
if (selector == this.sampleSellsFromKyberNetwork.selector) {
callData = abi.encodeWithSelector(
this.sampleSellsFromKyberNetwork.selector,
takerToken,
makerToken,
tmpTakerAmounts
);
} else {
callData = abi.encodeWithSelector(
this.sampleSellsFromLiquidityProviderRegistry.selector,
plpRegistryAddress,
takerToken,
makerToken,
tmpTakerAmounts
);
}
(bool success, bytes memory resultData) = address(this).staticcall(callData);
if (!success) {
return 0;
}
// solhint-disable indent
makerTokenAmount = abi.decode(resultData, (uint256[]))[0];
}
function _sampleApproximateBuysFromSource(
address takerToken,
address makerToken,
uint256[] memory makerTokenAmounts,
FakeBuyOptions memory opts,
bytes4 selector,
address plpRegistryAddress
)
private
view
returns (uint256[] memory takerTokenAmounts)
{
_assertValidPair(makerToken, takerToken);
if (makerTokenAmounts.length == 0) {
return takerTokenAmounts;
}
uint256 sellAmount;
uint256 buyAmount;
uint256 slippageFromTarget;
takerTokenAmounts = new uint256[](makerTokenAmounts.length);
sellAmount = _sampleSellForApproximateBuy(
makerToken,
takerToken,
makerTokenAmounts[0],
selector,
plpRegistryAddress
);
if (sellAmount == 0) {
return takerTokenAmounts;
}
buyAmount = _sampleSellForApproximateBuy(
takerToken,
makerToken,
sellAmount,
selector,
plpRegistryAddress
);
if (buyAmount == 0) {
return takerTokenAmounts;
}
for (uint256 i = 0; i < makerTokenAmounts.length; i++) {
for (uint256 iter = 0; iter < opts.maxIterations; iter++) {
// adjustedSellAmount = previousSellAmount * (target/actual) * JUMP_MULTIPLIER
sellAmount = LibMath.getPartialAmountCeil(
makerTokenAmounts[i],
buyAmount,
sellAmount
);
sellAmount = LibMath.getPartialAmountCeil(
(10000 + opts.targetSlippageBps),
10000,
sellAmount
);
uint256 _buyAmount = _sampleSellForApproximateBuy(
takerToken,
makerToken,
sellAmount,
selector,
plpRegistryAddress
);
if (_buyAmount == 0) {
break;
}
// We re-use buyAmount next iteration, only assign if it is
// non zero
buyAmount = _buyAmount;
// If we've reached our goal, exit early
if (buyAmount >= makerTokenAmounts[i]) {
uint256 slippageFromTarget = (buyAmount - makerTokenAmounts[i]) * 10000 /
makerTokenAmounts[i];
if (slippageFromTarget <= opts.targetSlippageBps) {
break;
}
}
}
// We do our best to close in on the requested amount, but we can either over buy or under buy and exit
// if we hit a max iteration limit
// We scale the sell amount to get the approximate target
takerTokenAmounts[i] = LibMath.getPartialAmountCeil(
makerTokenAmounts[i],
buyAmount,
sellAmount
);
}
}
function _appendToList(bytes32[] memory list, bytes32 item) private view returns (bytes32[] memory appendedList)
{
appendedList = new bytes32[](list.length + 1);
for (uint256 i = 0; i < list.length; i++) {
appendedList[i] = list[i];
}
appendedList[appendedList.length - 1] = item;
}
function _getKyberAddresses()
private
view
returns (IKyberHintHandler kyberHint, IKyberStorage kyberStorage)
{
(, , kyberHint, kyberStorage, ,) = IKyberNetwork(
IKyberNetworkProxy(_getKyberNetworkProxyAddress()).kyberNetwork()).getContracts();
return (IKyberHintHandler(kyberHint), IKyberStorage(kyberStorage));
}
function _sampleSellFromKyberNetwork(
address takerToken,
address makerToken,
uint256 takerTokenAmount
)
private
view
returns (uint256 makerTokenAmount)
{
(IKyberHintHandler kyberHint, IKyberStorage kyberStorage) = _getKyberAddresses();
// Ban reserves which can clash with our internal aggregation
bytes32[] memory reserveIds = kyberStorage.getReserveIdsPerTokenSrc(
takerToken == _getWethAddress() ? makerToken : takerToken
);
bytes32[] memory bannedReserveIds = new bytes32[](0);
// Poor mans resize and append
for (uint256 i = 0; i < reserveIds.length; i++) {
if (
reserveIds[i] == kyberStorage.getReserveId(KYBER_UNISWAP_RESERVE) ||
reserveIds[i] == kyberStorage.getReserveId(KYBER_UNISWAPV2_RESERVE) ||
reserveIds[i] == kyberStorage.getReserveId(KYBER_ETH2DAI_RESERVE)
) {
bannedReserveIds = _appendToList(bannedReserveIds, reserveIds[i]);
}
}
// Sampler either detects X->ETH/ETH->X
// or subsamples as X->ETH-Y. So token->token here is not possible
bytes memory hint;
if (takerToken == _getWethAddress()) {
// ETH -> X
hint = kyberHint.buildEthToTokenHint(
makerToken,
IKyberHintHandler.TradeType.MaskOut,
bannedReserveIds,
new uint256[](0));
} else {
// X->ETH
hint = kyberHint.buildEthToTokenHint(
takerToken,
IKyberHintHandler.TradeType.MaskOut,
bannedReserveIds,
new uint256[](0));
}
(bool didSucceed, bytes memory resultData) =
_getKyberNetworkProxyAddress().staticcall.gas(KYBER_CALL_GAS)(
abi.encodeWithSelector(
IKyberNetworkProxy(0).getExpectedRateAfterFee.selector,
takerToken == _getWethAddress() ? KYBER_ETH_ADDRESS : takerToken,
makerToken == _getWethAddress() ? KYBER_ETH_ADDRESS : makerToken,
takerTokenAmount,
0, // fee
hint
));
uint256 rate = 0;
if (didSucceed) {
(rate) = abi.decode(resultData, (uint256));
} else {
return 0;
}
uint256 makerTokenDecimals = _getTokenDecimals(makerToken);
uint256 takerTokenDecimals = _getTokenDecimals(takerToken);
makerTokenAmount =
rate *
takerTokenAmount *
10 ** makerTokenDecimals /
10 ** takerTokenDecimals /
10 ** 18;
return makerTokenAmount;
}
}

View File

@@ -24,6 +24,11 @@ import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
interface IERC20BridgeSampler {
struct FakeBuyOptions {
uint256 targetSlippageBps;
uint256 maxIterations;
}
/// @dev Call multiple public functions on this contract in a single transaction.
/// @param callDatas ABI-encoded call data for each function call.
/// @return callResults ABI-encoded results data for each call.
@@ -35,11 +40,13 @@ interface IERC20BridgeSampler {
/// @dev Queries the fillable taker asset amounts of native orders.
/// @param orders Native orders to query.
/// @param orderSignatures Signatures for each respective order in `orders`.
/// @param devUtilsAddress Address to the DevUtils contract.
/// @return orderFillableTakerAssetAmounts How much taker asset can be filled
/// by each order in `orders`.
function getOrderFillableTakerAssetAmounts(
LibOrder.Order[] calldata orders,
bytes[] calldata orderSignatures
bytes[] calldata orderSignatures,
address devUtilsAddress
)
external
view
@@ -48,11 +55,13 @@ interface IERC20BridgeSampler {
/// @dev Queries the fillable maker asset amounts of native orders.
/// @param orders Native orders to query.
/// @param orderSignatures Signatures for each respective order in `orders`.
/// @param devUtilsAddress Address to the DevUtils contract.
/// @return orderFillableMakerAssetAmounts How much maker asset can be filled
/// by each order in `orders`.
function getOrderFillableMakerAssetAmounts(
LibOrder.Order[] calldata orders,
bytes[] calldata orderSignatures
bytes[] calldata orderSignatures,
address devUtilsAddress
)
external
view
@@ -73,6 +82,23 @@ interface IERC20BridgeSampler {
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample buy quotes from Kyber.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @param opts `FakeBuyOptions` specifying target slippage and max iterations.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromKyberNetwork(
address takerToken,
address makerToken,
uint256[] calldata makerTokenAmounts,
FakeBuyOptions calldata opts
)
external
view
returns (uint256[] memory takerTokenAmounts);
/// @dev Sample sell quotes from Eth2Dai/Oasis.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
@@ -106,7 +132,7 @@ interface IERC20BridgeSampler {
/// @dev Sample buy quotes from Uniswap.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token sell amount for each sample.
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromUniswap(
@@ -121,7 +147,7 @@ interface IERC20BridgeSampler {
/// @dev Sample buy quotes from Eth2Dai/Oasis.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Maker token sell amount for each sample.
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromEth2Dai(
@@ -149,4 +175,119 @@ interface IERC20BridgeSampler {
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample buy quotes from Curve.
/// @param curveAddress Address of the Curve contract.
/// @param fromTokenIdx Index of the taker token (what to sell).
/// @param toTokenIdx Index of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromCurve(
address curveAddress,
int128 fromTokenIdx,
int128 toTokenIdx,
uint256[] calldata makerTokenAmounts
)
external
view
returns (uint256[] memory takerTokenAmounts);
/// @dev Sample sell quotes from an arbitrary on-chain liquidity provider.
/// @param registryAddress Address of the liquidity provider registry contract.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromLiquidityProviderRegistry(
address registryAddress,
address takerToken,
address makerToken,
uint256[] calldata takerTokenAmounts
)
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample sell quotes from MultiBridge.
/// @param multibridge Address of the MultiBridge contract.
/// @param takerToken Address of the taker token (what to sell).
/// @param intermediateToken The address of the intermediate token to
/// use in an indirect route.
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromMultiBridge(
address multibridge,
address takerToken,
address intermediateToken,
address makerToken,
uint256[] calldata takerTokenAmounts
)
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample buy quotes from an arbitrary on-chain liquidity provider.
/// @param registryAddress Address of the liquidity provider registry contract.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @param opts `FakeBuyOptions` specifying target slippage and max iterations.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromLiquidityProviderRegistry(
address registryAddress,
address takerToken,
address makerToken,
uint256[] calldata makerTokenAmounts,
FakeBuyOptions calldata opts
)
external
view
returns (uint256[] memory takerTokenAmounts);
/// @dev Returns the address of a liquidity provider for the given market
/// (takerToken, makerToken), from a registry of liquidity providers.
/// Returns address(0) if no such provider exists in the registry.
/// @param takerToken Taker asset managed by liquidity provider.
/// @param makerToken Maker asset managed by liquidity provider.
/// @return providerAddress Address of the liquidity provider.
function getLiquidityProviderFromRegistry(
address registryAddress,
address takerToken,
address makerToken
)
external
view
returns (address providerAddress);
/// @dev Sample sell quotes from UniswapV2.
/// @param path Token route.
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromUniswapV2(
address[] calldata path,
uint256[] calldata takerTokenAmounts
)
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample buy quotes from UniswapV2.
/// @param path Token route.
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromUniswapV2(
address[] calldata path,
uint256[] calldata makerTokenAmounts
)
external
view
returns (uint256[] memory takerTokenAmounts);
}

View File

@@ -0,0 +1,52 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
interface IKyberHintHandler {
function kyberStorage() external returns (address);
enum TradeType {BestOfAll, MaskIn, MaskOut, Split}
function buildTokenToEthHint(
address tokenSrc,
TradeType tokenToEthType,
bytes32[] calldata tokenToEthReserveIds,
uint256[] calldata tokenToEthSplits
) external view returns (bytes memory hint);
function buildEthToTokenHint(
address tokenDest,
TradeType ethToTokenType,
bytes32[] calldata ethToTokenReserveIds,
uint256[] calldata ethToTokenSplits
) external view returns (bytes memory hint);
function buildTokenToTokenHint(
address tokenSrc,
TradeType tokenToEthType,
bytes32[] calldata tokenToEthReserveIds,
uint256[] calldata tokenToEthSplits,
address tokenDest,
TradeType ethToTokenType,
bytes32[] calldata ethToTokenReserveIds,
uint256[] calldata ethToTokenSplits
) external view returns (bytes memory hint);
}

View File

@@ -1,6 +1,6 @@
/*
Copyright 2019 ZeroEx Intl.
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -18,15 +18,20 @@
pragma solidity ^0.5.9;
import "./IKyberStorage.sol";
import "./IKyberHintHandler.sol";
interface IKyberNetwork {
function getExpectedRate(
address fromToken,
address toToken,
uint256 fromAmount
)
function getContracts()
external
view
returns (uint256 expectedRate, uint256 slippageRate);
returns (
address kyberFeeHandlerAddress,
address kyberDaoAddress,
IKyberHintHandler kyberMatchingEngineAddress,
IKyberStorage kyberStorageAddress,
address gasHelperAddress,
address[] memory kyberProxyAddresses);
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
interface IKyberNetworkProxy {
function kyberNetwork() external view returns (address);
function kyberHintHandler() external view returns (address);
function getExpectedRateAfterFee(
address src,
address dest,
uint256 srcQty,
uint256 platformFeeBps,
bytes calldata hint
) external view returns (uint256 expectedRate);
}

View File

@@ -0,0 +1,37 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
interface IKyberStorage {
function getReserveId(
address reserve
)
external
view
returns (bytes32 reserveId);
function getReserveIdsPerTokenSrc(
address token
)
external
view
returns (bytes32[] memory reserveIds);
}

View File

@@ -0,0 +1,70 @@
/*
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
interface ILiquidityProvider {
/// @dev Transfers `amount` of the ERC20 `tokenAddress` from `from` to `to`.
/// @param tokenAddress The address of the ERC20 token to transfer.
/// @param from Address to transfer asset from.
/// @param to Address to transfer asset to.
/// @param amount Amount of asset to transfer.
/// @param bridgeData Arbitrary asset data needed by the bridge contract.
/// @return success The magic bytes `0xdc1600f3` if successful.
function bridgeTransferFrom(
address tokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success);
/// @dev Quotes the amount of `makerToken` that would be obtained by
/// selling `sellAmount` of `takerToken`.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param sellAmount Amount of `takerToken` to sell.
/// @return makerTokenAmount Amount of `makerToken` that would be obtained.
function getSellQuote(
address takerToken,
address makerToken,
uint256 sellAmount
)
external
view
returns (uint256 makerTokenAmount);
/// @dev Quotes the amount of `takerToken` that would need to be sold in
/// order to obtain `buyAmount` of `makerToken`.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param buyAmount Amount of `makerToken` to buy.
/// @return takerTokenAmount Amount of `takerToken` that would need to be sold.
function getBuyQuote(
address takerToken,
address makerToken,
uint256 buyAmount
)
external
view
returns (uint256 takerTokenAmount);
}

View File

@@ -0,0 +1,36 @@
/*
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
interface ILiquidityProviderRegistry {
/// @dev Returns the address of a liquidity provider for the given market
/// (takerToken, makerToken), reverting if the pool does not exist.
/// @param takerToken Taker asset managed by liquidity provider.
/// @param makerToken Maker asset managed by liquidity provider.
/// @return Address of the liquidity provider.
function getLiquidityProviderForMarket(
address takerToken,
address makerToken
)
external
view
returns (address providerAddress);
}

View File

@@ -0,0 +1,58 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
interface IMultiBridge {
/// @dev Transfers `amount` of the ERC20 `tokenAddress` from `from` to `to`.
/// @param tokenAddress The address of the ERC20 token to transfer.
/// @param from Address to transfer asset from.
/// @param to Address to transfer asset to.
/// @param amount Amount of asset to transfer.
/// @param bridgeData Arbitrary asset data needed by the bridge contract.
/// @return success The magic bytes `0xdc1600f3` if successful.
function bridgeTransferFrom(
address tokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success);
/// @dev Quotes the amount of `makerToken` that would be obtained by
/// selling `sellAmount` of `takerToken`.
/// @param takerToken Address of the taker token (what to sell).
/// @param intermediateToken The address of the intermediate token to
/// use in an indirect route.
/// @param makerToken Address of the maker token (what to buy).
/// @param sellAmount Amount of `takerToken` to sell.
/// @return makerTokenAmount Amount of `makerToken` that would be obtained.
function getSellQuote(
address takerToken,
address intermediateToken,
address makerToken,
uint256 sellAmount
)
external
view
returns (uint256 makerTokenAmount);
}

View File

@@ -0,0 +1,33 @@
/*
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.9;
interface IUniswapV2Router01 {
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata path)
external
view
returns (uint256[] memory amounts);
}

View File

@@ -24,7 +24,8 @@ import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "../src/ERC20BridgeSampler.sol";
import "../src/IEth2Dai.sol";
import "../src/IDevUtils.sol";
import "../src/IKyberNetwork.sol";
import "../src/IKyberNetworkProxy.sol";
import "../src/IUniswapV2Router01.sol";
library LibDeterministicQuotes {
@@ -194,15 +195,161 @@ contract TestERC20BridgeSamplerUniswapExchange is
}
contract TestERC20BridgeSamplerUniswapV2Router01 is
IUniswapV2Router01,
DeploymentConstants,
FailTrigger
{
bytes32 constant private SALT = 0xadc7fcb33c735913b8635927e66896b356a53a912ab2ceff929e60a04b53b3c1;
// Deterministic `IUniswapV2Router01.getAmountsOut()`.
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts)
{
require(path.length >= 2, "PATH_TOO_SHORT");
_revertIfShouldFail();
amounts = new uint256[](path.length);
amounts[0] = amountIn;
for (uint256 i = 0; i < path.length - 1; ++i) {
amounts[i + 1] = LibDeterministicQuotes.getDeterministicSellQuote(
SALT,
path[i],
path[i + 1],
amounts[i]
);
}
}
// Deterministic `IUniswapV2Router01.getAmountsInt()`.
function getAmountsIn(uint256 amountOut, address[] calldata path)
external
view
returns (uint256[] memory amounts)
{
require(path.length >= 2, "PATH_TOO_SHORT");
_revertIfShouldFail();
amounts = new uint256[](path.length);
amounts[path.length - 1] = amountOut;
for (uint256 i = path.length - 1; i > 0; --i) {
amounts[i - 1] = LibDeterministicQuotes.getDeterministicBuyQuote(
SALT,
path[i - 1],
path[i],
amounts[i]
);
}
}
}
// solhint-disable space-after-comma
contract TestERC20BridgeSamplerKyberNetwork is
IKyberNetwork,
DeploymentConstants,
FailTrigger
{
bytes32 constant private SALT = 0x0ff3ca9d46195c39f9a12afb74207b4970349fb3cfb1e459bbf170298d326bc7;
address constant public ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
// Deterministic `IKyberNetwork.getExpectedRate()`.
enum TradeType {BestOfAll, MaskIn, MaskOut, Split}
function kyberNetwork()
external
view
returns (address)
{
return address(this);
}
// IKyberNetwork
function getContracts()
external
view
returns (
address kyberFeeHandlerAddress,
address kyberDaoAddress,
address kyberMatchingEngineAddress,
address kyberStorageAddress,
address gasHelperAddress,
address[] memory kyberProxyAddresses
)
{
return (kyberFeeHandlerAddress,
kyberDaoAddress,
address(this),
address(this),
gasHelperAddress,
kyberProxyAddresses
);
}
// IKyberStorage
function getReserveIdsPerTokenSrc(
address /* token */
)
external
view
returns (bytes32[] memory reserveIds)
{
return reserveIds;
}
function getReserveId(
address /* reserve */
)
external
view
returns (bytes32 reserveId)
{
return reserveId;
}
// IKyberHintHandler
function buildTokenToEthHint(
address /* tokenSrc */,
TradeType /* tokenToEthType */,
bytes32[] calldata /* tokenToEthReserveIds */,
uint256[] calldata /* tokenToEthSplits */
) external view returns (bytes memory hint)
{
return hint;
}
function buildEthToTokenHint(
address /* tokenDest */,
TradeType /* ethToTokenType */,
bytes32[] calldata /* ethToTokenReserveIds */,
uint256[] calldata /* ethToTokenSplits */
) external view returns (bytes memory hint)
{
return hint;
}
// Deterministic `IKyberNetworkProxy.getExpectedRateAfterFee()`.
function getExpectedRateAfterFee(
address fromToken,
address toToken,
uint256 /* srcQty */,
uint256 /* fee */,
bytes calldata /* hint */
)
external
view
returns
(uint256 expectedRate)
{
_revertIfShouldFail();
fromToken = fromToken == ETH_ADDRESS ? _getWethAddress() : fromToken;
toToken = toToken == ETH_ADDRESS ? _getWethAddress() : toToken;
expectedRate = LibDeterministicQuotes.getDeterministicRate(
SALT,
fromToken,
toToken
);
}
// Deterministic `IKyberNetworkProxy.getExpectedRate()`.
function getExpectedRate(
address fromToken,
address toToken,
@@ -221,6 +368,14 @@ contract TestERC20BridgeSamplerKyberNetwork is
toToken
);
}
function _getKyberNetworkProxyAddress()
internal
view
returns (address)
{
return address(this);
}
}
@@ -302,13 +457,15 @@ contract TestERC20BridgeSampler is
FailTrigger
{
TestERC20BridgeSamplerUniswapExchangeFactory public uniswap;
TestERC20BridgeSamplerUniswapV2Router01 public uniswapV2Router;
TestERC20BridgeSamplerEth2Dai public eth2Dai;
TestERC20BridgeSamplerKyberNetwork public kyber;
uint8 private constant MAX_ORDER_STATUS = uint8(LibOrder.OrderStatus.CANCELLED) + 1;
constructor() public {
constructor() public ERC20BridgeSampler() {
uniswap = new TestERC20BridgeSamplerUniswapExchangeFactory();
uniswapV2Router = new TestERC20BridgeSamplerUniswapV2Router01();
eth2Dai = new TestERC20BridgeSamplerEth2Dai();
kyber = new TestERC20BridgeSamplerKyberNetwork();
}
@@ -327,6 +484,7 @@ contract TestERC20BridgeSampler is
bytes memory
)
public
pure
returns (
LibOrder.OrderInfo memory orderInfo,
uint256 fillableTakerAssetAmount,
@@ -357,15 +515,6 @@ contract TestERC20BridgeSampler is
return LibDeterministicQuotes.getDeterministicTokenDecimals(tokenAddress);
}
// Overriden to point to a this contract.
function _getDevUtilsAddress()
internal
view
returns (address devUtilAddress)
{
return address(this);
}
// Overriden to point to a custom contract.
function _getEth2DaiAddress()
internal
@@ -384,6 +533,15 @@ contract TestERC20BridgeSampler is
return address(uniswap);
}
// Overriden to point to a custom contract.
function _getUniswapV2Router01Address()
internal
view
returns (address uniswapV2RouterAddress)
{
return address(uniswapV2Router);
}
// Overriden to point to a custom contract.
function _getKyberNetworkProxyAddress()
internal

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc20-bridge-sampler",
"version": "1.4.1",
"version": "1.7.0",
"engines": {
"node": ">=6.12"
},
@@ -36,9 +36,9 @@
"compile:truffle": "truffle compile"
},
"config": {
"publicInterfaceContracts": "ERC20BridgeSampler,IERC20BridgeSampler",
"publicInterfaceContracts": "ERC20BridgeSampler,IERC20BridgeSampler,ILiquidityProvider,ILiquidityProviderRegistry,DummyLiquidityProviderRegistry,DummyLiquidityProvider",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
"abis": "./test/generated-artifacts/@(ERC20BridgeSampler|ICurve|IDevUtils|IERC20BridgeSampler|IEth2Dai|IKyberNetwork|IUniswapExchangeQuotes|TestERC20BridgeSampler).json"
"abis": "./test/generated-artifacts/@(DummyLiquidityProvider|DummyLiquidityProviderRegistry|ERC20BridgeSampler|ICurve|IDevUtils|IERC20BridgeSampler|IEth2Dai|IKyberHintHandler|IKyberNetwork|IKyberNetworkProxy|IKyberStorage|ILiquidityProvider|ILiquidityProviderRegistry|IMultiBridge|IUniswapExchangeQuotes|IUniswapV2Router01|TestERC20BridgeSampler).json"
},
"repository": {
"type": "git",
@@ -50,18 +50,18 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.2.1",
"@0x/contracts-asset-proxy": "^3.2.2",
"@0x/contracts-erc20": "^3.1.2",
"@0x/contracts-exchange": "^3.2.2",
"@0x/contracts-exchange-libs": "^4.3.2",
"@0x/contracts-gen": "^2.0.8",
"@0x/contracts-test-utils": "^5.3.0",
"@0x/contracts-utils": "^4.4.0",
"@0x/dev-utils": "^3.2.1",
"@0x/sol-compiler": "^4.0.8",
"@0x/tslint-config": "^4.0.0",
"@0x/web3-wrapper": "^7.0.7",
"@0x/abi-gen": "^5.3.1",
"@0x/contracts-asset-proxy": "^3.4.0",
"@0x/contracts-erc20": "^3.2.1",
"@0x/contracts-exchange": "^3.2.7",
"@0x/contracts-exchange-libs": "^4.3.7",
"@0x/contracts-gen": "^2.0.10",
"@0x/contracts-test-utils": "^5.3.4",
"@0x/contracts-utils": "^4.5.1",
"@0x/dev-utils": "^3.3.0",
"@0x/sol-compiler": "^4.1.1",
"@0x/tslint-config": "^4.1.0",
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
@@ -79,14 +79,15 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.1",
"@0x/types": "^3.1.2",
"@0x/typescript-typings": "^5.0.2",
"@0x/utils": "^5.4.1",
"ethereum-types": "^3.1.0",
"@0x/base-contract": "^6.2.3",
"@0x/types": "^3.2.0",
"@0x/typescript-typings": "^5.1.1",
"@0x/utils": "^5.5.1",
"ethereum-types": "^3.2.0",
"lodash": "^4.17.11"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}

View File

@@ -5,9 +5,17 @@
*/
import { ContractArtifact } from 'ethereum-types';
import * as DummyLiquidityProvider from '../generated-artifacts/DummyLiquidityProvider.json';
import * as DummyLiquidityProviderRegistry from '../generated-artifacts/DummyLiquidityProviderRegistry.json';
import * as ERC20BridgeSampler from '../generated-artifacts/ERC20BridgeSampler.json';
import * as IERC20BridgeSampler from '../generated-artifacts/IERC20BridgeSampler.json';
import * as ILiquidityProvider from '../generated-artifacts/ILiquidityProvider.json';
import * as ILiquidityProviderRegistry from '../generated-artifacts/ILiquidityProviderRegistry.json';
export const artifacts = {
ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
IERC20BridgeSampler: IERC20BridgeSampler as ContractArtifact,
ILiquidityProvider: ILiquidityProvider as ContractArtifact,
ILiquidityProviderRegistry: ILiquidityProviderRegistry as ContractArtifact,
DummyLiquidityProviderRegistry: DummyLiquidityProviderRegistry as ContractArtifact,
DummyLiquidityProvider: DummyLiquidityProvider as ContractArtifact,
};

View File

@@ -3,5 +3,9 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../generated-wrappers/dummy_liquidity_provider';
export * from '../generated-wrappers/dummy_liquidity_provider_registry';
export * from '../generated-wrappers/erc20_bridge_sampler';
export * from '../generated-wrappers/i_erc20_bridge_sampler';
export * from '../generated-wrappers/i_liquidity_provider';
export * from '../generated-wrappers/i_liquidity_provider_registry';

View File

@@ -5,21 +5,39 @@
*/
import { ContractArtifact } from 'ethereum-types';
import * as DummyLiquidityProvider from '../test/generated-artifacts/DummyLiquidityProvider.json';
import * as DummyLiquidityProviderRegistry from '../test/generated-artifacts/DummyLiquidityProviderRegistry.json';
import * as ERC20BridgeSampler from '../test/generated-artifacts/ERC20BridgeSampler.json';
import * as ICurve from '../test/generated-artifacts/ICurve.json';
import * as IDevUtils from '../test/generated-artifacts/IDevUtils.json';
import * as IERC20BridgeSampler from '../test/generated-artifacts/IERC20BridgeSampler.json';
import * as IEth2Dai from '../test/generated-artifacts/IEth2Dai.json';
import * as IKyberHintHandler from '../test/generated-artifacts/IKyberHintHandler.json';
import * as IKyberNetwork from '../test/generated-artifacts/IKyberNetwork.json';
import * as IKyberNetworkProxy from '../test/generated-artifacts/IKyberNetworkProxy.json';
import * as IKyberStorage from '../test/generated-artifacts/IKyberStorage.json';
import * as ILiquidityProvider from '../test/generated-artifacts/ILiquidityProvider.json';
import * as ILiquidityProviderRegistry from '../test/generated-artifacts/ILiquidityProviderRegistry.json';
import * as IMultiBridge from '../test/generated-artifacts/IMultiBridge.json';
import * as IUniswapExchangeQuotes from '../test/generated-artifacts/IUniswapExchangeQuotes.json';
import * as IUniswapV2Router01 from '../test/generated-artifacts/IUniswapV2Router01.json';
import * as TestERC20BridgeSampler from '../test/generated-artifacts/TestERC20BridgeSampler.json';
export const artifacts = {
DummyLiquidityProvider: DummyLiquidityProvider as ContractArtifact,
DummyLiquidityProviderRegistry: DummyLiquidityProviderRegistry as ContractArtifact,
ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
ICurve: ICurve as ContractArtifact,
IDevUtils: IDevUtils as ContractArtifact,
IERC20BridgeSampler: IERC20BridgeSampler as ContractArtifact,
IEth2Dai: IEth2Dai as ContractArtifact,
IKyberHintHandler: IKyberHintHandler as ContractArtifact,
IKyberNetwork: IKyberNetwork as ContractArtifact,
IKyberNetworkProxy: IKyberNetworkProxy as ContractArtifact,
IKyberStorage: IKyberStorage as ContractArtifact,
ILiquidityProvider: ILiquidityProvider as ContractArtifact,
ILiquidityProviderRegistry: ILiquidityProviderRegistry as ContractArtifact,
IMultiBridge: IMultiBridge as ContractArtifact,
IUniswapExchangeQuotes: IUniswapExchangeQuotes as ContractArtifact,
IUniswapV2Router01: IUniswapV2Router01 as ContractArtifact,
TestERC20BridgeSampler: TestERC20BridgeSampler as ContractArtifact,
};

View File

@@ -11,7 +11,11 @@ import { BigNumber, hexUtils } from '@0x/utils';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import { TestERC20BridgeSamplerContract } from './wrappers';
import {
DummyLiquidityProviderContract,
DummyLiquidityProviderRegistryContract,
TestERC20BridgeSamplerContract,
} from './wrappers';
blockchainTests('erc20-bridge-sampler', env => {
let testContract: TestERC20BridgeSamplerContract;
@@ -24,10 +28,16 @@ blockchainTests('erc20-bridge-sampler', env => {
const KYBER_SALT = '0x0ff3ca9d46195c39f9a12afb74207b4970349fb3cfb1e459bbf170298d326bc7';
const ETH2DAI_SALT = '0xb713b61bb9bb2958a0f5d1534b21e94fc68c4c0c034b0902ed844f2f6cd1b4f7';
const UNISWAP_BASE_SALT = '0x1d6a6a0506b0b4a554b907a4c29d9f4674e461989d9c1921feb17b26716385ab';
const UNISWAP_V2_SALT = '0xadc7fcb33c735913b8635927e66896b356a53a912ab2ceff929e60a04b53b3c1';
const ERC20_PROXY_ID = '0xf47261b0';
const INVALID_TOKEN_PAIR_ERROR = 'ERC20BridgeSampler/INVALID_TOKEN_PAIR';
const MAKER_TOKEN = randomAddress();
const TAKER_TOKEN = randomAddress();
let devUtilsAddress: string;
const FAKE_BUY_OPTS = {
targetSlippageBps: new BigNumber(5),
maxIterations: new BigNumber(5),
};
before(async () => {
testContract = await TestERC20BridgeSamplerContract.deployFrom0xArtifactAsync(
@@ -36,6 +46,8 @@ blockchainTests('erc20-bridge-sampler', env => {
env.txDefaults,
{},
);
// TestERC20BridgeSampler stubs DevUtils
devUtilsAddress = testContract.address;
});
function getPackedHash(...args: string[]): string {
@@ -165,8 +177,15 @@ blockchainTests('erc20-bridge-sampler', env => {
for (const source of sources) {
const sampleOutputs = [];
for (const amount of sampleAmounts) {
if (source === 'Eth2Dai') {
sampleOutputs.push(getDeterministicBuyQuote(ETH2DAI_SALT, sellToken, buyToken, amount));
if (source === 'Kyber' || source === 'Eth2Dai') {
sampleOutputs.push(
getDeterministicBuyQuote(
source === 'Kyber' ? KYBER_SALT : ETH2DAI_SALT,
sellToken,
buyToken,
amount,
),
);
} else if (source === 'Uniswap') {
sampleOutputs.push(getDeterministicUniswapBuyQuote(sellToken, buyToken, amount));
}
@@ -176,6 +195,22 @@ blockchainTests('erc20-bridge-sampler', env => {
return quotes;
}
function getDeterministicUniswapV2SellQuote(path: string[], sellAmount: BigNumber): BigNumber {
let bought = sellAmount;
for (let i = 0; i < path.length - 1; ++i) {
bought = getDeterministicSellQuote(UNISWAP_V2_SALT, path[i], path[i + 1], bought);
}
return bought;
}
function getDeterministicUniswapV2BuyQuote(path: string[], buyAmount: BigNumber): BigNumber {
let sold = buyAmount;
for (let i = path.length - 1; i > 0; --i) {
sold = getDeterministicBuyQuote(UNISWAP_V2_SALT, path[i - 1], path[i], sold);
}
return sold;
}
function getDeterministicFillableTakerAssetAmount(order: Order): BigNumber {
const hash = getPackedHash(hexUtils.leftPad(order.salt));
const orderStatus = new BigNumber(hash).mod(100).toNumber() > 90 ? 5 : 3;
@@ -200,7 +235,7 @@ blockchainTests('erc20-bridge-sampler', env => {
function getSampleAmounts(tokenAddress: string, count?: number): BigNumber[] {
const tokenDecimals = getDeterministicTokenDecimals(tokenAddress);
const _upperLimit = getRandomPortion(getRandomInteger(1, 1000).times(10 ** tokenDecimals));
const _upperLimit = getRandomPortion(getRandomInteger(1000, 50000).times(10 ** tokenDecimals));
const _count = count || _.random(1, 16);
const d = _upperLimit.div(_count);
return _.times(_count, i => d.times((i + 1) / _count).integerValue());
@@ -240,12 +275,14 @@ blockchainTests('erc20-bridge-sampler', env => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN);
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const expected = orders.map(getDeterministicFillableTakerAssetAmount);
const actual = await testContract.getOrderFillableTakerAssetAmounts(orders, signatures).callAsync();
const actual = await testContract
.getOrderFillableTakerAssetAmounts(orders, signatures, devUtilsAddress)
.callAsync();
expect(actual).to.deep.eq(expected);
});
it('returns empty for no orders', async () => {
const actual = await testContract.getOrderFillableTakerAssetAmounts([], []).callAsync();
const actual = await testContract.getOrderFillableTakerAssetAmounts([], [], devUtilsAddress).callAsync();
expect(actual).to.deep.eq([]);
});
@@ -253,7 +290,9 @@ blockchainTests('erc20-bridge-sampler', env => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
orders[0].makerAssetAmount = constants.ZERO_AMOUNT;
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const actual = await testContract.getOrderFillableTakerAssetAmounts(orders, signatures).callAsync();
const actual = await testContract
.getOrderFillableTakerAssetAmounts(orders, signatures, devUtilsAddress)
.callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
@@ -261,14 +300,18 @@ blockchainTests('erc20-bridge-sampler', env => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
orders[0].takerAssetAmount = constants.ZERO_AMOUNT;
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const actual = await testContract.getOrderFillableTakerAssetAmounts(orders, signatures).callAsync();
const actual = await testContract
.getOrderFillableTakerAssetAmounts(orders, signatures, devUtilsAddress)
.callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
it('returns zero for an order with an empty signature', async () => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
const signatures: string[] = _.times(orders.length, () => constants.NULL_BYTES);
const actual = await testContract.getOrderFillableTakerAssetAmounts(orders, signatures).callAsync();
const actual = await testContract
.getOrderFillableTakerAssetAmounts(orders, signatures, devUtilsAddress)
.callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
});
@@ -278,12 +321,14 @@ blockchainTests('erc20-bridge-sampler', env => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN);
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const expected = orders.map(getDeterministicFillableMakerAssetAmount);
const actual = await testContract.getOrderFillableMakerAssetAmounts(orders, signatures).callAsync();
const actual = await testContract
.getOrderFillableMakerAssetAmounts(orders, signatures, devUtilsAddress)
.callAsync();
expect(actual).to.deep.eq(expected);
});
it('returns empty for no orders', async () => {
const actual = await testContract.getOrderFillableMakerAssetAmounts([], []).callAsync();
const actual = await testContract.getOrderFillableMakerAssetAmounts([], [], devUtilsAddress).callAsync();
expect(actual).to.deep.eq([]);
});
@@ -291,7 +336,9 @@ blockchainTests('erc20-bridge-sampler', env => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
orders[0].makerAssetAmount = constants.ZERO_AMOUNT;
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const actual = await testContract.getOrderFillableMakerAssetAmounts(orders, signatures).callAsync();
const actual = await testContract
.getOrderFillableMakerAssetAmounts(orders, signatures, devUtilsAddress)
.callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
@@ -299,14 +346,18 @@ blockchainTests('erc20-bridge-sampler', env => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
orders[0].takerAssetAmount = constants.ZERO_AMOUNT;
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const actual = await testContract.getOrderFillableMakerAssetAmounts(orders, signatures).callAsync();
const actual = await testContract
.getOrderFillableMakerAssetAmounts(orders, signatures, devUtilsAddress)
.callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
it('returns zero for an order with an empty signature', async () => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
const signatures: string[] = _.times(orders.length, () => constants.NULL_BYTES);
const actual = await testContract.getOrderFillableMakerAssetAmounts(orders, signatures).callAsync();
const actual = await testContract
.getOrderFillableMakerAssetAmounts(orders, signatures, devUtilsAddress)
.callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
});
@@ -326,9 +377,10 @@ blockchainTests('erc20-bridge-sampler', env => {
expect(quotes).to.deep.eq([]);
});
it('can quote token - token', async () => {
it('can quote token -> token', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [expectedQuotes] = getDeterministicSellQuotes(TAKER_TOKEN, MAKER_TOKEN, ['Kyber'], sampleAmounts);
const [takerToEthQuotes] = getDeterministicSellQuotes(TAKER_TOKEN, WETH_ADDRESS, ['Kyber'], sampleAmounts);
const [expectedQuotes] = getDeterministicSellQuotes(WETH_ADDRESS, MAKER_TOKEN, ['Kyber'], takerToEthQuotes);
const quotes = await testContract
.sampleSellsFromKyberNetwork(TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
.callAsync();
@@ -384,6 +436,109 @@ blockchainTests('erc20-bridge-sampler', env => {
});
});
blockchainTests.resets('sampleBuysFromKyberNetwork()', () => {
const ACCEPTABLE_SLIPPAGE = 0.0005;
before(async () => {
await testContract.createTokenExchanges([MAKER_TOKEN, TAKER_TOKEN]).awaitTransactionSuccessAsync();
});
it('throws if tokens are the same', async () => {
const tx = testContract.sampleBuysFromKyberNetwork(MAKER_TOKEN, MAKER_TOKEN, [], FAKE_BUY_OPTS).callAsync();
return expect(tx).to.revertWith(INVALID_TOKEN_PAIR_ERROR);
});
it('can return no quotes', async () => {
const quotes = await testContract
.sampleBuysFromKyberNetwork(TAKER_TOKEN, MAKER_TOKEN, [], FAKE_BUY_OPTS)
.callAsync();
expect(quotes).to.deep.eq([]);
});
const expectQuotesWithinRange = (
quotes: BigNumber[],
expectedQuotes: BigNumber[],
maxSlippage: BigNumber | number,
) => {
quotes.forEach((_q, i) => {
// If we're within 1 base unit of a low decimal token
// then that's as good as we're going to get (and slippage is "high")
if (
expectedQuotes[i].isZero() ||
BigNumber.max(expectedQuotes[i], quotes[i])
.minus(BigNumber.min(expectedQuotes[i], quotes[i]))
.eq(1)
) {
return;
}
const slippage = quotes[i]
.dividedBy(expectedQuotes[i])
.minus(1)
.decimalPlaces(4);
expect(slippage, `quote[${i}]: ${slippage} ${quotes[i]} ${expectedQuotes[i]}`).to.be.bignumber.gte(0);
expect(slippage, `quote[${i}] ${slippage} ${quotes[i]} ${expectedQuotes[i]}`).to.be.bignumber.lte(
new BigNumber(maxSlippage),
);
});
};
it('can quote token -> token', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [ethToMakerQuotes] = getDeterministicBuyQuotes(WETH_ADDRESS, MAKER_TOKEN, ['Kyber'], sampleAmounts);
const [expectedQuotes] = getDeterministicBuyQuotes(TAKER_TOKEN, WETH_ADDRESS, ['Kyber'], ethToMakerQuotes);
const quotes = await testContract
.sampleBuysFromKyberNetwork(TAKER_TOKEN, MAKER_TOKEN, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expectQuotesWithinRange(quotes, expectedQuotes, ACCEPTABLE_SLIPPAGE);
});
it('returns zero if token -> token fails', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const quotes = await testContract
.sampleBuysFromKyberNetwork(TAKER_TOKEN, MAKER_TOKEN, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
it('can quote token -> ETH', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [expectedQuotes] = getDeterministicBuyQuotes(TAKER_TOKEN, WETH_ADDRESS, ['Kyber'], sampleAmounts);
const quotes = await testContract
.sampleBuysFromKyberNetwork(TAKER_TOKEN, WETH_ADDRESS, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expectQuotesWithinRange(quotes, expectedQuotes, ACCEPTABLE_SLIPPAGE);
});
it('returns zero if token -> ETH fails', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const quotes = await testContract
.sampleBuysFromKyberNetwork(TAKER_TOKEN, WETH_ADDRESS, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
it('can quote ETH -> token', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [expectedQuotes] = getDeterministicBuyQuotes(WETH_ADDRESS, TAKER_TOKEN, ['Kyber'], sampleAmounts);
const quotes = await testContract
.sampleBuysFromKyberNetwork(WETH_ADDRESS, TAKER_TOKEN, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expectQuotesWithinRange(quotes, expectedQuotes, ACCEPTABLE_SLIPPAGE);
});
it('returns zero if ETH -> token fails', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const quotes = await testContract
.sampleBuysFromKyberNetwork(WETH_ADDRESS, TAKER_TOKEN, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
});
blockchainTests.resets('sampleSellsFromEth2Dai()', () => {
before(async () => {
await testContract.createTokenExchanges([MAKER_TOKEN, TAKER_TOKEN]).awaitTransactionSuccessAsync();
@@ -716,13 +871,186 @@ blockchainTests('erc20-bridge-sampler', env => {
});
});
describe('getLiquidityProviderFromRegistry', () => {
const xAsset = randomAddress();
const yAsset = randomAddress();
const sampleAmounts = getSampleAmounts(yAsset);
let liquidityProvider: DummyLiquidityProviderContract;
let registryContract: DummyLiquidityProviderRegistryContract;
before(async () => {
liquidityProvider = await DummyLiquidityProviderContract.deployFrom0xArtifactAsync(
artifacts.DummyLiquidityProvider,
env.provider,
env.txDefaults,
{},
);
registryContract = await DummyLiquidityProviderRegistryContract.deployFrom0xArtifactAsync(
artifacts.DummyLiquidityProviderRegistry,
env.provider,
env.txDefaults,
{},
);
await registryContract
.setLiquidityProviderForMarket(xAsset, yAsset, liquidityProvider.address)
.awaitTransactionSuccessAsync();
});
it('should be able to get the liquidity provider', async () => {
const xyLiquidityProvider = await testContract
.getLiquidityProviderFromRegistry(registryContract.address, xAsset, yAsset)
.callAsync();
const yxLiquidityProvider = await testContract
.getLiquidityProviderFromRegistry(registryContract.address, yAsset, xAsset)
.callAsync();
const unknownLiquidityProvider = await testContract
.getLiquidityProviderFromRegistry(registryContract.address, yAsset, randomAddress())
.callAsync();
expect(xyLiquidityProvider).to.eq(liquidityProvider.address);
expect(yxLiquidityProvider).to.eq(liquidityProvider.address);
expect(unknownLiquidityProvider).to.eq(constants.NULL_ADDRESS);
});
it('should be able to query sells from the liquidity provider', async () => {
const result = await testContract
.sampleSellsFromLiquidityProviderRegistry(registryContract.address, yAsset, xAsset, sampleAmounts)
.callAsync();
result.forEach((value, idx) => {
expect(value).is.bignumber.eql(sampleAmounts[idx].minus(1));
});
});
it('should be able to query buys from the liquidity provider', async () => {
const result = await testContract
.sampleBuysFromLiquidityProviderRegistry(
registryContract.address,
yAsset,
xAsset,
sampleAmounts,
FAKE_BUY_OPTS,
)
.callAsync();
result.forEach((value, idx) => {
expect(value).is.bignumber.eql(sampleAmounts[idx].plus(1));
});
});
it('should just return zeros if the liquidity provider cannot be found', async () => {
const result = await testContract
.sampleBuysFromLiquidityProviderRegistry(
registryContract.address,
yAsset,
randomAddress(),
sampleAmounts,
FAKE_BUY_OPTS,
)
.callAsync();
result.forEach(value => {
expect(value).is.bignumber.eql(constants.ZERO_AMOUNT);
});
});
it('should just return zeros if the registry does not exist', async () => {
const result = await testContract
.sampleBuysFromLiquidityProviderRegistry(randomAddress(), yAsset, xAsset, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
result.forEach(value => {
expect(value).is.bignumber.eql(constants.ZERO_AMOUNT);
});
});
});
blockchainTests.resets('sampleSellsFromUniswapV2()', () => {
function predictSellQuotes(path: string[], sellAmounts: BigNumber[]): BigNumber[] {
return sellAmounts.map(a => getDeterministicUniswapV2SellQuote(path, a));
}
it('can return no quotes', async () => {
const quotes = await testContract.sampleSellsFromUniswapV2([TAKER_TOKEN, MAKER_TOKEN], []).callAsync();
expect(quotes).to.deep.eq([]);
});
it('can quote token -> token', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = predictSellQuotes([TAKER_TOKEN, MAKER_TOKEN], sampleAmounts);
const quotes = await testContract
.sampleSellsFromUniswapV2([TAKER_TOKEN, MAKER_TOKEN], sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
it('returns zero if token -> token fails', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const quotes = await testContract
.sampleSellsFromUniswapV2([TAKER_TOKEN, MAKER_TOKEN], sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
it('can quote token -> token -> token', async () => {
const intermediateToken = randomAddress();
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = predictSellQuotes([TAKER_TOKEN, intermediateToken, MAKER_TOKEN], sampleAmounts);
const quotes = await testContract
.sampleSellsFromUniswapV2([TAKER_TOKEN, intermediateToken, MAKER_TOKEN], sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
});
blockchainTests.resets('sampleBuysFromUniswapV2()', () => {
function predictBuyQuotes(path: string[], buyAmounts: BigNumber[]): BigNumber[] {
return buyAmounts.map(a => getDeterministicUniswapV2BuyQuote(path, a));
}
it('can return no quotes', async () => {
const quotes = await testContract.sampleBuysFromUniswapV2([TAKER_TOKEN, MAKER_TOKEN], []).callAsync();
expect(quotes).to.deep.eq([]);
});
it('can quote token -> token', async () => {
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
const expectedQuotes = predictBuyQuotes([TAKER_TOKEN, MAKER_TOKEN], sampleAmounts);
const quotes = await testContract
.sampleBuysFromUniswapV2([TAKER_TOKEN, MAKER_TOKEN], sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
it('returns zero if token -> token fails', async () => {
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const quotes = await testContract
.sampleBuysFromUniswapV2([TAKER_TOKEN, MAKER_TOKEN], sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
it('can quote token -> token -> token', async () => {
const intermediateToken = randomAddress();
const sampleAmounts = getSampleAmounts(MAKER_TOKEN);
const expectedQuotes = predictBuyQuotes([TAKER_TOKEN, intermediateToken, MAKER_TOKEN], sampleAmounts);
const quotes = await testContract
.sampleBuysFromUniswapV2([TAKER_TOKEN, intermediateToken, MAKER_TOKEN], sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
});
describe('batchCall()', () => {
it('can call one function', async () => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN);
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const expected = orders.map(getDeterministicFillableTakerAssetAmount);
const calls = [
testContract.getOrderFillableTakerAssetAmounts(orders, signatures).getABIEncodedTransactionData(),
testContract
.getOrderFillableTakerAssetAmounts(orders, signatures, devUtilsAddress)
.getABIEncodedTransactionData(),
];
const r = await testContract.batchCall(calls).callAsync();
expect(r).to.be.length(1);
@@ -739,8 +1067,12 @@ blockchainTests('erc20-bridge-sampler', env => {
orders[1].map(getDeterministicFillableMakerAssetAmount),
];
const calls = [
testContract.getOrderFillableTakerAssetAmounts(orders[0], signatures).getABIEncodedTransactionData(),
testContract.getOrderFillableMakerAssetAmounts(orders[1], signatures).getABIEncodedTransactionData(),
testContract
.getOrderFillableTakerAssetAmounts(orders[0], signatures, devUtilsAddress)
.getABIEncodedTransactionData(),
testContract
.getOrderFillableMakerAssetAmounts(orders[1], signatures, devUtilsAddress)
.getABIEncodedTransactionData(),
];
const r = await testContract.batchCall(calls).callAsync();
expect(r).to.be.length(2);
@@ -762,7 +1094,7 @@ blockchainTests('erc20-bridge-sampler', env => {
testContract
.batchCall([
testContract
.getOrderFillableTakerAssetAmounts(orders, signatures)
.getOrderFillableTakerAssetAmounts(orders, signatures, devUtilsAddress)
.getABIEncodedTransactionData(),
])
.getABIEncodedTransactionData(),

View File

@@ -3,11 +3,20 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../test/generated-wrappers/dummy_liquidity_provider';
export * from '../test/generated-wrappers/dummy_liquidity_provider_registry';
export * from '../test/generated-wrappers/erc20_bridge_sampler';
export * from '../test/generated-wrappers/i_curve';
export * from '../test/generated-wrappers/i_dev_utils';
export * from '../test/generated-wrappers/i_erc20_bridge_sampler';
export * from '../test/generated-wrappers/i_eth2_dai';
export * from '../test/generated-wrappers/i_kyber_hint_handler';
export * from '../test/generated-wrappers/i_kyber_network';
export * from '../test/generated-wrappers/i_kyber_network_proxy';
export * from '../test/generated-wrappers/i_kyber_storage';
export * from '../test/generated-wrappers/i_liquidity_provider';
export * from '../test/generated-wrappers/i_liquidity_provider_registry';
export * from '../test/generated-wrappers/i_multi_bridge';
export * from '../test/generated-wrappers/i_uniswap_exchange_quotes';
export * from '../test/generated-wrappers/i_uniswap_v2_router01';
export * from '../test/generated-wrappers/test_erc20_bridge_sampler';

View File

@@ -3,15 +3,28 @@
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"generated-artifacts/DummyLiquidityProvider.json",
"generated-artifacts/DummyLiquidityProviderRegistry.json",
"generated-artifacts/ERC20BridgeSampler.json",
"generated-artifacts/IERC20BridgeSampler.json",
"generated-artifacts/ILiquidityProvider.json",
"generated-artifacts/ILiquidityProviderRegistry.json",
"test/generated-artifacts/DummyLiquidityProvider.json",
"test/generated-artifacts/DummyLiquidityProviderRegistry.json",
"test/generated-artifacts/ERC20BridgeSampler.json",
"test/generated-artifacts/ICurve.json",
"test/generated-artifacts/IDevUtils.json",
"test/generated-artifacts/IERC20BridgeSampler.json",
"test/generated-artifacts/IEth2Dai.json",
"test/generated-artifacts/IKyberHintHandler.json",
"test/generated-artifacts/IKyberNetwork.json",
"test/generated-artifacts/IKyberNetworkProxy.json",
"test/generated-artifacts/IKyberStorage.json",
"test/generated-artifacts/ILiquidityProvider.json",
"test/generated-artifacts/ILiquidityProviderRegistry.json",
"test/generated-artifacts/IMultiBridge.json",
"test/generated-artifacts/IUniswapExchangeQuotes.json",
"test/generated-artifacts/IUniswapV2Router01.json",
"test/generated-artifacts/TestERC20BridgeSampler.json"
],
"exclude": ["./deploy/solc/solc_bin"]

View File

@@ -1,4 +1,58 @@
[
{
"timestamp": 1594788383,
"version": "3.2.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.2.0",
"changes": [
{
"note": "Add `LibERC20Token.approveIfBelow()`",
"pr": 2512
},
{
"note": "Add solidity 0.6 contracts",
"pr": 2545
},
{
"note": "Update `LibERC20TokenV06` comments.",
"pr": 2597
}
],
"timestamp": 1592969527
},
{
"timestamp": 1583220306,
"version": "3.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582837861,
"version": "3.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582677073,
"version": "3.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582623685,
"version": "3.1.2",

View File

@@ -5,6 +5,28 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.2.1 - _July 15, 2020_
* Dependencies updated
## v3.2.0 - _June 24, 2020_
* Add `LibERC20Token.approveIfBelow()` (#2512)
* Add solidity 0.6 contracts (#2545)
* Update `LibERC20TokenV06` comments. (#2597)
## v3.1.5 - _March 3, 2020_
* Dependencies updated
## v3.1.4 - _February 27, 2020_
* Dependencies updated
## v3.1.3 - _February 26, 2020_
* Dependencies updated
## v3.1.2 - _February 25, 2020_
* Dependencies updated

View File

@@ -3,6 +3,7 @@
"contractsDir": "./contracts",
"useDockerisedSolc": false,
"isOfflineMode": false,
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": {

View File

@@ -47,6 +47,25 @@ library LibERC20Token {
_callWithOptionalBooleanResult(token, callData);
}
/// @dev Calls `IERC20Token(token).approve()` and sets the allowance to the
/// maximum if the current approval is not already >= an amount.
/// Reverts if `false` is returned or if the return
/// data length is nonzero and not 32 bytes.
/// @param token The address of the token contract.
/// @param spender The address that receives an allowance.
/// @param amount The minimum allowance needed.
function approveIfBelow(
address token,
address spender,
uint256 amount
)
internal
{
if (IERC20Token(token).allowance(address(this), spender) < amount) {
approve(token, spender, uint256(-1));
}
}
/// @dev Calls `IERC20Token(token).transfer()`.
/// Reverts if `false` is returned or if the return
/// data length is nonzero and not 32 bytes.

View File

@@ -0,0 +1,95 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
interface IERC20TokenV06 {
// solhint-disable no-simple-event-func-name
event Transfer(
address indexed from,
address indexed to,
uint256 value
);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
/// @dev send `value` token to `to` from `msg.sender`
/// @param to The address of the recipient
/// @param value The amount of token to be transferred
/// @return True if transfer was successful
function transfer(address to, uint256 value)
external
returns (bool);
/// @dev send `value` token to `to` from `from` on the condition it is approved by `from`
/// @param from The address of the sender
/// @param to The address of the recipient
/// @param value The amount of token to be transferred
/// @return True if transfer was successful
function transferFrom(
address from,
address to,
uint256 value
)
external
returns (bool);
/// @dev `msg.sender` approves `spender` to spend `value` tokens
/// @param spender The address of the account able to transfer the tokens
/// @param value The amount of wei to be approved for transfer
/// @return Always true if the call has enough gas to complete execution
function approve(address spender, uint256 value)
external
returns (bool);
/// @dev Query total supply of token
/// @return Total supply of token
function totalSupply()
external
view
returns (uint256);
/// @dev Get the balance of `owner`.
/// @param owner The address from which the balance will be retrieved
/// @return Balance of owner
function balanceOf(address owner)
external
view
returns (uint256);
/// @dev Get the allowance for `spender` to spend from `owner`.
/// @param owner The address of the account owning tokens
/// @param spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address owner, address spender)
external
view
returns (uint256);
/// @dev Get the number of decimals this token has.
function decimals()
external
view
returns (uint8);
}

View File

@@ -0,0 +1,32 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
import "./IERC20TokenV06.sol";
interface IEtherTokenV06 is
IERC20TokenV06
{
/// @dev Wrap ether.
function deposit() external payable;
/// @dev Unwrap ether.
function withdraw(uint256 amount) external;
}

View File

@@ -0,0 +1,208 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6.5;
import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibBytesV06.sol";
import "./IERC20TokenV06.sol";
library LibERC20TokenV06 {
bytes constant private DECIMALS_CALL_DATA = hex"313ce567";
/// @dev Calls `IERC20TokenV06(token).approve()`.
/// Reverts if the result fails `isSuccessfulResult()` or the call reverts.
/// @param token The address of the token contract.
/// @param spender The address that receives an allowance.
/// @param allowance The allowance to set.
function compatApprove(
IERC20TokenV06 token,
address spender,
uint256 allowance
)
internal
{
bytes memory callData = abi.encodeWithSelector(
token.approve.selector,
spender,
allowance
);
_callWithOptionalBooleanResult(address(token), callData);
}
/// @dev Calls `IERC20TokenV06(token).approve()` and sets the allowance to the
/// maximum if the current approval is not already >= an amount.
/// Reverts if the result fails `isSuccessfulResult()` or the call reverts.
/// @param token The address of the token contract.
/// @param spender The address that receives an allowance.
/// @param amount The minimum allowance needed.
function approveIfBelow(
IERC20TokenV06 token,
address spender,
uint256 amount
)
internal
{
if (token.allowance(address(this), spender) < amount) {
compatApprove(token, spender, uint256(-1));
}
}
/// @dev Calls `IERC20TokenV06(token).transfer()`.
/// Reverts if the result fails `isSuccessfulResult()` or the call reverts.
/// @param token The address of the token contract.
/// @param to The address that receives the tokens
/// @param amount Number of tokens to transfer.
function compatTransfer(
IERC20TokenV06 token,
address to,
uint256 amount
)
internal
{
bytes memory callData = abi.encodeWithSelector(
token.transfer.selector,
to,
amount
);
_callWithOptionalBooleanResult(address(token), callData);
}
/// @dev Calls `IERC20TokenV06(token).transferFrom()`.
/// Reverts if the result fails `isSuccessfulResult()` or the call reverts.
/// @param token The address of the token contract.
/// @param from The owner of the tokens.
/// @param to The address that receives the tokens
/// @param amount Number of tokens to transfer.
function compatTransferFrom(
IERC20TokenV06 token,
address from,
address to,
uint256 amount
)
internal
{
bytes memory callData = abi.encodeWithSelector(
token.transferFrom.selector,
from,
to,
amount
);
_callWithOptionalBooleanResult(address(token), callData);
}
/// @dev Retrieves the number of decimals for a token.
/// Returns `18` if the call reverts.
/// @param token The address of the token contract.
/// @return tokenDecimals The number of decimals places for the token.
function compatDecimals(IERC20TokenV06 token)
internal
view
returns (uint8 tokenDecimals)
{
tokenDecimals = 18;
(bool didSucceed, bytes memory resultData) = address(token).staticcall(DECIMALS_CALL_DATA);
if (didSucceed && resultData.length == 32) {
tokenDecimals = uint8(LibBytesV06.readUint256(resultData, 0));
}
}
/// @dev Retrieves the allowance for a token, owner, and spender.
/// Returns `0` if the call reverts.
/// @param token The address of the token contract.
/// @param owner The owner of the tokens.
/// @param spender The address the spender.
/// @return allowance_ The allowance for a token, owner, and spender.
function compatAllowance(IERC20TokenV06 token, address owner, address spender)
internal
view
returns (uint256 allowance_)
{
(bool didSucceed, bytes memory resultData) = address(token).staticcall(
abi.encodeWithSelector(
token.allowance.selector,
owner,
spender
)
);
if (didSucceed && resultData.length == 32) {
allowance_ = LibBytesV06.readUint256(resultData, 0);
}
}
/// @dev Retrieves the balance for a token owner.
/// Returns `0` if the call reverts.
/// @param token The address of the token contract.
/// @param owner The owner of the tokens.
/// @return balance The token balance of an owner.
function compatBalanceOf(IERC20TokenV06 token, address owner)
internal
view
returns (uint256 balance)
{
(bool didSucceed, bytes memory resultData) = address(token).staticcall(
abi.encodeWithSelector(
token.balanceOf.selector,
owner
)
);
if (didSucceed && resultData.length == 32) {
balance = LibBytesV06.readUint256(resultData, 0);
}
}
/// @dev Check if the data returned by a non-static call to an ERC20 token
/// is a successful result. Supported functions are `transfer()`,
/// `transferFrom()`, and `approve()`.
/// @param resultData The raw data returned by a non-static call to the ERC20 token.
/// @return isSuccessful Whether the result data indicates success.
function isSuccessfulResult(bytes memory resultData)
internal
pure
returns (bool isSuccessful)
{
if (resultData.length == 0) {
return true;
}
if (resultData.length == 32) {
uint256 result = LibBytesV06.readUint256(resultData, 0);
if (result == 1) {
return true;
}
}
}
/// @dev Executes a call on address `target` with calldata `callData`
/// and asserts that either nothing was returned or a single boolean
/// was returned equal to `true`.
/// @param target The call target.
/// @param callData The abi-encoded call data.
function _callWithOptionalBooleanResult(
address target,
bytes memory callData
)
private
{
(bool didSucceed, bytes memory resultData) = target.call(callData);
if (didSucceed && isSuccessfulResult(resultData)) {
return;
}
LibRichErrorsV06.rrevert(resultData);
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc20",
"version": "3.1.2",
"version": "3.2.1",
"engines": {
"node": ">=6.12"
},
@@ -38,7 +38,7 @@
},
"config": {
"publicInterfaceContracts": "DummyERC20Token,ERC20Token,WETH9,ZRXToken,DummyNoReturnERC20Token,DummyMultipleReturnERC20Token",
"abis": "./test/generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IEtherToken|LibERC20Token|MintableERC20Token|TestLibERC20Token|TestLibERC20TokenTarget|UnlimitedAllowanceERC20Token|UntransferrableDummyERC20Token|WETH9|ZRXToken).json",
"abis": "./test/generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IERC20TokenV06|IEtherToken|IEtherTokenV06|LibERC20Token|LibERC20TokenV06|MintableERC20Token|TestLibERC20Token|TestLibERC20TokenTarget|UnlimitedAllowanceERC20Token|UntransferrableDummyERC20Token|WETH9|ZRXToken).json",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
},
"repository": {
@@ -51,18 +51,18 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.2.1",
"@0x/contracts-gen": "^2.0.8",
"@0x/contracts-test-utils": "^5.3.0",
"@0x/contracts-utils": "^4.4.0",
"@0x/dev-utils": "^3.2.1",
"@0x/sol-compiler": "^4.0.8",
"@0x/abi-gen": "^5.3.1",
"@0x/contracts-gen": "^2.0.10",
"@0x/contracts-test-utils": "^5.3.4",
"@0x/contracts-utils": "^4.5.1",
"@0x/dev-utils": "^3.3.0",
"@0x/sol-compiler": "^4.1.1",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.2",
"@0x/typescript-typings": "^5.0.2",
"@0x/utils": "^5.4.1",
"@0x/web3-wrapper": "^7.0.7",
"@0x/tslint-config": "^4.1.0",
"@0x/types": "^3.2.0",
"@0x/typescript-typings": "^5.1.1",
"@0x/utils": "^5.5.1",
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
@@ -70,7 +70,7 @@
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"ethereum-types": "^3.1.0",
"ethereum-types": "^3.2.0",
"lodash": "^4.17.11",
"make-promises-safe": "^1.1.0",
"mocha": "^6.2.0",
@@ -82,9 +82,10 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.1"
"@0x/base-contract": "^6.2.3"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}

View File

@@ -10,8 +10,11 @@ import * as DummyMultipleReturnERC20Token from '../test/generated-artifacts/Dumm
import * as DummyNoReturnERC20Token from '../test/generated-artifacts/DummyNoReturnERC20Token.json';
import * as ERC20Token from '../test/generated-artifacts/ERC20Token.json';
import * as IERC20Token from '../test/generated-artifacts/IERC20Token.json';
import * as IERC20TokenV06 from '../test/generated-artifacts/IERC20TokenV06.json';
import * as IEtherToken from '../test/generated-artifacts/IEtherToken.json';
import * as IEtherTokenV06 from '../test/generated-artifacts/IEtherTokenV06.json';
import * as LibERC20Token from '../test/generated-artifacts/LibERC20Token.json';
import * as LibERC20TokenV06 from '../test/generated-artifacts/LibERC20TokenV06.json';
import * as MintableERC20Token from '../test/generated-artifacts/MintableERC20Token.json';
import * as TestLibERC20Token from '../test/generated-artifacts/TestLibERC20Token.json';
import * as TestLibERC20TokenTarget from '../test/generated-artifacts/TestLibERC20TokenTarget.json';
@@ -28,6 +31,9 @@ export const artifacts = {
ZRXToken: (ZRXToken as any) as ContractArtifact,
IERC20Token: IERC20Token as ContractArtifact,
IEtherToken: IEtherToken as ContractArtifact,
IERC20TokenV06: IERC20TokenV06 as ContractArtifact,
IEtherTokenV06: IEtherTokenV06 as ContractArtifact,
LibERC20TokenV06: LibERC20TokenV06 as ContractArtifact,
DummyERC20Token: DummyERC20Token as ContractArtifact,
DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact,
DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact,

View File

@@ -8,8 +8,11 @@ export * from '../test/generated-wrappers/dummy_multiple_return_erc20_token';
export * from '../test/generated-wrappers/dummy_no_return_erc20_token';
export * from '../test/generated-wrappers/erc20_token';
export * from '../test/generated-wrappers/i_erc20_token';
export * from '../test/generated-wrappers/i_erc20_token_v06';
export * from '../test/generated-wrappers/i_ether_token';
export * from '../test/generated-wrappers/i_ether_token_v06';
export * from '../test/generated-wrappers/lib_erc20_token';
export * from '../test/generated-wrappers/lib_erc20_token_v06';
export * from '../test/generated-wrappers/mintable_erc20_token';
export * from '../test/generated-wrappers/test_lib_erc20_token';
export * from '../test/generated-wrappers/test_lib_erc20_token_target';

View File

@@ -14,8 +14,11 @@
"test/generated-artifacts/DummyNoReturnERC20Token.json",
"test/generated-artifacts/ERC20Token.json",
"test/generated-artifacts/IERC20Token.json",
"test/generated-artifacts/IERC20TokenV06.json",
"test/generated-artifacts/IEtherToken.json",
"test/generated-artifacts/IEtherTokenV06.json",
"test/generated-artifacts/LibERC20Token.json",
"test/generated-artifacts/LibERC20TokenV06.json",
"test/generated-artifacts/MintableERC20Token.json",
"test/generated-artifacts/TestLibERC20Token.json",
"test/generated-artifacts/TestLibERC20TokenTarget.json",

View File

@@ -1,4 +1,49 @@
[
{
"timestamp": 1594788383,
"version": "3.1.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "3.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1583220306,
"version": "3.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582837861,
"version": "3.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582677073,
"version": "3.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582623685,
"version": "3.1.2",

View File

@@ -5,6 +5,26 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.7 - _July 15, 2020_
* Dependencies updated
## v3.1.6 - _June 24, 2020_
* Dependencies updated
## v3.1.5 - _March 3, 2020_
* Dependencies updated
## v3.1.4 - _February 27, 2020_
* Dependencies updated
## v3.1.3 - _February 26, 2020_
* Dependencies updated
## v3.1.2 - _February 25, 2020_
* Dependencies updated

View File

@@ -3,6 +3,7 @@
"contractsDir": "./contracts",
"useDockerisedSolc": false,
"isOfflineMode": false,
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": {

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc721",
"version": "3.1.2",
"version": "3.1.7",
"engines": {
"node": ">=6.12"
},
@@ -52,18 +52,18 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.2.1",
"@0x/contracts-gen": "^2.0.8",
"@0x/contracts-test-utils": "^5.3.0",
"@0x/contracts-utils": "^4.4.0",
"@0x/dev-utils": "^3.2.1",
"@0x/sol-compiler": "^4.0.8",
"@0x/abi-gen": "^5.3.1",
"@0x/contracts-gen": "^2.0.10",
"@0x/contracts-test-utils": "^5.3.4",
"@0x/contracts-utils": "^4.5.1",
"@0x/dev-utils": "^3.3.0",
"@0x/sol-compiler": "^4.1.1",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.2",
"@0x/typescript-typings": "^5.0.2",
"@0x/utils": "^5.4.1",
"@0x/web3-wrapper": "^7.0.7",
"@0x/tslint-config": "^4.1.0",
"@0x/types": "^3.2.0",
"@0x/typescript-typings": "^5.1.1",
"@0x/utils": "^5.5.1",
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
@@ -71,7 +71,7 @@
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"ethereum-types": "^3.1.0",
"ethereum-types": "^3.2.0",
"lodash": "^4.17.11",
"make-promises-safe": "^1.1.0",
"mocha": "^6.2.0",
@@ -84,9 +84,10 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.1"
"@0x/base-contract": "^6.2.3"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}

View File

@@ -1,4 +1,49 @@
[
{
"timestamp": 1594788383,
"version": "4.2.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "4.2.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1583220306,
"version": "4.2.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582837861,
"version": "4.2.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582677073,
"version": "4.2.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582623685,
"version": "4.2.2",

View File

@@ -5,6 +5,26 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.2.7 - _July 15, 2020_
* Dependencies updated
## v4.2.6 - _June 24, 2020_
* Dependencies updated
## v4.2.5 - _March 3, 2020_
* Dependencies updated
## v4.2.4 - _February 27, 2020_
* Dependencies updated
## v4.2.3 - _February 26, 2020_
* Dependencies updated
## v4.2.2 - _February 25, 2020_
* Dependencies updated

View File

@@ -3,6 +3,7 @@
"contractsDir": "./contracts",
"useDockerisedSolc": false,
"isOfflineMode": false,
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": {

View File

@@ -151,6 +151,72 @@ contract Forwarder is
_unwrapAndTransferEth(wethRemaining);
}
/// @dev Purchases as much of orders' makerAssets as possible by selling the specified amount of ETH
/// accounting for order and forwarder fees. This functions throws if ethSellAmount was not reached.
/// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
/// @param ethSellAmount Desired amount of ETH to sell.
/// @param signatures Proofs that orders have been created by makers.
/// @param ethFeeAmounts Amounts of ETH, denominated in Wei, that are paid to corresponding feeRecipients.
/// @param feeRecipients Addresses that will receive ETH when orders are filled.
/// @return wethSpentAmount Amount of WETH spent on the given set of orders.
/// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders.
function marketSellAmountWithEth(
LibOrder.Order[] memory orders,
uint256 ethSellAmount,
bytes[] memory signatures,
uint256[] memory ethFeeAmounts,
address payable[] memory feeRecipients
)
public
payable
returns (
uint256 wethSpentAmount,
uint256 makerAssetAcquiredAmount
)
{
if (ethSellAmount > msg.value) {
LibRichErrors.rrevert(LibForwarderRichErrors.CompleteSellFailedError(
ethSellAmount,
msg.value
));
}
// Pay ETH affiliate fees to all feeRecipient addresses
uint256 wethRemaining = _transferEthFeesAndWrapRemaining(
ethFeeAmounts,
feeRecipients
);
// Need enough remaining to ensure we can sell ethSellAmount
if (wethRemaining < ethSellAmount) {
LibRichErrors.rrevert(LibForwarderRichErrors.OverspentWethError(
wethRemaining,
ethSellAmount
));
}
// Spends up to ethSellAmount to fill orders, transfers purchased assets to msg.sender,
// and pays WETH order fees.
(
wethSpentAmount,
makerAssetAcquiredAmount
) = _marketSellExactAmountNoThrow(
orders,
ethSellAmount,
signatures
);
// Ensure we sold the specified amount (note: wethSpentAmount includes fees)
if (wethSpentAmount < ethSellAmount) {
LibRichErrors.rrevert(LibForwarderRichErrors.CompleteSellFailedError(
ethSellAmount,
wethSpentAmount
));
}
// Calculate amount of WETH that hasn't been spent.
wethRemaining = wethRemaining.safeSub(wethSpentAmount);
// Refund remaining ETH to msg.sender.
_unwrapAndTransferEth(wethRemaining);
}
/// @dev Attempt to buy makerAssetBuyAmount of makerAsset by selling ETH provided with transaction.
/// The Forwarder may *fill* more than makerAssetBuyAmount of the makerAsset so that it can
/// pay takerFees where takerFeeAssetData == makerAssetData (i.e. percentage fees).

View File

@@ -53,6 +53,7 @@ contract MixinExchangeWrapper {
// ")"
// )));
bytes4 constant public EXCHANGE_V2_ORDER_ID = 0x770501f8;
bytes4 constant internal ERC20_BRIDGE_PROXY_ID = 0xdc1600f3;
// solhint-disable var-name-mixedcase
IExchange internal EXCHANGE;
@@ -73,6 +74,12 @@ contract MixinExchangeWrapper {
EXCHANGE_V2 = IExchangeV2(_exchangeV2);
}
struct SellFillResults {
uint256 wethSpentAmount;
uint256 makerAssetAcquiredAmount;
uint256 protocolFeePaid;
}
/// @dev Fills the input order.
/// Returns false if the transaction would otherwise revert.
/// @param order Order struct containing order specifications.
@@ -115,11 +122,16 @@ contract MixinExchangeWrapper {
uint256 remainingTakerAssetFillAmount
)
internal
returns (
uint256 wethSpentAmount,
uint256 makerAssetAcquiredAmount
)
returns (SellFillResults memory sellFillResults)
{
// If the maker asset is ERC20Bridge, take a snapshot of the Forwarder contract's balance.
bytes4 makerAssetProxyId = order.makerAssetData.readBytes4(0);
address tokenAddress;
uint256 balanceBefore;
if (makerAssetProxyId == ERC20_BRIDGE_PROXY_ID) {
tokenAddress = order.makerAssetData.readAddress(16);
balanceBefore = IERC20Token(tokenAddress).balanceOf(address(this));
}
// No taker fee or percentage fee
if (
order.takerFee == 0 ||
@@ -132,11 +144,11 @@ contract MixinExchangeWrapper {
signature
);
wethSpentAmount = singleFillResults.takerAssetFilledAmount
.safeAdd(singleFillResults.protocolFeePaid);
sellFillResults.wethSpentAmount = singleFillResults.takerAssetFilledAmount;
sellFillResults.protocolFeePaid = singleFillResults.protocolFeePaid;
// Subtract fee from makerAssetFilledAmount for the net amount acquired.
makerAssetAcquiredAmount = singleFillResults.makerAssetFilledAmount
sellFillResults.makerAssetAcquiredAmount = singleFillResults.makerAssetFilledAmount
.safeSub(singleFillResults.takerFeePaid);
// WETH fee
@@ -157,18 +169,27 @@ contract MixinExchangeWrapper {
);
// WETH is also spent on the taker fee, so we add it here.
wethSpentAmount = singleFillResults.takerAssetFilledAmount
.safeAdd(singleFillResults.takerFeePaid)
.safeAdd(singleFillResults.protocolFeePaid);
makerAssetAcquiredAmount = singleFillResults.makerAssetFilledAmount;
sellFillResults.wethSpentAmount = singleFillResults.takerAssetFilledAmount
.safeAdd(singleFillResults.takerFeePaid);
sellFillResults.makerAssetAcquiredAmount = singleFillResults.makerAssetFilledAmount;
sellFillResults.protocolFeePaid = singleFillResults.protocolFeePaid;
// Unsupported fee
} else {
LibRichErrors.rrevert(LibForwarderRichErrors.UnsupportedFeeError(order.takerFeeAssetData));
}
return (wethSpentAmount, makerAssetAcquiredAmount);
// Account for the ERC20Bridge transfering more of the maker asset than expected.
if (makerAssetProxyId == ERC20_BRIDGE_PROXY_ID) {
uint256 balanceAfter = IERC20Token(tokenAddress).balanceOf(address(this));
sellFillResults.makerAssetAcquiredAmount = LibSafeMath.max256(
balanceAfter.safeSub(balanceBefore),
sellFillResults.makerAssetAcquiredAmount
);
}
order.makerAssetData.transferOut(sellFillResults.makerAssetAcquiredAmount);
return sellFillResults;
}
/// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH has been sold by taker.
@@ -189,7 +210,6 @@ contract MixinExchangeWrapper {
)
{
uint256 protocolFee = tx.gasprice.safeMul(EXCHANGE.protocolFeeMultiplier());
bytes4 erc20BridgeProxyId = IAssetData(address(0)).ERC20Bridge.selector;
for (uint256 i = 0; i != orders.length; i++) {
// Preemptively skip to avoid division by zero in _marketSellSingleOrder
@@ -199,42 +219,27 @@ contract MixinExchangeWrapper {
// The remaining amount of WETH to sell
uint256 remainingTakerAssetFillAmount = wethSellAmount
.safeSub(totalWethSpentAmount)
.safeSub(_isV2Order(orders[i]) ? 0 : protocolFee);
// If the maker asset is ERC20Bridge, take a snapshot of the Forwarder contract's balance.
bytes4 makerAssetProxyId = orders[i].makerAssetData.readBytes4(0);
address tokenAddress;
uint256 balanceBefore;
if (makerAssetProxyId == erc20BridgeProxyId) {
tokenAddress = orders[i].makerAssetData.readAddress(16);
balanceBefore = IERC20Token(tokenAddress).balanceOf(address(this));
.safeSub(totalWethSpentAmount);
uint256 currentProtocolFee = _isV2Order(orders[i]) ? 0 : protocolFee;
if (remainingTakerAssetFillAmount > currentProtocolFee) {
// Do not count the protocol fee as part of the fill amount.
remainingTakerAssetFillAmount = remainingTakerAssetFillAmount.safeSub(currentProtocolFee);
} else {
// Stop if we don't have at least enough ETH to pay another protocol fee.
break;
}
(
uint256 wethSpentAmount,
uint256 makerAssetAcquiredAmount
) = _marketSellSingleOrder(
SellFillResults memory sellFillResults = _marketSellSingleOrder(
orders[i],
signatures[i],
remainingTakerAssetFillAmount
);
// Account for the ERC20Bridge transfering more of the maker asset than expected.
if (makerAssetProxyId == erc20BridgeProxyId) {
uint256 balanceAfter = IERC20Token(tokenAddress).balanceOf(address(this));
makerAssetAcquiredAmount = LibSafeMath.max256(
balanceAfter.safeSub(balanceBefore),
makerAssetAcquiredAmount
);
}
orders[i].makerAssetData.transferOut(makerAssetAcquiredAmount);
totalWethSpentAmount = totalWethSpentAmount
.safeAdd(wethSpentAmount);
.safeAdd(sellFillResults.wethSpentAmount)
.safeAdd(sellFillResults.protocolFeePaid);
totalMakerAssetAcquiredAmount = totalMakerAssetAcquiredAmount
.safeAdd(makerAssetAcquiredAmount);
.safeAdd(sellFillResults.makerAssetAcquiredAmount);
// Stop execution if the entire amount of WETH has been sold
if (totalWethSpentAmount >= wethSellAmount) {
@@ -243,6 +248,56 @@ contract MixinExchangeWrapper {
}
}
/// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH (exclusive of protocol fee)
/// has been sold by taker.
/// @param orders Array of order specifications.
/// @param wethSellAmount Desired amount of WETH to sell.
/// @param signatures Proofs that orders have been signed by makers.
/// @return totalWethSpentAmount Total amount of WETH spent on the given orders.
/// @return totalMakerAssetAcquiredAmount Total amount of maker asset acquired from the given orders.
function _marketSellExactAmountNoThrow(
LibOrder.Order[] memory orders,
uint256 wethSellAmount,
bytes[] memory signatures
)
internal
returns (
uint256 totalWethSpentAmount,
uint256 totalMakerAssetAcquiredAmount
)
{
uint256 totalProtocolFeePaid;
for (uint256 i = 0; i != orders.length; i++) {
// Preemptively skip to avoid division by zero in _marketSellSingleOrder
if (orders[i].makerAssetAmount == 0 || orders[i].takerAssetAmount == 0) {
continue;
}
// The remaining amount of WETH to sell
uint256 remainingTakerAssetFillAmount = wethSellAmount
.safeSub(totalWethSpentAmount);
SellFillResults memory sellFillResults = _marketSellSingleOrder(
orders[i],
signatures[i],
remainingTakerAssetFillAmount
);
totalWethSpentAmount = totalWethSpentAmount
.safeAdd(sellFillResults.wethSpentAmount);
totalMakerAssetAcquiredAmount = totalMakerAssetAcquiredAmount
.safeAdd(sellFillResults.makerAssetAcquiredAmount);
totalProtocolFeePaid = totalProtocolFeePaid.safeAdd(sellFillResults.protocolFeePaid);
// Stop execution if the entire amount of WETH has been sold
if (totalWethSpentAmount >= wethSellAmount) {
break;
}
}
totalWethSpentAmount = totalWethSpentAmount.safeAdd(totalProtocolFeePaid);
}
/// @dev Executes a single call of fillOrder according to the makerAssetBuyAmount and
/// the amount already bought.
/// @param order A single order specification.
@@ -338,8 +393,6 @@ contract MixinExchangeWrapper {
uint256 totalMakerAssetAcquiredAmount
)
{
bytes4 erc20BridgeProxyId = IAssetData(address(0)).ERC20Bridge.selector;
uint256 ordersLength = orders.length;
for (uint256 i = 0; i != ordersLength; i++) {
// Preemptively skip to avoid division by zero in _marketBuySingleOrder
@@ -354,7 +407,7 @@ contract MixinExchangeWrapper {
bytes4 makerAssetProxyId = orders[i].makerAssetData.readBytes4(0);
address tokenAddress;
uint256 balanceBefore;
if (makerAssetProxyId == erc20BridgeProxyId) {
if (makerAssetProxyId == ERC20_BRIDGE_PROXY_ID) {
tokenAddress = orders[i].makerAssetData.readAddress(16);
balanceBefore = IERC20Token(tokenAddress).balanceOf(address(this));
}
@@ -369,7 +422,7 @@ contract MixinExchangeWrapper {
);
// Account for the ERC20Bridge transfering more of the maker asset than expected.
if (makerAssetProxyId == erc20BridgeProxyId) {
if (makerAssetProxyId == ERC20_BRIDGE_PROXY_ID) {
uint256 balanceAfter = IERC20Token(tokenAddress).balanceOf(address(this));
makerAssetAcquiredAmount = LibSafeMath.max256(
balanceAfter.safeSub(balanceBefore),

View File

@@ -29,6 +29,10 @@ library LibForwarderRichErrors {
bytes4 internal constant COMPLETE_BUY_FAILED_ERROR_SELECTOR =
0x91353a0c;
// bytes4(keccak256("CompleteSellFailedError(uint256,uint256)"))
bytes4 internal constant COMPLETE_SELL_FAILED_ERROR_SELECTOR =
0x450a0219;
// bytes4(keccak256("UnsupportedFeeError(bytes)"))
bytes4 internal constant UNSUPPORTED_FEE_ERROR_SELECTOR =
0x31360af1;
@@ -61,6 +65,21 @@ library LibForwarderRichErrors {
);
}
function CompleteSellFailedError(
uint256 expectedAssetSellAmount,
uint256 actualAssetSellAmount
)
internal
pure
returns (bytes memory)
{
return abi.encodeWithSelector(
COMPLETE_SELL_FAILED_ERROR_SELECTOR,
expectedAssetSellAmount,
actualAssetSellAmount
);
}
function UnsupportedFeeError(
bytes memory takerFeeAssetData
)

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange-forwarder",
"version": "4.2.2",
"version": "4.2.7",
"engines": {
"node": ">=6.12"
},
@@ -52,25 +52,25 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.2.1",
"@0x/contracts-asset-proxy": "^3.2.2",
"@0x/contracts-dev-utils": "^1.3.0",
"@0x/contracts-erc1155": "^2.1.2",
"@0x/contracts-erc20": "^3.1.2",
"@0x/contracts-erc721": "^3.1.2",
"@0x/contracts-exchange": "^3.2.2",
"@0x/contracts-exchange-libs": "^4.3.2",
"@0x/contracts-gen": "^2.0.8",
"@0x/contracts-test-utils": "^5.3.0",
"@0x/contracts-utils": "^4.4.0",
"@0x/dev-utils": "^3.2.1",
"@0x/order-utils": "^10.2.2",
"@0x/sol-compiler": "^4.0.8",
"@0x/abi-gen": "^5.3.1",
"@0x/contracts-asset-proxy": "^3.4.0",
"@0x/contracts-dev-utils": "^1.3.5",
"@0x/contracts-erc1155": "^2.1.7",
"@0x/contracts-erc20": "^3.2.1",
"@0x/contracts-erc721": "^3.1.7",
"@0x/contracts-exchange": "^3.2.7",
"@0x/contracts-exchange-libs": "^4.3.7",
"@0x/contracts-gen": "^2.0.10",
"@0x/contracts-test-utils": "^5.3.4",
"@0x/contracts-utils": "^4.5.1",
"@0x/dev-utils": "^3.3.0",
"@0x/order-utils": "^10.3.0",
"@0x/sol-compiler": "^4.1.1",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.2",
"@0x/utils": "^5.4.1",
"@0x/web3-wrapper": "^7.0.7",
"@0x/tslint-config": "^4.1.0",
"@0x/types": "^3.2.0",
"@0x/utils": "^5.5.1",
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
@@ -90,11 +90,12 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.1",
"@0x/typescript-typings": "^5.0.2",
"ethereum-types": "^3.1.0"
"@0x/base-contract": "^6.2.3",
"@0x/typescript-typings": "^5.1.1",
"ethereum-types": "^3.2.0"
},
"publishConfig": {
"access": "public"
}
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}

View File

@@ -1,4 +1,49 @@
[
{
"timestamp": 1594788383,
"version": "4.3.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "4.3.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1583220306,
"version": "4.3.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582837861,
"version": "4.3.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582677073,
"version": "4.3.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582623685,
"version": "4.3.2",

View File

@@ -5,6 +5,26 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.3.7 - _July 15, 2020_
* Dependencies updated
## v4.3.6 - _June 24, 2020_
* Dependencies updated
## v4.3.5 - _March 3, 2020_
* Dependencies updated
## v4.3.4 - _February 27, 2020_
* Dependencies updated
## v4.3.3 - _February 26, 2020_
* Dependencies updated
## v4.3.2 - _February 25, 2020_
* Dependencies updated

Some files were not shown because too many files have changed in this diff Show More