Compare commits

..

1189 Commits

Author SHA1 Message Date
abls
2507028612 add multiplex TokenForEth functions to metatransactions 2023-02-20 12:36:19 -08:00
abls
90b826da61 add multiplexMultiHopSellTokenForToken to metatransactions, with related msgSender changes 2023-02-10 13:04:20 -08:00
abls
d022f2864b add msgSender field to replace msg.sender usage in MultiplexFeature's BatchSells 2023-02-08 20:43:21 -08:00
abls
5bbcc353f8 add multiplexBatchSellTokenForToken to metatransactions 2023-02-07 18:44:13 -08:00
Elena
c4b1f043c6 Remove obsoleted code from 0x/contracts-utils (#643)
* Remove TestAuthorizable

* Remove contracts/utils Authorizable and IAuthorizable

* Remove contracts/utils D18 contract

* Remove contracts/utils LibAddress contracts

* Remove contracts/utils LogDecoding contracts

* Remove contracts/utils Refundable contracts

* Remove contracts/utils LibAuthorizableRichErrors contracts

* Remove contracts/utils EIP712 contracts

* Remove contracts/utils TestRefundableReceiver contracts

* Remove contracts/utils EIP1271 contracts

* Remove contracts/utils ReentrancyGuardV06 contracts

* Remove contracts/utils LibMath contracts

* Remove contracts/utils LibFractions contracts

* Remove contracts/utils LibMathRichErrors contracts

* Remove DeploymentConstants as per PR review
https://github.com/0xProject/protocol/pull/643#pullrequestreview-1264963784
2023-02-06 19:35:39 +02:00
Github Actions
a472125c65 Publish
- @0x/contracts-erc20@3.3.57
 - @0x/contracts-test-utils@5.4.47
 - @0x/contracts-treasury@1.4.40
 - @0x/contracts-utils@4.8.38
 - @0x/contracts-zero-ex@0.38.6
 - @0x/contract-addresses@8.0.3
 - @0x/contract-wrappers@13.22.16
 - @0x/protocol-utils@11.17.6
2023-02-01 00:22:23 +00:00
Github Actions
8666121bd9 Updated CHANGELOGS & MD docs 2023-02-01 00:22:20 +00:00
Elyas
8cf1c8bbd2 chore: Add woofi to Arbitrum & Optimism bridge adapters [LIT-774] (#653)
* update arb bridge adapter

* update optimism bridge adapter

* make fixes

* fix lint

* update arbitrum fqt address

* changelog

* fix changelog
2023-01-31 18:02:02 -05:00
Github Actions
d2abe9ad97 Publish
- @0x/contracts-erc20@3.3.56
 - @0x/contracts-test-utils@5.4.46
 - @0x/contracts-treasury@1.4.39
 - @0x/contracts-utils@4.8.37
 - @0x/contracts-zero-ex@0.38.5
 - @0x/contract-addresses@8.0.2
 - @0x/contract-wrappers@13.22.15
 - @0x/protocol-utils@11.17.5
2023-01-30 18:59:56 +00:00
Github Actions
f8b65bd429 Updated CHANGELOGS & MD docs 2023-01-30 18:59:52 +00:00
Noah Khamliche
3a7a5d22a2 Feat: 🛠️ fix protocol release action (#652)
* 🔧 fix  and clean up foundry tests

* fix foundry tests import paths
2023-01-30 12:45:40 -05:00
Noah Khamliche
f87f5a40c0 Feat/Add Foundry Testing Environment s[TKR-525] (#555)
* added initial foundry transformERC20 tests

* added foundry tests into CircleCI flow

* add verbosity for failing tests in CI

* revert wrong CI commands

* feat: Foundry, added some more deployments (#558)

* Added some more deployments

* Rename WETH9 to WETH9V06

* Set to 0.6.x

* fix typo

* remove commit with bad prettier changes

* working bridge Fills through weth transformer

* remove unused reference

* clean up tests

* added working otc fill through transformERC20 in FQT

* resolve file imports, add samplers, arbitrumBridgeAdatper, and new FQT version

* add extra 'v' for debugging verbosity

* add extra 'v' for debugging verbosity in circleci config

* remove old traces

* refactor rpc's out of foundry.toml and into .env for CI compatibility

* remove verbosity from CI command as its now defined in foundry.toml

* setup rpc's

* ignore foundry artifacts in prettier

* change naming in prettierignore

* move /samplers to the tests subdirectory, modify remappings to reflext change

* one more try 🤞

* change CI steps

* remove yarn from CI step

* get to the right directory

* update foundry before tests

* fix tip() deprecation and use deal()

* use deal() instead of vm.deal()

* try to get foundry to have the right directory structure by updating it

* I HATE THIS

* remove foundryup

* Fix prettier issues

* Remove obsoleted import

* Use forge native commands to
install deps and test and add the --root option

* Try using forge with working-directory flag in CI

* Use nightly foundry docker image

* Update rpc endpoints config in foundry

* move tests into /forked and /local

* rename tests

* add foundry profiles to CI

* try to fix CI

* 🔧 add foundry local and forked tests to workflow

* prettier and lint

* revert deps update

* remove all samplers and add uniswapV2 sampler to ForkUtils

* address jacobs comments

* cleanup and comment

* prettier and lint

* bump contracts-zero-ex version

* set func-name-mixedcase to off in solhint for elenas new changes

* max line length to warn

* add --fix for check-md

* Update ci.yml

* fix some nitpcks and leftover code

* fix inconsistent naming

* fix bridge adapter reverts and foundry cache

* migrate foundry integration tests to /tests

* refactor contract-addresses to use the contract-addresses package style nested json

* fix solhint

* fix contract linting errors

* dont check broken links in libraries

* move forge order in gh action for testing

* add env instead of vars

* try again

* fix github actions ordering

* update licence and address comments

* remove verbosity from foundry.toml

* fix contract lint

* move back to emitting an event until samplers can be integrated as some chains dont have uniswap as a source

* add uniswap v3 sampling code for future use

* remove uniswap v3 code as its not used

* fix lint

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
Co-authored-by: Jacob Evans <jacob@dekz.net>
Co-authored-by: elenadimitrova <elena@arenabg.com>
2023-01-26 20:11:16 -05:00
Noah Khamliche
5571d1698d update contract-addresses with new bridge adapters with Woofi enabled (#649) 2023-01-26 18:38:45 -05:00
Noah Khamliche
6f7a7a7291 fix compiler to read in arbitrum bridge adapter (#648) 2023-01-26 17:45:45 -05:00
Elyas
b613de1547 add WooFi V2 Mixin (#644) 2023-01-23 20:48:27 -05:00
Github Actions
6fd269db34 Publish
- @0x/contracts-erc20@3.3.55
 - @0x/contracts-test-utils@5.4.45
 - @0x/contracts-treasury@1.4.38
 - @0x/contracts-utils@4.8.36
 - @0x/contracts-zero-ex@0.38.4
 - @0x/contract-addresses@8.0.1
 - @0x/contract-artifacts@3.18.3
 - @0x/contract-wrappers@13.22.14
 - @0x/protocol-utils@11.17.4
2023-01-23 23:46:11 +00:00
Github Actions
033db23929 Updated CHANGELOGS & MD docs 2023-01-23 23:46:08 +00:00
Savarn Dontamsetti (Sav)
891d173705 chore: adding V08 contracts [LIT-783] (#646)
* Adding V08 contracts

* Removing LibSafeMathV08

* Apply suggestions from code review

Co-authored-by: duncancmt <1207590+duncancmt@users.noreply.github.com>
2023-01-23 18:00:43 -05:00
Elena
091a10676c Run linter and formatter on staged files (#620)
* Add lint-staged package

* Add husky and configure it to run lint staged

* Fix the yarn lock file
2023-01-19 09:38:56 +02:00
Elena
0ae6f3e64f Remove manual step for code coverage (#642)
as this is no longer necessary since updating the coveralls upload action in https://github.com/0xProject/protocol/pull/640
2023-01-18 08:26:04 +02:00
wonge97
8197fee50a Update timelock days (#628)
* Update timelock days

* Fix spelling

Co-authored-by: Eric Wong <ewong@Erics-MBP.fios-router.home>
Co-authored-by: elenadimitrova <elena@arenabg.com>
2023-01-17 11:39:33 +02:00
Jacob Evans
ee48d4006b chore: Update rollback script (#580) 2023-01-17 10:54:37 +02:00
Elena
d2be56c30f Code coverage fixes (#640)
* Update coveralls link to point to protocol repo coverage

* Remove obsoleted ignores in .gitignore

* Run forge coverage in CI and upload results to coveralls

* Remove unused wrapper

* Remove legacy coverage setup

* Remove lcov-result-merger

* Add base-path setting to coverallsapp in CI
2023-01-17 10:53:43 +02:00
Elena
c4097e4203 Migrate ZeroEx proxy tests to foundry (#638)
* Implement base instantiation of the ZeroEx proxy in foundry
and move TestZeroExFeature contract to the foundry mocks

* Migrate zero-ex tests to foundry

* Update copyright year

* Update contracts/zero-ex/tests/mocks/TestZeroExFeature.sol

Co-authored-by: Jacob Evans <jacob@dekz.net>

Co-authored-by: Jacob Evans <jacob@dekz.net>
2023-01-12 11:45:33 +02:00
Elena
8f21d167cc Remove truffle (#639)
* Remove truffle config from zero-ex

* Remove truffle config erc20

* Remove obsoleted truffle ignores

* Remove truffle config under utils contracts
2023-01-12 11:26:48 +02:00
Elena
b33fc27220 Migrate FlashWallet tests to foundry (#637)
* Remove contracts/zero-ex/contracts/test/TestBridge.sol

* Move foundry tests to their default location

* Wire up base foundry test and start moving
FlashWallet tests and mocks to foundry

* Move remaining FlashWallet contract tests to foundry

* Switch to foundry default cache config
2023-01-10 15:47:25 +02:00
Elena
dcb17768cc Move repo setup to .github folder (#636) 2023-01-01 08:11:34 +02:00
Mimyo
82907f99a2 Update features.rst (#610)
`NativeLiquidityFeature` should be `NativeOrdersFeature`.
2022-12-28 07:29:45 +02:00
Elena
2e157cc307 Closes https://github.com/0xProject/protocol/issues/485 (#635) 2022-12-26 10:34:18 +02:00
Jacob Evans
3164d7882c fix: Bug Bounty git sha c1177416f5 (#626) 2022-12-26 09:54:20 +02:00
Elena
91587efe2e Replace stale bot (#634)
* Replace stale bot

* Update to latest version
2022-12-23 10:29:03 +02:00
Elena
008f00ba2f Update auto labeller and stale bot for issues and PRs (#631)
* Update message when closing stale issues with the correct duration

* Update autolabeller to correctly label

* Reformat the stale yml and change daysUntilClose to 14
2022-12-21 22:01:35 +02:00
elenadimitrova
0e38b0e54a Fix typo in dependabot yml 2022-12-21 17:33:26 +02:00
elenadimitrova
f6af4abd67 Move dependabot yml to root .github folder 2022-12-21 17:31:27 +02:00
Elena
6dc3084c30 Migrate CI to GitHub actions (#625)
* Update cci scrptisdas

* Add github action workflow for installing the solution

* Add building the solution to github actions

* Add linting and formatting checks to github action

* Add deps to list of prettier ignore

* Add tests for @0x/contracts*

* Add dependency checker tests in CI

* Add checks for markdown issues to CI

* Add foundry tests to CI

* Add Test local @0x/contracts-* to CI

* Add tests for doc generation to CI

* Surgeon out leftover circle references and config

* Fix foundry working-directory

* Switch order of generate docs and checks in CI

* Add dependabot action to github

* Run ci on push ot development branch
2022-12-21 16:27:19 +02:00
Github Actions
fd1f7a8a42 Publish
- @0x/contracts-erc20@3.3.54
 - @0x/contracts-test-utils@5.4.44
 - @0x/contracts-treasury@1.4.37
 - @0x/contracts-utils@4.8.35
 - @0x/contracts-zero-ex@0.38.3
 - @0x/contract-addresses@8.0.0
 - @0x/contract-wrappers@13.22.13
 - @0x/protocol-utils@11.17.3
2022-12-12 21:11:50 +00:00
Github Actions
3a03174a92 Updated CHANGELOGS & MD docs 2022-12-12 21:11:47 +00:00
Kyu
f5e34bce3b Remove Kovan and ArbitrumRinkeby from contract-addresses (#630) 2022-12-12 12:55:04 -08:00
Savarn Dontamsetti (Sav)
3f8dbf3fe9 Removing Balancer V2 from Bridge Adapters (#629) 2022-12-12 10:08:15 -05:00
Savarn Dontamsetti (Sav)
b040e55202 chore: removing Aave V2 and Aave V3 from Fantom (#627)
* Removing Aave V2 and Aave V3 from Fantom

* prettier fix for FantomBridgeAdapter.sol
2022-12-01 14:21:21 -05:00
Github Actions
fe0676cec3 Publish
- @0x/contracts-erc20@3.3.53
 - @0x/contracts-test-utils@5.4.43
 - @0x/contracts-treasury@1.4.36
 - @0x/contracts-utils@4.8.34
 - @0x/contracts-zero-ex@0.38.2
 - @0x/contract-addresses@7.4.1
 - @0x/contract-artifacts@3.18.2
 - @0x/contract-wrappers@13.22.12
 - @0x/protocol-utils@11.17.2
2022-11-23 20:25:30 +00:00
Github Actions
b697202e19 Updated CHANGELOGS & MD docs 2022-11-23 20:25:26 +00:00
Savarn Dontamsetti (Sav)
09bc48671c feat: adding AAVE V3 to selected Bridge Adapters [TKR-659] (#624)
* adding AAVE V3 to selected Bridge Adapters

* prettier fix

* Adding L2 optimizations for Arbitrum and Optimism

* Adding l2 encoded parameters to Aave V3 MixIn

* Removing L2 Encoder interface from MixinAaveV3.sol

* Updating FQT addresses

* prettier fix for MixinAaveV3.sol
2022-11-23 15:09:18 -05:00
Savarn Dontamsetti (Sav)
d31cc43ed6 Revert "feat: adding AAVE V3 to selected Bridge Adapters [TKR-659] (#614)" (#623)
This reverts commit 372f23156b.
2022-11-23 14:49:38 -05:00
Savarn Dontamsetti (Sav)
372f23156b feat: adding AAVE V3 to selected Bridge Adapters [TKR-659] (#614)
* adding AAVE V3 to selected Bridge Adapters

* prettier fix

* Adding L2 optimizations for Arbitrum and Optimism

* Adding l2 encoded parameters to Aave V3 MixIn

* Removing L2 Encoder interface from MixinAaveV3.sol

* Updating FQT addresses
2022-11-23 11:34:55 -05:00
Elena
010a926d79 Upgrade prettier-plugin-solidity to stable v1 (#622)
* Upgrade prettier-plugin-solidity to stable v1

* Prettier format contracts
2022-11-23 11:53:40 +02:00
Elena
0000143b4e Check for broken links in markdown (#621)
* Add check-md package and command

* Remove broken references to TESTING.md

* Fix broken link in contributing.md

* Fix staking docs headings

* Add checks for broken links to CI
2022-11-20 11:59:21 +02:00
Elena
22684ff5ba Switch contributor instructions to use github draft mode for PRs (#618)
instead of WIP title
2022-11-20 11:39:45 +02:00
Elena
4d9b68d527 Removes references to tslint (#619)
* Removes references to tslint in contract-wrappers
which are obsoleted since https://github.com/0xProject/protocol/pull/584

* Remove tslint references in contracts/utils and test utils
obsoleted by https://github.com/0xProject/protocol/pull/589

* Remove tslint references in contracts/zeroex and test utils
obsoleted by https://github.com/0xProject/protocol/pull/587

* Remove other obsoleted tslint references

* Update contributing guidelines with eslint

* Fix prettier errors
2022-11-19 17:52:00 +02:00
Kyu
957853788d chore: Delete asset-swapper [GOV-6] (#617)
* Delete `asset-swapper`

* Remove `package/asset-swapper` in CODEOWNERS
2022-11-15 14:02:33 -08:00
Github Actions
28193479c6 Publish
- @0x/contracts-erc20@3.3.52
 - @0x/contracts-test-utils@5.4.42
 - @0x/contracts-treasury@1.4.35
 - @0x/contracts-utils@4.8.33
 - @0x/contracts-zero-ex@0.38.1
 - @0x/asset-swapper@16.66.19
 - @0x/contract-addresses@7.4.0
 - @0x/contract-wrappers@13.22.11
 - @0x/protocol-utils@11.17.1
2022-11-15 01:50:44 +00:00
Github Actions
70212534a1 Updated CHANGELOGS & MD docs 2022-11-15 01:50:40 +00:00
Kyu
ea9575e94d Update Polygon FillQuoteTransformer to support Solidly (and its forks) (#616) 2022-11-14 16:01:08 -08:00
Elena
ca0b074893 Add Solidity linter (#608)
* Add solhint and basic configuration

* Add solhint-plugin-prettier to run prettier via solhint

* Remove all solhint-disable rules in contracts

* Turn off compiler version errors

* Fix max-line-length linter errors

* Fix linting and prettier issues in contracts

* Add global lint command to run both ts and solidity linter
2022-11-08 16:12:42 +02:00
Github Actions
b3281bfdb1 Publish
- @0x/contracts-erc20@3.3.51
 - @0x/contracts-test-utils@5.4.41
 - @0x/contracts-treasury@1.4.34
 - @0x/contracts-utils@4.8.32
 - @0x/contracts-zero-ex@0.38.0
 - @0x/asset-swapper@16.66.18
 - @0x/contract-addresses@7.3.0
 - @0x/contract-wrappers@13.22.10
 - @0x/protocol-utils@11.17.0
2022-11-05 00:19:12 +00:00
Github Actions
1516bf6a24 Updated CHANGELOGS & MD docs 2022-11-05 00:19:08 +00:00
Kyu
ab19bb41c4 Update fee-related transformer addresses (#615) 2022-11-04 17:02:44 -07:00
Kyu
7368aded88 Rename VelodromeMixin to SolidlyMixin and add Solidly support to PolygonBridgeAdapter (#612) 2022-11-04 14:41:35 -07:00
Github Actions
b1f856e7a4 Publish
- @0x/contracts-erc20@3.3.50
 - @0x/contracts-test-utils@5.4.40
 - @0x/contracts-treasury@1.4.33
 - @0x/contracts-utils@4.8.31
 - @0x/contracts-zero-ex@0.37.10
 - @0x/asset-swapper@16.66.17
 - @0x/contract-addresses@7.2.0
 - @0x/contract-wrappers@13.22.9
 - @0x/protocol-utils@11.16.17
2022-11-02 22:16:58 +00:00
Github Actions
9d42018fc6 Updated CHANGELOGS & MD docs 2022-11-02 22:16:54 +00:00
Noah Khamliche
624cbebe27 added new RFQTV2 compliant fqt (#611)
* added new RFQTV2 compliant fqt

* update changelog
2022-11-02 14:58:36 -07:00
Kyu
4ace7c8c43 fix: Migrate transformers to smart contract compatible unsafeTransformerTransfer [TKR-587] (#594)
* Use `call` instead of `transfer` in `LibERC20Transformer`

* Since `transfer` only forwards 2300 gas it can cause an `out of gas`
revert when the receipient is a smart contract.

* Add `unsafeTransformerTransfer` and migrate `transformers` to use
`unsafeTransformerTransfer` instead of `transformerTransfer`

* Update .prettierignore
2022-10-28 11:39:22 -07:00
Github Actions
66846c8aec Publish
- @0x/contracts-erc20@3.3.49
 - @0x/contracts-test-utils@5.4.39
 - @0x/contracts-treasury@1.4.32
 - @0x/contracts-utils@4.8.30
 - @0x/contracts-zero-ex@0.37.9
 - @0x/asset-swapper@16.66.16
 - @0x/contract-addresses@7.1.0
 - @0x/contract-wrappers@13.22.8
 - @0x/protocol-utils@11.16.16
2022-10-24 20:57:19 +00:00
Github Actions
33e38fd0a1 Updated CHANGELOGS & MD docs 2022-10-24 20:57:15 +00:00
Kyu
5a6df5a39a Add BalancerV2Batch support in Fantom FillQuoteTransformer (#607) 2022-10-24 13:39:06 -07:00
Savarn Dontamsetti (Sav)
592e7d34c9 adding BalancerV2 Batch support for Fantom Bridge Adapter (#606) 2022-10-24 14:15:11 -04:00
Github Actions
1776dbef44 Publish
- @0x/contracts-erc20@3.3.48
 - @0x/contracts-test-utils@5.4.38
 - @0x/contracts-treasury@1.4.31
 - @0x/contracts-utils@4.8.29
 - @0x/contracts-zero-ex@0.37.8
 - @0x/asset-swapper@16.66.15
 - @0x/contract-addresses@7.0.0
 - @0x/contract-wrappers@13.22.7
 - @0x/protocol-utils@11.16.15
2022-10-21 19:43:49 +00:00
Github Actions
089718df33 Updated CHANGELOGS & MD docs 2022-10-21 19:43:46 +00:00
Noah Khamliche
7500ac36de update changelog (#605) 2022-10-21 15:28:33 -04:00
Noah Khamliche
f347f4392c update contract fqt in contract-addresses (#604) 2022-10-21 15:02:23 -04:00
Github Actions
10af74e616 Publish
- @0x/contracts-erc20@3.3.47
 - @0x/contracts-treasury@1.4.30
 - @0x/contracts-utils@4.8.28
 - @0x/contracts-zero-ex@0.37.7
 - @0x/asset-swapper@16.66.14
 - @0x/protocol-utils@11.16.14
2022-10-13 14:12:06 +00:00
Github Actions
cfb2392ac7 Updated CHANGELOGS & MD docs 2022-10-13 14:12:02 +00:00
Kyu
5a2447bef3 Upgrade @0x/contracts-gen (#602) 2022-10-12 17:36:25 -07:00
Noah Khamliche
bf1b5c4257 Fix: FQT otc order encoding logic (#596)
* swap rfq and otc in fillQuoteTransformerDataEncoder to match our enum

* changelog

* fix changelog and move otcOrders field to last in fillQuoteTransformerDataEncoder

* prettier

* move otcOrders array to end of fqtTransformData

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
2022-10-12 17:10:16 -04:00
Github Actions
10916205ab Publish
- @0x/contracts-erc20@3.3.46
 - @0x/contracts-test-utils@5.4.37
 - @0x/contracts-treasury@1.4.29
 - @0x/contracts-utils@4.8.27
 - @0x/contracts-zero-ex@0.37.6
 - @0x/asset-swapper@16.66.13
 - @0x/contract-addresses@6.25.0
 - @0x/contract-wrappers@13.22.6
 - @0x/protocol-utils@11.16.13
2022-10-11 23:45:53 +00:00
Github Actions
69f8fd39f7 Updated CHANGELOGS & MD docs 2022-10-11 23:45:49 +00:00
Kyu
0cc2cdd16e Remove Ropsten and Rinkeby addresses (#597) 2022-10-11 16:29:44 -07:00
Kyu
d207a4267e Update forge-std and fix foundry.toml (#600) 2022-10-11 16:18:21 -07:00
Kyu
e846ed2f34 Replace branch-level Circle CI cache with commit-level cache (#599)
* Branch-level cache does not make sense for `lib` because it needs to be
updated whenever there is a change in TS files.
2022-10-11 10:41:36 -07:00
Elyas
b04455c36f chore: Configure prettier-solidity and run prettier-solidity [TKR-532] (#592)
* add prettier-solidity + config

* run prettier

* update lockfile

* run prettier again

* Prettier missed one /:

* keep bridge adapter the same

* yarn prettier
2022-10-06 11:44:57 -04:00
Github Actions
d06f6c8b4d Publish
- @0x/contracts-erc20@3.3.45
 - @0x/contracts-test-utils@5.4.36
 - @0x/contracts-treasury@1.4.28
 - @0x/contracts-utils@4.8.26
 - @0x/contracts-zero-ex@0.37.5
 - @0x/asset-swapper@16.66.12
 - @0x/contract-addresses@6.24.0
 - @0x/contract-wrappers@13.22.5
 - @0x/protocol-utils@11.16.12
2022-10-05 23:42:44 +00:00
Github Actions
a689e98b0f Updated CHANGELOGS & MD docs 2022-10-05 23:42:41 +00:00
Noah Khamliche
6f72a8e8e3 fix: add balancerV2/batch to optimismBridgeAdapter (#578)
* add balancerV2/batch to optimismBridgeAdapter

* changelog

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
Co-authored-by: Savarn Dontamsetti <sav.dontamsetti@gmail.com>
2022-09-29 12:16:34 -04:00
eobbad
422f83fc99 Chore: Remove Solhint + TSlint clean-up [TKR-585] (#593)
* contracts/ERC20

* remove tslint.json from erc20

* remove tslint.json from test-utils

* remove solhint from treasury

* remove tslint.json from treasury

* remove solhint from utils

* remove tslint.json from utils

* remove solhint from zero-ex

* remove lint-contracts
2022-09-27 14:51:47 -04:00
eobbad
b6597df84f ignore generated wrappers and asset-swapper (#591) 2022-09-26 16:05:55 -04:00
eobbad
c9b1aac8a5 remove scripts from asset swapper (#590) 2022-09-26 12:41:38 -04:00
Ido Kleinman
87f4189e93 chore: Replace TSLint with ESLint in contracts/utils,treasury,test-utils,erc20 (#589)
* replace TSLint with ESLint in contracts-utils

* also contracts/treasury

* also do test-utils

* yarn fix

* fix stuff yarn fix could not fix

* eslint erc20 contracts folder too

* changelogs

* actually zeroex was a different pr

* PR #589 in changelogs

* whitespace

* prettier
2022-09-23 12:39:27 -07:00
Ido Kleinman
390e1b8510 chore: Replace TSLint with ESLint in contracts/zeroex (#587)
* replace tslint with eslint

* config file

* fix linting errors

* changelog

* prettier
2022-09-23 12:39:17 -07:00
Ido Kleinman
5645e87aca chore: add ESLint to package contract wrappers (#584)
* replace tslint with eslint + add eslintrc config

* few more missing packages for eslint

* exclude. now eslint is running (but there are errors)

* correct excludes fixes all the linter issues

* no need for max warnings
2022-09-21 17:20:09 -07:00
eobbad
0daa988996 purge tslint comments (#585) 2022-09-21 19:53:47 -04:00
eobbad
b4d6f74d7b [protocol-utils] tslint->eslint (#582)
* initialize eslint and remove tslint

* change some packages + eslintrc

* run eslint fix

* run prettier

* changelog

* update package.json

* changelog update+prettier
2022-09-21 19:37:25 -04:00
Kyu
2163cb221b Add missing Arbitrum ZeroExGovernor address (#583) 2022-09-21 16:16:28 -07:00
Github Actions
4575300016 Publish
- @0x/contracts-erc20@3.3.44
 - @0x/contracts-test-utils@5.4.35
 - @0x/contracts-treasury@1.4.27
 - @0x/contracts-utils@4.8.25
 - @0x/contracts-zero-ex@0.37.4
 - @0x/asset-swapper@16.66.11
 - @0x/contract-addresses@6.23.4
 - @0x/contract-wrappers@13.22.4
 - @0x/protocol-utils@11.16.11
2022-09-21 19:02:46 +00:00
Github Actions
82341c3b9d Updated CHANGELOGS & MD docs 2022-09-21 19:02:43 +00:00
Noah Khamliche
f89c2d2fed feat: add new fqt address containing nerve mixin (#581)
* add new fqt address containing nerve

* changelog

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
2022-09-21 14:44:55 -04:00
Savarn Dontamsetti (Sav)
09419a7909 Adding Nerve Mixin to Arbitrum Bridge Adapter [TKR-554] (#579)
* adding Nerve Mixin to Arbitrum Bridge Adapter

* refactor bridgeAdapter to include currently deployed changes

* remove duplicate DODOV2

* removing DODO V1 from Arbitrum Bridge Adapter

* updating imports

* fixing CI: ganache tests

* Invalid caching configuration

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
Co-authored-by: Marcin Wolny <marcin@0xproject.com>
2022-09-20 10:54:50 -04:00
Github Actions
1fa093be64 Publish
- @0x/contracts-erc20@3.3.43
 - @0x/contracts-test-utils@5.4.34
 - @0x/contracts-treasury@1.4.26
 - @0x/contracts-utils@4.8.24
 - @0x/contracts-zero-ex@0.37.3
 - @0x/asset-swapper@16.66.10
 - @0x/contract-addresses@6.23.3
 - @0x/contract-wrappers@13.22.3
 - @0x/protocol-utils@11.16.10
2022-09-12 15:56:30 +00:00
Github Actions
8e9f358a02 Updated CHANGELOGS & MD docs 2022-09-12 15:56:27 +00:00
Noah Khamliche
0a2e8fc224 feat: add new fqt for optimism with balancerv2 (#577)
* add new fqt for optimism with balancerv2

* changelog

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
2022-09-09 15:50:23 -04:00
Github Actions
5653ee8f86 Publish
- @0x/contracts-erc20@3.3.42
 - @0x/contracts-test-utils@5.4.33
 - @0x/contracts-treasury@1.4.25
 - @0x/contracts-utils@4.8.23
 - @0x/contracts-zero-ex@0.37.2
 - @0x/asset-swapper@16.66.9
 - @0x/contract-addresses@6.23.2
 - @0x/contract-wrappers@13.22.2
 - @0x/protocol-utils@11.16.9
2022-09-07 14:10:14 +00:00
Github Actions
d180d5325d Updated CHANGELOGS & MD docs 2022-09-07 14:10:11 +00:00
Noah Khamliche
d249042b47 nwe fqt address and changelog (#574)
* nwe fqt address and changelog

* add pr

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
2022-09-07 09:52:42 -04:00
Github Actions
d3a6f79015 Publish
- @0x/contracts-erc20@3.3.41
 - @0x/contracts-test-utils@5.4.32
 - @0x/contracts-treasury@1.4.24
 - @0x/contracts-utils@4.8.22
 - @0x/contracts-zero-ex@0.37.1
 - @0x/asset-swapper@16.66.8
 - @0x/contract-addresses@6.23.1
 - @0x/contract-wrappers@13.22.1
 - @0x/protocol-utils@11.16.8
2022-09-02 19:31:26 +00:00
Github Actions
8c9dc96e5d Updated CHANGELOGS & MD docs 2022-09-02 19:31:23 +00:00
Noah Khamliche
fc0edba46b Fix/new arbitrum bridge adapter (#572)
* added new fqt with new bridge adapter for Arbitrum

* changelog

* changelog add pr

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
2022-09-02 15:16:00 -04:00
Github Actions
37dc99181e Publish
- @0x/contracts-erc20@3.3.40
 - @0x/contracts-test-utils@5.4.31
 - @0x/contracts-treasury@1.4.23
 - @0x/contracts-utils@4.8.21
 - @0x/contracts-zero-ex@0.37.0
 - @0x/asset-swapper@16.66.7
 - @0x/contract-addresses@6.23.0
 - @0x/contract-wrappers@13.22.0
 - @0x/protocol-utils@11.16.7
2022-09-01 15:27:33 +00:00
Github Actions
6efb9f532b Updated CHANGELOGS & MD docs 2022-09-01 15:27:30 +00:00
Noah Khamliche
9b7d88e136 change weth from OPWeth to ARBWeth (#571)
* change weth from OPWeth to ARBWeth

* udpate changelog

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
2022-09-01 11:12:46 -04:00
Noah Khamliche
e51e1f1674 added otc order array to createTranformData (#569)
* added otc order array to createTranformData

* changelog

* fix linting

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
2022-08-31 11:37:50 -04:00
Noah Khamliche
036a263267 prereq code for otc orders in asset-swapper (#565)
* prereq code for otc orders in asset-swapper

* update changelog

* add pr to changelog

Co-authored-by: Noah Khamliche <0xnoah@Noahs-MacBook-Pro-2.local>
2022-08-31 11:08:28 -04:00
Marcin Wolny
1fb44a55b4 Invalid working_directory (#568)
* Invalid working_directory

Invalid working_directory leads to a bug where some of commands are
executed incorrect code version.

* Fix prettier
2022-08-31 16:37:39 +02:00
Kyu
d738eede0e chore: Cleanup contract addresses [TKR-530] (#564)
* Delete unused addresses in addresses.json

* Update contract wrappers

* Update CHANGELOG.json
2022-08-29 20:10:53 +09:00
Github Actions
a99c916100 Publish
- @0x/contracts-erc20@3.3.39
 - @0x/contracts-test-utils@5.4.30
 - @0x/contracts-treasury@1.4.22
 - @0x/contracts-utils@4.8.20
 - @0x/contracts-zero-ex@0.36.6
 - @0x/asset-swapper@16.66.6
 - @0x/contract-addresses@6.22.0
 - @0x/contract-wrappers@13.21.3
 - @0x/protocol-utils@11.16.6
2022-08-25 21:18:21 +00:00
Github Actions
2abb00b5e2 Updated CHANGELOGS & MD docs 2022-08-25 21:18:18 +00:00
eobbad
ef723e6f36 Empty commit 2022-08-25 17:02:48 -04:00
Ido Kleinman
1fc139886e Arbitrum-rinkeby support in AS + contracts-addresses (#552)
* Arbitrum-rinkeby support in AS + contracts-addresses

* fix UniV3 router+quoter addresses to standard ones

* changelog update
2022-08-25 13:51:37 -07:00
Github Actions
2be10bc72f Publish
- @0x/contracts-erc20@3.3.38
 - @0x/contracts-test-utils@5.4.29
 - @0x/contracts-treasury@1.4.21
 - @0x/contracts-utils@4.8.19
 - @0x/contracts-zero-ex@0.36.5
 - @0x/asset-swapper@16.66.5
 - @0x/contract-addresses@6.21.0
 - @0x/contract-wrappers@13.21.2
 - @0x/protocol-utils@11.16.5
2022-08-25 20:34:36 +00:00
Github Actions
abdc02f066 Updated CHANGELOGS & MD docs 2022-08-25 20:34:30 +00:00
eobbad
b7ef5473cd update FQT address on Arbitrum 2022-08-25 15:49:17 -04:00
eobbad
e43cdda22f Arbitrum support (#560)
* Arbitrum support

* fix typo in bridge adapter

* changelog

* remove timestamp from changelog

* fix typo in brige adapter

* add new addresses

* Fix build error

* adjust DodoV2 arguments
2022-08-25 10:37:26 -04:00
Marcin Wolny
416f2ec24c CircleCI candies 🍬 (#550)
* Re-usable cache

By use of branch as a cache key, we invalidate the cache very often.
This leads to incresed builds time. By use of cache based on checksum of
yarn.lock, we may drop the build time.

It will increase the time every time checksum has changed. In our case,
it happens multiple times per month.

* Skip job run if no changes applied

* Skip tests if no changes applied

* Skip tests if no changes applied
2022-08-25 10:08:28 +02:00
Kyu
4f7fe66d74 Fix asset-swapper deprecation notice (#561) 2022-08-24 09:49:46 +09:00
Kyu
eb394383d8 chore: Deprecate asset-swapper [TKR-484] (#559)
* Add asset-swapper deprecation notice in README.md

* Remove asset-swapper references from the top-level README

* Remove asset-swapper from circleci config

* Set asset-swapper private to prevent it from being published

* Remove asset-swapper from `nonContractPackages`

* Disable asset-swapper build and test scripts
2022-08-24 09:30:52 +09:00
Github Actions
92e681f21b Publish
- @0x/contracts-erc20@3.3.37
 - @0x/contracts-test-utils@5.4.28
 - @0x/contracts-treasury@1.4.20
 - @0x/contracts-utils@4.8.18
 - @0x/contracts-zero-ex@0.36.4
 - @0x/asset-swapper@16.66.4
 - @0x/contract-addresses@6.20.1
 - @0x/contract-artifacts@3.18.1
 - @0x/contract-wrappers@13.21.1
 - @0x/protocol-utils@11.16.4
2022-08-22 05:20:31 +00:00
Github Actions
3f65dd6049 Updated CHANGELOGS & MD docs 2022-08-22 05:20:26 +00:00
Jacob Evans
4425c316a3 chore: update packages (#553)
* Update package.jsons to latest tools packages

* Skip tests relying on gasPrice > 0

* Yarn.lock

* Fix linter

* Update Balance checker, new ganache gets more ETH

* Fix new Ganache insufficient assertion string

* Temporarily set QuoteRequestor to skip

* Fix headers Axios now requests with
2022-08-22 14:55:42 +10:00
eobbad
9058839645 WooFi Gas Estimates (#551)
* change gas estimates

* changelog

* remove comments

* fix lerna run lint error
2022-08-16 14:10:53 -04:00
Ido Kleinman
46a7a2e620 Revert "chore: Remove unused addresses in addresses.json [TKR-519] (#548)"
This reverts commit 8aa313a437.
2022-08-11 13:31:47 -07:00
eobbad
b35dccd43d Offboard Cream (#546)
* offboard cream

* changelog

* remove BalancerFillData (unused)
2022-08-10 08:42:43 -04:00
Kyu
08e0c2ebb9 chore: Add checks for addresses.json [TKR-519] (#549) 2022-08-10 17:35:38 +09:00
Kyu
8aa313a437 chore: Remove unused addresses in addresses.json [TKR-519] (#548)
* Delete unused addresses in addresses.json and update index.ts

* Update contract wrappers

* Remove outdated references to `exchange` contract in `asset-swapper`

* Update CHANGELOG.json
2022-08-10 16:59:21 +09:00
Github Actions
8e9699c340 Publish
- @0x/contracts-erc20@3.3.36
 - @0x/contracts-test-utils@5.4.27
 - @0x/contracts-treasury@1.4.19
 - @0x/contracts-utils@4.8.17
 - @0x/contracts-zero-ex@0.36.3
 - @0x/asset-swapper@16.66.3
 - @0x/contract-addresses@6.19.2
 - @0x/contract-wrappers@13.20.8
 - @0x/protocol-utils@11.16.3
2022-08-10 01:12:34 +00:00
Github Actions
939b708e63 Updated CHANGELOGS & MD docs 2022-08-10 01:12:31 +00:00
Kyu
1617e3fc44 Fix Polygon and Ganache FillQuoteTransformer addresses (#547)
* Revert Ganache (1337) FQT address as it was mistakenly updated.
* Update Polygon (137) FQT address with the new one.
2022-08-10 09:43:42 +09:00
Github Actions
e0d705703d Publish
- @0x/contracts-erc20@3.3.35
 - @0x/contracts-test-utils@5.4.26
 - @0x/contracts-treasury@1.4.18
 - @0x/contracts-utils@4.8.16
 - @0x/contracts-zero-ex@0.36.2
 - @0x/asset-swapper@16.66.2
 - @0x/contract-addresses@6.19.1
 - @0x/contract-wrappers@13.20.7
 - @0x/protocol-utils@11.16.2
2022-08-09 19:27:28 +00:00
Github Actions
01a6d933ca Updated CHANGELOGS & MD docs 2022-08-09 19:27:24 +00:00
Kyu
9b9f0b91d7 Move woofi tokens to constant.ts and run prettier (#544) 2022-08-09 13:31:37 +09:00
Ido Kleinman
0d0fef841d PR # 2022-08-08 19:04:04 -05:00
Ido Kleinman
17adfbea32 changelogs 2022-08-08 19:04:04 -05:00
Noah Khamliche
80594622b2 empty commit to run workflow 2022-08-08 18:55:39 -05:00
Ido Kleinman
0dba5a5a3a lowercase addresses (#542) 2022-08-08 16:40:31 -07:00
phil-ociraptor
4dae8de1b6 feat: add Foundry support to contracts/zero-ex (#534)
Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>
2022-08-08 11:46:50 -05:00
eobbad
0046bb26d8 Update WooFi sampler logicand addresses.json w/ new FQT's 2022-08-08 12:27:45 -04:00
Kyu
fe935f787c Use @0x/fast-abi instead of deprecated fast-abi (#540) 2022-08-08 14:34:48 +09:00
Kyu
1b527ffcd8 Clean up Mirror and UST related stuff (#539) 2022-08-08 12:29:33 +09:00
Github Actions
9f5324d9c3 Publish
- @0x/asset-swapper@16.66.1
2022-08-08 02:47:26 +00:00
Github Actions
3647392a04 Updated CHANGELOGS & MD docs 2022-08-08 02:47:21 +00:00
Kyu
1d49662c58 Upgrade fast-abi (#538) 2022-08-08 11:27:44 +09:00
Github Actions
6324b08b4d Publish
- @0x/contracts-erc20@3.3.34
 - @0x/contracts-test-utils@5.4.25
 - @0x/contracts-treasury@1.4.17
 - @0x/contracts-utils@4.8.15
 - @0x/contracts-zero-ex@0.36.1
 - @0x/asset-swapper@16.66.0
 - @0x/contract-addresses@6.19.0
 - @0x/contract-wrappers@13.20.6
 - @0x/protocol-utils@11.16.1
2022-08-06 01:52:58 +00:00
Github Actions
fe73b63aaa Updated CHANGELOGS & MD docs 2022-08-06 01:52:55 +00:00
Kyu
192d0b17d9 Empty commit to trigger CI (something is wrong with Ido's account lol) 2022-08-06 10:34:15 +09:00
Ido Kleinman
aa74d04083 new contract address for goerli verified deploy (#537)
* new contract address for goerli verified deploy

* v6.18.0

* updated addresses for goerli + mumbai to verified contracts

* contract addresses changelog update

* unbump package version
2022-08-05 18:22:06 -07:00
Kyu
d586f5727d Rename Balancer pool cache files (#536) 2022-08-05 17:53:55 +09:00
Kyu
98fc79a085 Upgrade dependencies in asset-swapper to match the versions used in 0x-api [TKR-484] (#535)
* Upgrade dependencies to match the versions used in 0x-api

* Fix/disable tslint issues from the new version
2022-08-05 14:26:18 +09:00
eobbad
c12a10b96e Add WooFI support (#513)
* Add WooFI interface for sampling

* WooFi Sampler

* Add mixin

* Update bridge adapters

* fix some bugs

* update transformer_utils

* Add BSC support

* yarn prettier

* Capitalize WOOFI in bridge adapters

* Put rebateAddress in a constant, fixed some other stylistic errors

* bug fixes

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/contracts-erc20@3.3.33
 - @0x/contracts-test-utils@5.4.24
 - @0x/contracts-treasury@1.4.16
 - @0x/contracts-utils@4.8.14
 - @0x/contracts-zero-ex@0.36.0
 - @0x/asset-swapper@16.64.0
 - @0x/contract-addresses@6.17.0
 - @0x/contract-wrappers@13.20.5
 - @0x/protocol-utils@11.16.0

* Update reference.mdx (#531)

Align with `DEFAULT_QUOTE_SLIPPAGE_PERCENTAGE` value from c74e31c219/src/constants.ts (L26)

* code cleanup

* remove deusdc curve pool from this pr

* Refactor PoolsCache (part 1) [TKR-500] (#525)

* Make _refreshPoolCacheIfRequiredAsync type-safe and remove Promise.all

* Factor out PoolsCache key logic into a function

* Use Map instead of object in PoolsCache and increase the default timeout

* Clean up PoolsCache and simplify its public interface

* Refactor PoolsCache (part 2) [TKR-500]  (#526)

* Introduce NoOpPoolsCache and use it in unsupported chains for BeethovenX

* Use `NoOpPoolsCache` for `CreamPoolsCache` and `BalancerPoolsCache` on unsupported chains

* Remove `getBidAskLiquidityForMakerTakerAssetPairAsync` (#528)

* Add transfer approval for quote token for multi-hops and fix buy sampler typo

* Use 0x gas api instead of eth gas station api [TKR-502] (#532)

* Use 0x gas api instead of eth gas station api

* Add integration test for `ProtocolFeeUtils`

* Update CHANGELOG.json

* Add polygon, fantom, avalanche support

* yarn prettier

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/asset-swapper@16.65.0

* Remove references to `custom-no-magic-numbers` ts lint rule [TKR-484] (#533)

* Remove references to `custom-no-magic-numbers ts` lint rule

* Run prettier

* resolve Kyu's comments

* remove fqt change

* Add WooFI interface for sampling

* WooFi Sampler

* Add mixin

* Update bridge adapters

* fix some bugs

* update transformer_utils

* Add BSC support

* yarn prettier

* Capitalize WOOFI in bridge adapters

* Put rebateAddress in a constant, fixed some other stylistic errors

* bug fixes

* code cleanup

* remove deusdc curve pool from this pr

* Add transfer approval for quote token for multi-hops and fix buy sampler typo

* Add polygon, fantom, avalanche support

* yarn prettier

* resolve Kyu's comments

* remove fqt change

* merge types.ts

* WOOFi -> WOOFI

* fix lerna run lint

* Changelog

* nit changes

Co-authored-by: Github Actions <github-actions@github.com>
Co-authored-by: Pavel <51318041+pavel-bc@users.noreply.github.com>
Co-authored-by: Kyu <kyuhyun217@gmail.com>
2022-08-03 15:54:09 -04:00
Kyu
d3d4a08f91 Remove references to custom-no-magic-numbers ts lint rule [TKR-484] (#533)
* Remove references to `custom-no-magic-numbers ts` lint rule

* Run prettier
2022-08-01 17:50:40 -07:00
Github Actions
9ce090c8cd Publish
- @0x/asset-swapper@16.65.0
2022-08-01 22:10:47 +00:00
Github Actions
980d60deb8 Updated CHANGELOGS & MD docs 2022-08-01 22:10:42 +00:00
Kyu
d6d79e51e7 Use 0x gas api instead of eth gas station api [TKR-502] (#532)
* Use 0x gas api instead of eth gas station api

* Add integration test for `ProtocolFeeUtils`

* Update CHANGELOG.json
2022-08-01 14:42:45 -07:00
Kyu
3ef5de93bb Remove getBidAskLiquidityForMakerTakerAssetPairAsync (#528) 2022-07-28 09:26:07 -07:00
Kyu
ab7dc33ca4 Refactor PoolsCache (part 2) [TKR-500] (#526)
* Introduce NoOpPoolsCache and use it in unsupported chains for BeethovenX

* Use `NoOpPoolsCache` for `CreamPoolsCache` and `BalancerPoolsCache` on unsupported chains
2022-07-28 09:12:02 -07:00
Kyu
14dcee5bb6 Refactor PoolsCache (part 1) [TKR-500] (#525)
* Make _refreshPoolCacheIfRequiredAsync type-safe and remove Promise.all

* Factor out PoolsCache key logic into a function

* Use Map instead of object in PoolsCache and increase the default timeout

* Clean up PoolsCache and simplify its public interface
2022-07-28 09:04:42 -07:00
Pavel
9856e78609 Update reference.mdx (#531)
Align with `DEFAULT_QUOTE_SLIPPAGE_PERCENTAGE` value from c74e31c219/src/constants.ts (L26)
2022-07-27 12:35:16 -07:00
Github Actions
2801b066b3 Publish
- @0x/contracts-erc20@3.3.33
 - @0x/contracts-test-utils@5.4.24
 - @0x/contracts-treasury@1.4.16
 - @0x/contracts-utils@4.8.14
 - @0x/contracts-zero-ex@0.36.0
 - @0x/asset-swapper@16.64.0
 - @0x/contract-addresses@6.17.0
 - @0x/contract-wrappers@13.20.5
 - @0x/protocol-utils@11.16.0
2022-07-27 19:32:19 +00:00
Github Actions
5bc8b13fc3 Updated CHANGELOGS & MD docs 2022-07-27 19:32:17 +00:00
Kyu
36dba8f5be Update FQT addresses on mainnet and Optimism (#530) 2022-07-27 09:56:50 -07:00
Kyu
ee2c069889 Remove Mooniswap on Ethereum Mainnet (#529)
* Remove Mooniswap from EthereumBridgeAdapter

* Remove Mooniswap sampling on mainnet

* Update CHANGELOG.json
2022-07-27 08:09:27 -07:00
Kyu
6ca14ed7b2 Fix Beethoven X Cache Issue [TKR-486] (#519)
* Replace Beethoven X subgraph url and add a test

* Simplify PoolsCacheMap type

* Make `BalancerV2PoolsCache` optional for Beethoven X

* Update CHANGELOG.json
2022-07-26 09:54:05 -07:00
Kyu
a5babb9a34 Add Synthetix Atomic Swap support [TKR-324] (#518)
* Implement SyntehtixSampler

* Implement MixinSynthetix

* Update transformer_utils.ts

* Add Synthetix mainnet support

* Add Synthetix optimism support

* Fine-tune gas schedule

* Pass read proxy dynamically to SynthetixSampler

* Pass read proxy dynamically to SynthetixMixin

* Fetch Synthetix address from sampler

* Pass Synthetix address directly to MixinSynthetix

* Update CHANGELOG.json
2022-07-25 21:17:27 -07:00
Kyu
661cc4669d Fix formatting 2022-07-22 16:25:31 -07:00
Ido Kleinman
553ba5c868 Add Goerli and Mumbai liquidity and support [TKR-493] (#523)
* deployment contract addresses on goerli

* add Goerli chainID and liquidity support for Sushi, Uni1,2,3

* UniV1 fix for Goerli

* add UniV3 to Mumbai

* remove comments

* lowercase addresses

* update contract-addresses package version

* reset package.json's states
2022-07-22 16:12:58 -07:00
Kyu
d03d2f254d Remove unused dependencies in asset-swapper [TKR-484] (#521)
* Remove unused dependencies

* Remove unused devDependencies
2022-07-19 16:44:40 -07:00
Kyu
feb91a04b0 Fix typos in GMX sampling logic (#520) 2022-07-19 16:18:37 -07:00
Kyu
4d63f33aba Update CODEOWNERS (#522) 2022-07-19 16:09:42 -07:00
Kyu
b72b8b5ffd Refactor TokenAdjacency and TokenAdjacencyBuilder [TKR-324] (#517)
* Add a new TokenAdjacencyGraph implementation

* Replace old TokenAdjacencyGraph with new implementation

* Simplify token adjacency graph in constants.ts

* Fix lint error

* Update CHANGELOG.json
2022-07-18 13:02:56 -07:00
Github Actions
f7cb7a0f51 Publish
- @0x/asset-swapper@16.63.1
2022-07-12 21:26:51 +00:00
Github Actions
9fcb28f5d8 Updated CHANGELOGS & MD docs 2022-07-12 21:26:48 +00:00
Kyu
982173471c Wrap balancer fetch top pools with try and catch [TKR-481] (#515)
* Wrap balancer fetch top pool with try and catch

* Update CHANGELOG.json
2022-07-12 13:50:07 -07:00
Github Actions
e77958425f Publish
- @0x/asset-swapper@16.63.0
2022-06-29 08:36:38 +00:00
Github Actions
6af4d71573 Updated CHANGELOGS & MD docs 2022-06-29 08:36:34 +00:00
Jacob Evans
ee985240fb chore: FillAdjustor and clean up JS router and unused functions [TKR-403] (#480)
* Remove old JS router and add a FillAdjustor

Clean up JS router and unused functions

Remove more unused functions, add adjustment of fills

Comment on why we use fill over sample

update CODEOWNERS

lint

Clean up Fill removing unused properties

Remove CollapsedFills, omit flags bigint

Create GasSchedule vs FeeSchedule, return Fill and gas on OptimizedOrder

Use Fill Adjustment in Phase2 of routing

Fix Limit orders being treated as VIP

* Fix case where dex liquidity is empty

* Use best gas adjusted pricing for fee sources

* CHANGELOG
2022-06-29 18:10:56 +10:00
eobbad
2aadbda527 Offboard Smoothy and ComethSwap (#509)
* Offboard ComethSwap

* offboard smoothy

* Changelog + yarn prettier
2022-06-22 18:36:52 +02:00
Github Actions
297c73abcc Publish
- @0x/asset-swapper@16.62.1
2022-06-15 00:40:27 +00:00
Github Actions
4c9e1b21ec Updated CHANGELOGS & MD docs 2022-06-15 00:40:24 +00:00
Kyu
41685d1545 Empty commit to trigger CI 2022-06-14 17:16:23 -07:00
Ido Kleinman
b9c25112ed Remove nUSD from intermediate liquidity to save on sampler gas (#505)
* remote nUSD from intermediate liquidity

* changelog
2022-06-14 16:07:47 -07:00
Github Actions
f0738fc122 Publish
- @0x/contracts-erc20@3.3.32
 - @0x/contracts-test-utils@5.4.23
 - @0x/contracts-treasury@1.4.15
 - @0x/contracts-utils@4.8.13
 - @0x/contracts-zero-ex@0.35.0
 - @0x/asset-swapper@16.62.0
 - @0x/contract-addresses@6.16.0
 - @0x/contract-wrappers@13.20.4
 - @0x/protocol-utils@11.15.0
2022-06-14 22:16:09 +00:00
Github Actions
42baf504b7 Updated CHANGELOGS & MD docs 2022-06-14 22:16:07 +00:00
Kyu
56038d122f Update Ethereum and Optimism FQT addresses (#504) 2022-06-14 14:45:26 -07:00
eobbad
c4446b6c0e Offboard Jetswap, CafeSwap, JulSwap, and PolyDex (#503)
* Offboard Jetswap

* Offboarded CafeSwap

* Offboarded JulSwap

* Offboarded PolyDex

* Changelog

* Update changelog

* Changelog update
2022-06-14 23:05:53 +02:00
eobbad
eaed2958c3 KnightSwap and Mdex cosmetic changes (#502)
* Lowercased KnightSwap and MDEX router address

* Changelog.JSON
2022-06-14 14:45:47 +02:00
Jorge Pérez
a045a3afb8 Chore: Do not send empty entries on Quote Report (#501)
* Chore: Do not send empty entries on Quote Report

* Changelog
2022-06-13 15:52:59 -05:00
Kyu
1cc59ab1ab feat: Add Velodrome support [TKR-432] (#494)
* Implement MixinVelodrome

* Add preliminary implementation of VelodromeSampler

* Add Velodrome in BridgeProtocol of transformer_utils.ts

* Fix MixinVelodrome

* Wire Velodrome sampler in market_operation_utils

* Fix lint error

* Remove gas schedule TODO

* Format VelodromeSampler.sol

* Fix MixinVelodrome

* Update CHANGELOG.json
2022-06-13 11:55:40 -07:00
Kyu
2c6a714b71 Fix a lint error in CHANGELOG.json 2022-06-13 10:41:58 -07:00
Kyu
d8c97d6720 Fix a lint error introduced in earlier PRs 2022-06-13 09:09:13 -07:00
eobbad
d6bc702550 Add KnightSwap on BSC (#498)
* Curve pool script to generate pools and their info. Still need to integrate into API

* Added MDEX to BSC

* Removed curve automation scripts from this PR

* Fixed typo

* Changelog

* fix formatting

* Fixed yarn lint

* Add KnightSwap

* Changelog

* update changelog

* changelog again...
2022-06-10 16:57:42 +02:00
eobbad
2838cb9420 Add MDEX support (BSC) [TKR-426] (#496)
* Curve pool script to generate pools and their info. Still need to integrate into API

* Added MDEX to BSC

* Removed curve automation scripts from this PR

* Fixed typo

* Changelog

* fix formatting

* Fixed yarn lint
2022-06-10 14:14:08 +02:00
Github Actions
b10cfc50d3 Publish
- @0x/contracts-erc20@3.3.31
 - @0x/contracts-test-utils@5.4.22
 - @0x/contracts-treasury@1.4.14
 - @0x/contracts-utils@4.8.12
 - @0x/contracts-zero-ex@0.34.0
 - @0x/asset-swapper@16.61.0
 - @0x/contract-addresses@6.15.0
 - @0x/contract-wrappers@13.20.3
 - @0x/protocol-utils@11.14.0
2022-06-03 19:20:52 +00:00
Github Actions
2e6317b01e Updated CHANGELOGS & MD docs 2022-06-03 19:20:49 +00:00
Noah Khamliche
50e99e6eac address comments 2022-06-03 15:03:00 -04:00
Noah Khamliche
8f2f4554eb fix linting 2022-06-03 15:03:00 -04:00
Noah Khamliche
67d9678a3a fix linting 2022-06-03 15:03:00 -04:00
Noah Khamliche
f70341fb48 rebase development 2022-06-03 15:03:00 -04:00
Megan
14cd24ea47 feat/add MeshSwap on Polygon [TKR-374] (#491)
* Added MeshSwap on Polygon

* Updated changelog
2022-06-03 15:03:00 -04:00
Noah Khamliche
78328056d7 Added BancorV3 to fqt, and added support in asset-swapper 2022-06-03 15:03:00 -04:00
Noah Khamliche
0045a60b0f updated contract-addresses with new ethereum fqt 2022-06-03 15:03:00 -04:00
Noah Khamliche
e4e71c76e1 add weth/eth wrap/unwrap support for bancorv3 2022-06-03 15:03:00 -04:00
Megan
ca8127545f feat/add MeshSwap on Polygon [TKR-374] (#491)
* Added MeshSwap on Polygon

* Updated changelog
2022-06-03 15:03:00 -04:00
Noah Khamliche
7b709089ce fix versioning issue on protocol-utils 2022-06-03 15:03:00 -04:00
Noah Khamliche
190f7e45f2 final changes 2022-06-03 15:03:00 -04:00
Noah Khamliche
0dcc3a6fc3 nitpicks 2022-06-03 15:03:00 -04:00
Noah Khamliche
c2e8cae293 added changelog entries 2022-06-03 15:03:00 -04:00
Noah Khamliche
83da7caab4 fixed bancor sell quotes 2022-06-03 15:03:00 -04:00
Noah Khamliche
fd69a0c273 added weth/eth support to sampler 2022-06-03 15:03:00 -04:00
Noah Khamliche
9b131199ad add weth/eth wrap/unwrap support for bancorv3 2022-06-03 15:03:00 -04:00
Noah Khamliche
f5c486050b added bancor mixin/sampler and started linking up with asset-swapper 2022-06-03 15:03:00 -04:00
Megan
1f41fe6a20 feat/add MeshSwap on Polygon [TKR-374] (#491)
* Added MeshSwap on Polygon

* Updated changelog
2022-06-02 19:11:25 +02:00
Kyu
7f4080e0a2 Delete packages/migrations (#488)
* Delete packages/migrations

* Remove 0x/migrations from asset-swapper dev dependency

* Remove 0x/migrations references
2022-06-02 10:00:50 -07:00
Kyu
db76da58d7 Add stETH wrap/unwrap support [TKR-377] (#476)
* Update MixinLido to support stETH wrapping/unwrapping

* Update LidoSampler and asset-swapper

* Re-use token address constants in LIDO_INFO_BY_CHAIN

* Update CHANGELOG.json

* Add stETH <-> wstETH to TokenAdjacencyGraph

* Change lido gas schedule code style

* Move allowance approval inside the wrap branch

* Refactor LidoSampler to reduce its bytecode size
2022-05-31 09:58:44 -07:00
mzhu25
cf8fc0ff8e Split up BridgeAdapter by chain [TKR-402] (#487)
* Split up BridgeAdapter by chain

* Fix BridgeProtocols enum

* Add isSupportedSource to bridge adapter contracts

* Add bridge adapter tests

* Fix FQT test
2022-05-25 14:18:24 -04:00
Kyu
2d16f83e37 Offboard/clean up Oasis, CoFix, and legacy Kyber [TKR-405] (#482)
* Remove Oasis

* Remove CoFix code

* Remove MixinKyber

* Remove Kyber from asset-swapper

* Delete unused imports, interface, and etc.

* Fix the test failure issue when it's run with neon-router

* Update CHANGELOG.json
2022-05-19 17:39:02 -07:00
Github Actions
4057bdab91 Publish
- @0x/asset-swapper@16.60.1
2022-05-19 03:40:00 +00:00
Github Actions
1cd10f0ac9 Updated CHANGELOGS & MD docs 2022-05-19 03:39:57 +00:00
Jacob Evans
68f87b2432 fix: BalancerV2 sor alias (#481)
* Install both Balancer sor and rename early version to v1

* yarn.lock

* CHANGELOG
2022-05-19 13:19:25 +10:00
Github Actions
69bafc3bcd Publish
- @0x/contracts-erc20@3.3.30
 - @0x/contracts-test-utils@5.4.21
 - @0x/contracts-treasury@1.4.13
 - @0x/contracts-utils@4.8.11
 - @0x/contracts-zero-ex@0.33.0
 - @0x/asset-swapper@16.60.0
 - @0x/contract-addresses@6.14.0
 - @0x/contract-wrappers@13.20.2
 - @0x/migrations@8.1.19
 - @0x/protocol-utils@11.13.0
2022-05-19 00:21:50 +00:00
Github Actions
2c44b06b7b Updated CHANGELOGS & MD docs 2022-05-19 00:21:47 +00:00
Kyu
0233f00b4e Increase KyberDMM base gas [TKR-317] (#479)
* Increase KyberDMM base gas

* Update CHANGELOG.json
2022-05-18 17:00:11 -07:00
Kyu
fedb53187d Add Yoshi Exchange support (Fantom) [TKR-270] (#473)
* Resolve conflicts

* Update CHANGELOG.json
2022-05-18 16:58:41 -07:00
Noah Khamliche
6774d2f588 prettier and lint everything 2022-05-18 19:53:50 -04:00
Noah Khamliche
cf740b74f5 removed extraneous comments in sampler 2022-05-18 19:53:50 -04:00
Noah Khamliche
177c00463a comments and nits 2022-05-18 19:53:50 -04:00
Noah Khamliche
49b0e32129 added address ref from AVALANCHE_TOKENS for mim instead of raw address 2022-05-18 19:53:50 -04:00
Noah Khamliche
938fc94756 final deployments and updates for bridge adapter and fqt on avax/bsc 2022-05-18 19:53:50 -04:00
Noah Khamliche
1561d91c2b added changelog entries 2022-05-18 19:53:50 -04:00
Noah Khamliche
9a28e51f51 rebased dev and merged 2022-05-18 19:53:50 -04:00
Ido Kleinman
f55eaa867b Add BiSwap (as UniV2 clone) on BSC (#471)
* Add BiSwap (as UniV2 clone) on BSC

* changelog PR number

* add BSW

* remove BiSwap from transformer_utils

* Do not initialize BalancerV2SwapInfoCache on unsupported chains [TKR-365] (#472)

* Do not initialize BalancerV2SwapInfoCache on unsupported chains
* Update CHANGELOG.json

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/asset-swapper@16.57.3

* chore: Decomission SnowSwap [TKR-356] (#468)

* Decomission SnowSwap

* SnowSwap doesn't have much liquidity anymore (the largest pool has ~$50k)

* Update CHANGELOG.json

* Update CHANGELOG.json

* chore: Offboard Swerve Finance and LinkSwap [TKR-356] (#469)

* Offboard swerve

* Update CHANGELOG.json

* Offboard LinkSwap

* Remove unused import

* Fix CHANGELOG.json

* chore: Offboard Eth2Dai [TKR-356] (#470)

* Offboard Eth2Dai

* Update CHANGELOG.json

* feat: add IRfqClient (#467)

* add message to changelog for #467 (#474)

* Update saddle mainnet pools (#450)

* Add saddle v2 pools

* remove outdated pools

* add two saddle meta pools

* forgot changelog

* remove saddle metapools

* changelog update

* Fix a lint issue (#475)

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/asset-swapper@16.59.0

* Add BiSwap (as UniV2 clone) on BSC

* rebase new changes for balv2, up changelog, quotes working

* remove Biswap from transformer_utils once again

Co-authored-by: Kyu <kyuhyun217@gmail.com>
Co-authored-by: Github Actions <github-actions@github.com>
Co-authored-by: phil-ociraptor <phil@0x.org>
Co-authored-by: Cece Z <me@cecez.xyz>
Co-authored-by: Noah Khamliche <noah@0xproject.com>
2022-05-16 17:11:23 -07:00
Github Actions
6b2856424a Publish
- @0x/asset-swapper@16.59.0
2022-05-13 00:07:18 +00:00
Github Actions
da757c4700 Updated CHANGELOGS & MD docs 2022-05-13 00:07:16 +00:00
Kyu
75e6654884 Fix a lint issue (#475) 2022-05-12 16:49:10 -07:00
Cece Z
87308e7693 Update saddle mainnet pools (#450)
* Add saddle v2 pools

* remove outdated pools

* add two saddle meta pools

* forgot changelog

* remove saddle metapools

* changelog update
2022-05-12 18:59:55 -04:00
phil-ociraptor
d5eef93a76 add message to changelog for #467 (#474) 2022-05-11 22:17:17 -05:00
phil-ociraptor
a7f23a982e feat: add IRfqClient (#467) 2022-05-11 12:35:05 -05:00
Kyu
9eadc5fc28 chore: Offboard Eth2Dai [TKR-356] (#470)
* Offboard Eth2Dai

* Update CHANGELOG.json
2022-05-10 13:54:28 -07:00
Kyu
92ad1a612e chore: Offboard Swerve Finance and LinkSwap [TKR-356] (#469)
* Offboard swerve

* Update CHANGELOG.json

* Offboard LinkSwap

* Remove unused import

* Fix CHANGELOG.json
2022-05-10 13:13:18 -07:00
Kyu
09413c0e12 chore: Decomission SnowSwap [TKR-356] (#468)
* Decomission SnowSwap

* SnowSwap doesn't have much liquidity anymore (the largest pool has ~$50k)

* Update CHANGELOG.json

* Update CHANGELOG.json
2022-05-10 09:55:43 -07:00
Github Actions
23788b41d5 Publish
- @0x/asset-swapper@16.57.3
2022-05-10 01:41:10 +00:00
Github Actions
ccf999a495 Updated CHANGELOGS & MD docs 2022-05-10 01:41:06 +00:00
Kyu
aa1016ee5f Do not initialize BalancerV2SwapInfoCache on unsupported chains [TKR-365] (#472)
* Do not initialize BalancerV2SwapInfoCache on unsupported chains
* Update CHANGELOG.json
2022-05-09 18:21:04 -07:00
Github Actions
423ef57344 Publish
- @0x/asset-swapper@16.57.2
2022-05-02 21:22:37 +00:00
Github Actions
c18149e82f Updated CHANGELOGS & MD docs 2022-05-02 21:22:33 +00:00
Jorge Pérez
d14aebf724 Fix the filter for considered sources on indicative sells for Quote Report (#466) 2022-05-02 15:45:15 -05:00
Kyu
ba719a9631 Add cvxfxs-fxs curve pool on Ethereum mainnet (#465)
* Add cvxfxs-fxs curve pool on Ethereum mainnet

* Update CHANGELOG.json

* Fix an existing formatting issue

* Adjust gasSchedule and merge the change under 16.57.1
2022-04-27 17:07:36 -07:00
eobbad
d36034d958 chore/ANY-QUICK on polygon MAG-MIM on avax (#464)
* Added ANY/QUICK pair on Polygon

* Updated changelog.json

* Update CHANGELOG.json
2022-04-26 10:55:03 -04:00
Github Actions
7750c57620 Publish
- @0x/contracts-erc20@3.3.29
 - @0x/contracts-test-utils@5.4.20
 - @0x/contracts-treasury@1.4.12
 - @0x/contracts-utils@4.8.10
 - @0x/contracts-zero-ex@0.32.0
 - @0x/asset-swapper@16.57.0
 - @0x/contract-addresses@6.13.0
 - @0x/contract-wrappers@13.20.1
 - @0x/migrations@8.1.18
 - @0x/protocol-utils@11.12.0
2022-04-22 07:05:10 +00:00
Github Actions
4d027e11d1 Updated CHANGELOGS & MD docs 2022-04-22 07:05:06 +00:00
Lawrence Forman
470e9a4697 AS: Balancer V2 batchSwap (#462)
* Draft. PoC pseudo code showing general idea for resuing SOR path creation logic and adding multihop support.

* Add actual Balancer SDK function calls.

* Update to handle buys.

* Correct taker>maker for buy.

* Draft. PoC pseudo code showing general idea for resuing SOR path creation logic and adding multihop support.

* make it build

* rebase

* add BalancerV2Batch protocol

* add BalancerV2Batch protocol

* get balancer v2 multihop working

* fix BalancerV2Batch for sells (buys still iffy)

* fix buys, appease linter and prettier

* remove unused RPC URL from balancer sdk construction

* update changelogs

* clean up comments
add event loop yield in `BalancerV2SwapInfoCache.loadTopPools()`

* add negative result check on balancerv2batch swap output

* compiler hack

* reintroduce CompilerHack

* delete unused multibridge sampler

* remove compilerhack

* reintroduce compilerhack

* try to fix CI compile errors

* plz work

* plz work

* pretty plz work

* yay it works, also address feedback

* appease linter

* deploy new FQTs

Co-authored-by: johngrantuk <johngrantuk@googlemail.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2022-04-22 02:43:41 -04:00
Github Actions
7c51412e2f Publish
- @0x/asset-swapper@16.56.0
2022-04-21 21:16:27 +00:00
Github Actions
b3d1f3cd10 Updated CHANGELOGS & MD docs 2022-04-21 21:16:23 +00:00
mzhu25
389bb77439 Add estimatedGas to ExtendedQuoteReport (#463) 2022-04-21 13:52:13 -07:00
Github Actions
4327885a00 Publish
- @0x/asset-swapper@16.55.0
2022-04-07 16:07:52 +00:00
Github Actions
0aef0afbbb Updated CHANGELOGS & MD docs 2022-04-07 16:07:49 +00:00
Lawrence Forman
fa4c3a4f5f fix quote consumer RFQ VIP code path not checking if transfromERC20 is required (#461)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2022-04-07 11:58:07 -04:00
Github Actions
1d7c527c5c Publish
- @0x/asset-swapper@16.54.0
2022-04-06 03:26:22 +00:00
Github Actions
cbe3135e4b Updated CHANGELOGS & MD docs 2022-04-06 03:26:18 +00:00
Lawrence Forman
955ad49711 add real VIP support for eligible RFQT swaps (#458)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2022-04-05 23:00:12 -04:00
Github Actions
8d6f6e76e0 Publish
- @0x/contracts-erc20@3.3.28
 - @0x/contracts-test-utils@5.4.19
 - @0x/contracts-treasury@1.4.11
 - @0x/contracts-utils@4.8.9
 - @0x/contracts-zero-ex@0.31.2
 - @0x/asset-swapper@16.53.0
 - @0x/contract-addresses@6.12.1
 - @0x/contract-artifacts@3.18.0
 - @0x/contract-wrappers@13.20.0
 - @0x/migrations@8.1.17
 - @0x/protocol-utils@1.11.2
2022-03-31 15:09:24 +00:00
Github Actions
9337115650 Updated CHANGELOGS & MD docs 2022-03-31 15:09:21 +00:00
Kim Persson
fa45a44fe4 fix: use Node 16 for publish GH action (#457) 2022-03-31 16:47:02 +02:00
Kim Persson
c9c7ac8559 feat: add block number to quote report data [TKR-314] (#448)
* feat: add blockNumber to MarketSideLiquidity response

* fix: return block number back in swap quote response

* chore: add asset-swapper changelog entry
2022-03-31 15:42:34 +02:00
Kim Persson
c881723578 feat: use neon-router in CI tests (#453)
* fix: initially skip all tests that don't work with the Rust router

* fix: enable rust router for CircleCI tests

* fix: handle invalid output sampels & enable numSamples tests

* chore: add comments about disabled tests

* chore: add asset-swapper changelog entry
2022-03-31 14:32:59 +02:00
Kim Persson
c9c30d3a76 chore: bump ts version to solve type issue with ethereumjs (#455) 2022-03-31 13:55:17 +02:00
Noah Khamliche
73dfdb5b69 fixed gas estimation and removed hint from intermediate tokens 2022-03-21 14:51:23 -04:00
Noah Khamliche
e638268f94 updated routing 2022-03-21 14:51:23 -04:00
Noah Khamliche
0bfd765481 updating changelog 2022-03-21 14:51:23 -04:00
Noah Khamliche
1f12893735 fixing routing 2022-03-21 14:51:23 -04:00
Noah Khamliche
dd3d9337c4 Added Stargate curve pool 2022-03-21 14:51:23 -04:00
Lawrence Forman
904214f4a8 ugprade tools deps and regenerate wrappers (#449)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2022-03-16 12:14:31 -04:00
Noah Khamliche
64c090c4b4 removed local bignumber resolution 2022-03-10 21:22:28 -05:00
Noah Khamliche
e24474f152 lint and prettier 2022-03-10 21:22:28 -05:00
Noah Khamliche
29fa408256 final nitpicks 2022-03-10 21:22:28 -05:00
Noah Khamliche
1b94cc68af fixed gas schedule 2022-03-10 21:22:28 -05:00
Noah Khamliche
f5b4bb3035 removed low liquidity pools, and fixed some routing 2022-03-10 21:22:28 -05:00
Noah Khamliche
afd880f28c poolAddress -> NULL_ADDRESS for consitent types 2022-03-10 21:22:28 -05:00
Noah Khamliche
cd14cdd168 fixed lint 2022-03-10 21:22:28 -05:00
Noah Khamliche
c8ff53a75f fixed mobius common argument abstraction 2022-03-10 21:22:28 -05:00
Noah Khamliche
6d08add20b minimized reused code for mobius pairs 2022-03-10 21:22:28 -05:00
Noah Khamliche
29f9c725e3 bump changelog to version after feat/BTRFLYCurve 2022-03-10 21:22:28 -05:00
Noah Khamliche
a83453f07f prettier and lint 2022-03-10 21:22:28 -05:00
Noah Khamliche
ae365ce92c finished off mobius money pairs 2022-03-10 21:22:28 -05:00
Noah Khamliche
77a592e891 added mobius config for celo and some inital test pools 2022-03-10 21:22:28 -05:00
Github Actions
9a1df67d6b Publish
- @0x/asset-swapper@16.51.0
2022-03-10 04:58:07 +00:00
Github Actions
4b91411faf Updated CHANGELOGS & MD docs 2022-03-10 04:58:04 +00:00
Jacob Evans
622a542d57 feat: Curve YFI-ETH (#444)
* feat: Curve YFI-ETH

* CHANGELOG
2022-03-10 14:36:59 +10:00
Github Actions
cba53a9a50 Publish
- @0x/asset-swapper@16.50.3
2022-03-09 14:59:25 +00:00
Github Actions
e186f27f63 Updated CHANGELOGS & MD docs 2022-03-09 14:59:22 +00:00
Kim Persson
4cd767ecb8 feat: VIP routing in the router, don't create fallback orders for native [TKR-243] (#440)
* feat: calculate all routes and VIP only routes in a single router call

* fix: Try to disable using fallback orders for quotes with native orders

* fix: create VIP sources set once per routing call

* chore: use private publish version of neon-router to test

* chore(lint): comment out unused fn _addOptionalFallbackAsync

* chore: update to latest private publish of neon-router

* refactor: fix router metrics beforeTimeMs naming

* feat: don't recompute isVip for ever sample of a source

* chore: update neon-router to real published version

* fix: merge conflict resolution issue

* chore: add asset-swapper changelog entry
2022-03-09 15:39:47 +01:00
Shawn
f6e85aedf1 Fix/routing glue optimization (#439)
* fix: only create fills if using js router, remove `unoptimizedPath`

* minor optimizations

* remove the cap of route output in buys

* change PR number

* fix: Update Ropsten UniswapV3 Router address (#441)

* fix: Update Ropsten UniswapV3 Router address

* Update CHANGELOG

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/asset-swapper@16.50.2

* change PR number

Co-authored-by: Kim Persson <kimpersson88@gmail.com>
Co-authored-by: Jacob Evans <jacob@dekz.net>
Co-authored-by: Github Actions <github-actions@github.com>
2022-03-08 16:26:22 -08:00
Github Actions
b3ee294ba5 Publish
- @0x/asset-swapper@16.50.2
2022-03-07 01:37:11 +00:00
Github Actions
1c242def93 Updated CHANGELOGS & MD docs 2022-03-07 01:37:07 +00:00
Jacob Evans
f0fe6f2f69 fix: Update Ropsten UniswapV3 Router address (#441)
* fix: Update Ropsten UniswapV3 Router address

* Update CHANGELOG
2022-03-07 11:18:25 +10:00
Github Actions
f86d555e49 Publish
- @0x/asset-swapper@16.50.1
2022-03-03 13:04:04 +00:00
Github Actions
b0f2c40463 Updated CHANGELOGS & MD docs 2022-03-03 13:04:00 +00:00
Kim Persson
87be6fbb8a fix: lower UniswapV3Sampler quote gas allowance to 700k (#438)
* fix: lower UniswapV3Sampler quote gas allowance to 700k

* chore: add asset-swapper changelog entry
2022-03-03 13:45:20 +01:00
Noah Khamliche
9141a9d2c8 feat: BTRFLY/WETH factory pool (#437)
* added curve support for BTRFLY/WETH factory pool

* prettier and lint

* remove timestamp

* fixed gas schedule for btrflyweth pool

* chore: update Node16 (#384)


* Node 16

* update yarn.lock

* Update ganache-cli and merkle-patricia-tree

* [TKR-275] Add Geist on Fantom (#398)

* Add Geist on Fantom

* nvm there is not subgraph for it

* finish giest utils

* Address pr comments

* lowercase gtoken addresses

* return undefined instead of error for unsupported pairs

* another lower case

* Update fantom fillQuoteTransformer address

* more const clean up

* feat: Improve Uniswap V3 gas schedule redux (#424)

* Revert "fix: Revert Improve Uniswap V3 gas schedule (#397) (#419)"

This reverts commit df0e0866e4.

* fix: UniswapV3Sampler return token amounts as the last value in return tuple

* fix: bump Uniswap V3 quote max gas because QuoterV2 is more expensive

* fix: don't try to rout 0 sellAmount/buyAmount quotes

* fix: Linting issue

* fix: use median gas usage instead of mean in UniV3 gas schedule

* chore: add asset-swapper changelog entry

* fix: remove contract-addresses changelog empty row failing linting

* Updated CHANGELOGS & MD docs

* Publish

 - @0x/contracts-erc20@3.3.27
 - @0x/contracts-test-utils@5.4.18
 - @0x/contracts-treasury@1.4.10
 - @0x/contracts-utils@4.8.8
 - @0x/contracts-zero-ex@0.31.1
 - @0x/asset-swapper@16.50.0
 - @0x/contract-addresses@6.12.0
 - @0x/contract-wrappers@13.19.1
 - @0x/migrations@8.1.16
 - @0x/protocol-utils@1.11.1

* Add v4 NFT Audits (#435)

* prettier and lint

Co-authored-by: Jacob Evans <jacob@dekz.net>
Co-authored-by: Cece Z <cece@0xproject.com>
Co-authored-by: Kim Persson <kimpers@users.noreply.github.com>
Co-authored-by: Github Actions <github-actions@github.com>
Co-authored-by: Jessica Lin <jlin2700@gmail.com>
2022-03-02 21:18:40 -05:00
Jessica Lin
7f75de347e Add v4 NFT Audits (#435) 2022-03-02 10:46:00 -08:00
Github Actions
329f7761c3 Publish
- @0x/contracts-erc20@3.3.27
 - @0x/contracts-test-utils@5.4.18
 - @0x/contracts-treasury@1.4.10
 - @0x/contracts-utils@4.8.8
 - @0x/contracts-zero-ex@0.31.1
 - @0x/asset-swapper@16.50.0
 - @0x/contract-addresses@6.12.0
 - @0x/contract-wrappers@13.19.1
 - @0x/migrations@8.1.16
 - @0x/protocol-utils@1.11.1
2022-03-02 12:55:58 +00:00
Github Actions
0d8e83cd75 Updated CHANGELOGS & MD docs 2022-03-02 12:55:55 +00:00
Kim Persson
e5d60b8077 feat: Improve Uniswap V3 gas schedule redux (#424)
* Revert "fix: Revert Improve Uniswap V3 gas schedule (#397) (#419)"

This reverts commit df0e0866e4.

* fix: UniswapV3Sampler return token amounts as the last value in return tuple

* fix: bump Uniswap V3 quote max gas because QuoterV2 is more expensive

* fix: don't try to rout 0 sellAmount/buyAmount quotes

* fix: Linting issue

* fix: use median gas usage instead of mean in UniV3 gas schedule

* chore: add asset-swapper changelog entry

* fix: remove contract-addresses changelog empty row failing linting
2022-03-02 13:36:12 +01:00
Cece Z
ae2fe55efa [TKR-275] Add Geist on Fantom (#398)
* Add Geist on Fantom

* nvm there is not subgraph for it

* finish giest utils

* Address pr comments

* lowercase gtoken addresses

* return undefined instead of error for unsupported pairs

* another lower case

* Update fantom fillQuoteTransformer address

* more const clean up
2022-03-02 01:34:30 -05:00
Jacob Evans
6073607d3e chore: update Node16 (#384)
* Node 16

* update yarn.lock

* Update ganache-cli and merkle-patricia-tree
2022-03-02 11:50:35 +10:00
Github Actions
389ebb5df8 Publish
- @0x/asset-swapper@16.49.9
2022-02-24 09:52:41 +00:00
Github Actions
fd9655e9d4 Updated CHANGELOGS & MD docs 2022-02-24 09:52:38 +00:00
Kim Persson
6480aaa189 fix: native order scaling & don't try to route 1 wei trades (it will fail) (#430)
* feat: scale oversized native orders to quote amount for fake samples

* chore: temporarily use private publish neon-router version

* fix: short circuit 1 base unit trades to avoid router error

* chore: use published version of `neon-router`

* chore: add changelog entry for asset-swapper
2022-02-24 10:34:17 +01:00
Github Actions
38969bb0a8 Publish
- @0x/contracts-erc20@3.3.26
 - @0x/contracts-test-utils@5.4.17
 - @0x/contracts-treasury@1.4.9
 - @0x/contracts-utils@4.8.7
 - @0x/contracts-zero-ex@0.31.0
 - @0x/asset-swapper@16.49.8
 - @0x/contract-artifacts@3.17.0
 - @0x/contract-wrappers@13.19.0
 - @0x/migrations@8.1.15
 - @0x/protocol-utils@1.11.0
2022-02-22 22:32:24 +00:00
Github Actions
1847ab93af Updated CHANGELOGS & MD docs 2022-02-22 22:32:20 +00:00
mzhu25
c1177416f5 [Final] ERC721 and ERC1155 Orders (#429)
* add LibERC721Order.sol

* Add ERC721 interface to vendor/

* Add ERC721OrdersFeature interface

* Storage lib for ERC721 orders feature

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

* Add isValidERC721OrderSignature to interface

* implement onERC721Received

* Implement batchBuyERC721s

* left/right orders -> sell/buy orders

* Add missing @return comments

* Implement matching functions

* Use SafeMath where necessary

* add rich errors for ERC721OrdersFeature

* Add comments

* Add presign support for ERC721 orders

* Cancel using just the order nonce

* Add IERC721OrdersFeature to IZeroEx

* Add taker callback

* Assembly optimizations in LibERC721Order

* Add ERC721Orders TS class

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

* TestMintableERC721Token

* tmp

* address feedback from original PR (#391)

* address feedback from original PR

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

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

* address review feedback and improve order parameter naming

* Add batchCancel function

* Emit order fields in preSign

* Fix tests

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

* Remove revertIfIncomplete from batchMatch

* Sanity check maker address in preSign

* ERC1155OrdersFeature contracts

* Commence refactor, abstract base contract

* ERC721OrdersFeature inherits from NFTOrders

* Refactor ERC1155OrdersFeature to inherit from NFTOrders

* Fix order hashing

* Fix ERC721OrdersFeature tests

* Typos

* Remove maker address from preSigned mapping

* disable dex sampler tests

* Refactor TS tooling

* Address PR feedback

* Rearrange event fields to better align with struct fields

* Update comments

* update AbiEncoder.create params

* Add ERC1155Order to protocol-utils

* Add ERC1155OrdersFeeature tests

* Bump package versions and regenerate contract wrappers

* Add ERC165Feature

* NFT orders: address audit findings (#417)

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

* CVF-11: fix inaccurate comment

* CVF-16: Enable taker callbacks for batchBuyERC1155s

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

* CVF-21: avoid duplicate SLOAD

* CVF-23: merge if statements

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

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

* CVF-31: Document keys of orderState mapping

* CVF-45: DRY up fees/properties hashing

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

* CVF-56: More descriptive names for assembly variables

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

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

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

* CVF-82: Update inaccurate comment

* CVF-86: Enable taker callbacks for batchBuyERC721s

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

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

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

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

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

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

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

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

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

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

* Update changelogs, IZeroEx artifact/wrapper

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Kim Persson <kimpers@users.noreply.github.com>
2022-02-22 10:00:22 -08:00
Github Actions
4fdd203211 Publish
- @0x/asset-swapper@16.49.7
2022-02-22 12:50:50 +00:00
Github Actions
4bc11776d7 Updated CHANGELOGS & MD docs 2022-02-22 12:50:47 +00:00
Kim Persson
eb12eac5f3 fix: start native orders "samples" at 0 & don't skip neg adj orders (#425)
* fix: start native orders "samples" at 0 & don't skip neg adj orders

* fix: bail on routes with invalid output estimation (no valid route)

* chore: bump neon-router version

* chore: add asset-swapper changelog entry
2022-02-22 13:31:47 +01:00
Github Actions
5f5b951998 Publish
- @0x/asset-swapper@16.49.6
2022-02-17 16:02:38 +00:00
Github Actions
8e90547604 Updated CHANGELOGS & MD docs 2022-02-17 16:02:34 +00:00
Noah Khamliche
fbea74d7ff remove comments 2022-02-17 10:40:59 -05:00
Noah Khamliche
dcea16bc13 removed ohmv2/dai and ohmv2/weth, routing is the same without the search overhead 2022-02-17 10:40:59 -05:00
Noah Khamliche
d59a074bd7 updated changelog 2022-02-17 10:40:59 -05:00
Noah Khamliche
39cc4f4dbf fixed btrfly routing to include the ohmV2/dai, ohmV2/btfly, and ohmV2/weth pools 2022-02-17 10:40:59 -05:00
Github Actions
85bcf87af8 Publish
- @0x/asset-swapper@16.49.5
2022-02-14 13:12:38 +00:00
Github Actions
a0fe1c610f Updated CHANGELOGS & MD docs 2022-02-14 13:12:35 +00:00
Kim Persson
5d21af1a0a fix: 1 base unit output amount being scale down, rounding to 0 output (#422)
* fix: 1 base unit output amount being scale down, rounding to 0 output

* chore: add asset-swapper changelog entry

* fix: round scaled output to base units before clamping
2022-02-14 13:54:53 +01:00
Jacob Evans
f6edbd210c Update protocol docs (#421)
* Update protocol docs

* Added functions

* fix table

* eligbility section?

* Trader.xyz shoutout

* Up to
2022-02-11 22:53:49 +10:00
Github Actions
e084807a8f Publish
- @0x/asset-swapper@16.49.4
2022-02-10 15:34:41 +00:00
Github Actions
1c7d512829 Updated CHANGELOGS & MD docs 2022-02-10 15:34:38 +00:00
Kim Persson
df0e0866e4 fix: Revert Improve Uniswap V3 gas schedule (#397) (#419)
* Revert "feat: Improve Uniswap V3 gas schedule (#397)"

This reverts commit 84e4819e6e.

* chore: Add changelog entry
2022-02-10 16:15:54 +01:00
Github Actions
9e6efc3676 Publish
- @0x/asset-swapper@16.49.3
2022-02-10 12:12:08 +00:00
Github Actions
3aef29dace Updated CHANGELOGS & MD docs 2022-02-10 12:12:05 +00:00
Kim Persson
9a16e00577 fix: router RFQ underutilization (#413)
* fix: pass EP overhead to Path & use path comparison all & vip routes

* chore: add changelog entry for asset-swapper
2022-02-10 12:55:30 +01:00
Kim Persson
84e4819e6e feat: Improve Uniswap V3 gas schedule (#397)
* feat: UniswapV3Sampler use QuoterV2 for sells WIP

* feat: UniswapV3Sampler for QuoterV2 buys WIP

* refactor: separate logic to remove stack too deep issue

* feat: Use initializedTicksCrossed from Uniswap QuoterV2 for gas est.

* fix: use Quoter gasUsed instead of estimating gas from pools + ticks

* refactor: clean up UniswapV3Sampler & remove old Quoter interface

* refactor: unify code for buys and sells while handling stack too deep

* fix: use mean gas price from all sample estimating UniV3 gas schedule

* fix: fallback to legacy Uniswap V3 gas estimate if we can't get gasUsed

* refactor: use named function instead of fat arrow

* chore: add asset-swapper changelog entry
2022-02-10 11:16:24 +01:00
Kim Persson
25dd6bc79a fix: incorrect output scaling when input is less than desired amount (#401)
* fix: incorrect output scaling when input is less than desired amount

* chore: bump fast-abi

* chore: add changelog entry for asset-swapper
2022-02-10 10:43:44 +01:00
Jacob Evans
5d2cdb00c2 fix: slippage inconsistency when recalculated in exchange proxy quote consumer (#412)
* fix: Pass slippage down rather than recalculate due to accuracy

* CHANGELOG
2022-02-04 10:37:38 +10:00
Github Actions
0f701f42d3 Publish
- @0x/asset-swapper@16.49.2
2022-01-31 18:24:47 +00:00
Github Actions
3e3e82d3f7 Updated CHANGELOGS & MD docs 2022-01-31 18:24:44 +00:00
Lawrence Forman
c57bf86273 Fix ABI encoding error with two hop buys due to applying slippage to uint(-1) values (#410)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2022-01-31 12:51:17 -05:00
Github Actions
f470d282ee Publish
- @0x/asset-swapper@16.49.1
2022-01-31 07:20:03 +00:00
Github Actions
b8a2526da5 Updated CHANGELOGS & MD docs 2022-01-31 07:19:59 +00:00
Jacob Evans
97575bbde9 fix: worstCaseQuoteInfo calculating buys incorrectly [TKR-296] (#402)
* fix: WorstCaseQuoteInfo buy encoding

* CHANGELOG
2022-01-31 17:01:17 +10:00
Github Actions
e5ed8b2c81 Publish
- @0x/asset-swapper@16.49.0
2022-01-28 22:11:46 +00:00
Github Actions
61fbae3ae2 Updated CHANGELOGS & MD docs 2022-01-28 22:11:42 +00:00
Shawn
5c2255c841 feat: add curve pools (#409)
* feat: Additional Curve pools

* more pools

* fix the format

* changlog

* lowercase address

Co-authored-by: Jacob Evans <jacob@dekz.net>
2022-01-28 12:08:28 -08:00
Github Actions
e036dee6c5 Publish
- @0x/asset-swapper@16.48.0
2022-01-25 22:00:25 +00:00
Github Actions
8583aab241 Updated CHANGELOGS & MD docs 2022-01-25 22:00:21 +00:00
Jacob Evans
5d05b62821 chore: Use MIM on Fantom as an intermediary asset (#405) 2022-01-26 07:42:29 +10:00
Github Actions
0063e8178f Publish
- @0x/asset-swapper@16.47.0
2022-01-25 18:51:07 +00:00
Github Actions
ec6e5dd517 Updated CHANGELOGS & MD docs 2022-01-25 18:51:04 +00:00
Noah Khamliche
9d08fefa1c Feat/synapse (#400)
* added synapse support
2022-01-25 13:21:07 -05:00
Github Actions
2fdca24d4e Publish
- @0x/asset-swapper@16.46.0
2022-01-11 01:10:02 +00:00
Github Actions
42ec0b144e Updated CHANGELOGS & MD docs 2022-01-11 01:09:58 +00:00
Jacob Evans
3f6ce78b46 chore: Enable Curve ETH/CVX (#394)
* chore: Enable Curve ETH/CVX

* pr number
2022-01-11 09:32:07 +10:00
Github Actions
c1300c1068 Publish
- @0x/asset-swapper@16.45.2
2022-01-10 15:09:26 +00:00
Github Actions
9a641cfab6 Updated CHANGELOGS & MD docs 2022-01-10 15:09:23 +00:00
Kim Persson
60345d4465 fix: don't create fills for 0 output samples and negative adjusted rate orders (#387)
* fix: don't try to create fills for 0 output samples

* fix: negative adjusted output native orders causing undefined fills

* fix: make sure to use the same sourcePathId for fills from same source

* fix: should be same sourcePathId within the same DexSample[]

* fix: split native orders into 13 samples to align with interpolation

* chore: add changelog entry for asset-swapper
2022-01-10 14:55:03 +01:00
Github Actions
11dfea47a6 Publish
- @0x/asset-swapper@16.45.1
2022-01-05 05:08:43 +00:00
Github Actions
55e9dd39a2 Updated CHANGELOGS & MD docs 2022-01-05 05:08:41 +00:00
Jacob Evans
1993929bed chore: Celo Update certain tokens since Optics v2 (#390)
* chore: Celo Update certain tokens since Optics v2

* Changelog
2022-01-05 14:44:29 +10:00
Oskar Paolini
e1d81de517 fixes axios object dumping in logs (#345) 2022-01-05 09:46:01 +10:00
Github Actions
a6b3a21635 Publish
- @0x/asset-swapper@16.45.0
2022-01-04 15:00:16 +00:00
Github Actions
fd59cdc2db Updated CHANGELOGS & MD docs 2022-01-04 15:00:13 +00:00
Jacob Evans
98e11b5189 feat: Capture Routing timing metrics (#388) 2022-01-04 15:42:14 +01:00
Github Actions
3bebc7cd62 Publish
- @0x/asset-swapper@16.44.0
2021-12-29 11:45:33 +00:00
Github Actions
56dab6ae8c Updated CHANGELOGS & MD docs 2021-12-29 11:45:30 +00:00
Kim Persson
285f98e9e9 feat: Udate neon-router and use router estimated output amount (#354)
* feat: use Rust router estimated output amount when possible

* fix: use strings for sample ids, and increase samples in the rust router

* fix: remove unnecessary interpolation of out of range values

* fix: don't recalculate sampled dist sum in a loop

* fix: use 14 samples for rust router to work around interpolation issues

* fix: unintentional logic change

* fix: remove local dev plotting param from route fn call

* feat: make neon-router number of samples configurable

* chore: bump to newly published neon-router version

* fix: handle insufficient liquidity at all requested sources

* chore: update asset-swapper changelog
2021-12-29 12:08:24 +01:00
Github Actions
8ae9f59f20 Publish
- @0x/contracts-erc20@3.3.25
 - @0x/contracts-test-utils@5.4.16
 - @0x/contracts-treasury@1.4.8
 - @0x/contracts-utils@4.8.6
 - @0x/contracts-zero-ex@0.30.1
 - @0x/asset-swapper@16.43.0
 - @0x/contract-addresses@6.11.0
 - @0x/contract-wrappers@13.18.5
 - @0x/migrations@8.1.14
 - @0x/protocol-utils@1.10.1
2021-12-24 16:45:24 +00:00
Github Actions
4c341c5ca3 Updated CHANGELOGS & MD docs 2021-12-24 16:45:21 +00:00
Shawn
a3c912c2af feat/optimism [TKR-280] (#385)
* rebase and remove WIP Clipper new weth router test

* remove clipper test

* restore from clipper test

* add uniswapV3 on optimism

* modify token addresses and add EP-related addresses on optimism

* prettier

* modify CHANGLOG.json

* convert addresses to lowercase

* remove testnet addresses

Co-authored-by: Romain Butteaud <romain.butteaud@gmail.com>
2021-12-24 08:28:06 -08:00
Github Actions
5e72eb9af9 Publish
- @0x/asset-swapper@16.42.0
2021-12-21 22:02:45 +00:00
Github Actions
9b08b73c06 Updated CHANGELOGS & MD docs 2021-12-21 22:02:41 +00:00
Jacob Evans
76c7eb7c3e fix: Beethovenx graphql endpoint (#383) 2021-12-22 07:44:25 +10:00
Jacob Evans
9b2e5a3adb fix: PR number in CHANGELOG 2021-12-22 08:11:28 +11:00
Jacob Evans
813d703d12 feat: UniswapV3 on Polygon (#382) 2021-12-22 07:10:21 +10:00
Github Actions
83005d0f3d Publish
- @0x/asset-swapper@16.41.0
2021-12-06 21:48:27 +00:00
Github Actions
d07ffd2688 Updated CHANGELOGS & MD docs 2021-12-06 21:48:24 +00:00
Noah Khamliche
4170f970d0 Sushi router celo fix (#376)
* Updated Sushiswap router on CELO 

Sushi address in the docs was incorrect, this is the correct address `0x1421bDe4B10e8dd459b3BCb598810B1337D56842`.

* address to lowercase

* Update CHANGELOG.json

* fixed sushi router address, replaced celo ref with wcelo, fixed mcusd address

* celo->wcelo

* Update packages/asset-swapper/CHANGELOG.json

Co-authored-by: Jacob Evans <jacob@dekz.net>

* changelog

* version bump

Co-authored-by: Jacob Evans <jacob@dekz.net>
2021-12-06 13:31:45 -08:00
Github Actions
dcde12dd70 Publish
- @0x/contracts-erc20@3.3.24
 - @0x/contracts-test-utils@5.4.15
 - @0x/contracts-treasury@1.4.7
 - @0x/contracts-utils@4.8.5
 - @0x/contracts-zero-ex@0.30.0
 - @0x/asset-swapper@16.40.0
 - @0x/contract-addresses@6.10.0
 - @0x/contract-wrappers@13.18.4
 - @0x/migrations@8.1.13
 - @0x/protocol-utils@1.10.0
2021-12-01 20:22:43 +00:00
Github Actions
84a60ec982 Updated CHANGELOGS & MD docs 2021-12-01 20:22:39 +00:00
Kim Persson
9615570dc6 feat: deploy interest tokens (#321)
* feat: Aave aToken deposit/withdrawal [TKR-111] (#293)

* feat: AaveV2 deposit/withdrawal integration WIP

* feat: add basic Aave Reserves cache with data from subgraphs WIP

* feat: hook up Aave Reserves integration

* fix: set allowance before trade & use ERC20 token interface

* refactor: pass aToken to mixin to avoid lookup

* fix: migrate from swap/revert to normal sampling

* fix: Aave gas estimate & refactor to clean up code

* feat: Create a sampler no operation type and make AaveV2Sampler a no-op

* fix: Clipper merge conflict resolution issues

* fix: don't fetch unnecessary Aave pool data & clean up code

* chore: Add changelog entries

* feat: cToken deposit/withdrawal [TKR-222] (#294)

* feat: first stab at a CompoundSampler implementation

* feat: MixinCompound implementation WIP

* feat: Compound integration with cache WIP

* fix: decimals scaling in CompoundSampler

* feat: handle minting and redeeming of cETH

* fix: adjust Compound gas schedule

* refactor: clean up code and add comments in cToken cache

* fix: MixinCompound check allowance on WETH withdrawal & fix indentation

* fix: address review comments and clean up code

* chore: add changelog entries

* feat: enable AaveV2 on Avalanche

* chore: add freshly deployed FQT on Polygon, Avalanche

* fix: temporarily disable on Ethereum mainnet until we redeploy EP

* fix: address PR comments and update changelogs

* fix: correct contract-addresses changelog note
2021-12-01 17:10:22 +01:00
Jacob Evans
880a9c3da0 chore: Curve added ETH/CRV pool (#378) 2021-12-01 14:51:47 +10:00
Jacob Evans
c44bd9d42d Revert "chore: Curve added ETH/CRV pool"
This reverts commit 90b441330b.
2021-12-01 14:19:49 +10:00
Jacob Evans
90b441330b chore: Curve added ETH/CRV pool 2021-12-01 14:17:40 +10:00
Github Actions
e12ed1eddf Publish
- @0x/asset-swapper@16.38.0
2021-11-29 23:23:57 +00:00
Github Actions
ac94023ab3 Updated CHANGELOGS & MD docs 2021-11-29 23:23:54 +00:00
Jacob Evans
281e6acca5 chore: Add ability to capture sampler metrics (#374)
* chore: Add ability to capture sampler metrics

* Added block number metrics
2021-11-30 09:06:05 +10:00
Github Actions
2f1b520409 Publish
- @0x/asset-swapper@16.37.0
2021-11-19 19:15:43 +00:00
Github Actions
21b4eb3d26 Updated CHANGELOGS & MD docs 2021-11-19 19:15:40 +00:00
Noah Khamliche
644f6c7d28 removed comma 2021-11-19 13:46:57 -05:00
Noah Khamliche
0647b9e4f8 Update CHANGELOG.json 2021-11-19 13:46:57 -05:00
Noah Khamliche
82d42eeede address to lowercase 2021-11-19 13:46:57 -05:00
Noah Khamliche
6ef4d95043 Updated Sushiswap router on CELO
Sushi address in the docs was incorrect, this is the correct address `0x1421bDe4B10e8dd459b3BCb598810B1337D56842`.
2021-11-19 13:46:57 -05:00
Github Actions
6044140f86 Publish
- @0x/asset-swapper@16.36.0
2021-11-19 02:59:33 +00:00
Github Actions
4da1ef0f56 Updated CHANGELOGS & MD docs 2021-11-19 02:59:30 +00:00
Jacob Evans
8c668a3918 feat: Specify FEI/TRIBE liquid pool (#371)
* feat: Specify FEI/TRIBE liquid pool

* CHANGELOG

* FXS/FRAX and OHM/FRAX
2021-11-18 15:39:07 +10:00
Github Actions
f1ff1cde39 Publish
- @0x/asset-swapper@16.35.0
2021-11-18 03:31:36 +00:00
Github Actions
1668a24e31 Updated CHANGELOGS & MD docs 2021-11-18 03:31:32 +00:00
Shawn
4b7c376d96 feat: Add Beethoven X, MorpheusSwap and JetSwap on Fantom (#370)
* Rebase to development branch

* add support for MorpheusSwap and JetSwap on Fantom

* fix lint

* modify changelog.json for asset-swapper

* fix the comments

* prettier

* Use BalancerV2PoolsCache for BeethovenX

Co-authored-by: Romain Butteaud <romain.butteaud@gmail.com>
2021-11-17 19:14:01 -08:00
Github Actions
bb4a9c656c Publish
- @0x/contracts-erc20@3.3.23
 - @0x/contracts-test-utils@5.4.14
 - @0x/contracts-treasury@1.4.6
 - @0x/contracts-utils@4.8.4
 - @0x/contracts-zero-ex@0.29.5
 - @0x/asset-swapper@16.34.0
 - @0x/contract-addresses@6.9.0
 - @0x/contract-wrappers@13.18.3
 - @0x/migrations@8.1.12
 - @0x/protocol-utils@1.9.5
2021-11-16 22:49:46 +00:00
Github Actions
6ab07b6304 Updated CHANGELOGS & MD docs 2021-11-16 22:49:43 +00:00
Noah Khamliche
8903f1ab01 Update packages/contract-addresses/CHANGELOG.json
Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
2021-11-16 16:55:57 -05:00
Noah Khamliche
415535612a removed duplicate celo code 2021-11-16 16:55:57 -05:00
Noah Khamliche
5248a135c3 upped versions in changelog 2021-11-16 16:55:57 -05:00
Lawrence Forman
602290925c fix celo rebase 2021-11-16 16:55:57 -05:00
Github Actions
01813746e8 Publish
- @0x/contracts-zero-ex@0.29.4
 - @0x/asset-swapper@16.33.0
 - @0x/migrations@8.1.11
2021-11-16 12:27:06 +00:00
Github Actions
7d668d8801 Updated CHANGELOGS & MD docs 2021-11-16 12:27:02 +00:00
Jacob Evans
797a00a33a feat: Uniswap V3 1bps pools [TKR-263] (#366)
* feat: Uniswap V3 1bps pools

* Update CHANGELOG
2021-11-16 08:15:24 +10:00
Lawrence Forman
4b3d98f43c @0x/contracts-zero-ex: Prevent EP ETH balance from reducing when executin mtxs (#365)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-11-09 22:11:36 -05:00
Github Actions
9ff77c1cd5 Publish
- @0x/asset-swapper@16.32.0
2021-11-09 19:36:14 +00:00
Github Actions
18a8351671 Updated CHANGELOGS & MD docs 2021-11-09 19:36:10 +00:00
Jorge Pérez
9a994dfcd3 fix: Extended Quote Report Changelog typo 2021-11-09 13:17:14 -06:00
Jorge Pérez
b7adc5a889 feat: Extended Quote Report
* Extended Quote report for indicative quote

* feat: Only save 'full' quotes on quote report

* Unify extended quote report
2021-11-09 13:05:01 -06:00
Github Actions
10b0d7f363 Publish
- @0x/asset-swapper@16.31.0
2021-11-04 06:52:28 +00:00
Github Actions
e2c905a15f Updated CHANGELOGS & MD docs 2021-11-04 06:52:25 +00:00
Jacob Evans
8589ba728c feat: [Avalanche] Add Curve, CurveV2 and KyberDMM (#363)
* feat: [Avalanche] Add Curve, CurveV2 and KyberDMM

* CHANGELOG

* fix missing file

* lint
2021-11-04 16:34:48 +10:00
Github Actions
43512fd07a Publish
- @0x/contracts-erc20@3.3.22
 - @0x/contracts-test-utils@5.4.13
 - @0x/contracts-treasury@1.4.5
 - @0x/contracts-utils@4.8.3
 - @0x/contracts-zero-ex@0.29.3
 - @0x/asset-swapper@16.30.1
 - @0x/contract-addresses@6.8.1
 - @0x/contract-wrappers@13.18.2
 - @0x/migrations@8.1.10
 - @0x/protocol-utils@1.9.4
2021-11-03 01:40:34 +00:00
Github Actions
c090608d99 Updated CHANGELOGS & MD docs 2021-11-03 01:40:30 +00:00
phil-ociraptor
89817428ed chore: add OtcOrder feature to fullMigrateAsync (#350) 2021-11-02 20:19:27 -05:00
Lawrence Forman
fce3664258 @0x/contracts-zero-ex: Register transformERC20() and remove transformERC20Staging() (#355)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-10-25 20:08:58 -04:00
Github Actions
aa522fe49b Publish
- @0x/contracts-erc20@3.3.21
 - @0x/contracts-test-utils@5.4.12
 - @0x/contracts-treasury@1.4.4
 - @0x/contracts-utils@4.8.2
 - @0x/contracts-zero-ex@0.29.2
 - @0x/asset-swapper@16.30.0
 - @0x/contract-addresses@6.8.0
 - @0x/contract-wrappers@13.18.1
 - @0x/migrations@8.1.9
 - @0x/protocol-utils@1.9.3
2021-10-19 18:27:29 +00:00
Github Actions
c03653ebd7 Updated CHANGELOGS & MD docs 2021-10-19 18:27:25 +00:00
Shawn
ae08f77381 Feat/ftm (#347)
* ftm deployment

* add Fantom Curve

* add support for ftm

* add more Fantom liquidity sources

* clean up codes

* lint

* prettier codes

* modify CHANGLOG

* undo some changes

* use lowercase addresses

* Update EP FlashWallet

* Update addresses and remove timestamps

Co-authored-by: Jacob Evans <jacob@dekz.net>

* Cleanup

* cleanup json

Co-authored-by: Romain Butteaud <romain.butteaud@gmail.com>
Co-authored-by: Jacob Evans <jacob@dekz.net>
2021-10-19 09:51:07 -07:00
Github Actions
73a07e512d Publish
- @0x/asset-swapper@16.29.3
2021-10-18 10:36:39 +00:00
Github Actions
7cff09f40a Updated CHANGELOGS & MD docs 2021-10-18 10:36:36 +00:00
Kim Persson
a6d690f10a chore: update to new router version and address breaking changes (#344)
* chore: update to new router version and address breaking changes

* chore: add changelog entry
2021-10-18 11:15:31 +01:00
Github Actions
d7cff52e75 Publish
- @0x/contracts-treasury@1.4.3
 - @0x/asset-swapper@16.29.2
2021-10-13 17:44:45 +00:00
Github Actions
cf1f29a37d Updated CHANGELOGS & MD docs 2021-10-13 17:44:41 +00:00
mzhu25
9af22110b4 Chore: go back to using transformERC20 in AS (#343)
* go back to using transformERC20

* Update changelog
2021-10-12 22:47:29 -07:00
mzhu25
2c187c7e85 Add Proposal 2 and test (#339) 2021-10-08 13:04:09 -07:00
Phạm Minh Đức
d46756ae2e fix(asset-swapper): Check MAX_IN_RATIO in sampleBuysFromBalancer (#338)
* fix: for swapExactAmountIn

* chore: update change log

* Update packages/asset-swapper/CHANGELOG.json

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
2021-10-05 16:25:02 -04:00
Github Actions
d9a16ed1f9 Publish
- @0x/contracts-treasury@1.4.2
 - @0x/contracts-zero-ex@0.29.1
 - @0x/asset-swapper@16.29.1
 - @0x/migrations@8.1.8
 - @0x/protocol-utils@1.9.2
2021-10-04 19:01:10 +00:00
Github Actions
57a1120997 Updated CHANGELOGS & MD docs 2021-10-04 19:01:06 +00:00
Romain Butteaud
0945d4cef2 fix: removing Clipper custom integration (to add it later as a real PLP) (#335)
* fix: removing Clipper custom integration (to add it later as a real PLP)

* fix: update CHHANGELOG

* fix: keep Clipper as BridgeProtocols so we dont have to redeploy and comment this is not used

* fix: prettier
2021-10-04 11:39:07 -07:00
Github Actions
8f6f7ad453 Publish
- @0x/asset-swapper@16.29.0
2021-10-04 12:21:46 +00:00
Github Actions
bb4fad37fa Updated CHANGELOGS & MD docs 2021-10-04 12:21:43 +00:00
Kim Persson
d06daf2957 feat: initial integration of new router (#295)
* feat: integrate Rust router with asset-swapper WIP

* fix: produce outputFees in the format the Rust router expects

* fix: correct output fee calc and only use the rust router for sells

* fix: make sure numbers sent to the rust router are integers

* hack: try to debug why rust router output is being overestimated WIP

* refactor: clean up router debugging code

* fix: don't use negative output fees for sells

* feat: try VIP sources in isolation and compare with routing all sources

* fix: adjust for FQT overhead when choosing between VIP, all sources WIP

* fix: pass gasPrice to path_optimizer for EP overhead calculations

* feat: buy support with the Rust Router WIP

* chore: WIP commit trying to get buys working

* refactor: use samples instead of fills for the Rust router

* feat: add vip handling hack to sample based routing

* fix: revert to 200 samplings for rust router when using pure samples

* refactor: remove old hacky Path based Rust code, add back feature toggle

* fix: scale both fill output and adjustedOutput my same factor as input

* feat: initial plumbing for supporting RFQ/Limit orders

* fix: incorrect bump of input amount by one base unit before routing

* fix: add fake samples for rfq/limit orders to fulfill the 3 sample req

* fix pass rfq orders in the correct format to the rust router

* chore: remove debugging logs and clean up code & comments

* fix: use published version of @0x/neon-router

* hack: scale routed amounts to account for precision loss of number/f64

* refactor: clean up code and address initial review comments

* fix: only remove trailing 0 output samples before passing to the router

* refactor: consolidate eth to output token calc into ethToOutputAmount fn

* fix: interpolate input between samples on output amount instead of price

* fix: return no path when we have no samples, add sanity asserts

* refactor: fix interpolation comment wording

* fix: remove double adjusted source route input amount

* chore: update changelog for asset-swapper
2021-10-04 12:09:54 +02:00
Megan
34314960ef Updated docs for zero protocol fees (#337) 2021-10-01 13:04:25 +02:00
Github Actions
832ba737ec Publish
- @0x/contracts-treasury@1.4.1
 - @0x/contracts-zero-ex@0.29.0
 - @0x/asset-swapper@16.28.0
 - @0x/contract-artifacts@3.16.0
 - @0x/contract-wrappers@13.18.0
 - @0x/migrations@8.1.7
 - @0x/protocol-utils@1.9.1
2021-09-29 23:19:10 +00:00
Github Actions
6950fdbebb Updated CHANGELOGS & MD docs 2021-09-29 23:19:06 +00:00
mzhu25
1849b1bb9a Update ExchangeProxySwapQuoteConsumer for MultiplexV2 (#282)
* Update ExchangeProxySwapQuoteConsumer for MultiplexV2

* Move TransformERC20FeatureContract instance into private readonly
2021-09-29 16:02:13 -07:00
Megan
a883139220 feat: remove protocol fees for V4 in AssetSwapper WIP (#333)
* Set AssetSwapper protocol fee multiplier to zero

* Set market_operation_utils protocol fee multiplier to zero

* Updated CHANGELOG.json

* Removed whitespace in CHANGELOG.json

* Remove unnecessary timestamp in packages/asset-swapper/CHANGELOG.json

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

* Updated  param for quote simulation test

* Updated quote simulation test

* fix failing tests

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-09-29 12:37:42 -04:00
Kevin Li
bb2c26cb94 fix(docs): pin Sphinx version to 3.x to generate CSS
Custom CSS seems to [have broken in Sphinx 4](https://github.com/sphinx-doc/sphinx/issues/2442).
Guessing readthedocs.io or their package repository upgraded the default
version of Sphinx to 4 and that caused our builds to start breaking.

They [recommend pinning dependencies](https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html#pinning-dependencies), let's do that here for Sphinx!
2021-09-15 18:18:44 -07:00
Github Actions
ba09a0b2bf Publish
- @0x/contracts-erc20@3.3.20
 - @0x/contracts-test-utils@5.4.11
 - @0x/contracts-treasury@1.4.0
 - @0x/contracts-utils@4.8.1
 - @0x/contracts-zero-ex@0.28.5
 - @0x/asset-swapper@16.27.4
 - @0x/contract-artifacts@3.15.1
 - @0x/contract-wrappers@13.17.7
 - @0x/migrations@8.1.6
 - @0x/protocol-utils@1.9.0
2021-09-15 12:58:17 +00:00
Github Actions
b2d54f0238 Updated CHANGELOGS & MD docs 2021-09-15 12:58:13 +00:00
Daniel Pyrathon
4a3096495b Mocked RFQ (#326) 2021-09-15 08:39:10 -04:00
Lawrence Forman
23f6e9e53c fix mixed @0x deps (#328)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-09-15 00:01:15 -04:00
Cece Z
d7dbc0576d Support cast vote by signature in ZrxTreasury (#297)
* Support cast vote by signature in ZrxTreasury

* Address comments and fix existing tests

* test that doesnt work

* test file format

* updates

* address some of the comments

* Remove unused const

* get rid of vote_factory

* unit test for castVoteBySignature p1

* unit test for castVoteBySignature p2

* Add version to domain, and one more test

* unit test for castVoteBySignature p3

* unit test for castVoteBySignature p4

* bump utils version

* remove debug code

* address some comments

* address more pr comments

* move Vote class to protocol-utils

* Address pr comments and update changelogs
2021-09-14 16:12:51 -04:00
Github Actions
15fb00e958 Publish
- @0x/asset-swapper@16.27.3
2021-09-14 19:04:09 +00:00
Github Actions
1d9295cc94 Updated CHANGELOGS & MD docs 2021-09-14 19:04:05 +00:00
Daniel Pyrathon
79f36cf6fb fix: Remove API key whitelist field (#323)
* Refactor integrator ID and add Prometheus metrics

* Update packages/asset-swapper/src/swap_quoter.ts

Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com>

* Update packages/asset-swapper/src/swap_quoter.ts

Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com>

* Update packages/asset-swapper/src/swap_quoter.ts

Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com>

* Added documentation and fixed some minor requests

* Added more metrics

* more docs

* lint fix

* added new Integrator ID addition

* refactor tests

* Refactor new types

Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com>
2021-09-14 14:43:02 -04:00
Github Actions
6ce4458a5d Publish
- @0x/asset-swapper@16.27.2
2021-09-14 17:13:46 +00:00
Github Actions
fad6e65c07 Updated CHANGELOGS & MD docs 2021-09-14 17:13:42 +00:00
Daniel Pyrathon
840c85373e fix: Refactor integrator ID and add Prometheus metrics (#322)
* Refactor integrator ID and add Prometheus metrics

* Update packages/asset-swapper/src/swap_quoter.ts

Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com>

* Update packages/asset-swapper/src/swap_quoter.ts

Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com>

* Update packages/asset-swapper/src/swap_quoter.ts

Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com>

* Added documentation and fixed some minor requests

* Added more metrics

* more docs

* lint fix

* added new Integrator ID addition

* refactor tests

Co-authored-by: David Walsh <5778036+rhinodavid@users.noreply.github.com>
2021-09-14 12:45:41 -04:00
Github Actions
0479bb5fe1 Publish
- @0x/contracts-erc20@3.3.19
 - @0x/contracts-treasury@1.3.5
 - @0x/contracts-utils@4.8.0
 - @0x/contracts-zero-ex@0.28.4
 - @0x/asset-swapper@16.27.1
 - @0x/migrations@8.1.5
2021-09-08 17:06:09 +00:00
Github Actions
9ecc31ed54 Updated CHANGELOGS & MD docs 2021-09-08 17:06:06 +00:00
Lawrence Forman
eb29abd36c Fix ApproximateBuys sampler to terminate if the buy amount is not met (#319)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-09-08 01:17:42 -04:00
Lawrence Forman
d202e01522 update package mainfests (#318)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-09-07 23:09:30 -04:00
Daniel Pyrathon
e838a6801b fix: Exclusive API keys for select integrations (#317)
* Initial commit of changes

* Added unit tests for filtering process

* linting

* Update packages/asset-swapper/src/utils/quote_requestor.ts

Co-authored-by: phil-ociraptor <philipliao@gmail.com>

* lint and refactor based on feedback

Co-authored-by: phil-ociraptor <philipliao@gmail.com>
2021-09-07 14:26:40 -04:00
Noah Khamliche
7439871aa0 Final Rebase 2021-09-01 17:07:16 -04:00
Noah Khamliche
317f2138c5 feat: fixed json 2021-09-01 17:07:16 -04:00
Noah Khamliche
e5834f1901 m: Fixed json formatting 2021-09-01 17:07:16 -04:00
Noah Khamliche
5063446f93 feat: Added FundRecoveryFeature to CHANGELOG.json 2021-09-01 17:07:16 -04:00
Noah Khamliche
0caf495a1a fixed prettier error with tests 2021-09-01 17:07:16 -04:00
Noah Khamliche
a20de0fc69 Added support for TestMintableERC20TokenContract instead of DummyERC20 2021-09-01 17:07:16 -04:00
Noah Khamliche
9aa0065d2d fixed package.json rebase bug 2021-09-01 17:07:16 -04:00
Noah Khamliche
c24855e627 fixed rebase issues 2021-09-01 17:07:16 -04:00
Noah Khamliche
6bb72dd775 ran yarn prettier to fix issues 2021-09-01 17:07:16 -04:00
Noah Khamliche
77d1ed257c removed unsued bal variable, and removed .only modifier on blockchain tests 2021-09-01 17:07:16 -04:00
Noah Khamliche
5d265360c4 fixed linting and EP transfering less than the total amount of ETH in the wallet 2021-09-01 17:07:16 -04:00
Noah Khamliche
c9097f6e8b fixed rebase issues 2021-09-01 17:07:16 -04:00
Noah Khamliche
d3df985a42 fixed michaels comments and finished off writing the test 2021-09-01 17:07:16 -04:00
Noah Khamliche
7267420874 fixed rebase issues 2021-09-01 17:07:16 -04:00
Noah Khamliche
17e81432f1 Fixed PR comments, now onto writing tests 2021-09-01 17:07:16 -04:00
Noah Khamliche
57c767c3b1 fixed package.json 2021-09-01 17:07:16 -04:00
Noah Khamliche
dbb1c88ad9 initial EpFundRecoveryFeature implementation without tests 2021-09-01 17:07:16 -04:00
Github Actions
254b850a8b Publish
- @0x/contracts-erc20@3.3.18
 - @0x/contracts-test-utils@5.4.10
 - @0x/contracts-treasury@1.3.4
 - @0x/contracts-utils@4.7.18
 - @0x/contracts-zero-ex@0.28.3
 - @0x/asset-swapper@16.27.0
 - @0x/contract-addresses@6.7.0
 - @0x/contract-wrappers@13.17.6
 - @0x/migrations@8.1.4
 - @0x/protocol-utils@1.8.4
2021-09-01 01:31:37 +00:00
Github Actions
e2242e5955 Updated CHANGELOGS & MD docs 2021-09-01 01:31:34 +00:00
Jacob Evans
7a0255fee7 feat: 🔺 (#312)
* feat: Avalanche

* Update Addresses for Avalanche deployment

* Cleanup

* Rebased development
2021-09-01 11:11:56 +10:00
Github Actions
ec6522cfbf Publish
- @0x/asset-swapper@16.26.2
2021-08-31 07:06:30 +00:00
Github Actions
1bf96e91bb Updated CHANGELOGS & MD docs 2021-08-31 07:06:27 +00:00
Romain Butteaud
eb733cc58f add: Curve new pools (CVX-CRX, MIM, atricrypto3) (#315)
* add: Curve new pools (CVX-CRX, MIM, atricrypto3)

* prettier

* fix: AS CHANGELOG

* fix: update monorepo-scripts
2021-08-30 23:45:47 -07:00
Jacob Evans
d9fdcf813b fix: UST spam by temporarily disabling (#316) 2021-08-31 16:17:17 +10:00
Romain Butteaud
88bd1c9cea add: Curve new pools (CVX-CRX, MIM, atricrypto3) - CHANGELOG (#314)
* add: Curve new pools (CVX-CRX, MIM, atricrypto3)

* prettier

* fix: AS CHANGELOG
2021-08-30 16:19:32 -07:00
Romain Butteaud
9e759e82b4 add: Curve new pools (CVX-CRX, MIM, atricrypto3) (#313)
* add: Curve new pools (CVX-CRX, MIM, atricrypto3)

* prettier
2021-08-30 15:22:10 -07:00
Daniel Pyrathon
da433854ac fix: added prometheus changes on expiration (#308)
* added prometheus changes on expiration

* added unit tests

* prettier

* addressed comments

* remove unused tests

* fix lint:

* Update quote_requestor_test.ts
2021-08-23 13:59:49 -07:00
Github Actions
ed3524e0d7 Publish
- @0x/contracts-zero-ex@0.28.2
 - @0x/asset-swapper@16.26.1
 - @0x/migrations@8.1.3
2021-08-19 23:12:22 +00:00
Github Actions
20e23bf3f6 Updated CHANGELOGS & MD docs 2021-08-19 23:12:19 +00:00
David Walsh
be4f85690e Add ethers as a dependency of @0x/contracts-zero-ex (#310) 2021-08-19 16:25:47 -06:00
Github Actions
e061dfa59b Publish
- @0x/contracts-erc20@3.3.17
 - @0x/contracts-test-utils@5.4.9
 - @0x/contracts-treasury@1.3.3
 - @0x/contracts-utils@4.7.17
 - @0x/contracts-zero-ex@0.28.1
 - @0x/asset-swapper@16.26.0
 - @0x/contract-addresses@6.6.1
 - @0x/contract-wrappers@13.17.5
 - @0x/migrations@8.1.2
 - @0x/protocol-utils@1.8.3
2021-08-19 06:13:36 +00:00
Github Actions
cb4f42dfea Updated CHANGELOGS & MD docs 2021-08-19 06:13:32 +00:00
Jacob Evans
9727f0cebe feat: Enable partial Native order fills. Union intermediary tokens (#309)
* feat: Enable partial Native order fills

* change intermediary tokens to be a UNION.

Hint to cvxCRV and CRV

* Pin asset-swapper to use contracts-zero-ex 0.27.0 for now

* feat: Retire Eth2Dai/Oasis
2021-08-19 15:21:23 +10:00
Jacob Evans
68656b4a4d chore: Prune old contracts (#304)
Prune exchange-libs
deploy migrations at specific address
remove exchange-libs, moving LibMath into Utils
Remove staking order-utils multisig and remaining asset-proxy
2021-08-18 10:33:47 +10:00
Github Actions
aae46bef84 Publish
- @0x/contracts-asset-proxy@3.7.19
 - @0x/contracts-broker@1.1.37
 - @0x/contracts-coordinator@3.1.38
 - @0x/contracts-dev-utils@1.3.36
 - @0x/contracts-erc1155@2.1.37
 - @0x/contracts-erc20@3.3.16
 - @0x/contracts-erc721@3.1.37
 - @0x/contracts-exchange-forwarder@4.2.38
 - @0x/contracts-exchange-libs@4.3.37
 - @0x/contracts-exchange@3.2.38
 - @0x/contracts-extensions@6.2.32
 - @0x/contracts-integrations@2.7.64
 - @0x/contracts-multisig@4.1.38
 - @0x/contracts-staking@2.0.45
 - @0x/contracts-test-utils@5.4.8
 - @0x/contracts-treasury@1.3.2
 - @0x/contracts-utils@4.7.16
 - @0x/contracts-zero-ex@0.28.0
 - @0x/asset-swapper@16.25.0
 - @0x/contract-wrappers-test@12.2.53
 - @0x/migrations@8.1.1
 - @0x/protocol-utils@1.8.2
2021-08-16 02:03:23 +00:00
Github Actions
a0bb36954e Updated CHANGELOGS & MD docs 2021-08-16 02:03:19 +00:00
Jacob Evans
4f32f3174f fix: fallbacks duplicate check on source-index (#307) 2021-08-16 11:25:22 +10:00
Daniel Pyrathon
b84107d142 fix: Adds "MetricsProxy" that allows us to proxy Prometheus metrics across… (#300)
* Adds "MetricsProxy" that allows us to proxy Prometheus metrics across to the API

* added more metric

* update linting
2021-08-12 18:11:51 -07:00
mzhu25
b46eeadc64 Feat/multiplex/v2 (#263)
* Refactor Multiplex into multiple files

* Pull UniswapV3 into separate file

* Add support for multihop nested within batch sell

* Add useSelfBalance and recipient to _fillRfqOrder

* Expose onlySelf variant in UniswapV3Feature for Multiplex

* Add useSelfBalance and recipient to _transformERC20

* Add support for proportional fill amounts in batchSell

* Comments and renaming

* Unit tests

* Use caps for immutables

* Rename taker -> recipient in TransformContext and SettleOrderInfo

* lint

* Address nits

* Swallow reverts for LiquidityProvider and UniswapV2 batch sells

* Address spot-check findings (#279)

* Check didSucceed in _callWithOptionalBooleanResult

* Add takerToken=ETH support to OtcOrdersFeature (#287)

* Add takerToken=ETH support to OtcOrdersFeature

* Add batchFillTakerSignedOtcOrders

* Add support for OTC to Multiplex

* Address PR feedback

* Update TransformERC20Feature (#303)

* remove multiplex_utils

* Update changelog

* unbreak tests
2021-08-12 17:09:46 -07:00
Github Actions
692231c2ea Publish
- @0x/contracts-asset-proxy@3.7.18
 - @0x/contracts-broker@1.1.36
 - @0x/contracts-coordinator@3.1.37
 - @0x/contracts-dev-utils@1.3.35
 - @0x/contracts-erc1155@2.1.36
 - @0x/contracts-erc20@3.3.15
 - @0x/contracts-erc721@3.1.36
 - @0x/contracts-exchange-forwarder@4.2.37
 - @0x/contracts-exchange-libs@4.3.36
 - @0x/contracts-exchange@3.2.37
 - @0x/contracts-extensions@6.2.31
 - @0x/contracts-integrations@2.7.63
 - @0x/contracts-multisig@4.1.37
 - @0x/contracts-staking@2.0.44
 - @0x/contracts-test-utils@5.4.7
 - @0x/contracts-treasury@1.3.1
 - @0x/contracts-utils@4.7.15
 - @0x/contracts-zero-ex@0.27.1
 - @0x/asset-swapper@16.24.1
 - @0x/contract-addresses@6.6.0
 - @0x/contract-wrappers-test@12.2.52
 - @0x/contract-wrappers@13.17.4
 - @0x/migrations@8.1.0
 - @0x/order-utils@10.4.28
 - @0x/protocol-utils@1.8.1
2021-08-11 07:09:54 +00:00
Github Actions
3a1becc3e4 Updated CHANGELOGS & MD docs 2021-08-11 07:09:50 +00:00
David Walsh
3653e2d7f9 fix: Add ethers dependency to 0x/contracts-erc20 (#305) 2021-08-10 22:50:35 -06:00
mzhu25
65def38d98 Add treasury address to contract-addresses (#301)
* Add treasury address to contract-addresses

* Update changelogs
2021-08-06 00:28:47 -07:00
Github Actions
859c36cb10 Publish
- @0x/contracts-asset-proxy@3.7.17
 - @0x/contracts-broker@1.1.35
 - @0x/contracts-coordinator@3.1.36
 - @0x/contracts-dev-utils@1.3.34
 - @0x/contracts-erc1155@2.1.35
 - @0x/contracts-erc20@3.3.14
 - @0x/contracts-erc721@3.1.35
 - @0x/contracts-exchange-forwarder@4.2.36
 - @0x/contracts-exchange-libs@4.3.35
 - @0x/contracts-exchange@3.2.36
 - @0x/contracts-extensions@6.2.30
 - @0x/contracts-integrations@2.7.62
 - @0x/contracts-multisig@4.1.36
 - @0x/contracts-staking@2.0.43
 - @0x/contracts-test-utils@5.4.6
 - @0x/contracts-treasury@1.3.0
 - @0x/contracts-utils@4.7.14
 - @0x/contracts-zero-ex@0.27.0
 - @0x/asset-swapper@16.24.0
 - @0x/contract-addresses@6.5.0
 - @0x/contract-wrappers-test@12.2.51
 - @0x/contract-wrappers@13.17.3
 - @0x/migrations@8.0.12
 - @0x/order-utils@10.4.27
 - @0x/protocol-utils@1.8.0
2021-08-06 04:54:38 +00:00
Github Actions
3e34386812 Updated CHANGELOGS & MD docs 2021-08-06 04:54:34 +00:00
Jacob Evans
a35af11981 feat: Clipper (#299)
* feat: Clipper

* feat: Curve tricrypto2 (#302)

* Scope down the token list search space for Clipper

* update deployed addresses
2021-08-06 14:12:43 +10:00
mzhu25
59eabec71e Add proposal 1 and test (#298)
* Add proposal 1 and test

* update changelog
2021-08-05 13:10:36 -07:00
Github Actions
bf4c7e7d50 Publish
- @0x/contracts-integrations@2.7.61
 - @0x/asset-swapper@16.23.1
2021-07-29 15:23:54 +00:00
Github Actions
fd098ca4df Updated CHANGELOGS & MD docs 2021-07-29 15:23:49 +00:00
Lawrence Forman
c360f8d8fd Publish (#296)
- @0x/contracts-integrations@2.7.60
 - @0x/asset-swapper@16.23.0

Co-authored-by: Github Actions <github-actions@github.com>
2021-07-29 10:54:37 -04:00
Github Actions
b358559421 Publish
- @0x/contracts-integrations@2.7.60
 - @0x/asset-swapper@16.23.0
2021-07-16 22:11:44 +00:00
Github Actions
df5aad8e8e Updated CHANGELOGS & MD docs 2021-07-16 22:11:39 +00:00
Andreas Andreakis
8dbf79db59 fix: lint (#289) 2021-07-16 12:24:56 -07:00
Andreas Andreakis
1839608e84 feat: ACryptoS StableSwap (#284) 2021-07-15 15:19:40 -07:00
Github Actions
6e3e795b8b Publish
- @0x/contracts-integrations@2.7.59
 - @0x/asset-swapper@16.22.0
2021-07-13 22:19:54 +00:00
Github Actions
d9c410a7e3 Updated CHANGELOGS & MD docs 2021-07-13 22:19:49 +00:00
Romain Butteaud
609727afe8 feat: Saddle alETH, D4 pools (#283) 2021-07-13 14:22:16 -07:00
Romain Butteaud
8a5c74c0b4 feat: IronSwap (#281)
* feat: IronSwap

* feat: IronSwap, changelog

* feat: IronSwap, prettier
2021-07-13 14:07:45 -07:00
Github Actions
cd93f3b07e Publish
- @0x/contracts-integrations@2.7.58
 - @0x/asset-swapper@16.21.0
2021-07-10 08:00:34 +00:00
Github Actions
8397b12de6 Updated CHANGELOGS & MD docs 2021-07-10 08:00:29 +00:00
Romain Butteaud
3f85acec3a feat: JetSwap (#280)
* feat: JetSwap

* feat: JetSwap, changelog
2021-07-10 00:18:29 -07:00
phil-ociraptor
d6a9e3d600 fix: uncaught type error while logging (#277) 2021-07-07 14:28:42 -05:00
phil-ociraptor
361569ac2f chore: emit a log when a quote is returned that is between 99-100% of quote (#275) 2021-07-06 17:19:41 -05:00
Github Actions
719664c145 Publish
- @0x/contracts-integrations@2.7.57
 - @0x/asset-swapper@16.20.0
2021-07-06 21:34:44 +00:00
Github Actions
f800d6c24c Updated CHANGELOGS & MD docs 2021-07-06 21:34:39 +00:00
Romain Butteaud
a9a81bcafb feat: ShibaSwap (#276) 2021-07-06 13:53:39 -07:00
Github Actions
4280307a15 Publish
- @0x/contracts-integrations@2.7.56
 - @0x/asset-swapper@16.19.1
2021-07-06 04:03:16 +00:00
Github Actions
7b57d3ae51 Updated CHANGELOGS & MD docs 2021-07-06 04:03:11 +00:00
Romain Butteaud
8a8a5bbda0 fix: adding MultiHop for Polygon (#271) 2021-07-06 13:33:41 +10:00
Jacob Evans
76987c8db1 fix: PLP fallback (#272)
* fix: PLP fallback

* CHANGELOG
2021-07-06 13:32:34 +10:00
Github Actions
6f8971cc42 Publish
- @0x/contracts-integrations@2.7.55
 - @0x/asset-swapper@16.19.0
2021-07-02 01:48:13 +00:00
Github Actions
71ab882143 Updated CHANGELOGS & MD docs 2021-07-02 01:48:08 +00:00
Romain Butteaud
5a4961c8d9 fix: KyberDMM pick best pools, Polygon KyberDMM (#269)
* fix: KyberDMM all pools, Polygon KyberDMM

* fix: KyberDMM, remove getPoolsLength interface and revert if no pools found
2021-07-01 18:07:02 -07:00
mzhu25
4c4fb99d87 Add PLP as a source for Polygon (#270)
* Whitelist PLP as a source for Polygon

* changelog
2021-07-01 17:21:23 -07:00
Github Actions
872abf09e9 Publish
- @0x/contracts-integrations@2.7.54
 - @0x/asset-swapper@6.18.3
2021-06-29 17:20:15 +00:00
Github Actions
f10bfe7d04 Updated CHANGELOGS & MD docs 2021-06-29 17:20:11 +00:00
Romain Butteaud
a74d8deff3 feat: Balancer V2 Polygon (#267) 2021-06-29 09:46:17 -07:00
Github Actions
835ee4e8de Publish
- @0x/contracts-integrations@2.7.53
 - @0x/asset-swapper@6.18.2
2021-06-24 19:25:12 +00:00
Github Actions
63ec42303f Updated CHANGELOGS & MD docs 2021-06-24 19:25:07 +00:00
Romain Butteaud
f789aebddc fix: duplicate SOURCE_FLAGS index (#266) 2021-06-24 11:58:05 -07:00
Github Actions
efd83be779 Publish
- @0x/contracts-integrations@2.7.52
 - @0x/asset-swapper@6.18.1
2021-06-22 23:37:28 +00:00
Github Actions
603bc1d51c Updated CHANGELOGS & MD docs 2021-06-22 23:37:23 +00:00
Romain Butteaud
32a930a7fc feat: FirebirdOneSwap, ApeSwap [TKR-182] [TKR-173] (#265)
* fix: removing TITAN and IRON as intermediate tokens

* feat: FirebirdOneSwap, ApeSwap, intermediate tokens update

* chore: changelog
2021-06-22 16:04:09 -07:00
Github Actions
f464bf68d7 Publish
- @0x/contracts-asset-proxy@3.7.16
 - @0x/contracts-broker@1.1.34
 - @0x/contracts-coordinator@3.1.35
 - @0x/contracts-dev-utils@1.3.33
 - @0x/contracts-erc1155@2.1.34
 - @0x/contracts-erc20@3.3.13
 - @0x/contracts-erc721@3.1.34
 - @0x/contracts-exchange-forwarder@4.2.35
 - @0x/contracts-exchange-libs@4.3.34
 - @0x/contracts-exchange@3.2.35
 - @0x/contracts-extensions@6.2.29
 - @0x/contracts-integrations@2.7.51
 - @0x/contracts-multisig@4.1.35
 - @0x/contracts-staking@2.0.42
 - @0x/contracts-test-utils@5.4.5
 - @0x/contracts-treasury@1.2.3
 - @0x/contracts-utils@4.7.13
 - @0x/contracts-zero-ex@0.26.0
 - @0x/asset-swapper@6.18.0
 - @0x/contract-addresses@6.4.0
 - @0x/contract-wrappers-test@12.2.50
 - @0x/contract-wrappers@13.17.2
 - @0x/migrations@8.0.11
 - @0x/order-utils@10.4.26
 - @0x/protocol-utils@1.7.2
2021-06-22 10:03:41 +00:00
Github Actions
ebdc4fb509 Updated CHANGELOGS & MD docs 2021-06-22 10:03:35 +00:00
Kim Persson
7580719586 feat: Lido StETH deposit integration [TKR-90] (#260)
* feat: initial stab at the LidoSampler and the MixinLido

* feat: full integration of lido sampler and mixin

* fix: return pooled Ether amount not shares & properly unwrap WETH

* refactor: clean up Lido sampler and data passing

* fix: lower gas schedule for WETH to stETH deposits

* refactor: remove MixinLido unused ETH code path

* chore: add changelog entries

* fix: lower Lido gas schedule slightly

* fix: revert MixinLido on unsupported token pair

* fix: address review comments, improve early exit if wrong tokens

* fix: add contract addresses to Lido FQT
2021-06-22 11:25:47 +02:00
Github Actions
aba9db2be7 Publish
- @0x/contracts-integrations@2.7.50
 - @0x/asset-swapper@6.17.3
2021-06-16 01:38:55 +00:00
Github Actions
a6680411c8 Updated CHANGELOGS & MD docs 2021-06-16 01:38:51 +00:00
Romain Butteaud
0d0e87de94 QUICK, TITAN, IRON as intermediate tokens, integrating WaultSwap and Polydex for Polygon, Curve renBTC pool (#264) 2021-06-15 18:12:07 -07:00
Github Actions
ccf2000c09 Publish
- @0x/contracts-asset-proxy@3.7.15
 - @0x/contracts-broker@1.1.33
 - @0x/contracts-coordinator@3.1.34
 - @0x/contracts-dev-utils@1.3.32
 - @0x/contracts-erc1155@2.1.33
 - @0x/contracts-erc20@3.3.12
 - @0x/contracts-erc721@3.1.33
 - @0x/contracts-exchange-forwarder@4.2.34
 - @0x/contracts-exchange-libs@4.3.33
 - @0x/contracts-exchange@3.2.34
 - @0x/contracts-extensions@6.2.28
 - @0x/contracts-integrations@2.7.49
 - @0x/contracts-multisig@4.1.34
 - @0x/contracts-staking@2.0.41
 - @0x/contracts-test-utils@5.4.4
 - @0x/contracts-treasury@1.2.2
 - @0x/contracts-utils@4.7.12
 - @0x/contracts-zero-ex@0.25.1
 - @0x/asset-swapper@6.17.2
 - @0x/contract-addresses@6.3.1
 - @0x/contract-wrappers-test@12.2.49
 - @0x/contract-wrappers@13.17.1
 - @0x/migrations@8.0.10
 - @0x/order-utils@10.4.25
 - @0x/protocol-utils@1.7.1
2021-06-11 03:34:49 +00:00
Github Actions
3eb2e0f56a Updated CHANGELOGS & MD docs 2021-06-11 03:34:44 +00:00
Romain Butteaud
d07c7d5b69 feat: Curve V2 (#262)
* feat: Curve V2

* fix: CurveV2 gas schedule, remove unused import from MixinCurveV2

* feat: FQT address update

* chore: Curve V2 exchange_underlying, adding Polygon atricrypto pool

* prettier

* feat: FQT Polygon address update

* feat: FQT address update
2021-06-10 19:01:11 -07:00
Romain Butteaud
adf6684c29 chore: adding Uni v3 as a fee source (#261) 2021-06-08 17:57:49 -07:00
Github Actions
9bf889aa30 Publish
- @0x/contracts-asset-proxy@3.7.14
 - @0x/contracts-broker@1.1.32
 - @0x/contracts-coordinator@3.1.33
 - @0x/contracts-dev-utils@1.3.31
 - @0x/contracts-erc1155@2.1.32
 - @0x/contracts-erc20@3.3.11
 - @0x/contracts-erc721@3.1.32
 - @0x/contracts-exchange-forwarder@4.2.33
 - @0x/contracts-exchange-libs@4.3.32
 - @0x/contracts-exchange@3.2.33
 - @0x/contracts-extensions@6.2.27
 - @0x/contracts-integrations@2.7.48
 - @0x/contracts-multisig@4.1.33
 - @0x/contracts-staking@2.0.40
 - @0x/contracts-test-utils@5.4.3
 - @0x/contracts-treasury@1.2.1
 - @0x/contracts-utils@4.7.11
 - @0x/contracts-zero-ex@0.25.0
 - @0x/asset-swapper@6.17.1
 - @0x/contract-artifacts@3.15.0
 - @0x/contract-wrappers-test@12.2.48
 - @0x/contract-wrappers@13.17.0
 - @0x/migrations@8.0.9
 - @0x/order-utils@10.4.24
 - @0x/protocol-utils@1.7.0
2021-06-02 04:53:54 +00:00
Github Actions
e81c88564e Updated CHANGELOGS & MD docs 2021-06-02 04:53:49 +00:00
Lawrence Forman
901d400d62 Address spot check feedback (#251)
* UniswapV3 VIP (#237)

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

* `@0x/contracts-zero-ex`: Add UniswapV3 VIP
`@0x/contract-artifacts`: Regenerate.
`@0x/contract-wrappers`: Regenerate.
`@0x/asset-swapper`: Add UniswapV3 VIP support.

* address review comments and appease linter

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

* Multiplex UniswapV3 (#241)

* Add UniswapV3 support to Multiplex batchFill

* Add AssetSwapper support for Multiplex UniswapV3

* fix repo scripts that use PKG= env var (#242)

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

* `@0x/asset-swapper`: Adjust uniswap gas overhead

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>

* OTC orders feature (#244)

* Add OTC orders feature contracts

* Address PR feedback

* Remove partial fills for takerSigned variant

* Add function to query the min valid nonce

* Add ETH support

* Tightly pack expiry, nonceBucket, and nonce

* Address PR feedback

* OTC orders unit tests

* Bump prettier version

* Skip unnecessary math if takerTokenFillAmount == order.takerAmount

* appease CI

* Update contract-artifacts and contract-wrappers and CHANGELOGs

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

* `regen wrappers

* prettier

* `@0x/asset-swapper`: prettier and tweak gas schedule slightly for uni3

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>
2021-06-02 14:21:14 +10:00
Github Actions
289474e2ce Publish
- @0x/contracts-integrations@2.7.47
 - @0x/contracts-treasury@1.2.0
 - @0x/asset-swapper@6.17.0
2021-05-27 22:22:14 +00:00
Github Actions
407ca21168 Updated CHANGELOGS & MD docs 2021-05-27 22:22:09 +00:00
mzhu25
5c68fc24d2 Miscellaneous Liquidity Provider changes (#253)
* Update KNC address and reenable PLP

* Enable PLP VIP on BSC
2021-05-25 14:01:07 -07:00
mzhu25
548800e0a9 Add proposal 0 params and mainnet fork test (#252) 2021-05-25 13:48:34 -07:00
Github Actions
bde3d6dc6a Publish
- @0x/contracts-asset-proxy@3.7.13
 - @0x/contracts-broker@1.1.31
 - @0x/contracts-coordinator@3.1.32
 - @0x/contracts-dev-utils@1.3.30
 - @0x/contracts-erc1155@2.1.31
 - @0x/contracts-erc20@3.3.10
 - @0x/contracts-erc721@3.1.31
 - @0x/contracts-exchange-forwarder@4.2.32
 - @0x/contracts-exchange-libs@4.3.31
 - @0x/contracts-exchange@3.2.32
 - @0x/contracts-extensions@6.2.26
 - @0x/contracts-integrations@2.7.46
 - @0x/contracts-multisig@4.1.32
 - @0x/contracts-staking@2.0.39
 - @0x/contracts-test-utils@5.4.2
 - @0x/contracts-treasury@1.1.8
 - @0x/contracts-utils@4.7.10
 - @0x/contracts-zero-ex@0.24.1
 - @0x/asset-swapper@6.16.0
 - @0x/contract-addresses@6.3.0
 - @0x/contract-wrappers-test@12.2.47
 - @0x/contract-wrappers@13.16.3
 - @0x/migrations@8.0.8
 - @0x/order-utils@10.4.23
 - @0x/protocol-utils@1.6.2
2021-05-25 12:13:43 +00:00
Github Actions
56550a6acc Updated CHANGELOGS & MD docs 2021-05-25 12:13:38 +00:00
Kim Persson
e51b83accc Polygon support (#240)
* feat: Polygon deployed

* Updated polygon FQT address

* feat: add SushiSwap on Polygon WIP

* fix: add Matic as a native token

* refactor: import valueByChainId from token-metadata to consolidate impl

* refactor: use same gas schedule fn for all uni v2 clones

* feat: Add QuickSwap Polygon integration

* fix: add Polygon tokens to initial TokenAdjacencyGraph

* feat: ComethSwap Polygon integration

* feat: Add Curve, Dfyn, mStable for Polygon

* fix: temporarily private publish contract-addresses, token-metadata

* feat: Add DODO V2 support for polygon, stability pool on mainnet, bsc

* chore: fix linting

* fix: incorrect Curve Polygon gas schedule

Co-authored-by: Jacob Evans <jacob@dekz.net>

* refator: consolidate Polygon token addresses in POLYGON_TOKENS

* feat: Polygon DODO V1 integration

* fix: remove dependency on @0x/token-metadata

* chore: remove private publish dependencies and add changelog entry

Co-authored-by: Jacob Evans <jacob@dekz.net>
Co-authored-by: Romain Butteaud <romain.butteaud@gmail.com>
2021-05-25 13:40:52 +02:00
Github Actions
d5ae971f1c Publish
- @0x/contracts-asset-proxy@3.7.12
 - @0x/contracts-broker@1.1.30
 - @0x/contracts-coordinator@3.1.31
 - @0x/contracts-dev-utils@1.3.29
 - @0x/contracts-erc1155@2.1.30
 - @0x/contracts-erc20@3.3.9
 - @0x/contracts-erc721@3.1.30
 - @0x/contracts-exchange-forwarder@4.2.31
 - @0x/contracts-exchange-libs@4.3.30
 - @0x/contracts-exchange@3.2.31
 - @0x/contracts-extensions@6.2.25
 - @0x/contracts-integrations@2.7.45
 - @0x/contracts-multisig@4.1.31
 - @0x/contracts-staking@2.0.38
 - @0x/contracts-test-utils@5.4.1
 - @0x/contracts-treasury@1.1.7
 - @0x/contracts-utils@4.7.9
 - @0x/contracts-zero-ex@0.24.0
 - @0x/asset-swapper@6.15.0
 - @0x/contract-addresses@6.2.0
 - @0x/contract-wrappers-test@12.2.46
 - @0x/contract-wrappers@13.16.2
 - @0x/migrations@8.0.7
 - @0x/order-utils@10.4.22
 - @0x/protocol-utils@1.6.1
2021-05-21 12:37:26 +00:00
Github Actions
5a2f5f9a42 Updated CHANGELOGS & MD docs 2021-05-21 12:37:22 +00:00
Jacob Evans
75a3b70cef chore: Temporarily disable a LiquidityProvider (#248) 2021-05-21 22:08:55 +10:00
Jacob Evans
803cf65ba1 fix: Deploy FQT for KyberDmm/Mstable (#247) 2021-05-19 08:34:26 +10:00
Jacob Evans
5d3947b838 fix prettier 2021-05-18 09:10:29 +10:00
mzhu25
4397a59008 Add Huobi Token to liquidity provider tokens (#246) 2021-05-17 15:21:53 -07:00
Jacob Evans
966d54c935 fix: KyberDmm (#236)
* fix: KyberDmm

* fix: pass buyToken to kyberDmm and require that path ends with buyToken

* Pass BigNumber down to FastABI

* Address Feedback

Co-authored-by: Kim Persson <kimpersson88@gmail.com>
2021-05-18 08:12:28 +10:00
Romain Butteaud
234ddb495d fix: mStable USD Sampler and Mixin fix (#238)
* fix: mStable USD Sampler and Mixin fix

* chore: adding mBTC (mStable) pool

* fix linter
2021-05-16 19:43:06 -07:00
mzhu25
a744acc7bc Add special selectors to selector collision test (#243) 2021-05-14 10:50:58 -07:00
Lawrence Forman
27c624633c fix repo scripts that use PKG= env var (#242)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-05-12 18:53:06 -04:00
Github Actions
7ef75101b4 Publish
- @0x/contracts-integrations@2.7.44
 - @0x/asset-swapper@6.14.0
2021-05-12 09:13:31 +00:00
Github Actions
6f8aace00d Updated CHANGELOGS & MD docs 2021-05-12 09:13:23 +00:00
Kim Persson
6c264b2f18 feat: add DAI and USDC as intermediate tokens on Ropsten [TKR-93] (#231)
* feat: add DAI and USDC as intermediate tokens on Ropsten

* chore: add changelog entry
2021-05-11 19:36:46 +02:00
Daniel Pyrathon
df055e1958 fix: Added fee parameter to Quote Requestor (#235)
* Added changes

* Fixes

* Applied PR feedback

* lint fix
2021-05-11 12:57:51 -04:00
Github Actions
70d2117470 Publish
- @0x/contracts-integrations@2.7.43
 - @0x/asset-swapper@6.13.0
2021-05-11 03:18:25 +00:00
Github Actions
2c173ccaf3 Updated CHANGELOGS & MD docs 2021-05-11 03:18:20 +00:00
mzhu25
d2f4a0c5f3 Updated config.yml 2021-05-10 19:51:12 -07:00
mzhu25
0d6021e5e3 Add LiquidityProvider to BSC sources (#234) 2021-05-10 18:27:52 -07:00
Github Actions
bb04726e7f Publish
- @0x/contracts-integrations@2.7.42
 - @0x/asset-swapper@6.12.0
2021-05-10 01:36:49 +00:00
Github Actions
220ca370c2 Updated CHANGELOGS & MD docs 2021-05-10 01:36:44 +00:00
Jacob Evans
63af4e3e98 fix: TwoHopSampler call (#233) 2021-05-10 11:05:30 +10:00
Github Actions
9754e12d82 Publish
- @0x/contracts-integrations@2.7.41
 - @0x/asset-swapper@6.11.0
2021-05-07 04:35:35 +00:00
Github Actions
d72ebed246 Updated CHANGELOGS & MD docs 2021-05-07 04:35:31 +00:00
Jacob Evans
587fc71058 fix: Sampler contract address overrides (#232)
* fix: Sampler contract address overrides

* Update CHANGELOG
2021-05-07 13:52:51 +10:00
Kim Persson
7d34e09a12 fix: add separate priceComparisonsReport to fix missing quoteReport data [TKR-91] (#219)
* fix: add separate priceComparisonsReport to fix missing quoteReport data

* chore: remove notice about unconfirmed Uniswap V3 addresses

* refactor: move price comparisons computation logic into separate method

* chore: add AS changelog entry
2021-05-06 14:54:54 +02:00
Kim Persson
7d15baad0f feat: Balancer V2 load and cache top pools by num swaps on startup [TKR-96] (#228)
* feat: Balancer V2 load and cache top pools by num swaps on startup

* refactor: Clean up code for Balancer V1 & V2 cache heating

* chore: add AS changelog entry
2021-05-06 14:21:30 +02:00
mzhu25
1e6476ada7 Add ETH pseudo-address when wrapping/unwrapping in Multiplex multihop (#230)
* Add ETH pseudo-address when wrapping/unwrapping in Multiplex multihop

* Update changelog
2021-05-06 15:29:24 +10:00
Lawrence Forman
1d6ca5f6b5 @0x/asset-swapper: Tweak compiler settings for smaller sampler size (#229)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-05-05 18:36:38 -04:00
Github Actions
fb249f02fc Publish
- @0x/contracts-asset-proxy@3.7.11
 - @0x/contracts-broker@1.1.29
 - @0x/contracts-coordinator@3.1.30
 - @0x/contracts-dev-utils@1.3.28
 - @0x/contracts-erc1155@2.1.29
 - @0x/contracts-erc20@3.3.8
 - @0x/contracts-erc721@3.1.29
 - @0x/contracts-exchange-forwarder@4.2.30
 - @0x/contracts-exchange-libs@4.3.29
 - @0x/contracts-exchange@3.2.30
 - @0x/contracts-extensions@6.2.24
 - @0x/contracts-integrations@2.7.40
 - @0x/contracts-multisig@4.1.30
 - @0x/contracts-staking@2.0.37
 - @0x/contracts-test-utils@5.4.0
 - @0x/contracts-treasury@1.1.6
 - @0x/contracts-utils@4.7.8
 - @0x/contracts-zero-ex@0.23.0
 - @0x/asset-swapper@6.10.0
 - @0x/contract-addresses@6.1.0
 - @0x/contract-artifacts@3.14.2
 - @0x/contract-wrappers-test@12.2.45
 - @0x/contract-wrappers@13.16.1
 - @0x/migrations@8.0.6
 - @0x/order-utils@10.4.21
 - @0x/protocol-utils@1.6.0
2021-05-05 11:32:51 +00:00
Github Actions
fdf04ef275 Updated CHANGELOGS & MD docs 2021-05-05 11:32:46 +00:00
Jacob Evans
b0f5f634f2 bump test-publish resource_class 2021-05-05 21:02:31 +10:00
Jacob Evans
6ee0108565 fix: async pool cache (#226) 2021-05-05 21:01:51 +10:00
Jacob Evans
c73097e688 chore: Deploy FQT with UniswapV3 support (#227) 2021-05-05 21:01:39 +10:00
Lawrence Forman
a2d42b07b5 UniswapV3 [TKR-4] (#197)
* add balancer v2

* fetch balancer v2 pools from subgraph

* feat: initial stab at a Balancer V2 Sampler WIP

* feat: add sampling for buys and fix build issues WIP [untested]

* fix: BalancerV2Sampler implementation issues, works on Kovan

* chore: BalancerV2 sampling boilerplate

* fix: update Balancer V2 mainnet address

* fix: consolidate differences between the 2 working branches

* fix: use mainnet Balancer V2 subgraph

* fix: stack too deep by minimizing and inline Balancer V2 vault interface

* fix: address review comments and clean up

* fix: sampler vault interface and pools cache assuming a pool has swaps

* address more review comments

* fix: TS type issues and add a comment about deadline argument

* fix: pools_cache_tests incorrect token addresses, prettier incompat

* fix: make ERC20BridgeSampler support BalancerV2 non view sampler fns

* fix: use a struct for passing encoded bridge data for Balancer V2

* chore: add changelog entries

* fix: improve gas accuracy of gas schedule for Balancer V2 & Maker Psm

* fix: don't exclude sources with stale caches & wait for cache refresh

* rebase

* `@0x/asset-swapper`: Fix stack too deep errors in sampler

* `@0x/asset-swapper`: Add uniswap V3 sampler.

* `@0x/contracts-zero-ex`: Add UniswapV3 support to FQT

* `@0x/protocol-utils`: Update BridgeProtocols.
`@0x/asset-swapper`: Add sell integration for UniswapV3.

* `@0x/asset-swapper`: Remove unnecessary swap quote consumer constructor arg.
`@0x/asset-swapper`: Enable UniswapV3 on ropsten.

* `@0x/asset-swapper`: UniswapV3 fixes

* `@0x/asset-swapper`: Fix stuff based on latest deployed testnet contracts

* `@0x/asset-swapper`: Remove UniV3 from mainnet sources for now

* `@0x/asset-swapper`: Tweak univ3 gas schedule

* fix CI?

* `@0x/contracts-test-utils`: Set default ganache gas limit to 100e6

Co-authored-by: xianny <xianny@gmail.com>
Co-authored-by: Kim Persson <kimpersson88@gmail.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Jacob Evans <jacob@dekz.net>
2021-05-05 19:44:17 +10:00
Xianny
f9a794af93 feat: Balancer V2 integration (#206)
* add balancer v2

* fetch balancer v2 pools from subgraph

* feat: initial stab at a Balancer V2 Sampler WIP

* feat: add sampling for buys and fix build issues WIP [untested]

* fix: BalancerV2Sampler implementation issues, works on Kovan

* chore: BalancerV2 sampling boilerplate

* fix: update Balancer V2 mainnet address

* fix: consolidate differences between the 2 working branches

* fix: use mainnet Balancer V2 subgraph

* fix: stack too deep by minimizing and inline Balancer V2 vault interface

* fix: address review comments and clean up

* fix: sampler vault interface and pools cache assuming a pool has swaps

* address more review comments

* fix: TS type issues and add a comment about deadline argument

* fix: pools_cache_tests incorrect token addresses, prettier incompat

* fix: make ERC20BridgeSampler support BalancerV2 non view sampler fns

* fix: use a struct for passing encoded bridge data for Balancer V2

* chore: add changelog entries

* fix: improve gas accuracy of gas schedule for Balancer V2 & Maker Psm

* fix: don't exclude sources with stale caches & wait for cache refresh

* rebase

* `@0x/asset-swapper`: Fix stack too deep errors in sampler

Co-authored-by: Kim Persson <kimpersson88@gmail.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-05-05 11:01:28 +02:00
Jacob Evans
a2643674ca Fix: PLP now generates a fallback (#223)
* fix: PLP requires a fallback

* update changelog

* Fix missed source exclusion
2021-05-05 08:22:19 +10:00
Jacob Evans
c00ce9daac feat: Support ETH based Curve pools (#220)
* feat: Support ETH based Curve pools

* Disable Curve VIP for WETH trades

* feat: Support for sETH and ankrETH (Curve)

* Disable SnowSwap ETH pools

* feat: add BUSD Curve 3pool

* fix changelog

Co-authored-by: Romain Butteaud <romain.butteaud@gmail.com>
2021-05-05 07:33:41 +10:00
mzhu25
c68b5d7844 Fix/staking epoch finalization (#221)
* Patch staking and recover state in constructor

* Add ganache mainnet fork test

* Add ganache mainnet fork test

* update changelog

* hardcode last pool ID

* Separate patch contract to unbreak tests
2021-05-04 11:29:16 -07:00
Jacob Evans
09ed106d4c feat: Deployed Balancer V2 and Curve ETH support (#225) 2021-05-04 16:52:36 +10:00
Jacob Evans
a6b92fc658 fix: Fix test forever with new sources being added 2021-05-04 16:49:16 +10:00
mzhu25
4be4a1a30b Fix exchangeProxyGasOverhead used to compute fallback orders (#215)
* Fix exchangeProxyGasOverhead used to compute fallback orders

* update changelog
2021-05-04 13:41:21 +10:00
Romain Butteaud
9bede5d331 fix: reactive PancakeSwap, BakerySwap VIP on BSC (#222) 2021-05-04 13:40:57 +10:00
Romain Butteaud
b50d4aee6d Chore: adding xSigma liquidity source [TKR-59] (#201)
* Chore: adding xSigma liquidity source

* fix: prettier
2021-05-03 19:50:26 -07:00
Jacob Evans
55bc367bd6 feat: Add LUSD Curve pool (#218) 2021-05-04 08:08:27 +10:00
Github Actions
7a59b7eafe Publish
- @0x/contracts-integrations@2.7.39
 - @0x/contracts-zero-ex@0.22.3
 - @0x/asset-swapper@6.9.1
 - @0x/contract-wrappers-test@12.2.44
 - @0x/migrations@8.0.5
2021-05-01 01:03:24 +00:00
Github Actions
9e59d41e44 Updated CHANGELOGS & MD docs 2021-05-01 01:03:19 +00:00
Jacob Evans
475e6c7bca fix: Temporarily remove PancakeV2/Bakery from VIP (#217) 2021-05-01 10:35:54 +10:00
Github Actions
dbc5a5293e Publish
- @0x/contracts-integrations@2.7.38
 - @0x/contracts-treasury@1.1.5
 - @0x/contracts-zero-ex@0.22.2
 - @0x/asset-swapper@6.9.0
 - @0x/contract-wrappers-test@12.2.43
 - @0x/migrations@8.0.4
2021-04-30 23:39:46 +00:00
Github Actions
f4bd2bd0d8 Updated CHANGELOGS & MD docs 2021-04-30 23:39:42 +00:00
Romain Butteaud
f1782a83ba chore: BSC PancakeSwap forks VIP, PancakeSwapV2, Saddle BTC pool, Curve gas schedule [TKR-41] [TKR-11] [TKR-79] [TKR-86] (#208)
* chore: popular BSC Uniswap clones, Curve gas schedule update, Saddle BTC pool

* chore: adding PancakeSwapV2 VIP

* fix: yarn prettier
2021-05-01 08:48:10 +10:00
Jacob Evans
cbade0d558 fix: Ban colliding Kyber reserve (#216) 2021-04-29 15:24:39 +10:00
mzhu25
fe0c26387c Fix treasury voting power calculation (#214)
* Fix treasury voting power calculation

* Update changelog
2021-04-28 10:22:52 -07:00
Github Actions
c03a014740 Publish
- @0x/contracts-asset-proxy@3.7.10
 - @0x/contracts-broker@1.1.28
 - @0x/contracts-coordinator@3.1.29
 - @0x/contracts-dev-utils@1.3.27
 - @0x/contracts-erc1155@2.1.28
 - @0x/contracts-erc20@3.3.7
 - @0x/contracts-erc721@3.1.28
 - @0x/contracts-exchange-forwarder@4.2.29
 - @0x/contracts-exchange-libs@4.3.28
 - @0x/contracts-exchange@3.2.29
 - @0x/contracts-extensions@6.2.23
 - @0x/contracts-integrations@2.7.37
 - @0x/contracts-multisig@4.1.29
 - @0x/contracts-staking@2.0.36
 - @0x/contracts-test-utils@5.3.25
 - @0x/contracts-treasury@1.1.4
 - @0x/contracts-utils@4.7.7
 - @0x/contracts-zero-ex@0.22.1
 - @0x/asset-swapper@6.8.0
 - @0x/contract-artifacts@3.14.1
 - @0x/contract-wrappers-test@12.2.42
 - @0x/contract-wrappers@13.16.0
 - @0x/migrations@8.0.3
 - @0x/order-utils@10.4.20
 - @0x/protocol-utils@1.5.1
2021-04-28 07:48:31 +00:00
Github Actions
84e6d788aa Updated CHANGELOGS & MD docs 2021-04-28 07:48:27 +00:00
Jacob Evans
cd296b8767 feat: Prune Paths + Fast ABI (#183)
* Cull paths which cannot improve price

* fixes and rename

* optimizations

* disable ABI optimization for sampler

* fix lint

* use fastabi

* Update to fastabi 0.0.2

* update packages

* Fix NaN case

* update to published packages

* rebased

* Update generated wrappers
2021-04-28 17:16:24 +10:00
Lawrence Forman
5946d32a7d Berlin wrappers (#212)
* `@0x/contract-wrappers`: Regenerate wrappers using updated abi-gen
Update tools deps

* update deps to hopefully fix doc gen
2021-04-27 12:16:08 -04:00
Alex Kroeger
842dd8572b bump NativeOrdersFeature version to 1.2 (#213)
* bump version to 1.2

* update changelog
2021-04-27 08:11:13 -07:00
Github Actions
33e260f9db Publish
- @0x/contracts-integrations@2.7.36
 - @0x/contracts-treasury@1.1.3
 - @0x/contracts-zero-ex@0.22.0
 - @0x/asset-swapper@6.7.0
 - @0x/contract-wrappers-test@12.2.41
 - @0x/migrations@8.0.2
 - @0x/protocol-utils@1.5.0
2021-04-26 23:59:58 +00:00
Github Actions
c44f8d0060 Updated CHANGELOGS & MD docs 2021-04-26 23:59:53 +00:00
Kim Persson
411548a33e feat: PancakeSwap 2 integration [TKR-83] (#211)
* feat: PancakeSwap 2 integration

* chore: add PancakeSwap V2 changelog entry

Co-authored-by: Romain Butteaud <romain@0xproject.com>
2021-04-26 15:51:04 -07:00
Alex Kroeger
9a17ce1383 add registerAllowedSigner to NativeOrdersFeature (#195)
* add registerAllowedSigner to NativeOrdersFeature

* fix PR reference in changelog

* prettier

* add cancel pair orders functions for signers

* refactored cancelPairOrders logic, changed naming of signerRegistry to orderSigner registry everywhere, cleaned up tests

* updated changelog for protocol-utils, made batchCancelPairOrders functions more efficient

* clean up function documentation

* added additional tests for batchCancelPairsWithSigner functions, added additional checks for events being emitted correctly

* fix typos in function documentation

* fix typo in function documentation

* update docs

* update comments on cancel functions, small tweaks to docs
2021-04-26 14:32:35 -07:00
Romain Butteaud
2b120d0669 fix: feeType=positive_slippage logic [TKR-81] (#209)
* fix: Fix feeType=positive_slippage logic to not force the EP route

* fix: yarn prettier
2021-04-26 11:26:57 -07:00
Github Actions
6d877d5242 Publish
- @0x/contracts-integrations@2.7.35
 - @0x/asset-swapper@6.6.0
2021-04-16 17:07:22 +00:00
Github Actions
e4abd690e7 Updated CHANGELOGS & MD docs 2021-04-16 17:07:17 +00:00
Jacob Evans
2a194384b6 [asset-swapper] Support Ropsten testnet (#203) 2021-04-16 13:55:35 +10:00
Jacob Evans
1e069e6f8a Remove 10 days from protocol fees docs (#202) 2021-04-16 10:51:41 +10:00
Daniel Pyrathon
a019bb913d only set Last Look parameter if it's explicitly set (#200)
* only set Last Look parameter if it's explicitly set

* remove expoectation of having isLastLook
2021-04-14 16:38:55 -07:00
Github Actions
9ce73931f7 Publish
- @0x/contracts-integrations@2.7.34
 - @0x/asset-swapper@6.5.3
2021-04-14 20:56:21 +00:00
Github Actions
97020df178 Updated CHANGELOGS & MD docs 2021-04-14 20:56:14 +00:00
Lawrence Forman
dfb7b3de8f Apply slippage to non-native orders [TKR-39] (#198)
* `@0x/asset-swapper`: Apply slippage to FQT bridge orders

* review comments

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-04-13 19:24:50 -04:00
Github Actions
9e152912fe Publish
- @0x/contracts-integrations@2.7.33
 - @0x/asset-swapper@6.5.2
2021-04-13 11:51:04 +00:00
Github Actions
b2c2f1e1aa Updated CHANGELOGS & MD docs 2021-04-13 11:50:57 +00:00
Jacob Evans
629c7d8e92 Fix asset-swapper test (#199) 2021-04-13 21:01:26 +10:00
Jacob Evans
62f24d4356 [asset-swapper] add Native fee token on all chains (#191) 2021-04-13 08:21:26 +10:00
Github Actions
ae281c33ca Publish
- @0x/contracts-integrations@2.7.32
 - @0x/contracts-treasury@1.1.2
 - @0x/contracts-zero-ex@0.21.1
 - @0x/asset-swapper@6.5.1
 - @0x/contract-wrappers-test@12.2.40
 - @0x/migrations@8.0.1
 - @0x/protocol-utils@1.4.1
2021-04-12 20:37:59 +00:00
Github Actions
5d034dd106 Updated CHANGELOGS & MD docs 2021-04-12 20:37:55 +00:00
Romain Butteaud
c1f8df0eca chore: Component.finance, Smoothy.finance, Saddle.finance, Curve open pools, Gas schedule [TKR-1] (#182)
* chore: Component.finance, Smoothy.finance (mainnet + BSC), Saddle.finance, Curve open pools, adjusting gas schedule, fixing Shell buys

* chore: adding a Sampler for Smoothy.finance to only use whats in the contracts reserve

* fix: Smoothy sampler, only use approx. for buys, removing y and BUSD curve pools

* add CHANGELOGs

* fix: prettier

* add: FRAX Curve open pool

* fix: prettier

* chore: adjusting gas schedule for BSC Smoothy
2021-04-08 18:07:12 -07:00
Github Actions
76dda9eeda Publish
- @0x/contracts-integrations@2.7.31
 - @0x/asset-swapper@6.5.0
2021-04-08 20:27:04 +00:00
Github Actions
a9b84a92ac Updated CHANGELOGS & MD docs 2021-04-08 20:26:57 +00:00
mzhu25
0f7e881899 Add default liquidity provider registry and allow gas costs to be a function of tokens (#196) 2021-04-08 11:09:32 -07:00
mzhu25
6045f777ab Add Kyber DMM as a liquidity source (#194)
* Add Kyber DMM as a liquidity source

* update changelog
2021-04-07 10:08:19 -07:00
Github Actions
5a15044ead Publish
- @0x/contracts-asset-proxy@3.7.9
 - @0x/contracts-broker@1.1.27
 - @0x/contracts-coordinator@3.1.28
 - @0x/contracts-dev-utils@1.3.26
 - @0x/contracts-erc1155@2.1.27
 - @0x/contracts-erc20@3.3.6
 - @0x/contracts-erc721@3.1.27
 - @0x/contracts-exchange-forwarder@4.2.28
 - @0x/contracts-exchange-libs@4.3.27
 - @0x/contracts-exchange@3.2.28
 - @0x/contracts-extensions@6.2.22
 - @0x/contracts-integrations@2.7.30
 - @0x/contracts-multisig@4.1.28
 - @0x/contracts-staking@2.0.35
 - @0x/contracts-test-utils@5.3.24
 - @0x/contracts-treasury@1.1.1
 - @0x/contracts-utils@4.7.6
 - @0x/contracts-zero-ex@0.21.0
 - @0x/asset-swapper@6.4.0
 - @0x/contract-addresses@6.0.0
 - @0x/contract-artifacts@3.14.0
 - @0x/contract-wrappers-test@12.2.39
 - @0x/contract-wrappers@13.15.0
 - @0x/migrations@8.0.0
 - @0x/order-utils@10.4.19
 - @0x/protocol-utils@1.4.0
2021-04-01 21:09:06 +00:00
Github Actions
a69d76e487 Updated CHANGELOGS & MD docs 2021-04-01 21:09:02 +00:00
Kim Persson
3adfcdffa8 Maker PSM integration [TKR-2] (#150)
* ADDS basic boilerplate for PSM bridge WIP

* ADDS integrate the MakerPSM mixin and fix incorrect naming

* fix: take into account PSM fee when buying USDC from PSM

* feat: intial stab at a PSM sampler WIP

* feat: integrate MakerPsm into AS WIP

* refactor: get VAT contract address from PSM instead of passing it in

* fix: hardcode PSM Gemtoken to USDC

* fix: remove passing in authGem, get from PSM contract instead

* fix: use constant modified to avoid using storage variables

* fix: incorrect num decimals after multiplication in sampler

* fix: PSM buy sampling

* fix: use fillData to estimate gas schedule

* Rebased on latest development

* Guard and use latest Curve LiquidityProvider

* `@0x/contract-addresses`: Redeploy FQT on mainnet and ropsten

Co-authored-by: Jacob Evans <jacob@dekz.net>
Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
2021-04-01 15:45:06 -04:00
Lawrence Forman
164a5d44d9 bsc<->development rebase (#189)
* FQT: Pack Protocol/source name into source ID (#162)

* `@0x/contracts-zero-ex`: Encode protocol ID and source name in bridge source ID
`@0x/asset-swapper`: Use new bridge source ID encoding.

* fix linter issues

* contracts cleanup (#164)

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

* `@0x/contracts-zero-ex`: Remove tokenspender/allowance target/greedy tokens stuff.'
`@0x/contract-addresses`: Add BSC addresses. Remove exchangeProxyAllowanceTarget.
`@0x/migrations`: Remove exchangeProxyAllowanceTarget.

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

Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>

* `@0x/contracts-zero-ex`: Add sushiswap support to PancakeSwap

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

* `@0x/contract-addresses`: Add BSC addresses

Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>

Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>

* feat: Better chain support (#163)

* feat: Better chain support

* feat: better chain support refactor deployment constants (#166)

* proliferate the chainId

* Refactor sampler to remove DeploymentConstants dependency and fixed addresses

* Rework WETH out, replacing with address(0)

* wat

* hack DeploymentConstants for now

* proliferate the chainId

* Refactor sampler to remove DeploymentConstants dependency and fixed addresses

* remove duped network addresses

* Rework the bridge source encoder

* Use the constants NATIVE_FEE_TOKEN in EP consumer

* `@0x/contract-addresses`: Fix WBNB address (#170)

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

* multichain enable cakez vip (#171)

* feat: Better chain support

* feat: better chain support refactor deployment constants (#166)

* proliferate the chainId

* Refactor sampler to remove DeploymentConstants dependency and fixed addresses

* Rework WETH out, replacing with address(0)

* wat

* hack DeploymentConstants for now

* proliferate the chainId

* Refactor sampler to remove DeploymentConstants dependency and fixed addresses

* remove duped network addresses

* `asset-swapper`: enable pancake VIP route generation

Co-authored-by: Jacob Evans <jacob@dekz.net>
Co-authored-by: Lawrence Forman <me@merklejerk.com>

* `@0x/contracts-zero-ex`: Fix `PancakeSwapFeature` sushi values (#172)

* `@0x/contracts-zero-ex`: Fix `PancakeSwapFeature` sushi values

* `@0x/contracts-zero-ex`: I am a bad protocologist

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

* feat: BSC Nerve + Dodo + Nerve + Ellipsis (#181)

* feat: BSC Nerve + DODO v1

* CHANGELOGs

* Remove extra balance fetch

* Add Belt

* Added Ellipsis

* Update FQT address

* `@0x/contracts-zero-ex`: Delete TokenSpenderFeature and get stuff compiling

* `@0x/asset-swapper`: fix compilation

* prettier

* `@0x/asset-swapper`: Truncate LiquidityProvider source ID name

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

Co-authored-by: Jacob Evans <jacob@dekz.net>

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

Co-authored-by: Jacob Evans <jacob@dekz.net>

* `@0x/contracts-zero-ex`: Fix BakerySwap on PackageSwapFeature (#190)

* address review comments

Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>
Co-authored-by: Jacob Evans <jacob@dekz.net>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-03-31 18:49:44 -04:00
phil-ociraptor
70ddab0231 [MKR-3] Prepare Asset Swapper for RFQM (#187)
* Prepare QuoteRequestor for RFQM

* Add unit tests for Quote Requestor changes

* Fix lint errors
2021-03-31 12:11:10 -05:00
Xianny
7bf009fbf6 Upgrade to typescript v4.2.2 (#188)
* upgrade to typescript v4.2.2

* prettier; remove outdated test
2021-03-30 13:26:05 -07:00
Daniel Pyrathon
525bc8197b Revive quote report (#184)
* Revives Quote Report

* prettier

* Remove unused parameters

* updated a few issues with tests

* Remove old code

* Fixed other unit tests
2021-03-30 09:57:03 -07:00
Alex Kroeger
24397c51a8 improve logging for alt rfq request (#158)
* improve logging for alt rfq request

* clean up unsuccessful status code logic

* Fix quote requestor tests

* get rid of unnecessary promise handling

* remove unused code

* update changelog

* changed warning message for no quote

* appease prettier
2021-03-24 13:45:54 -07:00
phil-ociraptor
06b3464756 Rename {Rfqt=>Rfq} for types in Asset Swapper (#179)
* Rename {Rfqt=>Rfq} for types in Asset Swapper

* PR edit 1 - fix build errors

* PR edit 2 - rename mocked types used in tests

* PR edit 3 - fix broken test build

* PR edit 4 - rename SwapQuoterRfqOpts and add changelog entry
2021-03-23 17:21:50 -05:00
phil-ociraptor
bbaa90bd9a Add a cancel token to manually enforce a timeout in Quote Requestor (#176)
* Add a cancel token to manually enforce a timeout in Quote Requestor

* Start setTimeout before making requests, add an extra buffer

* Run prettier

* Add comment to changelog
2021-03-22 17:08:51 -05:00
mzhu25
5c683cbc0f Fix Multiplex multi-hop encoding issue (#178) 2021-03-17 22:28:35 -07:00
Alex Kroeger
95345f18bc use the RfqOrder source flag for comparison price EP overhead (#177)
* use the RfqOrder source flag for comparison price EP overhead

* updated changelog

* changelog -> 6.4
2021-03-17 16:37:56 -07:00
Github Actions
4c3fbe83ac Publish
- @0x/contracts-asset-proxy@3.7.8
 - @0x/contracts-broker@1.1.26
 - @0x/contracts-coordinator@3.1.27
 - @0x/contracts-dev-utils@1.3.25
 - @0x/contracts-erc1155@2.1.26
 - @0x/contracts-erc20@3.3.5
 - @0x/contracts-erc721@3.1.26
 - @0x/contracts-exchange-forwarder@4.2.27
 - @0x/contracts-exchange-libs@4.3.26
 - @0x/contracts-exchange@3.2.27
 - @0x/contracts-extensions@6.2.21
 - @0x/contracts-integrations@2.7.29
 - @0x/contracts-multisig@4.1.27
 - @0x/contracts-staking@2.0.34
 - @0x/contracts-test-utils@5.3.23
 - @0x/contracts-treasury@1.1.0
 - @0x/contracts-utils@4.7.5
 - @0x/contracts-zero-ex@0.20.0
 - @0x/asset-swapper@6.3.0
 - @0x/contract-artifacts@3.13.0
 - @0x/contract-wrappers-test@12.2.38
 - @0x/contract-wrappers@13.14.0
 - @0x/migrations@7.0.1
 - @0x/order-utils@10.4.18
 - @0x/protocol-utils@1.3.1
2021-03-17 18:23:51 +00:00
Github Actions
7caa43d02c Updated CHANGELOGS & MD docs 2021-03-17 18:23:47 +00:00
mzhu25
3d4c03c9df Update asset-swapper to support MultiplexFeature (#168)
* Update asset-swapper to support MultiplexFeature

* Address PR feedback

* Update changelogs
2021-03-16 22:20:33 -07:00
Lawrence Forman
22e1ed35d3 docs: Fix EIP712 hashing docs for limit and RFQ orders (#173) 2021-03-16 15:09:00 -04:00
Alex Kroeger
dabe6fd793 add tx origin blacklist to RFQ options (#169)
* add tx origin blacklist to RFQ options

* Fix typo

* use set instead of array

* make sure tx origin is lower case

* changed default blacklist value from array to set
2021-03-11 18:05:16 -08:00
mzhu25
3cc639c8d0 MultiplexFeature and BatchFillNativeOrdersFeature (#140)
* WrappedFillFeature

* Address internal feedback

* create features/interfaces/ directory

* Split NativeOrdersFeature into mixins

* Rename mixins to use NativeOrders namespace

* Add BatchFillNativeOrdersFeature

* Rename WrapperFillFeature => MultiplexFeature and add natspec comments

* Emit LiquidityProviderSwap event

* post-rebase fixes

* Multiplex mainnet fork tests

* lint

* Add tests for batch fill functions

* Remove market functions

* Addres PR feedback

* Remove nested _batchFill calls from _multiHopFill

* Add BatchFillIncompleteRevertError type

* Use call{value: amount}() instead of transfer(amount)

* Remove outdated comment

* Update some comments

* Add events

* Address spot-check recommendations

* Remove-top level events, add ExpiredRfqOrder event

* Update changelog

* Change ExpiredRfqOrder event

* Update IZeroEx artifact and contract wrapper
2021-03-08 15:45:49 -08:00
mzhu25
22c8e0b6db Make the proposal/quorum thresholds updatable (#165)
* Make the proposal/quorum thresholds updatable

* Test threshold updating
2021-03-04 10:56:37 -08:00
Oskar Paolini
f3ca4293bc feat: add proxy configuration to axios instance in RFQT asset-swapper (#159)
* add proxy configuration to axios instance

* add support for additional axios instance opts

* move quoteRequestorHttpClient parameter

* fix tests, build errors

* prettier

* bump axios

* bumped mock-axios-adapter version

* downgrade axios again

* re-upgrade axios 🤦

* updated yarn.lock

* updated changelog

Co-authored-by: Alex Kroeger <alexrkroeger@gmail.com>
2021-03-03 11:38:54 -08:00
Lawrence Forman
db3e076d03 update deps and publish gh action for prerelease support 2021-03-03 01:16:22 -05:00
Lawrence Forman
1a6759820a Mooniswap LP (#143)
* `@0x/asset-swapper`: Fix compiler error on `ILiquidityProvider` call
`@0x/protocol-utils`: Add VIP utils.

* `@0x/asset-swapper`: Clean up curve VIP integration

* `@0x/contracts-zero-ex`: Add `MooniswapLiquidityProvider`.
`@0x/asset-swapper`: Add Mooniswap "vip" to EP quote consumer.

* rebase and prettier

* fix linter error

* `@0x/contracts-zero-ex`: Add `MooniswapLiquidityProvider` tests.

* review feedback

* `@0x/contracts-zero-ex`: Emit `LiquidityProviderFill` events in LPs

* `@0x/asset-swapper`: Fix compilation error

* `@0x/asset-swapper`: Add EP gas overhead to Curve and Mooni LP bridge routes

* `@0x/asset-swapper`: Remove consumer gas overhead for LP VIPs

* `@0x/contracts-zero-ex`: Add more params to `LiquidityProviderFill` event

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

* `@0x/asset-swapper`: Update deployed Curve and Mooni LPs

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-03-02 16:50:37 -05:00
Github Actions
61c5e7b948 Publish
- @0x/contracts-integrations@2.7.28
 - @0x/asset-swapper@6.2.0
2021-03-02 00:44:13 +00:00
Github Actions
5fd78ef32f Updated CHANGELOGS & MD docs 2021-03-02 00:44:06 +00:00
Lawrence Forman
14ff9b827c @0x/asset-swapper: Drop Y and BUSD curve pools (#161) 2021-03-02 07:56:43 +10:00
Lawrence Forman
598dc2cd71 docs: update allowances blurb (#160) 2021-02-25 17:11:44 -05:00
Github Actions
08e1c5109f Publish
- @0x/contracts-asset-proxy@3.7.7
 - @0x/contracts-broker@1.1.25
 - @0x/contracts-coordinator@3.1.26
 - @0x/contracts-dev-utils@1.3.24
 - @0x/contracts-erc1155@2.1.25
 - @0x/contracts-erc20@3.3.4
 - @0x/contracts-erc721@3.1.25
 - @0x/contracts-exchange-forwarder@4.2.26
 - @0x/contracts-exchange-libs@4.3.25
 - @0x/contracts-exchange@3.2.26
 - @0x/contracts-extensions@6.2.20
 - @0x/contracts-integrations@2.7.27
 - @0x/contracts-multisig@4.1.26
 - @0x/contracts-staking@2.0.33
 - @0x/contracts-test-utils@5.3.22
 - @0x/contracts-treasury@1.0.2
 - @0x/contracts-utils@4.7.4
 - @0x/contracts-zero-ex@0.19.0
 - @0x/asset-swapper@6.1.0
 - @0x/contract-addresses@5.11.0
 - @0x/contract-artifacts@3.12.0
 - @0x/contract-wrappers-test@12.2.37
 - @0x/contract-wrappers@13.13.0
 - @0x/migrations@7.0.0
 - @0x/order-utils@10.4.17
 - @0x/protocol-utils@1.3.0
2021-02-24 04:42:41 +00:00
Github Actions
6f7a843742 Updated CHANGELOGS & MD docs 2021-02-24 04:42:32 +00:00
Jacob Evans
c9c9615bb5 Fix contract merge conflict 2021-02-24 14:08:54 +10:00
Romain Butteaud
f98609686d feat: opt-in positive slippage fee for integrators (#101)
* feat: Positive Slippage Fee

* fix: rename ethToTakerAssetRate to takerAssetPriceForOneEth

* fix: rename takerAssetPriceForOneEth to takerAssetsPerEth

* fix: export AffiliateFeeType

* rebased off development

* Add a gasOverhead for non-deterministic operations

* CHANGELOGs

* rename outputTokens to outputAmount

* Confirm transformer addresses on Mainnet and Ropsten

* fix import

Co-authored-by: Jacob Evans <jacob@dekz.net>
2021-02-24 12:51:58 +10:00
Jacob Evans
5b8bbc34e8 fix: FQT in migrations (#157) 2021-02-24 12:36:58 +10:00
Jacob Evans
49cb00a9ab feat: DODO V2, Linkswap (#152)
* feat: DODO V2

* Fix typo

* feat: Linkswap (#153)

* fix: intermediate hops WBTC (#154)

* feat: Linkswap

* fix: Re-add WBTC in default hop tokens

* Update review changes

* FQT deploy + no gas limit ETH refund (#155)

* `@0x/contracts-zero-ex`: refund ETH with no gas limit in FQT
`@0x/contract-addresses`: Deploy FQT

* Update packages/contract-addresses/CHANGELOG.json

Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>
2021-02-24 12:19:26 +10:00
Alex Kroeger
74b240fb88 add exchange proxy overhead penalty to comparison price (#156)
* add exchange proxy overhead penalty to comparison price

* prettier
2021-02-23 17:32:15 -08:00
Alex Kroeger
514f9d2621 feat/alt RFQ MM implementation (#139)
* baseline adapter code [WIP]

* fixed adapter logic, quote_requester instantiation

* modified quote-requestor test to include alt implementation

* type changes, fixes to quote requestor test

* small fixes

* working tests, made alt utils more readable

* lint errors

* added alt indicative quote tests, minor fixes

* export alt MM market offering types

* altered alt market offering to have id instead of symbols

* addressed minor comments

* updated changelog

* got rid of unnecessary, large if-block, fixed the buy-sell assignment to be from the MM's perspective

* extra logging for debugging

* fixed existingOrder size

* get rid of only flag on test, get rid of extra logging

* prettier
2021-02-22 16:07:30 -08:00
Jacob Evans
fa78d1092a feat: asset-swapper Fake Taker contract (#151) 2021-02-22 08:32:53 +10:00
Lawrence Forman
297342092b @0x/asset-swapper: special case BNB in uni v1 sampler (#147)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-02-19 16:56:16 +10:00
Jacob Evans
076f263a86 feat: Validate v4 limit orders (#148)
re-renable tests
2021-02-19 16:42:10 +10:00
Jacob Evans
0c56207abc fix: Protocol fee in fee schedule (#146)
* fix: Protocol fee in fee schedule

* CHANGELOG

* hack imports
2021-02-18 14:12:11 +10:00
Lawrence Forman
23953d8a5a Update artifacts and wrappers (#145)
* `@0x/contract-artifacts`: Update artifacts.
`@0x/contract-wrappers`: Regenerate wrappers

* fix doc gen

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-02-17 14:34:43 -05:00
Jacob Evans
c6919eb25a feat: Mirror Protocol tokens (#142)
* feat: Mirror Protocol tokens

* added .tap to builder
2021-02-17 10:14:38 +10:00
Lawrence Forman
d509604b52 @0x/contracts-zero-ex: Export CurveLiquidityProviderContract (#144)
`@0x/asset-swapper`: Add deployed `CurveLiquidityProvider` addresses

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-02-16 16:17:08 -05:00
Lawrence Forman
a74a3450eb @0x/contracts-zero-ex: Add CurveLiquidityProvider and misc refactors (#127)
* `@0x/contracts-zero-ex`: Add `CurveLiquidityProvider` and misc refactors

* `@0x/asset-swapper`: Fix compiler error on `ILiquidityProvider` call
`@0x/protocol-utils`: Add VIP utils.

* `@0x/contracts-zero-ex`: Rebase and fix comiler warnings

* `@0x/asset-swapper`: Clean up curve VIP integration

* `@0x/protocol-utils`: Update changelog

* `@0x/protocol-utils`: tsdoc new functions

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-02-11 19:13:17 -05:00
Jacob Evans
72c5399b9d fix: Second hop source is missing (#138)
* fix: Second hop source is missing

* CHANGELOGs
2021-02-11 00:13:58 +10:00
Github Actions
b29196b983 Publish
- @0x/contracts-asset-proxy@3.7.6
 - @0x/contracts-broker@1.1.24
 - @0x/contracts-coordinator@3.1.25
 - @0x/contracts-dev-utils@1.3.23
 - @0x/contracts-erc1155@2.1.24
 - @0x/contracts-erc20@3.3.3
 - @0x/contracts-erc721@3.1.24
 - @0x/contracts-exchange-forwarder@4.2.25
 - @0x/contracts-exchange-libs@4.3.24
 - @0x/contracts-exchange@3.2.25
 - @0x/contracts-extensions@6.2.19
 - @0x/contracts-integrations@2.7.26
 - @0x/contracts-multisig@4.1.25
 - @0x/contracts-staking@2.0.32
 - @0x/contracts-test-utils@5.3.21
 - @0x/contracts-treasury@1.0.1
 - @0x/contracts-utils@4.7.3
 - @0x/contracts-zero-ex@0.18.2
 - @0x/asset-swapper@6.0.0
 - @0x/contract-addresses@5.10.0
 - @0x/contract-wrappers-test@12.2.36
 - @0x/contract-wrappers@13.12.3
 - @0x/migrations@6.6.0
 - @0x/order-utils@10.4.16
 - @0x/protocol-utils@1.2.0
2021-02-10 09:49:05 +00:00
Github Actions
ce76a7033d Updated CHANGELOGS & MD docs 2021-02-10 09:48:52 +00:00
Jacob Evans
3f4bb933d1 feat: v4 final (#136)
* v4 FillQuoteTransformer (#104)

* Update FQT to support v4 orders

* `@0x/contracts-zero-ex`: Tweak FQT
`@0x/contracts-zero-ex`: Drop `ERC20BridgeTransfer` event and add `PartialQuoteFill` event.

* `@0x/contracts-utils`: Add `LibSafeMathV06.downcastToUint128()`

* `@0x/protocol-utils`: Update transformer utils for V4 FQT

* `@0x/contracts-zero-ex`: Fixing FQT tests...

* `@0x/contracts-zero-ex`: rename FQT bridge event

* `@0x/contracts-zero-ex`: Un-`only` tests

* `@0x/migrations`: Update `BridgeAdapter` deployment

* `@0x/contracts-integrations`: Delete `mtx_tests`

* `@0x/protocol-utils`: Address review comments

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

* `@0x/migrations`: Update migrations

Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>

* v4: Asset-swapper (main branch) (#113)

* refactor quote_requestor

* WIP v4/asset-swapper: Clean up SwapQuoter and remove @0x/orderbook

* Start replacing SignedOrder everywhere

* wip: new order type

* wip

* remove order-utils from most places

* hack: Play around with VerboseX types (#119)

* hack: Play around with VerboseX types

* More hacks

* Fix up the bridgeData encodings

* Rework Orderbook return type

* feat: Don't charge a protocol fee for RFQ orders WIP (#121)

* fix simple build errors

* simplify types a little

* remove SwapQuoteCalculator: unnecessary abstraction

* Fix all ./src build errors; make types consistent

* export more types for use in 0x API; modify Orderbook interface

* stop overriding APIOrder

* feat: RFQ v4 + consolidated bridge encoders (#125)

* feat: check if taker address is contract

* Rework bridge data

* Worst case adjustments

* RFQT v4

* Future/v4 validate orders (#126)

* RFQT v4

* v4 validate native orders

* use default invalid signature

* refactor rfqt validations in swap quoter

* fix types

* fix RFQT unlisted api key

* remove priceAwareRFQFlag

* adjust maker/taker amounts

* update JSON schemas

* filter zero fillable orders

Co-authored-by: xianny <xianny@gmail.com>

* fix type export

Co-authored-by: xianny <xianny@gmail.com>

* remove order-utils as much as possible

* work on tests compile

* Comment out quote reporter test

* updated tests

* restore order-utils accidental changes

* some lints

* Remove old fill_test

* ts lint disable for now

* update quote report

* Re-enable quote report tests

* make fill data required field

* fix lint

* type guards

* force fillData as required

* fix lint

* fix naming

* exports

* adjust MultiBridge by slippage

* cleanups (checkpoint 1)

* cleanup types (checkpoint #2)

* remove unused deps

* `@0x/contract-addresses`: Deploy new FQT (#129)

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

* commit bump to republish

* DRY up the rfqt mocker

* fix: Balancer load top pools (#131)

* fix: Balancer load top 250 pools

* refetch top pools on an interval

Co-authored-by: Jacob Evans <jacob@dekz.net>
Co-authored-by: Kim Persson <kimpers@users.noreply.github.com>
Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>

* Update post rebase

* prettier

* Remove test helpers exported in asset-swapper

* Clean up from review comments

* prettier

* lint

* recreate rfqt mocker

* change merge and INVALID_SIGNATURE

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Xianny <8582774+xianny@users.noreply.github.com>
Co-authored-by: Kim Persson <kimpers@users.noreply.github.com>
2021-02-10 19:20:15 +10:00
Greg Hysz
501b7b9b65 Updated releases (#133) 2021-02-08 18:32:21 -08:00
Daniel Pyrathon
c0ea88e864 lint fix (#130) 2021-02-05 09:56:35 -08:00
Lawrence Forman
48f8bea460 docs: Fix wrong method name for order signature generation (#128)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-02-02 23:30:26 -05:00
Github Actions
f4e5b6e38d Publish
- @0x/contracts-integrations@2.7.25
 - @0x/contracts-treasury@1.0.0
 - @0x/asset-swapper@5.8.2
2021-01-28 21:36:31 +00:00
Github Actions
477cb0a48d Updated CHANGELOGS & MD docs 2021-01-28 21:36:22 +00:00
Jacob Evans
d6bc0a3368 fix: [asset-swapper] prevent error when multihop data is not present (#80)
* fix: [asset-swapper] prevent error when multihop is not present for a route

* Update changelog

Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>
2021-01-28 13:04:32 -08:00
mzhu25
e544a804c2 ZrxTreasury (#120)
* `@0x/contracts-treasury` (squashed)

Fix @0x/contracts-zero-ex readme

Create package for governance contracts

Rename @0x/contracts-governance to @0x/contracts-treasury and write contracts

Write tests and such

Missed a few places where "governance" should be "treasury"`

Update changelog with PR number

Appease CI

Arbitrary treasury actions

Export treasury artifacts and wrappers

Continue to do battle with CI

Address PR feedback

* More PR feedback
2021-01-26 09:33:14 -08:00
Github Actions
96e0ad7899 Publish
- @0x/contracts-asset-proxy@3.7.5
 - @0x/contracts-broker@1.1.23
 - @0x/contracts-coordinator@3.1.24
 - @0x/contracts-dev-utils@1.3.22
 - @0x/contracts-erc1155@2.1.23
 - @0x/contracts-erc20@3.3.2
 - @0x/contracts-erc721@3.1.23
 - @0x/contracts-exchange-forwarder@4.2.24
 - @0x/contracts-exchange-libs@4.3.23
 - @0x/contracts-exchange@3.2.24
 - @0x/contracts-extensions@6.2.18
 - @0x/contracts-integrations@2.7.24
 - @0x/contracts-multisig@4.1.24
 - @0x/contracts-staking@2.0.31
 - @0x/contracts-test-utils@5.3.20
 - @0x/contracts-utils@4.7.2
 - @0x/contracts-zero-ex@0.18.1
 - @0x/asset-swapper@5.8.1
 - @0x/contract-artifacts@3.11.1
 - @0x/contract-wrappers-test@12.2.35
 - @0x/contract-wrappers@13.12.2
 - @0x/migrations@6.5.11
 - @0x/order-utils@10.4.15
 - @0x/protocol-utils@1.1.5
2021-01-26 08:02:10 +00:00
Github Actions
5a1fee5d31 Updated CHANGELOGS & MD docs 2021-01-26 08:02:03 +00:00
Lawrence Forman
3557a5e5a9 @0x/contracts-zero-ex: Update tests to work with ganache chainId of 1337 (#123)
* `@0x/contracts-zero-ex`: Update tests to work with ganache chainId of 1337

* `update org deps

* `@0x/protocol-utils`: Use `Web3Wrapper.signTypedDataAsync()` instead of removed `Web3Wrapper.signTypedDataV4Async()` (#124)

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

* `update org deps
`@0x/order-utils`: Fix broken tests

* remove lingering console.logs

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-01-26 02:50:09 -05:00
Lawrence Forman
0bd43d5265 docs: add big-pantsuit-energy release (#122)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-01-21 19:02:44 -05:00
Lawrence Forman
8fd7c1b386 @0x/migrations: Update dockerfile to override networkId and chainId in ganache-cli (#118)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-01-20 12:10:24 -05:00
Lawrence Forman
50068750f5 EP: Swallow reverts in batchGetLimit/RfqRelevantStates() (#117)
* `@0x/contracts-zero-ex`: Swallow reverts in `batchGetLimit/RfqRelevantStates()`.

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

* `@0x/contracts-zero-ex`: Fix misleading RFQ typehash comment in `LibNativeOrder.sol`

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-01-20 00:25:48 -05:00
Daniel Pyrathon
a7a905de4c fix: Upgrade quote server and Asset Swapper types (and specify protocol ve… (#108)
* Upgrade quote server and Asset Swapper types (and specify protocol version in API requests)

* add package and lockfile

* fix tests
2021-01-13 17:07:45 -08:00
Github Actions
f283108586 Publish
- @0x/contracts-asset-proxy@3.7.4
 - @0x/contracts-broker@1.1.22
 - @0x/contracts-coordinator@3.1.23
 - @0x/contracts-dev-utils@1.3.21
 - @0x/contracts-erc1155@2.1.22
 - @0x/contracts-erc20@3.3.1
 - @0x/contracts-erc721@3.1.22
 - @0x/contracts-exchange-forwarder@4.2.23
 - @0x/contracts-exchange-libs@4.3.22
 - @0x/contracts-exchange@3.2.23
 - @0x/contracts-extensions@6.2.17
 - @0x/contracts-integrations@2.7.23
 - @0x/contracts-multisig@4.1.23
 - @0x/contracts-staking@2.0.30
 - @0x/contracts-test-utils@5.3.19
 - @0x/contracts-utils@4.7.1
 - @0x/contracts-zero-ex@0.18.0
 - @0x/asset-swapper@5.8.0
 - @0x/contract-addresses@5.9.0
 - @0x/contract-wrappers-test@12.2.34
 - @0x/contract-wrappers@13.12.1
 - @0x/migrations@6.5.10
 - @0x/order-utils@10.4.14
 - @0x/protocol-utils@1.1.4
2021-01-13 04:08:45 +00:00
Github Actions
9afe05095a Updated CHANGELOGS & MD docs 2021-01-13 04:08:39 +00:00
Jacob Evans
3dab892978 feat: Kyber reserve discovery using getTradingReserves (#111)
* feat: Kyber reserve discovery using getTradingReserves

* refactor sampler operations with

* Added Mooniswap v2.1
2021-01-13 13:28:15 +10:00
Greg Hysz
e40ddb800e Updated docs for Panettone release + v4 audit + v4 bounty (#112) 2021-01-12 15:19:50 -08:00
Lawrence Forman
72a74e7c66 Panettone cleanup (#109)
* `@0x/contracts-zero-ex`: Updates for panettone release

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

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-01-12 10:53:50 -08:00
Greg Hysz
e8ae64673f Updating docs after cyberpants2077 release (#110) 2021-01-08 11:51:43 -08:00
mzhu25
2451f419c8 Update PLP sandbox addresses (#107) 2021-01-05 12:41:52 -08:00
Lawrence Forman
2394eb62aa @0x/contracts-zero-ex: Use consistent returndatasize checks in UniswapFeature (#96)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-01-05 14:40:08 -05:00
Lawrence Forman
f9078bb1c3 `Add SPDX license IDs to 0.6+ solidity files (#105)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-01-05 13:55:24 -05:00
Greg Hysz
bf25c81f1c Added Panettone release to docs (#95)
* Updated releases to include Panettone

* Updated releases + addresses
2021-01-04 18:45:31 -08:00
Github Actions
03ecc530c3 Publish
- @0x/contracts-asset-proxy@3.7.3
 - @0x/contracts-broker@1.1.21
 - @0x/contracts-coordinator@3.1.22
 - @0x/contracts-dev-utils@1.3.20
 - @0x/contracts-erc1155@2.1.21
 - @0x/contracts-erc20@3.3.0
 - @0x/contracts-erc721@3.1.21
 - @0x/contracts-exchange-forwarder@4.2.22
 - @0x/contracts-exchange-libs@4.3.21
 - @0x/contracts-exchange@3.2.22
 - @0x/contracts-extensions@6.2.16
 - @0x/contracts-integrations@2.7.22
 - @0x/contracts-multisig@4.1.22
 - @0x/contracts-staking@2.0.29
 - @0x/contracts-test-utils@5.3.18
 - @0x/contracts-utils@4.7.0
 - @0x/contracts-zero-ex@0.17.0
 - @0x/asset-swapper@5.6.2
 - @0x/contract-artifacts@3.11.0
 - @0x/contract-wrappers-test@12.2.33
 - @0x/contract-wrappers@13.12.0
 - @0x/migrations@6.5.9
 - @0x/order-utils@10.4.13
 - @0x/protocol-utils@1.1.3
2021-01-04 23:22:36 +00:00
Github Actions
d52b1d24d0 Updated CHANGELOGS & MD docs 2021-01-04 23:22:26 +00:00
Lawrence Forman
5083fab06a That time DevUtils wouldn't die (#97)
* `@0x/contracts-utils`: Allow for excess return data in `LibERC20TokenV06` compat* functions

* `@0x/contracts-zero-ex`: Add DevUtils-like functions to `NativeOrdersFeature`

* `@0x/contract-artifacts`: Update IZeroEx artifact

* `@0x/contract-wrappers`: Update IZeroExContract wrapper

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

* `@0x/contracts-utils`: Add `LibSafeMathV06.safeDowncastToUint128()`

* `@0x/contracts-zero-ex`: Fix changelog and add cancelled get relevant state tests

* `@0x/contracts-utils`: Fix changelog

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-01-04 17:52:29 -05:00
Romain Butteaud
1249bf9ccc feat: adding UST, BBTC, OBTC, aDAI, aUSDC, aUSDT, sEUR, EURS, sETH pools (#103)
* feat: adding UST, BBTC, OBTC, aDAI, aUSDC, aUSDT, sEUR, EURS, sETH pools

* fix: comment seth curve pool

* fix: prettify, remove seth pool
2021-01-04 13:56:18 -08:00
Jacob Evans
681f6b3f07 chore: [asset-swapper] Update Shells to new version (#102) 2021-01-04 13:56:05 -08:00
Github Actions
d3ca1fe96b Publish
- @0x/contracts-integrations@2.7.21
 - @0x/asset-swapper@5.6.1
2020-12-31 04:02:02 +00:00
Github Actions
9e4f5815e4 Updated CHANGELOGS & MD docs 2020-12-31 04:01:53 +00:00
Jacob Evans
c3c27eaedc fix: [asset-swapper] Encoded Buy fillAmount (#106) 2020-12-31 13:18:25 +10:00
Github Actions
4bf6a23d23 Publish
- @0x/contracts-integrations@2.7.20
 - @0x/asset-swapper@5.6.0
2020-12-27 23:59:31 +00:00
Github Actions
aaaf0d02de Updated CHANGELOGS & MD docs 2020-12-27 23:59:23 +00:00
Jacob Evans
825cc4d035 feat: [asset-swapper] Added Mooniswap V2 factory address (#100) 2020-12-28 09:23:52 +10:00
Github Actions
c2d44e5c10 Publish
- @0x/contracts-asset-proxy@3.7.2
 - @0x/contracts-broker@1.1.20
 - @0x/contracts-coordinator@3.1.21
 - @0x/contracts-dev-utils@1.3.19
 - @0x/contracts-erc1155@2.1.20
 - @0x/contracts-erc20@3.2.14
 - @0x/contracts-erc721@3.1.20
 - @0x/contracts-exchange-forwarder@4.2.21
 - @0x/contracts-exchange-libs@4.3.20
 - @0x/contracts-exchange@3.2.21
 - @0x/contracts-extensions@6.2.15
 - @0x/contracts-integrations@2.7.19
 - @0x/contracts-multisig@4.1.21
 - @0x/contracts-staking@2.0.28
 - @0x/contracts-test-utils@5.3.17
 - @0x/contracts-utils@4.6.5
 - @0x/contracts-zero-ex@0.16.0
 - @0x/asset-swapper@5.5.3
 - @0x/contract-addresses@5.8.0
 - @0x/contract-wrappers-test@12.2.32
 - @0x/contract-wrappers@13.11.2
 - @0x/migrations@6.5.8
 - @0x/order-utils@10.4.12
 - @0x/protocol-utils@1.1.2
2020-12-23 02:55:08 +00:00
Github Actions
0efd0860c8 Updated CHANGELOGS & MD docs 2020-12-23 02:55:01 +00:00
Lawrence Forman
a890a06664 @0x/contract-addresses: Redeploy FQT (#99)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-12-23 13:13:49 +11:00
Jacob Evans
5befb87071 fix: CryptoCom rollup (#98) 2020-12-23 11:43:11 +11:00
mintcloud
12ba4c373a Update staking.md
Changed epoch length
2020-12-18 11:14:49 -08:00
Github Actions
7fd25be02e Publish
- @0x/contracts-asset-proxy@3.7.1
 - @0x/contracts-broker@1.1.19
 - @0x/contracts-coordinator@3.1.20
 - @0x/contracts-dev-utils@1.3.18
 - @0x/contracts-erc1155@2.1.19
 - @0x/contracts-erc20@3.2.13
 - @0x/contracts-erc721@3.1.19
 - @0x/contracts-exchange-forwarder@4.2.20
 - @0x/contracts-exchange-libs@4.3.19
 - @0x/contracts-exchange@3.2.20
 - @0x/contracts-extensions@6.2.14
 - @0x/contracts-integrations@2.7.18
 - @0x/contracts-multisig@4.1.20
 - @0x/contracts-staking@2.0.27
 - @0x/contracts-test-utils@5.3.16
 - @0x/contracts-utils@4.6.4
 - @0x/contracts-zero-ex@0.15.0
 - @0x/asset-swapper@5.5.2
 - @0x/contract-addresses@5.7.0
 - @0x/contract-wrappers-test@12.2.31
 - @0x/contract-wrappers@13.11.1
 - @0x/migrations@6.5.7
 - @0x/order-utils@10.4.11
 - @0x/protocol-utils@1.1.1
2020-12-17 22:52:27 +00:00
Github Actions
aa688c4a92 Updated CHANGELOGS & MD docs 2020-12-17 22:52:20 +00:00
mzhu25
fb437551c9 Bancor FQT rollup (#91)
* Add MixinBancor for BridgeAdapter

* Update changelog

* Use 0.6 call value syntax

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

* feat: Rollup CoFiX (#92)

* `@0x/contract-addreses`: update FQT addresses

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Jacob Evans <jacob@dekz.net>
2020-12-17 17:12:40 -05:00
Greg Hysz
6fa1de7889 Emergency docs (#94) 2020-12-17 10:24:16 -08:00
mzhu25
7a42df9a65 Only use subgraph query result to populate function history (#93)
* Only use subgraph query result to populate function history

* Fix rollback for functions with no rollback history
2020-12-16 23:14:19 -08:00
Github Actions
15a508f3ea Publish
- @0x/contracts-integrations@2.7.17
 - @0x/contracts-zero-ex@0.14.0
 - @0x/asset-swapper@5.5.1
 - @0x/contract-wrappers-test@12.2.30
 - @0x/migrations@6.5.6
 - @0x/protocol-utils@1.1.0
2020-12-16 20:09:57 +00:00
Github Actions
b3c20ff909 Updated CHANGELOGS & MD docs 2020-12-16 20:09:48 +00:00
Lawrence Forman
682c07cb73 Add mtx tooling to @0x/protocol-utils (#90)
* `@0x/contracts-zero-ex`: Use the `MetaTransaction` class from `@0x/protocol-utils` in tests.

* `@0x/protocol-utils`: Add the `MetaTransaction` class for EP mtxs + refactors

* update changelogs

* `@0x/protocol-utils`: Add mtx tests

* `@0x/protocol-utils`: Rename `mtx.ts` to `meta_transactions.ts` and misc review feedback

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-12-16 14:22:00 -05:00
Jacob Evans
602605ab4b Disable Bancor Service for non-mainnet (#89)
* Disable Bancor Service for non-mainnet

* Fix import

* Fix mocked tests
2020-12-16 21:58:39 +10:00
Github Actions
0eff2548d5 Publish
- @0x/contracts-asset-proxy@3.7.0
 - @0x/contracts-broker@1.1.18
 - @0x/contracts-coordinator@3.1.19
 - @0x/contracts-dev-utils@1.3.17
 - @0x/contracts-exchange-forwarder@4.2.19
 - @0x/contracts-exchange@3.2.19
 - @0x/contracts-extensions@6.2.13
 - @0x/contracts-integrations@2.7.16
 - @0x/contracts-multisig@4.1.19
 - @0x/contracts-staking@2.0.26
 - @0x/contracts-zero-ex@0.13.0
 - @0x/asset-swapper@5.5.0
 - @0x/contract-wrappers-test@12.2.29
 - @0x/migrations@6.5.5
2020-12-16 08:03:31 +00:00
Github Actions
93ee681204 Updated CHANGELOGS & MD docs 2020-12-16 08:03:25 +00:00
Jacob Evans
d7bea98075 fix: [asset-swapper] Rework Bancor to only use paths and sample best path (#88)
* Rework Bancor to only use paths and sample best path

* Deployed address

* Clean up and pin bancor sdk

* CHANGELOGs
2020-12-16 17:34:47 +10:00
Lawrence Forman
437a3b048d EP: Address audit feedback (#82)
* `@0x/contracts-zero-ex`: Address audit feedback (1/2)

* `@0x/contracts-zero-ex`: Cap the ETH transfer amount to a liquidity provider to `msg.value`

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

* `@0x/contracts-zero-ex`: Always transfer msg.value to the liqudity provider in LiquiidityProviderFeature

* Remove PLP backwards-compatibility (#85)

* Remove backwards-compatibility from MixinZeroExBridge and LiquidityProviderSandbox

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

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

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>
2020-12-16 01:37:39 -05:00
Daniel Pyrathon
f55a9454b5 fix: Fix quote report (#87)
* updates market side liquidity with the appropriate firm and indicative quotes for reporting

* linting and fixing

* linting and fixing
2020-12-15 16:57:54 -08:00
Daniel Pyrathon
3b03ad0db4 fix: added SRA schema for V4 orders (#86)
* added SRA schema for V4 orders

* address comments
2020-12-14 17:39:42 -08:00
mzhu25
27d679e1f1 Rollback CLI tools (#79)
* Rollback CLI tools

* Refactor

* Address PR feedback

* Sort deployment history

* Rollback specific deployment

* Split calldata
2020-12-10 19:42:00 -08:00
Github Actions
1e16d59c23 Publish
- @0x/contracts-asset-proxy@3.6.9
 - @0x/contracts-broker@1.1.17
 - @0x/contracts-coordinator@3.1.18
 - @0x/contracts-dev-utils@1.3.16
 - @0x/contracts-erc1155@2.1.18
 - @0x/contracts-erc20@3.2.12
 - @0x/contracts-erc721@3.1.18
 - @0x/contracts-exchange-forwarder@4.2.18
 - @0x/contracts-exchange-libs@4.3.18
 - @0x/contracts-exchange@3.2.18
 - @0x/contracts-extensions@6.2.12
 - @0x/contracts-integrations@2.7.15
 - @0x/contracts-multisig@4.1.18
 - @0x/contracts-staking@2.0.25
 - @0x/contracts-test-utils@5.3.15
 - @0x/contracts-utils@4.6.3
 - @0x/contracts-zero-ex@0.12.0
 - @0x/asset-swapper@5.4.2
 - @0x/contract-artifacts@3.10.0
 - @0x/contract-wrappers-test@12.2.28
 - @0x/contract-wrappers@13.11.0
 - @0x/migrations@6.5.4
 - @0x/order-utils@10.4.10
 - @0x/protocol-utils@1.0.1
2020-12-09 03:40:56 +00:00
Github Actions
1e7c9bbb1f Updated CHANGELOGS & MD docs 2020-12-09 03:40:51 +00:00
Lawrence Forman
edda1edc50 @0x/protocol-utils (#76)
* add new packages

* `@0x/protocol-utils`: Update with latest code from `@0x/contracs-zero-ex` + misc stuff

* @0x/contracts-zero-ex`: Switch to using `@0x/protocol-utils` in most places

* @0x/protocol-types`: Delete this package.

* regen yarn lock

* `@0x/contracts-zero-ex`: Unpin `@0x/protocol-utils` dep.

* `@0x/contracts-integrations`: Fix borken test

* update changelogs

* `@0x/protocol-utils`: Update deps

* `@0x/protocol-utils`: add tests

* `@0x/protocol-utils`: More tests

* `@0x/protocol-utils`: Update readme.

* update deps

* run prettier

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

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

* `@0x/protocol-utils`: Update changelog

* `@0x/contract-wrappers`: Export stuff for doc gen

* `@0x/protocol-utils`: Use `Web3Wrapper.signTypedDataV4Async()` for MM compatibility.

* upgrade org deps

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-12-08 22:08:52 -05:00
Greg Hysz
d1eb6279b4 Updated addresses and transformer nonces after hot-pants (#78) 2020-12-08 11:33:36 -08:00
Greg Hysz
4ace79d947 Updated Releases + Fix Links (#77)
* Updated releases

* fixed some typos and links in docs
2020-12-08 10:44:59 -08:00
mzhu25
e5eee96487 Add naive selector collision test (#74) 2020-12-07 19:49:37 -08:00
Github Actions
907adf9145 Publish
- @0x/contracts-asset-proxy@3.6.8
 - @0x/contracts-broker@1.1.16
 - @0x/contracts-coordinator@3.1.17
 - @0x/contracts-dev-utils@1.3.15
 - @0x/contracts-erc1155@2.1.17
 - @0x/contracts-erc20@3.2.11
 - @0x/contracts-erc721@3.1.17
 - @0x/contracts-exchange-forwarder@4.2.17
 - @0x/contracts-exchange-libs@4.3.17
 - @0x/contracts-exchange@3.2.17
 - @0x/contracts-extensions@6.2.11
 - @0x/contracts-integrations@2.7.14
 - @0x/contracts-multisig@4.1.17
 - @0x/contracts-staking@2.0.24
 - @0x/contracts-test-utils@5.3.14
 - @0x/contracts-utils@4.6.2
 - @0x/contracts-zero-ex@0.11.1
 - @0x/asset-swapper@5.4.1
 - @0x/contract-addresses@5.6.0
 - @0x/contract-wrappers-test@12.2.27
 - @0x/contract-wrappers@13.10.3
 - @0x/migrations@6.5.3
 - @0x/order-utils@10.4.9
2020-12-07 22:56:33 +00:00
Github Actions
c046fe6220 Updated CHANGELOGS & MD docs 2020-12-07 22:56:27 +00:00
Lawrence Forman
84bf20de41 Update CHANGELOG.json (#75)
* Update CHANGELOG.json

* Update CHANGELOG.json
2020-12-07 17:17:43 -05:00
Lawrence Forman
f5a6f74d9a Update mainnet and ropsten transformer addresses for hot-pants release (#70)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-12-07 16:41:56 -05:00
Github Actions
7c7fc51ccf Publish
- @0x/contracts-integrations@2.7.13
 - @0x/asset-swapper@5.4.0
2020-12-07 20:42:41 +00:00
Github Actions
fa22f6de0d Updated CHANGELOGS & MD docs 2020-12-07 20:42:34 +00:00
Kim Persson
4f41214af2 feat: add takerAssetToEthRate and makerAssetToEthRate to quote response (#49)
* ADDS expose ethToTakerAssetRate and ethToTakerAssetRate

* REFACTORS rename to more correct takerAssetToEth/makerAssetToEth naming

* ADDS asset-swapper change log entry
2020-12-07 20:40:56 +01:00
Github Actions
607b7169bc Publish
- @0x/contracts-integrations@2.7.12
 - @0x/asset-swapper@5.3.1
2020-12-03 23:05:32 +00:00
Github Actions
1253490a38 Updated CHANGELOGS & MD docs 2020-12-03 23:05:26 +00:00
Alex Kroeger
0a37a588e8 Added BalanceChecker contract (#60)
* Added BalanceChecker contract

* Upgraded to solidity 0.6, simplified contract, added tests

* uint -> uint256

* export BalanceChecker contract wrapper

* prettier

* removed superfluous test code

* prettier
2020-12-03 14:31:45 -08:00
Greg Hysz
23ee108089 updated release names (#72) 2020-12-03 11:00:44 -08:00
Github Actions
64feeeea75 Publish
- @0x/contracts-asset-proxy@3.6.7
 - @0x/contracts-broker@1.1.15
 - @0x/contracts-coordinator@3.1.16
 - @0x/contracts-dev-utils@1.3.14
 - @0x/contracts-erc1155@2.1.16
 - @0x/contracts-erc20@3.2.10
 - @0x/contracts-erc721@3.1.16
 - @0x/contracts-exchange-forwarder@4.2.16
 - @0x/contracts-exchange-libs@4.3.16
 - @0x/contracts-exchange@3.2.16
 - @0x/contracts-extensions@6.2.10
 - @0x/contracts-integrations@2.7.11
 - @0x/contracts-multisig@4.1.16
 - @0x/contracts-staking@2.0.23
 - @0x/contracts-test-utils@5.3.13
 - @0x/contracts-utils@4.6.1
 - @0x/contracts-zero-ex@0.11.0
 - @0x/asset-swapper@5.3.0
 - @0x/contract-addresses@5.5.0
 - @0x/contract-artifacts@3.9.1
 - @0x/contract-wrappers-test@12.2.26
 - @0x/contract-wrappers@13.10.2
 - @0x/migrations@6.5.2
 - @0x/order-utils@10.4.8
2020-12-03 02:08:13 +00:00
Github Actions
2ebef23b8c Updated CHANGELOGS & MD docs 2020-12-03 02:08:07 +00:00
mzhu25
cc9f43ba3b Reenable PLP VIP and add gasCost field to LiquidityProviderRegistry (#65) 2020-12-02 17:26:48 -08:00
Xianny
5f1c139176 fix: handle potentially undefined path (#69)
* handle potentially undefined path

* Remove unused import

Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>
2020-12-02 16:23:19 -08:00
mzhu25
9eea7de340 Point to ILiquidityProvider interface in docs, not ILiquidityProviderSandbox (#71) 2020-12-02 14:38:46 -08:00
Lawrence Forman
4480f84efa @0x/contracts-staking: Set isOfflineMode: false in compiler.json (#68)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-12-02 16:43:25 -05:00
Lawrence Forman
5a8b8afff1 Independent compilation for contracts-zero-ex package (#67)
* `@0x/contracts-zero-ex`: Update `compiler.json`

* update org deps and regen yarn lock

* fix `@0x/contracts-gen` being pinned (why?)

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-12-02 11:14:19 -05:00
xianny
67c95bc0b7 add changelog and comments to pr #62 2020-12-01 13:05:21 -08:00
Greg Hysz
e70ec02be8 updated releases (#64) 2020-12-01 12:47:15 -08:00
Xianny
db81a94adb Return unoptimized quote in SwapQuote (#62)
* return unoptimized alternatives in SwapQuote

* refactor: dedupe
2020-12-01 12:40:48 -08:00
Lawrence Forman
475b608338 EP: FeeCollectorController (#59)
* `@0x/contracts-zero-ex`: Govern `FeeCollector`s through a separate `FeeCollectorController` contract.

* `@0x/contracts-integrations`: Fix broken EP protocol fees test.
`@0x/contracts-integrations`: Make this package private.

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

* Update contracts/zero-ex/contracts/src/external/FeeCollectorController.sol

Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>

* Apply suggestions from code review

Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>

* rebase

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>
2020-12-01 12:17:21 -05:00
Jacob Evans
27e36b112e feat: [asset-swapper] support selling entire balance (#37) 2020-12-01 12:54:06 +10:00
Jacob Evans
f698721484 feat: [asset-swapper] Add Crypto.com as a source (#43)
* feat: [asset-swapper] Add Crypto.com as a source

* Exclude in tests

* Disable hop sources to avoid excess inaccuracy

* Added CryptoCom Bridge and FQT rollup

* update test

* Deploy CryptoCom bridge

* Update package.json

* CHANGELOGs
2020-12-01 12:52:48 +10:00
Daniel Pyrathon
0c08353b2c reanme function to Async (#63) 2020-11-30 17:02:28 -08:00
Greg Hysz
a074b49732 Added link to Transformer Deployer section + fixeed safety checklist in Features (#61) 2020-11-30 17:00:33 -08:00
Greg Hysz
43b75c7953 minor doc updates: include Best Practices for Feature Development. (#58) 2020-11-30 09:50:20 -08:00
Greg Hysz
84a78eafc4 minor doc improvements (#57) 2020-11-28 11:21:35 -08:00
Greg Hysz
3c1ab889dd V4 Docs. See live on https://0xprotocol.readthedocs.io. (#56) 2020-11-28 00:51:50 -08:00
Steve Marx
012fff46f6 add permissionless transformer deployer (#55)
* add permissionless transformer deployer
2020-11-27 18:21:49 -05:00
Greg Hysz
6307ebc3a2 Replace PairOrdersCancelled event with PairCancelledLimitOrders and PairCancelledRfqOrders (#54) 2020-11-27 13:31:12 -08:00
Steve Marx
88d7e73eba remove calldata signing (#51) 2020-11-25 16:55:12 -05:00
Steve Marx
9653eb9e70 RFQ order with 0 txOrigin is INVALID (#50) 2020-11-25 14:15:59 -05:00
Steve Marx
ad337271d3 Miscellaneous fixes to RFQ origin registration (#48)
* Contracts can no longer call registerAllowedRfqOrigins()
* registerAllowedRfqOrigins() is now plural, registers an array of
addresses
2020-11-25 14:08:15 -05:00
Lawrence Forman
7591e99316 Remove protocol fees from RFQ orders (#45)
* `@0x/contracts-zero-ex`: Remove protocol fees from native orders in certain scenarios.

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

* `@0x/contracts-zero-ex`: Add `taker` field to RFQ orders.`
`@0x/contracts-zero-ex`: Introduce protocol fees to all limit orders again.

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

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-24 18:24:06 -05:00
Lawrence Forman
ca20df4752 @0x/contracts-zero-ex: Fix TransformERC20Feature reverting when selling taker's entire balance when input token is ETH (#46)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-24 17:52:22 -05:00
Steve Marx
841e4ee666 require txOrigin for RFQ orders, allow origins to register alternate … (#47)
require txOrigin for RFQ orders, allow origins to register alternate addresses that can fill orders
2020-11-24 16:53:32 -05:00
Steve Marx
e2ee3414ea limit order metatransactions (#44) 2020-11-24 13:39:40 -05:00
Steve Marx
5306cc03e9 Convert MetaTransactionsFeature to use the new LibSignature (#31) 2020-11-23 16:14:09 -05:00
F. Eugene Aumson
85f5d32de2 Allow injection of an RfqtFirmQuoteValidator and an RfqtQuoteObserver (#11)
* Allow injection of RFQT quote hooks

* Remove QuoteObserver

* Remove unnecessary `async`

* modernized the code based on latest spec

* prettify

Co-authored-by: Daniel Pyrathon <daniel@0x.org>
2020-11-23 12:05:28 -08:00
Lawrence Forman
ab698cec14 EP: misc fixes (#38)
* `@0x/contracts-zero-ex`: Fix NativeOrdersFeature order hash cancellation not emitting proper maker.
`@0x/contracts-zero-ex`: Revert to original (deployed) ZeroEx/EP proxy implementation. Optimized one is now at `ZeroExOptimized.sol`.
`@0x/contracts-zero-ex`: Add gas limits to first `transferFrom()` call in `LibTokenSpender` and `UniswapFeature`.

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

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

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

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

* rebase and update changelog

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

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

* update orders docs

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

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-23 12:59:02 -05:00
Steve Marx
b463a39bfa protocol fee / staking integration tests (#40) 2020-11-20 09:19:59 -05:00
Github Actions
018e25345b Publish
- @0x/contracts-asset-proxy@3.6.6
 - @0x/contracts-broker@1.1.14
 - @0x/contracts-coordinator@3.1.15
 - @0x/contracts-dev-utils@1.3.13
 - @0x/contracts-erc1155@2.1.15
 - @0x/contracts-erc20@3.2.9
 - @0x/contracts-erc721@3.1.15
 - @0x/contracts-exchange-forwarder@4.2.15
 - @0x/contracts-exchange-libs@4.3.15
 - @0x/contracts-exchange@3.2.15
 - @0x/contracts-extensions@6.2.9
 - @0x/contracts-integrations@2.7.10
 - @0x/contracts-multisig@4.1.15
 - @0x/contracts-staking@2.0.22
 - @0x/contracts-test-utils@5.3.12
 - @0x/contracts-utils@4.6.0
 - @0x/contracts-zero-ex@0.10.0
 - @0x/asset-swapper@5.2.0
 - @0x/contract-addresses@5.4.0
 - @0x/contract-wrappers-test@12.2.25
 - @0x/contract-wrappers@13.10.1
 - @0x/migrations@6.5.1
 - @0x/order-utils@10.4.7
2020-11-19 05:32:03 +00:00
Github Actions
b60fa8a7d7 Updated CHANGELOGS & MD docs 2020-11-19 05:31:53 +00:00
Jacob Evans
048d8dee60 fix: [asset-swapper] disable off-chain sampling for Balancer and CREAM (#41)
* fix: [asset-swapper] disable off-chain sampling for Balancer and CREAM

* Modify  Balancer off-chain test to expect only pools

* CHANGELOG
2020-11-19 15:00:09 +10:00
Alex Kroeger
927fe2b58b Improved ComparisonPrice function (#32)
* separated comparison price function into a new file, accounted for backup orders

* removed scratch code

* Adjusted documentation, object naming

* Refactored comparisonPrice function to use adjusted rate from optimizer, used native order fee schedule to adjust for order fees

* Small fixes to function, added unit tests

* Adjusted fee calculation for comparisonPrice function

* use available OptimalPathRate object

* fix lint error in test, separate out fee calculation

* Fixed market operation utils test, added additional checks for fee schedule

* removed unused dep, prettier
2020-11-18 17:12:35 -08:00
mzhu25
89948b360c Add checkAllowance flag to LibTokenSpender.spendERC20Tokens (#39) 2020-11-18 12:23:13 -08:00
Lawrence Forman
561b60a24d EP Native Orders (#27)
* `@0x/contracts-zero-ex`: add limit orders feature
`@0x/contracts-utils`: add `uint128` functions to `LibSafeMathV06`

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

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

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

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

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

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

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

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

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

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

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

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

* update orders docs

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

* rebuild after rebase

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

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

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

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

* update orders docs

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-17 15:39:40 -05:00
Jacob Evans
4f82543bdf feat: asset-swapper tweak the gas schedule + return decimals (#34)
* feat: asset-swapper Return decimals from sampler in quote

* feat: asset-swapper tweak the gas schedule

* fix lint

* CHANGELOG
2020-11-17 11:36:53 +10:00
Github Actions
3133c509f9 Publish
- @0x/contracts-integrations@2.7.9
 - @0x/asset-swapper@5.1.1
2020-11-14 02:19:41 +00:00
Github Actions
426c15692d Updated CHANGELOGS & MD docs 2020-11-14 02:19:33 +00:00
mzhu25
8c87a77faa Remove PLP VIP path from EP swap quote consumer (#36) 2020-11-13 17:49:30 -08:00
Github Actions
d2018f07a2 Publish
- @0x/contracts-asset-proxy@3.6.5
 - @0x/contracts-broker@1.1.13
 - @0x/contracts-coordinator@3.1.14
 - @0x/contracts-dev-utils@1.3.12
 - @0x/contracts-erc1155@2.1.14
 - @0x/contracts-erc20@3.2.8
 - @0x/contracts-erc721@3.1.14
 - @0x/contracts-exchange-forwarder@4.2.14
 - @0x/contracts-exchange-libs@4.3.14
 - @0x/contracts-exchange@3.2.14
 - @0x/contracts-extensions@6.2.8
 - @0x/contracts-integrations@2.7.8
 - @0x/contracts-multisig@4.1.14
 - @0x/contracts-staking@2.0.21
 - @0x/contracts-test-utils@5.3.11
 - @0x/contracts-utils@4.5.8
 - @0x/contracts-zero-ex@0.9.0
 - @0x/asset-swapper@5.1.0
 - @0x/contract-addresses@5.3.0
 - @0x/contract-artifacts@3.9.0
 - @0x/contract-wrappers-test@12.2.24
 - @0x/contract-wrappers@13.10.0
 - @0x/migrations@6.5.0
 - @0x/order-utils@10.4.6
2020-11-13 21:14:01 +00:00
Github Actions
d2e57d8163 Updated CHANGELOGS & MD docs 2020-11-13 21:13:51 +00:00
mzhu25
7403c0255a Feature/liquidity provider sandbox (#16)
* Update liquidity provider feature to use sandbox

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

* Move to off-chain liquidity provider registry

* Update ILiquidityProvider interface

* Remove some unused artifacts and wrappers

* Consolidate ILiquidityProvider

* prettier

* lint

* Address PR feedback

* Add failover to sandbox

* Add test for failover behavior in LiquidityProviderSandbox

* Update changelogs

* Emit events for the new LiquidityProvider scenarios

* Fix swap quote consumer bug

* post-rebase fixes

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

* Add default field to TokenAdjacencyGraph

* update addresses

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-13 12:22:21 -08:00
Steve Marx
75dcd687e2 better protocol fee tests (#25)
* better protocol fee tests
2020-11-09 12:44:52 -05:00
Steve Marx
afd4805421 rewrite ZeroEx in Yul (#23)
rewrite ZeroEx in Yul
2020-11-06 22:03:07 -05:00
Github Actions
6aa582d140 Publish
- @0x/contracts-integrations@2.7.7
 - @0x/asset-swapper@5.0.3
2020-11-05 23:57:34 +00:00
Github Actions
534d92fa00 Updated CHANGELOGS & MD docs 2020-11-05 23:57:28 +00:00
Romain Butteaud
37aae134ab feat: adding Curve pools: PAX, hBTC, metapools: gUSD, hUSD, USDn, mUSD, tBTC (#26)
* feat: adding Curve pools: PAX, hbtc, metapools: gusd, husd, usdn, musd, tbtc

* feat: CHANGELOG

* fix: bad import

* fix: curve_y address downcase, use POOLS addresses for names

* feat: add metaToken attribute to disable metapools for non-metaTokens in Curve

* fix: CHANGELOG
2020-11-05 15:27:45 -08:00
Daniel Pyrathon
36bd8f68c9 adds amendments to the rollout feature flag. Rollout indicative quote… (#30)
* adds amendments to the rollout feature flag. Rollout indicative quotes indipendently from firm quotes.

* Updates based on Brandon's feedback
2020-11-05 12:46:06 -08:00
Github Actions
c3ad42221e Publish
- @0x/contracts-asset-proxy@3.6.4
 - @0x/contracts-broker@1.1.12
 - @0x/contracts-coordinator@3.1.13
 - @0x/contracts-dev-utils@1.3.11
 - @0x/contracts-erc1155@2.1.13
 - @0x/contracts-erc20@3.2.7
 - @0x/contracts-erc721@3.1.13
 - @0x/contracts-exchange-forwarder@4.2.13
 - @0x/contracts-exchange-libs@4.3.13
 - @0x/contracts-exchange@3.2.13
 - @0x/contracts-extensions@6.2.7
 - @0x/contracts-integrations@2.7.6
 - @0x/contracts-multisig@4.1.13
 - @0x/contracts-staking@2.0.20
 - @0x/contracts-test-utils@5.3.10
 - @0x/contracts-utils@4.5.7
 - @0x/contracts-zero-ex@0.8.0
 - @0x/asset-swapper@5.0.2
 - @0x/contract-addresses@5.2.0
 - @0x/contract-wrappers-test@12.2.23
 - @0x/contract-wrappers@13.9.5
 - @0x/migrations@6.4.7
 - @0x/order-utils@10.4.5
2020-11-03 06:46:11 +00:00
Github Actions
602ac1f626 Updated CHANGELOGS & MD docs 2020-11-03 06:46:05 +00:00
Lawrence Forman
3126795efe @0x/contract-addresses: deploy FQT with CORRECT address (#29)
`@0x/contracts-zero-ex`: Trust `boughtAmount` returned by LP

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-03 01:12:57 -05:00
Github Actions
dbcb221a59 Publish
- @0x/contracts-asset-proxy@3.6.3
 - @0x/contracts-broker@1.1.11
 - @0x/contracts-coordinator@3.1.12
 - @0x/contracts-dev-utils@1.3.10
 - @0x/contracts-erc1155@2.1.12
 - @0x/contracts-erc20@3.2.6
 - @0x/contracts-erc721@3.1.12
 - @0x/contracts-exchange-forwarder@4.2.12
 - @0x/contracts-exchange-libs@4.3.12
 - @0x/contracts-exchange@3.2.12
 - @0x/contracts-extensions@6.2.6
 - @0x/contracts-integrations@2.7.5
 - @0x/contracts-multisig@4.1.12
 - @0x/contracts-staking@2.0.19
 - @0x/contracts-test-utils@5.3.9
 - @0x/contracts-utils@4.5.6
 - @0x/contracts-zero-ex@0.7.0
 - @0x/asset-swapper@5.0.1
 - @0x/contract-addresses@5.1.0
 - @0x/contract-artifacts@3.8.2
 - @0x/contract-wrappers-test@12.2.22
 - @0x/contract-wrappers@13.9.4
 - @0x/migrations@6.4.6
 - @0x/order-utils@10.4.4
2020-11-03 04:16:44 +00:00
Github Actions
6bbc179f52 Updated CHANGELOGS & MD docs 2020-11-03 04:16:37 +00:00
Lawrence Forman
48e7a391c8 Deploy new FQT (#28)
* `@0x/contracts-zero-ex`: Change `ProtocolFeeUnfunded` event in FQT
`@0x/contracts-zero-ex`: Use new PLP interface in FQT.

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

* fix failing FQT test

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-11-02 21:47:25 -05:00
Github Actions
2334e64d0c Publish
- @0x/contracts-asset-proxy@3.6.2
 - @0x/contracts-broker@1.1.10
 - @0x/contracts-coordinator@3.1.11
 - @0x/contracts-dev-utils@1.3.9
 - @0x/contracts-erc1155@2.1.11
 - @0x/contracts-erc20@3.2.5
 - @0x/contracts-erc721@3.1.11
 - @0x/contracts-exchange-forwarder@4.2.11
 - @0x/contracts-exchange-libs@4.3.11
 - @0x/contracts-exchange@3.2.11
 - @0x/contracts-extensions@6.2.5
 - @0x/contracts-integrations@2.7.4
 - @0x/contracts-multisig@4.1.11
 - @0x/contracts-staking@2.0.18
 - @0x/contracts-test-utils@5.3.8
 - @0x/contracts-utils@4.5.5
 - @0x/contracts-zero-ex@0.6.0
 - @0x/asset-swapper@5.0.0
 - @0x/contract-artifacts@3.8.1
 - @0x/contract-wrappers-test@12.2.21
 - @0x/contract-wrappers@13.9.3
 - @0x/migrations@6.4.5
 - @0x/order-utils@10.4.3
2020-11-02 22:21:36 +00:00
Github Actions
14f920ee84 Updated CHANGELOGS & MD docs 2020-11-02 22:21:30 +00:00
Jacob Evans
e10a81023a feat: [asset-swapper] more hops via token adjacency (#24)
* feat: [asset-swapper] more hops via token adjacency

* fix lint

* CHANGELOG
2020-11-03 07:48:37 +10:00
Lawrence Forman
f4709ed1cb EP: Add LibSignature library (#21)
* `@0x/contracts-zero-ex`: Add `LibSignature` library

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

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-10-29 17:47:17 -04:00
Daniel Pyrathon
e2e14a977a fix: [WIP] Adds RFQ price-aware comparison price to Quote Report (#18)
* Adds RFQ price-aware comparison price to Quote Report

* added linting fix

* added small lints

* better syntax
2020-10-29 08:48:01 -07:00
Jacob Evans
866f958a10 Update README.md 2020-10-29 17:12:23 +10:00
Jacob Evans
717db99b38 fix: Support Multiple Shells (#17)
* fix: Support Multiple Shells

* CHANGEGLOG
2020-10-29 17:09:23 +10:00
Lawrence Forman
02006118c7 Fix broken tools deps (#20)
* update tools deps to highest
add custom doc gen config

* remove phantom package in manifest

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-10-29 16:33:16 +10:00
Steve Marx
9816019bc5 add protocol fees fixin (#2) 2020-10-28 17:10:59 -04:00
Github Actions
9c821dbfc3 Publish
- @0x/contracts-asset-proxy@3.6.1
 - @0x/contracts-broker@1.1.9
 - @0x/contracts-coordinator@3.1.10
 - @0x/contracts-dev-utils@1.3.8
 - @0x/contracts-erc1155@2.1.10
 - @0x/contracts-erc20@3.2.4
 - @0x/contracts-erc721@3.1.10
 - @0x/contracts-exchange-forwarder@4.2.10
 - @0x/contracts-exchange-libs@4.3.10
 - @0x/contracts-exchange@3.2.10
 - @0x/contracts-extensions@6.2.4
 - @0x/contracts-integrations@2.7.3
 - @0x/contracts-multisig@4.1.10
 - @0x/contracts-staking@2.0.17
 - @0x/contracts-test-utils@5.3.7
 - @0x/contracts-utils@4.5.4
 - @0x/contracts-zero-ex@0.5.1
 - @0x/asset-swapper@4.8.1
 - @0x/contract-addresses@5.0.1
 - @0x/contract-wrappers-test@12.2.20
 - @0x/contract-wrappers@13.9.2
 - @0x/migrations@6.4.4
 - @0x/order-utils@10.4.2
2020-10-28 02:10:57 +00:00
Github Actions
af1b890423 Updated CHANGELOGS & MD docs 2020-10-28 02:10:51 +00:00
Romain Butteaud
673835d2de fix: update kovan erc20BridgeSampler (#14)
* fix: update kovan erc20BridgeSampler

* fix update CHANGELOG
2020-10-27 17:51:51 -07:00
Greg Hysz
500b57e935 Adds Template for Specs (#12)
* Adds `docs` directory, along with boilerplate code and templates for readthedocs.org.

* docs: update orders spec

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-10-27 16:31:15 -07:00
Jacob Evans
3f7d0580c1 Set the FeeSchedule to Required (#15) 2020-10-28 09:26:14 +10:00
Github Actions
a71c356bba Publish
- @0x/contracts-asset-proxy@3.6.0
 - @0x/contracts-broker@1.1.8
 - @0x/contracts-coordinator@3.1.9
 - @0x/contracts-dev-utils@1.3.7
 - @0x/contracts-erc1155@2.1.9
 - @0x/contracts-erc20@3.2.3
 - @0x/contracts-erc721@3.1.9
 - @0x/contracts-exchange-forwarder@4.2.9
 - @0x/contracts-exchange-libs@4.3.9
 - @0x/contracts-exchange@3.2.9
 - @0x/contracts-extensions@6.2.3
 - @0x/contracts-integrations@2.7.2
 - @0x/contracts-multisig@4.1.9
 - @0x/contracts-staking@2.0.16
 - @0x/contracts-test-utils@5.3.6
 - @0x/contracts-utils@4.5.3
 - @0x/contracts-zero-ex@0.5.0
 - @0x/asset-swapper@4.8.0
 - @0x/contract-addresses@5.0.0
 - @0x/contract-wrappers-test@12.2.19
 - @0x/contract-wrappers@13.9.1
 - @0x/migrations@6.4.3
 - @0x/order-utils@10.4.1
2020-10-27 21:13:56 +00:00
Github Actions
c3a95b7fb1 Updated CHANGELOGS & MD docs 2020-10-27 21:13:47 +00:00
Lawrence Forman
f01540fb35 fix publish 2020-10-27 16:42:30 -04:00
Daniel Pyrathon
689a8881c2 fix: Changed price-aware RFQ flag to be a argument parameter (#13)
* Changed price-aware RFQ flag to be a argument parameter

* prettified tests

* lint
2020-10-27 12:56:26 -07:00
Jacob Evans
99f5be8378 chore: [asset swapper] sampler Solidity 0.6 + Bridge addresses in AS (#4)
* Refactor excess interfaces

* Compiles on 0.6

* Refactored into try/catch

* Rebase and Refactored to v06

* Handle invalid registry in LP

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

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

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

* curve->pool

* lint

* Refactor to fix module load order

* Move FEE Schedule

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

* rollup: Swerve/Sushi

* DODO Rollup + Snowswap Swerve

* hardcode addresses temporarily

* rebase

* rename to SUSHISWAP_ROUTER

* CHANGELOGs

* CHANGELOGs

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
2020-10-27 15:16:09 +10:00
Lawrence Forman
8de0282d92 fix run:publish:gha package script 2020-10-23 17:11:56 -04:00
Github Actions
f99804d56a Publish
- @0x/contracts-integrations@2.7.1
 - @0x/contracts-zero-ex@0.4.0
 - @0x/asset-swapper@4.7.1
 - @0x/contract-wrappers-test@12.2.18
 - @0x/migrations@6.4.2
2020-10-23 21:08:02 +00:00
Github Actions
f13d27b749 Updated CHANGELOGS & MD docs 2020-10-23 21:07:56 +00:00
Lawrence Forman
465fd59cbc add publish github action 2020-10-23 16:56:36 -04:00
F. Eugene Aumson
5fdabe6612 Change contracts/integrations to use LOCAL a-s (#9)
Change contracts/integrations/package.json to refer to the LOCAL
asset-swapper, not a gitpkg one, since asset-swapper does live in this
same repo now.
2020-10-23 13:21:25 -04:00
Steve Marx
861871134b add LibTokenSpender and convert to using that (#3)
add LibTokenSpender and convert to using that

This skips the allowance target. Allowances are instead just set on the
exchange proxy itself. There is a fallback, though, to try spending from
the allowance target if the original transfer fails.
2020-10-23 10:45:46 -04:00
Daniel Pyrathon
c246d98093 Merge pull request #1 from 0xProject/asset-swapper-update-lockfile
updated lockfile
2020-10-21 10:20:01 -07:00
Daniel Pyrathon
02076dba1b updated lockfile 2020-10-21 10:07:56 -07:00
Lawrence Forman
7b136a5ad8 Publish
- @0x/contracts-asset-proxy@3.5.0
 - @0x/contracts-broker@1.1.7
 - @0x/contracts-coordinator@3.1.8
 - @0x/contracts-dev-utils@1.3.6
 - @0x/contracts-erc1155@2.1.8
 - @0x/contracts-erc20@3.2.2
 - @0x/contracts-erc721@3.1.8
 - @0x/contracts-exchange-forwarder@4.2.8
 - @0x/contracts-exchange-libs@4.3.8
 - @0x/contracts-exchange@3.2.8
 - @0x/contracts-extensions@6.2.2
 - @0x/contracts-integrations@2.7.0
 - @0x/contracts-multisig@4.1.8
 - @0x/contracts-staking@2.0.15
 - @0x/contracts-test-utils@5.3.5
 - @0x/contracts-utils@4.5.2
 - @0x/contracts-zero-ex@0.3.0
 - @0x/asset-swapper@4.7.0
 - @0x/contract-addresses@4.12.0
 - @0x/contract-artifacts@3.8.0
 - @0x/contract-wrappers-test@12.2.17
 - @0x/contract-wrappers@13.9.0
 - @0x/migrations@6.4.1
 - @0x/order-utils@10.4.0
2020-10-21 03:33:23 -04:00
Lawrence Forman
0c4a67fa35 Updated CHANGELOGS & MD docs 2020-10-21 03:33:18 -04:00
Lawrence Forman
668aeb77f7 disable coverage ci job 2020-10-21 03:08:33 -04:00
Lawrence Forman
135ae392d5 add @0x/asset-swapper to non contract packages
fix missing non-dev dep in `@0x/contracts-coordinator`
2020-10-21 02:53:41 -04:00
Lawrence Forman
88ba04307c update deps 2020-10-21 02:27:55 -04:00
Lawrence Forman
e4b8000a48 update yarn.lock 2020-10-21 02:14:47 -04:00
Lawrence Forman
b9df108314 disable doc gen on contract packages 2020-10-21 02:13:27 -04:00
Lawrence Forman
6106185bf6 disable testing inactive packages in ci 2020-10-21 02:11:04 -04:00
Lawrence Forman
3a3e289864 pin doc related deps and regen yarn lock 2020-10-21 01:56:47 -04:00
Lawrence Forman
6558632f10 remove bundlewatch from static-tests ci job 2020-10-21 01:18:41 -04:00
Lawrence Forman
376ee6bdff fix missing non-dev dependencies in packages 2020-10-21 01:18:41 -04:00
Lawrence Forman
fc5d759131 update typedoc-plugin-markdown deps
fix broken static-tests ci job
2020-10-21 00:54:56 -04:00
Lawrence Forman
7c16bb3df8 update prettierrc and run prettier 2020-10-20 23:52:44 -04:00
Lawrence Forman
5df74d35d0 @0x/contract-artifacts: Fix contract-artifacts tests 2020-10-20 23:24:42 -04:00
Lawrence Forman
72fc0c845a Fix prettier minor version.
update lock file
2020-10-20 23:24:08 -04:00
Lawrence Forman
b995715a2c update URLs in package manifests 2020-10-20 23:08:05 -04:00
Lawrence Forman
857b5c97b0 update deps 2020-10-20 23:00:26 -04:00
Lawrence Forman
178d9c280a update repo scripts 2020-10-20 22:59:39 -04:00
Lawrence Forman
2416deba25 update root package.json 2020-10-20 20:53:39 -04:00
Lawrence Forman
0ce6243653 update @0x/tools deps
skip kyber bridge tests
ignore some contract packages in tests by default
update package deps
update README, CI, and GH configs
2020-10-20 20:53:39 -04:00
Lawrence Forman
40dc10729b delete packages 2020-10-20 20:53:39 -04:00
Daniel Pyrathon
0571244e9e Merge pull request #2720 from 0xProject/refactor_rfq_comparison_price_integration
feat: Refactor rfq comparison price integration
2020-10-20 16:17:04 -07:00
Daniel Pyrathon
3213131cad Merge pull request #2735 from 0xProject/rfqt_comparison_feature_flag
Rfqt comparison feature flag
2020-10-20 15:48:29 -07:00
F. Eugene Aumson
61bf93aac2 Leave link to PR in comments 2020-10-20 14:30:04 -04:00
F. Eugene Aumson
a9d0cec6d1 Ran prettier 2020-10-20 14:17:48 -04:00
F. Eugene Aumson
b5e3f0b90c Disable tests per IS_PRICE_AWARE_RFQ_ENABLED flag 2020-10-20 13:48:46 -04:00
F. Eugene Aumson
61f1fe42b0 Merge branch 'refactor_rfq_comparison_price_integration' into rfqt_comparison_feature_flag 2020-10-20 13:48:27 -04:00
F. Eugene Aumson
1cfdc49021 Ran prettier 2020-10-20 12:15:44 -04:00
Lawrence Forman
c4d58277cf Merge pull request #2738 from 0xProject/feat/sol-compiler/changelog-fix
add updated changelog for sol-compiler
2020-10-20 12:10:18 -04:00
Lawrence Forman
9ac66c2130 add updated changelog for sol-compiler 2020-10-20 12:09:02 -04:00
Daniel Pyrathon
6366163006 small lint fix 2020-10-19 17:09:37 -07:00
Daniel Pyrathon
85fde8f9a5 comments and renaming 2020-10-19 17:03:26 -07:00
Daniel Pyrathon
a03d0800b0 Add changes for the feature flag 2020-10-19 16:58:45 -07:00
Romain Butteaud
9cb21006a7 Merge pull request #2729 from 0xProject/feat/snowswap
feat: SnowSwap
2020-10-19 16:21:31 -07:00
Romain Butteaud
649202f1c4 fix: prettier 2020-10-19 14:59:18 -07:00
Romain Butteaud
b798556774 feat: adjusting CURVE_CALL_GAS for SnowSwap, disabling yVaultUSDUnderlying pool for underlying tokens 2020-10-19 13:24:44 -07:00
Romain Butteaud
03bc15fbdf fix: add _target comment for Swerve pool 2020-10-19 13:24:44 -07:00
Romain Butteaud
b2dfd8740c feat: fix CURVE_CALL_GAS and SnowSwap pool addresses 2020-10-19 13:24:44 -07:00
Romain Butteaud
3182c12b4d feat: use pool attribute instead of curve for all Curve like pools 2020-10-19 13:24:44 -07:00
Romain Butteaud
f783625d60 feat: adding yVaultUSDUnderlying 2020-10-19 13:24:44 -07:00
Romain Butteaud
891aa8e8bf feat: SnowSwap 2020-10-19 13:24:44 -07:00
Daniel Pyrathon
4b508d255d Merge branch 'development' of github.com:0xProject/0x-monorepo into refactor_rfq_comparison_price_integration 2020-10-19 13:04:25 -07:00
Lawrence Forman
1cad43bf5d Merge pull request #2733 from 0xProject/feat/sol-compiler/0.7.x-pr-2710
sol-compiler: support 0.7x (#2710)
2020-10-19 13:41:07 -04:00
Lawrence Forman
a0cd727832 @0x/sol-compiler: Update changelog 2020-10-19 13:40:36 -04:00
Lawrence Forman
ab90e15015 @0x.js: add pinned node types to 0x.js 2020-10-19 13:03:48 -04:00
Lawrence Forman
52cbddf054 @0x/sol-compiler: fix build error with new node types 2020-10-19 12:25:01 -04:00
Lawrence Forman
db98ff8cb7 fix sol-compiler linter error
pin `@types/node` to appease publish job
2020-10-19 12:04:38 -04:00
Lawrence Forman
1d8dd2f89c Merge pull request #2710 from HenryNguyen5/feature/sol-compiler_support_v0.7
Support solidity v0.7.x
2020-10-19 11:52:17 -04:00
Daniel Pyrathon
0ae1c926d3 Merge branch 'development' of github.com:0xProject/0x-monorepo into refactor_rfq_comparison_price_integration
# Conflicts:
#	packages/asset-swapper/src/utils/market_operation_utils/index.ts
2020-10-16 15:16:59 -07:00
Daniel Pyrathon
1fcab58e2f cheap lint fix 2020-10-16 14:49:25 -07:00
Daniel Pyrathon
a8cbd1a16c apply PR feedback 2020-10-16 14:47:37 -07:00
Alex Kroeger
3aaa0ad6b2 Merge pull request #2715 from 0xProject/feat/add-cream
feat: Add CREAM as a liquidity source
2020-10-16 14:18:09 -07:00
HenryNguyen5
e34bc77157 Support solidity v0.7.x 2020-10-16 17:02:39 -04:00
Alex Kroeger
088b331f19 Prettier, cleared up naming 2020-10-16 10:28:48 -07:00
Alex Kroeger
56f2dec441 Merge branch 'development' into feat/add-cream 2020-10-16 10:23:38 -07:00
Alex Kroeger
ac8b08d3cf Fix type error in migrations 2020-10-15 23:35:23 -07:00
Jacob Evans
c4ead689a9 fix: [asset-swapper] excludedFeeSources. DODO Trade Allowed (#2731)
* fix: Fee sources and Ganache existence

* Added excludedFeeSources

* Comments and CHANGELOG

* fix: DODO Trade Allowed (#2732)
2020-10-16 10:01:12 +10:00
Alex Kroeger
07ab10b000 Deployed CreamBridge, refactor to simplify code 2020-10-15 16:58:39 -07:00
F. Eugene Aumson
c969a8652a Reduce solidity compiler optimizer runs...
...in order to accomodate now-too-big contract TestERC20BridgeSampler,
which imports the recently-added-to NativeOrderSampler.sol.

Fixes test failing like:
  1) erc20-bridge-sampler
       "before all" hook in "erc20-bridge-sampler":
     RuntimeError: VM Exception while processing transaction: out of gas
2020-10-15 13:18:31 -04:00
Jacob Evans
fb21ca5404 fix: [asset-swapper] MultiHop edge cases (#2730)
* fix: [asset-swapper] MultiHop edge cases

* CHANGELOG
2020-10-15 17:31:22 +10:00
Alex Kroeger
bbfa9c34ab Add CREAM to market operation utils constants 🤦 2020-10-14 12:42:06 -07:00
Alex Kroeger
7161bbe836 prettier 2020-10-14 11:38:05 -07:00
Alex Kroeger
ef65aa5bf6 further fixes in market operation utils 2020-10-14 11:37:03 -07:00
F. Eugene Aumson
2cf31f05a1 Drop |undefined from type of optional param
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2720#discussion_r500453526
2020-10-14 13:23:02 -04:00
F. Eugene Aumson
2b1a1ba0db Fix failing test-doc-generation 2020-10-14 13:21:14 -04:00
F. Eugene Aumson
05b25c6229 Ran prettier 2020-10-14 13:02:17 -04:00
F. Eugene Aumson
2db52c6983 Fixed linter error
ERROR: 793:24  no-unnecessary-type-assertion  This assertion is unnecessary since it does not change the type of the expression.
2020-10-14 13:02:17 -04:00
Alex Kroeger
4803e2f68c Add peer dependencies for cream-sor, small fix to sampler routing 2020-10-14 09:56:23 -07:00
F. Eugene Aumson
7030572f1d Stop referring to GetMarketOrdersOpts.shouldBat...
Because it doesn't exist on that type.
2020-10-14 11:58:18 -04:00
F. Eugene Aumson
6e2eb9c5bb Merge branch 'development' into refactor_rfq_comparison_price_integration 2020-10-14 11:57:58 -04:00
Alex Kroeger
eb27e260e0 merged into development to grab dodo 2020-10-13 23:23:05 -07:00
Alex Kroeger
c72aa653e8 Integrated CREAM into asset-swapper 2020-10-13 20:27:08 -07:00
Jacob Evans
4d04b72674 feat: DODO (#2701)
* feat: DODO

* DODO Bridge

* export DODOFillData

* Use deployed DODOHelper

* Deployed Bridge. Half of buys supported

* other half of buys

* refactor

* CHANGELOGs

* Lint
2020-10-13 18:20:31 +10:00
F. Eugene Aumson
e3b92d2c8b Fix linter errors 2020-10-12 18:01:22 -04:00
F. Eugene Aumson
4aa5a89cd7 Merge branch 'development' into refactor_rfq_comparison_price_integration 2020-10-12 12:44:30 -04:00
Alex Kroeger
c6b9ea5723 Merge branch 'development' into feat/add-cream 2020-10-11 20:11:24 -07:00
Alex Kroeger
2dc0bff1ea Merge pull request #2725 from 0xProject/refactor-asset-swapper-v1
removed v0-specific code in asset-swapper
2020-10-09 09:55:15 -07:00
Alex Kroeger
408e66e8b4 altered changelog wording 2020-10-08 16:54:16 -07:00
Alex Kroeger
40fe12a86b Updated changelog 2020-10-08 16:52:14 -07:00
Alex Kroeger
1adb56f092 prettier 🤦 2020-10-08 16:43:52 -07:00
Alex Kroeger
629d48c766 removed unused functions 2020-10-08 16:43:52 -07:00
Alex Kroeger
c8886febb9 removed v0-specific code in asset-swapper 2020-10-08 16:43:52 -07:00
Daniel Pyrathon
efe598c8fd Merge branch 'development' of github.com:0xProject/0x-monorepo into refactor_rfq_comparison_price_integration 2020-10-08 15:27:14 -07:00
mzhu25
32218ce25e Merge pull request #2728 from 0xProject/fix/uint80
add abi encoder support for uint80 lol
2020-10-08 15:12:57 -07:00
F. Eugene Aumson
f7ae697475 Merge pull request #2726 from 0xProject/fix/asset-swapper/rfqtMakerInteraction-with-blacklisting
asset-swapper: isBlacklisted in rfqtMakerInteraction
2020-10-08 14:19:10 -04:00
F. Eugene Aumson
6e954385ce Include requestParams in maker-blacklisted log
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2726#discussion_r501332160
2020-10-08 09:15:58 -04:00
Daniel Pyrathon
f8df89b506 fixed broken package 2020-10-07 23:49:04 -07:00
Daniel Pyrathon
a3ff406461 update quote server 2020-10-07 19:37:38 -07:00
Daniel Pyrathon
221de054f4 fixes a few issues with the typing 2020-10-07 19:34:12 -07:00
Michael Zhu
98e6aa4bac add abi encoder support for uint80 lol 2020-10-07 18:40:17 -07:00
Daniel Pyrathon
199808dc44 Merge branch 'development' of github.com:0xProject/0x-monorepo into refactor_rfq_comparison_price_integration
# Conflicts:
#	packages/asset-swapper/src/utils/market_operation_utils/index.ts
2020-10-07 14:28:35 -07:00
F. Eugene Aumson
5d8e35fb68 asset-swapp: isBlacklisted in rfqtMakerInteraction 2020-10-07 16:32:22 -04:00
Jacob Evans
36546480b1 fix: [asset-swapper] Catch Uint256BinOp which can occur (#2724)
* fix: [asset-swapper] Catch Uint256BinOp which can occur

* Perform a local bounds check
2020-10-07 17:36:44 +10:00
Jacob Evans
cd9e408ea3 fix: exchange proxy overhead scaled by gas price (#2723) 2020-10-06 21:09:46 +10:00
Jacob Evans
7698f21517 feat: [asset-swapper] Shell 🐚 (#2722)
* feat: [asset-swapper] Shell

* Deployed and Changelogs

* Glue up the deployed address

* Glue for FQT rollup
2020-10-06 15:55:51 +10:00
mzhu25
10724e5745 Merge pull request #2691 from 0xProject/feature/liquidity_provider_swap
`@0x/contracts-zero-ex`: LiquidityProviderFeature
2020-10-05 19:01:41 -07:00
Daniel Pyrathon
dde76a4dbb Mark decimal places 2020-10-05 17:36:52 -07:00
Michael Zhu
86ff5c53bb account for EP gas overhead in multihop 2020-10-05 17:33:13 -07:00
Daniel Pyrathon
efef5f122f added fix 2020-10-05 17:24:23 -07:00
Daniel Pyrathon
83c942ad8c Added fix for decimals 2020-10-05 17:20:43 -07:00
Michael Zhu
31e90e314c lint 2020-10-05 10:20:54 -07:00
Michael Zhu
33caae705e Update changelogs 2020-10-05 10:09:06 -07:00
Michael Zhu
961273a2ff Fix broken test 2020-10-05 10:09:06 -07:00
Michael Zhu
46e512a27c Fix test-doc-generation 2020-10-05 10:09:06 -07:00
Michael Zhu
290a04a0ad Appease linter 2020-10-05 10:09:06 -07:00
Michael Zhu
12ff4ec438 Add tests for exchange proxy gas overhead accounting in the path optimizer 2020-10-05 10:09:06 -07:00
Michael Zhu
1c15ecacb0 add tests for LiquidityProviderFeature 2020-10-05 10:09:06 -07:00
Michael Zhu
c6d738ed0c Refactor asset-swapper 2020-10-05 10:09:06 -07:00
Michael Zhu
f089f5d87f Add migrate function to LiquidityProviderFeature 2020-10-05 09:43:19 -07:00
Michael Zhu
78e3cd39d1 @0x/contracts-zero-ex: Add LiquidityProviderFeature contracts 2020-10-05 09:43:19 -07:00
Daniel Pyrathon
1588c1f362 Added initial unit tests and implementation 2020-10-02 15:04:50 -07:00
F. Eugene Aumson
a35d1b8a9d Merge pull request #2714 from 0xProject/feat/asset-swapper/rfq-maker-blacklist-logging
asset-swapper: log RFQ maker (un)blacklistings
2020-10-02 15:52:23 -04:00
F. Eugene Aumson
32923ec7e1 Blacklist for timeout === max, not just > 2020-10-02 14:18:31 -04:00
F. Eugene Aumson
5a3bd716ad Merge branch 'development' into feat/asset-swapper/rfq-maker-blacklist-logging 2020-10-02 13:44:31 -04:00
F. Eugene Aumson
84862f15c1 Store blacklistedUntil as local var, don't ref map
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2714#discussion_r497816501
2020-10-02 13:43:17 -04:00
Daniel Pyrathon
9e42dce5c4 added initial implementation 2020-10-01 14:28:36 -07:00
Daniel Pyrathon
a360109013 Merge pull request #2716 from 0xProject/fix/buy-orders-quote-report
fix: fixed a small bug with buys and quote reporter
2020-10-01 10:39:47 -07:00
F. Eugene Aumson
68d6b3a033 Merge branch 'development' into feat/asset-swapper/rfq-maker-blacklist-logging 2020-10-01 12:09:28 -04:00
Daniel Pyrathon
733c3046bc fixed a small bug with buys and quote reporter 2020-09-30 17:02:09 -07:00
Daniel Pyrathon
23d4b6bf1c Merge branch 'development' of github.com:0xProject/0x-monorepo into refactor_rfq_request_positioning
# Conflicts:
#	packages/asset-swapper/src/utils/market_operation_utils/index.ts
2020-09-30 16:59:21 -07:00
Daniel Pyrathon
39bd0c5459 Merge pull request #2713 from 0xProject/refactor_reporter
[Price-aware RFQ requests] Decouple QuoteReporter from _generateOptimizedOrdersAsync
2020-09-30 14:11:43 -07:00
Daniel Pyrathon
c13ffb2072 added linting and prettifying 2020-09-30 13:54:48 -07:00
Daniel Pyrathon
38bcab1f86 Merge branch 'development' of github.com:0xProject/0x-monorepo into refactor_rfq_request_positioning 2020-09-30 11:18:32 -07:00
Daniel Pyrathon
a24f01c90f added a few fixed and added some comments: 2020-09-29 23:07:14 -07:00
Daniel Pyrathon
708e34602b added further unit tests 2020-09-29 23:00:02 -07:00
Daniel Pyrathon
d60c8ddd5a added more unit tests 2020-09-29 22:25:24 -07:00
Daniel Pyrathon
eea63292f0 added initial RFQ tests 2020-09-29 17:02:12 -07:00
Alex Kroeger
a97342a594 updated changelog 2020-09-29 13:06:36 -07:00
Alex Kroeger
00f55be83e Added cream bridge contract 2020-09-29 12:59:54 -07:00
Daniel Pyrathon
90ed283b20 performed linting 2020-09-29 02:08:00 -07:00
Daniel Pyrathon
61272961a8 fixed a broken import, renamed variable 2020-09-29 02:02:17 -07:00
Daniel Pyrathon
507690f9db refactor coding and avoid running indicative quotes when sampling market liquidity 2020-09-29 00:59:14 -07:00
Daniel Pyrathon
90ad5eb6c4 refactor market side ops 2020-09-28 13:57:30 -07:00
Daniel Pyrathon
7bc9701c81 initial implementation 2020-09-28 13:15:44 -07:00
Daniel Pyrathon
a7d502a501 create quote report regardless of RFQT 2020-09-28 12:53:40 -07:00
F. Eugene Aumson
fbe99b41f8 asset-swapper: log RFQ maker (un)blacklistings 2020-09-28 14:14:52 -04:00
Lawrence Forman
66e2d93e9c Merge pull request #2711 from 0xProject/fix/balancer-sampling
Handle max in/out ratio reverts in Balancer sampling functions
2020-09-25 00:45:47 -04:00
Lawrence Forman
4672c72fef @0x/asset-swapper: compute max quote slippage from the first non-native order in getSwapMinBuyAmount() 2020-09-24 23:22:27 -04:00
Lawrence Forman
ac6b03cd4a fix LP and MB sources leaking into getSell/BuyOperations() when they should be disabled 2020-09-24 23:22:27 -04:00
Lawrence Forman
d7de191947 @0x/asset-swapper: Handle native orders in getSwapMinBuyAmount() 2020-09-24 23:22:27 -04:00
Lawrence Forman
de7f1fc207 @0x/asset-swapper: rename getMinBuyAmount() to getSwapMinBuyAmount()` and export for use in API. 2020-09-24 23:22:27 -04:00
Lawrence Forman
99de5a3814 @0x/asset-swapper: factor affiliate fees into new minBuyAmount calculation in EP consumer 2020-09-24 23:22:27 -04:00
Lawrence Forman
4cf566cad8 @0x/asset-swapper: Special case two-hop quotes in getMinBuyAmount() 2020-09-24 23:22:27 -04:00
Lawrence Forman
6138955f93 @0x/asset-swapper: respect max slippage in EP consumer 2020-09-24 23:22:27 -04:00
Michael Zhu
a57cf68ee4 Handle max in/out ratio reverts in Balancer sampling functions 2020-09-24 23:22:25 -04:00
Daniel Pyrathon
20edcd1ae5 lint and fix 2020-09-24 16:32:56 -07:00
Daniel Pyrathon
5333befd89 optionally return a quote report too 2020-09-24 15:37:18 -07:00
Daniel Pyrathon
235e406620 initial decoupling of Quote reporter 2020-09-24 15:27:55 -07:00
Kim Persson
5f570b772d asset-swapper: Quote report pass back optional fill data (#2702)
* ADDS quote report: pass back optional fill data for dex samples

* ADDS return fillData for Multihop in quote report

* FIXES quote report generator tests handle passing back fillData

* FIXES typing multi hop report source will always have fillData

* ADDS asset-swapper CHANGELOG entry
2020-09-24 15:06:44 +02:00
Jacob Evans
f2507cb94a [asset-swapper]: Added Curve Tripool (#2708) 2020-09-23 17:03:03 +10:00
Lawrence Forman
f84b375cde UniswapFeature (#2703)
* Minimal Uniswap accessor.

* Add comments

* Safe math

* mainnet gas benchmark

* Assembler Uniswap

* Selectors and addresses

* Fix bugs in ABI encoders

* Typo

* AsmUniswap test

* Fix wantAmount computation

* Golfing

* Bypass AllowanceTarget

* Generalized asm uniswapper

* Implement ordering

* Fix pair computation

* #6 Golfing Iron

* Remove 'to' argument (saves 377 gas)

* New contract api

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Co-authored-by: Remco Bloemen <remco@0x.org>
Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-09-23 16:27:48 +10:00
F. Eugene Aumson
32d11d1ba5 Merge pull request #2706 from 0xProject/feat/asset-swapper/punish-latent-rfqt-makers
asset-swapper: Punish latent RFQT makers
2020-09-18 18:06:12 -04:00
F. Eugene Aumson
5c9b6eb078 Add tests of class RfqMakerBlacklist
Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2706#pullrequestreview-489852363
2020-09-16 19:18:13 -04:00
F. Eugene Aumson
f53a512e70 Blacklist when threshhold reached, not surpassed 2020-09-16 19:09:17 -04:00
F. Eugene Aumson
ec08715090 Streamline isMakerBlacklisted() logic 2020-09-16 19:09:17 -04:00
F. Eugene Aumson
79e0a9ef37 Add and use constant ONE_MINUTE_MS
Addresses review comments
https://github.com/0xProject/0x-monorepo/pull/2706#discussion_r489610605
and
https://github.com/0xProject/0x-monorepo/pull/2706#discussion_r489614731
2020-09-16 19:08:27 -04:00
F. Eugene Aumson
1ce8a33937 asset-swapper: Punish latent RFQT makers 2020-09-14 19:07:48 -04:00
xianny
b3053dfb91 remove Bancor from list of on-chain sources 2020-09-11 16:05:14 -07:00
Xianny
3da05f2812 batch requests with bancor SDK (#2699)
* upgrade bancor SDK for batch requests

* lint

* changes after review

* deploy bancor bridge

* small fixes
2020-09-11 11:09:10 -07:00
Steve Klebanoff
0ba79b060d Merge pull request #2696 from 0xProject/bugfix/quote-report-generator-signature
Quote report generator: use signature instead of order hash for lookup
2020-09-09 17:32:51 -05:00
Steve Klebanoff
c4bcc26e29 Merge branch 'development' into bugfix/quote-report-generator-signature 2020-09-09 09:36:21 -05:00
Jacob Evans
630108ccb6 feat: Swerve Finance and SushiSwap (#2698)
* feat: Swerve Finance

* export SwerveFillData

* test and CHANGELOG

* feat: Sushiswap (#2700)

* feat: SushiSwap

* Changelog

* fix tests

* Deployed SushiSwap bridge

* Fix test

* IGNORED_EXCESSIVE_TYPES
2020-09-09 21:35:24 +10:00
Steve Klebanoff
1ab33aa132 Merge branch 'development' into bugfix/quote-report-generator-signature 2020-09-08 11:35:14 -05:00
Steve Klebanoff
ee456ea6e7 remove unused import 2020-09-04 11:01:24 -05:00
Steve Klebanoff
e7541ac2af update tests to use signatures instead of order hashes 2020-09-04 10:52:49 -05:00
Steve Klebanoff
d34d46b7fd change look up from order hash to order signature 2020-09-04 09:54:47 -05:00
Lawrence Forman
08ae43aad3 Merge pull request #2657 from 0xProject/fix/ep/meta-transactions
EP: MetaTransactions fixes
2020-09-03 23:21:19 -04:00
Lawrence Forman
eb141075c7 Merge pull request #2692 from 0xProject/feat/ep/fqt-rfqt-kyber-mooni-events
FQT: RFQT, more rollups, etc
2020-09-03 21:02:17 -04:00
Lawrence Forman
bd3387a408 @0x/contract-addresses: Update EP addresses 2020-09-03 16:52:28 -04:00
Lawrence Forman
e1a48e80e1 @0x/asset-swapper: Fix mooniswap sell sampling bug 2020-09-03 14:45:03 -04:00
Lawrence Forman
bf899d40a0 @0x/contracts-zero-ex: Only deploy FlashWallet in TransformERC20 migration if it does not already exist. 2020-09-03 13:39:30 -04:00
Lawrence Forman
dc66f1b886 @0x/asset-swapper: Fix Mooniswap buy sampling bug. 2020-09-03 11:01:41 -04:00
Lawrence Forman
3753b1a7d0 @0x/asset-swapper: Increase default error tolerance on quote simulation tests.
Run prettier.
2020-09-03 09:45:54 -04:00
Lawrence Forman
05c5acdb15 @0x/contracts-zero-ex: Fix Mooniswap WETH buying bug 2020-09-03 03:27:58 -04:00
Lawrence Forman
ca63bcc9b0 @0x/migrations: Remove mooniswapRegistry from BridgeAdapter addreses 2020-09-03 01:21:21 -04:00
Lawrence Forman
3733d503db @0x/contracts-zero-ex: Remove mooniswapRegistry from BridgeAdapter addreses 2020-09-03 01:21:09 -04:00
Lawrence Forman
ab28e42c22 @0x/asset-swapper: Fix mooniswap encoding 2020-09-03 01:07:00 -04:00
Lawrence Forman
7e53b4f834 @0x/contract-addresses: Update transformer deployer and transformers for champagne-problems deployment.
`@0x/migrations`: Reorder transformer deployments.
2020-09-02 22:23:20 -04:00
Lawrence Forman
3bb60fee19 @0x/asset-swapper: Export MooniswapFillData. 2020-09-02 21:22:24 -04:00
Lawrence Forman
9f7840e12b @0x/contracts-zero-ex: Remove only from tests. 2020-09-02 21:22:07 -04:00
Lawrence Forman
f41e13b574 @0x/contracts-zero-ex: Decode secret mooniswap bridge data parameter. 2020-09-02 17:45:37 -04:00
Lawrence Forman
4049143630 @0x/asset-swapper: Return Mooniswap pool in sampler and encode it in bridge data 2020-09-02 17:42:03 -04:00
Lawrence Forman
705f46717f @0x/contracts-integrations: Add EP + MTX + RFQT integration tests. 2020-09-02 15:58:41 -04:00
Lawrence Forman
a6cf8ae0b6 @0x/asset-swapper: Add rfqtTakerAddress to FillQuoteTransformerData 2020-09-02 15:58:41 -04:00
Lawrence Forman
dba6972281 @0x/order-utils: Add rfqtTakerAddress to FillQuoteTransformerData 2020-09-02 15:58:41 -04:00
Lawrence Forman
52d36f5a8b @0x/migrations: Fix FQT deployment 2020-09-02 15:58:41 -04:00
Lawrence Forman
889b58a914 @0x/contracts-zero-ex: Add RFQT taker enforcement to FQT.
`@0x/contracts-zero-ex`: Remove redundant event from `BridgeAdapter`.
`@0x/contracts-zero-ex`: Treat all calldata as signed if quote signer is not in `TransformERC20Feature`.

`@0x/contracts-zero-ex`: Update bridge adapters
2020-09-02 15:58:38 -04:00
Lawrence Forman
43810835d7 @0x/utils: Fix broken test 2020-09-01 18:52:32 -04:00
Lawrence Forman
4b9867f167 update changelogs 2020-09-01 18:02:17 -04:00
Lawrence Forman
e9c91e59bd @0x/contracts-zero-ex: Fix shadowed variable in TransformerDeployer. 2020-09-01 17:51:53 -04:00
Lawrence Forman
d8844f6970 @0x/contracts-integrations: Fix broken tests. 2020-09-01 17:32:29 -04:00
Lawrence Forman
1cdc6e7184 @0x/contracts-integrations: Remove stray only modifier. 2020-09-01 16:56:32 -04:00
Lawrence Forman
36ad373f03 @0x/utils: Fix StakingErrors.ExchangeManagerError incorrect param name 2020-09-01 16:55:04 -04:00
Lawrence Forman
78dfb6d525 @0x/migrations: Fix linter error. 2020-09-01 16:54:17 -04:00
Lawrence Forman
79254de7bc @0x/contracts-exchange: Fix failing tests. 2020-09-01 16:53:49 -04:00
Lawrence Forman
1d6aef5cd6 @0x/contracts-zero-ex: Remove UniswapFeature
`@0x/contracts-zero-ex`: Fix broken tests.
2020-09-01 16:05:14 -04:00
Lawrence Forman
f9d02c9e27 @0x/utils: Fix nested revert decoding 2020-09-01 16:04:01 -04:00
Lawrence Forman
228246089e Merge branch 'feat/exchange-proxy/vip-uniswap' into fix/ep/meta-transactions 2020-09-01 11:59:44 -04:00
Lawrence Forman
b6319ba3d8 @0x/contracts-zero-ex: Fix rebase artifacts. 2020-09-01 10:35:02 -04:00
Lawrence Forman
2636384ead Merge remote-tracking branch 'origin/feat/exchange-proxy/post-cd-audit' into fix/ep/meta-transactions 2020-09-01 09:48:17 -04:00
Lawrence Forman
0425f76284 Merge remote-tracking branch 'origin/fix/zero-ex/transformer-deployer-kill-fix' into fix/ep/meta-transactions 2020-09-01 09:42:38 -04:00
Lawrence Forman
d93e72f56a @0x/asset-swapper: Fix rebase conflicts 2020-09-01 09:41:00 -04:00
Lawrence Forman
195d543ce3 @0x/contracts-zero-ex: Remove bugged parity signature compatibility. 2020-09-01 09:41:00 -04:00
Lawrence Forman
9cda9f69cd @0x/contracts-zero-ex: Add reentrancy guard to mtx functions
`@0x/contracts-zero-ex`: Add refund mechanism to mtxs
`@0x/contracts-zero-ex`: Pass sender to transfomers.
`@0x/contracts-zero-ex`: Refund protocol fees to `refundReceiver` in FQT.
`@0x/utils`: Add EP flavor of `IllegalReentrancyError`
`@0x/order-utils`: Add `refundReceiver` to FQT transform data.
`@0x/asset-swapper`: Add `refundReceiver` support to EP swap quote consumer.
2020-09-01 09:40:58 -04:00
F. Eugene Aumson
7b0a1c3630 Merge pull request #2684 from 0xProject/feat/asset-swapper/rfqt-indicative-without-takerAddress
asset-swapper: Stop requiring takerAddress for indicative RFQ-T quotes.
2020-08-31 20:14:30 -04:00
F. Eugene Aumson
a8f3a47240 asset-swapper: Update comments 2020-08-31 16:36:00 -04:00
F. Eugene Aumson
db0f3a8780 Merge branch 'development' into feat/asset-swapper/rfqt-indicative-without-takerAddress 2020-08-31 12:11:00 -04:00
Jacob Evans
514db24ceb chore: Optional quote report generation (#2687) 2020-08-29 09:41:01 +10:00
F. Eugene Aumson
e738743c89 asset-swapper: ensure takerAddress for indiciative
Ensure the presence of a taker address query parameter in the request to
market maker endpoints for indicative RFQ-T quotes.

Addresses review comment https://github.com/0xProject/0x-monorepo/pull/2684#pullrequestreview-477242367
2020-08-28 16:30:01 -04:00
F. Eugene Aumson
f471e1a8a3 Merge branch 'development' into feat/asset-swapper/rfqt-indicative-without-takerAddress 2020-08-27 13:49:46 -04:00
Jacob Evans
a2f0d5eedf feat: better Kyber quotes (#2683)
* feat: Kyber rework

* Get additional reserves per token
2020-08-27 15:58:57 +10:00
Jacob Evans
2f9b894d71 fix: bunny-hop small amounts (#2685)
* fix: bunny-hop small amounts

* fix lint and Dockerfile

* HACK: temporarily disable python
2020-08-27 10:49:14 +10:00
mzhu25
bab34c2d21 Feature/bunny hop (#2647)
* `@0x/contracts-erc20-bridge-sampler`: Add TwoHopSampler + refactor

* `@0x/asset-swapper`: Refactor + add two-hop skeleton

* Round out two-hop support in asset-swapper

* Add BalancerSampler, use it for two-hop quotes

* Fix bugs discovered from simbot

* rebases are hard

* Add intermediate token to MultiHop source breakdown

* Fix market buy bugs

* Use hybrid on-chain/off-chain sampling for Balancer

* Another day, another rebase

* Update changelogs

* Address PR feedback, CI fixes

* Address more PR feedback
2020-08-27 08:20:09 +10:00
F. Eugene Aumson
a68421b0f8 update CHANGELOG 2020-08-26 16:31:27 -04:00
F. Eugene Aumson
e9b0ac8820 asset-swapper: Stop req'ing takerAddr for RFQT ind
Stop requiring takerAddress for indicative RFQ-T quotes.
2020-08-25 17:42:02 -04:00
Jacob Evans
4f78f55c2a fix: mooniswap usdt (#2681) 2020-08-25 21:43:19 +10:00
Daniel Pyrathon
156093127b Merge pull request #2678 from 0xProject/moreLogging
adds more logging keys
2020-08-24 19:45:04 -07:00
Daniel Pyrathon
47d91bb4e0 adds more logging keys 2020-08-24 15:54:09 -07:00
Jacob Evans
cc31445189 feat: asset-swapper mooniswap (#2675)
* feat: asset-swapper sampler early exit

* feat: asset-swapper mooniswap

* tests and linter

* deploy to mainnet

* CHANGELOGs

* fix excluded sources difference

* typo
2020-08-24 11:21:01 +10:00
Xianny
af78238507 Feat/bancor v2 (#2650)
* Bancor Bridge contract

* refactor Quote and FillData types

* BancorService (wrapper for the Bancor SDK)

* disable bancor while waiting for bancor SDK update

* add bancor to test
2020-08-21 15:11:35 -07:00
Lawrence Forman
b30f87f50c @0x/asset-swapper: Use IZeroExContract in EP swap quote consumer. 2020-08-20 16:56:40 -04:00
Lawrence Forman
3cd03ed0f1 @0x/migrations: Update EP migration 2020-08-20 16:55:47 -04:00
Lawrence Forman
e7ad7c3af7 @0x/contracts-zero-ex: Add IUniswapV2Feature.
`@0x/contracts-zero-ex`: Rename all feature contracts to have `Feature` suffix.
`@0x/contracts-zero-ex`: Return an `IZeroExContract` instance from `fullMigrateAsync()`.
2020-08-20 16:54:50 -04:00
Jacob Evans
7e8b56eef4 feat: mStable + FQT Rollup (#2662)
* feat: mStable

* deploy and CHANGELOG

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

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

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

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

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

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

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

* feat: ExchangeProxy FQT fruit rollup (#2645)

* feat: Optimize Bridges in ExchangeProxy

* compile and most work

* work around to trust the delecall contract

* force allowances

* Update Kyber/Eth2Dai bridges

* Remove memory state where not required

* cleanup

* Combine Bridges into one adapter

* mixins

* refactor out ZeroExBridge

* move out interface

* comment out hacks

* update migrations

* remove simbot hacks

* AdapterAddresses and mStable

* Share constructor arg

* fix migration

* Remove whitespace

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

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

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

* update ganache contract addresses

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

* update ganache contract addresses

* fix: asset-swapper prevent empty sampler batch call

* add sampler to migrations

* change migrations version

* Use contract-wrappers and artifacts

* remove extra data

* remove deps, set sampler to NULL_ADDRESS

* all the exports

* noop sell rate too

* update ganache contract addresses

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
2020-08-20 08:18:44 +10:00
mzhu25
458a014e6d Merge pull request #2668 from 0xProject/improvement/nested-revert-decoding
`@0x/utils`: Add support for nested rich revert decoding
2020-08-19 11:12:54 -07:00
Lawrence Forman
9b6703398e @0x/contracts-integrations: Add EP mtx tests. 2020-08-19 13:52:32 -04:00
Lawrence Forman
71700e69af @0x/zero-ex: Address CD post-audit feedback.
Add `LogMetadataTransformer`.
2020-08-19 13:52:32 -04:00
Lawrence Forman
14d6330b40 @0x/asset-swaper: Use transformer utils from @0x/order-utils. 2020-08-19 13:52:32 -04:00
Lawrence Forman
d31d646ecc @0x/order-utils: Fix EP signature utils schema assertion. 2020-08-19 13:52:32 -04:00
Michael Zhu
270d7a3f19 Update changelog 2020-08-19 10:11:25 -07:00
Michael Zhu
e078f3d479 Appease CI 2020-08-19 09:50:39 -07:00
Lawrence Forman
6aa8f17ed5 @0x/json-schemas: Add exchangeProxyMetaTransactionSchema. 2020-08-19 11:39:49 -04:00
Lawrence Forman
8e73ae3614 @0x/order-utils: Add findTransformerNonce() and getTransformerAddress() functions. 2020-08-18 16:39:59 -04:00
Michael Zhu
89117beda2 @0x/utils: Add support for nested rich revert decoding 2020-08-18 13:13:10 -07:00
Lawrence Forman
e27e6baabe @0x/contracts-integrations: Add EP mtx tests. 2020-08-17 22:08:25 -04:00
Daniel Pyrathon
15ce90c0ec Merge pull request #2665 from 0xProject/smaller_log
Smaller logs (avoid circular buffers) + add a boolean to indicate if order was included in the salad or not
2020-08-14 17:02:35 -07:00
Daniel Pyrathon
39e157499d removed toJSON check 2020-08-14 16:29:52 -07:00
Daniel Pyrathon
d22c0641fb are you included or not 2020-08-14 15:45:06 -07:00
Daniel Pyrathon
82806b6fcb avoid returning objects with circular buffers 2020-08-14 14:54:53 -07:00
Daniel Pyrathon
fe293d91ee added smaller log 2020-08-14 13:41:49 -07:00
Brandon Millman
7842bb4cad Fix deprecation message in instant README 2020-08-13 13:33:45 -06:00
Brandon Millman
6f7e156f49 Add deprecation warning to Instant README 2020-08-13 13:32:57 -06:00
Daniel Pyrathon
0d19cac487 Merge pull request #2663 from 0xProject/feature/keepAlive-timeout
Feature/keep alive timeout
2020-08-12 09:15:54 -07:00
Daniel Pyrathon
f30dfcc572 adds a long TTL to quote requestor client 2020-08-12 07:38:57 -07:00
Daniel Pyrathon
3df39d8cfe added httpAgent and httpsAgent timeouts 2020-08-11 19:12:53 -07:00
Daniel Pyrathon
ece93fed78 Merge pull request #2661 from 0xProject/feature/keepAlive
added keepAlive
2020-08-10 21:12:20 -07:00
Daniel Pyrathon
3a2c6ae9d6 updates balancer pinns to 0.3.2 2020-08-10 20:12:40 -07:00
Daniel Pyrathon
2ed71b36b6 Revert "added balancer packages"
This reverts commit ae9c301795.
2020-08-10 20:08:15 -07:00
Daniel Pyrathon
ae9c301795 added balancer packages 2020-08-10 19:26:29 -07:00
Daniel Pyrathon
68206ffb6e update balancer to 0.3.2 2020-08-10 18:10:50 -07:00
Daniel Pyrathon
25a3c18bfe fixed small test bug 2020-08-10 17:59:37 -07:00
Daniel Pyrathon
d28476e9f7 export axios 2020-08-10 16:57:08 -07:00
Daniel Pyrathon
7cd30610f9 fixed tests 2020-08-10 16:33:42 -07:00
Daniel Pyrathon
ceb90989d0 Merge branch 'development' of github.com:0xProject/0x-monorepo into feature/keepAlive
# Conflicts:
#	packages/asset-swapper/src/utils/quote_requestor.ts
2020-08-10 16:13:53 -07:00
Daniel Pyrathon
bb39d63d37 fixed class instantiation issue 2020-08-10 15:12:16 -07:00
Daniel Pyrathon
213709d020 added keepAlive 2020-08-10 14:47:15 -07:00
Jacob Evans
d0e9081852 feat: asset-swapper use ethToInputRate when ethToOutputRate is unavailable (#2660) 2020-08-10 20:41:17 +10:00
Jacob Evans
71cde281b9 fix: asset-swapper depth buy scale (#2659) 2020-08-09 16:38:59 +10:00
Lawrence Forman
c03f1586e6 asset-swapper: Fix optimization of buy paths (#2655)
* `@0x/asset-swapper`: Fix optimization of buy paths

* `@0x/asset-swapper`: Fix optimization of buy paths

* `@0x/asset-swapper`: Optimize the optimizer.

* `@0x/asset-swapper`: Remove unused `Fill` fields

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-08-07 13:03:52 +10:00
Lawrence Forman
10aceb164d @0x/asset-swapper: Fix rebase conflicts 2020-08-06 22:48:55 -04:00
Lawrence Forman
34f516a417 @0x/contracts-zero-ex: Remove bugged parity signature compatibility. 2020-08-06 22:32:42 -04:00
Lawrence Forman
5dd686f22f @0x/contracts-zero-ex: Add reentrancy guard to mtx functions
`@0x/contracts-zero-ex`: Add refund mechanism to mtxs
`@0x/contracts-zero-ex`: Pass sender to transfomers.
`@0x/contracts-zero-ex`: Refund protocol fees to `refundReceiver` in FQT.
`@0x/utils`: Add EP flavor of `IllegalReentrancyError`
`@0x/order-utils`: Add `refundReceiver` to FQT transform data.
`@0x/asset-swapper`: Add `refundReceiver` support to EP swap quote consumer.
2020-08-06 22:28:35 -04:00
mzhu25
5f47ad3363 Merge pull request #2658 from 0xProject/feat/asset-swapper/affiliate-fees
`@0x/asset-swapper`: Buy token affiliate fees
2020-08-06 10:39:37 -07:00
Michael Zhu
e166e9762a update changelogs 2020-08-06 09:38:33 -07:00
Michael Zhu
341c5782e5 @0x/asset-swapper: Add affiliate fee support to EP swap quote consumer 2020-08-05 22:56:39 -07:00
mzhu25
d5180d3ebc Merge pull request #2656 from 0xProject/refactor/migrations
Redeploy/verify testnet contracts
2020-08-04 15:35:24 -07:00
Michael Zhu
2c73bbd689 appease CI 2020-08-04 14:58:16 -07:00
Michael Zhu
b10522479c Update changelogs 2020-08-04 11:13:09 -07:00
Michael Zhu
2b39ae4800 Redeploy/verify testnet contracts 🙄 2020-08-04 11:08:03 -07:00
Jacob Evans
788bdba8cd fix: asset-swapper source collapse regression (#2654)
fixes source collapse regression where a split on the same source was collapsed into a single fill.
This should be kept distinct as separate fills.
2020-08-04 15:09:17 +10:00
Jacob Evans
222fd5d822 fix: Deploy UniswapV2 Bridge on Kovan (#2652)
* fix: Deploy UniswapV2 Bridge on Kovan

* CHANGELOG
2020-08-03 16:26:37 +10:00
Lawrence Forman
eedfc64a8c Merge pull request #2649 from 0xProject/feat/contract-wrappers/exchangeProxy
Add `exchangeProxy` to `ContractWrappers`
2020-07-30 20:43:33 -04:00
Lawrence Forman
78170b26e9 Merge pull request #2648 from 0xProject/fix/ethereum-types/ConstructorAbi-payable
`@0x/ethereum-types`: Make `ConstructorAbi.payable` optional.
2020-07-30 16:29:47 -04:00
Lawrence Forman
f966b6f4df @0x/ethereum-types: Make ConstructorAbi.payable optional. 2020-07-30 15:52:48 -04:00
Lawrence Forman
053b55fbbf @0x/order-utils: Add gitpkg 2020-07-30 13:56:43 -04:00
Lawrence Forman
84a55a2d84 @0x/contract-wrappers: add exchangeProxy to ContractWrappers tyoe. 2020-07-30 13:56:00 -04:00
Steve Klebanoff
498a50b229 Merge pull request #2646 from 0xProject/feature/fix-quote-report-rfqt
Send in quoteRequestor to fix RFQT tracking
2020-07-28 14:32:28 -07:00
Steve Klebanoff
766888ec41 Send in quoteRequestor to fix RFQT tracking 2020-07-28 13:39:21 -07:00
Jacob Evans
466d962c07 fix: Redeploy ERC20BridgeSampler on Kovan (#2644) 2020-07-28 12:49:21 +10:00
Lawrence Forman
ae2a6fb685 asset-swapper: Quicker path-finding (#2640)
* `@0x/asset-swapper`: Speed up path optimizer.

* `@0x/asset-swapper`: address my own review comment

* `@0x/asset-swapper`: Update changelog

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: Jacob Evans <jacob@dekz.net>
2020-07-27 15:09:49 +10:00
Jacob Evans
5afe2616a4 feat: asset-swapper market depth (#2641)
* feat: asset-swapper market depth

* split promises into 2

* fix lint and docs

* chore: refactor

* rebase off development

* CHANGELOG
2020-07-27 15:07:52 +10:00
Steve Klebanoff
72c869649a Merge pull request #2627 from 0xProject/feature/new-order-reporter
asset-swapper: QuoteReport response
2020-07-23 17:50:48 -07:00
Steve Klebanoff
34138fc3b5 handle empty array in reduce 2020-07-23 17:15:04 -07:00
Steve Klebanoff
f67d2b96ac fix up changelog 2020-07-23 16:25:24 -07:00
Steve Klebanoff
d877d3686c linting 2020-07-23 16:03:09 -07:00
Steve Klebanoff
8260615b4e fix merge conflict 2020-07-23 16:02:16 -07:00
Steve Klebanoff
c3f6d48966 Merge branch 'development' into feature/new-order-reporter 2020-07-23 16:01:27 -07:00
Steve Klebanoff
02f979bc74 linting 2020-07-23 15:55:56 -07:00
Steve Klebanoff
de1c71aacc fix syntax 2020-07-23 15:54:34 -07:00
Steve Klebanoff
ca2aa72e0f Merge development 2020-07-23 15:17:35 -07:00
Daniel Pyrathon
9a16f5736e Merge pull request #2642 from 0xProject/only-rfqt
Add the `nativeExclusivelyRFQT` argument.
2020-07-23 15:05:02 -07:00
Lawrence Forman
82774df715 Merge pull request #2633 from 0xProject/feat/btc-curves
BTC Curves
2020-07-23 16:43:13 -04:00
Lawrence Forman
314f53c0b3 @0x/contract-addresses: Update CurveBridge on all networks. 2020-07-23 15:58:17 -04:00
Daniel Pyrathon
6553ee0130 reordered imports 2020-07-23 11:04:51 -07:00
Daniel Pyrathon
d7918ea047 prettified 2020-07-23 10:16:22 -07:00
Lawrence Forman
4aa9c85503 @0x/asset-swapper: Reenable some curves. 2020-07-23 09:59:30 -04:00
Lawrence Forman
f172591059 @0x/contracts-integrations: Fix curve bridge mainnet tests. 2020-07-23 09:59:03 -04:00
Steve Klebanoff
dfa7e30e42 fix version number, this is just a minor bump 2020-07-23 00:35:25 -07:00
Steve Klebanoff
3fe2013398 Merge branch 'development' into feature/new-order-reporter-merged 2020-07-22 23:59:09 -07:00
Steve Klebanoff
391d501ce6 Export rfqt opts 2020-07-22 23:56:07 -07:00
Steve Klebanoff
9edaa3a64e fix 2020-07-22 23:50:55 -07:00
Steve Klebanoff
6e4e313792 Merge branch 'development' into feature/new-order-reporter-merged 2020-07-22 23:50:28 -07:00
Daniel Pyrathon
e6dcf92ec8 added new parameter nativeExclusivelyRFQT 2020-07-22 23:02:40 -07:00
Daniel Pyrathon
f359de2cac fixed a small bug in indicative quotes 2020-07-22 22:46:25 -07:00
Lawrence Forman
2d29014091 @0x/contracts-erc20-bridge-sampler: address review comments 2020-07-23 00:37:58 -04:00
Lawrence Forman
0450e430f1 @0x/asset-swapper: Support more varied curves. 2020-07-23 00:37:58 -04:00
Lawrence Forman
b6700af6a8 @0x/contract-wrappers: Regenerate ERC20BridgeSampler wrapper. 2020-07-23 00:37:57 -04:00
Lawrence Forman
bcee7546ae 0x/contract-artifacts: Regenerate ERC20BridgeSampler artifact. 2020-07-23 00:37:32 -04:00
Lawrence Forman
4dac620156 @0x/contracts-asset-proxy: Update CurveBridge to support more varied curves.
`@0x/contracts-erc20-bridge-sampler`: Refactor.
`@0x/contracts-erc20-bridge-sampler`: Add support for more varied curves.
`@0x/contracts-integrations`: Update curve bridge tests.
2020-07-23 00:36:32 -04:00
Lawrence Forman
74d9df2fb0 Merge pull request #2626 from 0xProject/feat/zero-ex/TransformERC20-call-data-validation
ZeroEx: transformERC20 call data validation
2020-07-23 00:35:34 -04:00
Lawrence Forman
9d1615fa23 @0x/contract-wrappers: Fix doc gen 2020-07-23 00:03:23 -04:00
Lawrence Forman
b1b9949e72 @0x/contract-wrappers: Add IZeroEx wrapper. 2020-07-22 23:41:11 -04:00
Lawrence Forman
957ef5ab77 @0x/contract-artifacts: Add IZeroEx artifact. 2020-07-22 23:41:11 -04:00
Lawrence Forman
07a681c77e @0x/contracts-zero-ex: Add IZeroEx contract. 2020-07-22 22:59:46 -04:00
Lawrence Forman
145ec8ede1 address review comments 2020-07-22 22:18:41 -04:00
Lawrence Forman
5f5a158060 @0x/contracts-zero-ex: Update TransformERC20 and MetaTransactions to handle signed calldata. 2020-07-22 22:18:39 -04:00
Steve Klebanoff
3e99c95791 Linting 2020-07-22 13:26:31 -07:00
Steve Klebanoff
4f83521be8 Merge branch 'development' into feature/new-order-reporter-merged 2020-07-22 13:25:35 -07:00
Jacob Evans
aae93bb6a7 fix: asset-swapper yield to the event loop every mix path (#2637)
* fix: allow a empty overrides to signal no default

* fix: asset-swapper yield to the event loop every mix path

* fix: optimizations skip order find if Native excluded

* changelogs

* chore: update protocol fee multiplier

* fix: tests async
2020-07-21 17:06:05 +10:00
Steve Klebanoff
5c1ffe7fc8 add exclude to EXTERNAL_TYPE_MAP 2020-07-13 17:11:53 -07:00
Steve Klebanoff
b1c3c60def additional imports 2020-07-13 16:45:40 -07:00
Steve Klebanoff
8763713596 ds -> dq 2020-07-13 15:49:39 -07:00
Steve Klebanoff
3e823cc9e3 export new types 2020-07-10 16:07:14 -07:00
Steve Klebanoff
1c84709db3 isApiKeyWhitelisted helper fn 2020-07-10 16:03:14 -07:00
Steve Klebanoff
9150d6bd2a major version bump 2020-07-10 16:00:24 -07:00
Steve Klebanoff
10f29b66b8 newline 2020-07-10 15:58:31 -07:00
Steve Klebanoff
259aec52a9 linting 2020-07-10 15:58:06 -07:00
Steve Klebanoff
6554bf9f08 test for buy amount and no quote requestor 2020-07-10 15:57:06 -07:00
Steve Klebanoff
d8558f5956 QuoteReportGenerator test 2020-07-10 15:45:59 -07:00
Steve Klebanoff
31fa530845 add CHANGELOG entry 2020-07-08 15:54:19 -07:00
Steve Klebanoff
120714ecfc linting and remove unused function 2020-07-08 15:49:42 -07:00
Steve Klebanoff
615874d2ec always pass through quoterequestor 2020-07-08 15:38:36 -07:00
Steve Klebanoff
67b195c942 take out old todo comment 2020-07-08 15:13:53 -07:00
Steve Klebanoff
75689cee96 create new quote requestor each time 2020-07-08 15:07:36 -07:00
Steve Klebanoff
8ba77e95a4 export swap quoter types into own object 2020-07-08 15:07:20 -07:00
Steve Klebanoff
934fbca860 make QuoteReport optional instead of forcing it for bash operaitons, fix tests so build works 2020-07-07 11:00:03 -07:00
Steve Klebanoff
e78c8038c7 take out delete note 2020-07-06 22:24:02 -07:00
Steve Klebanoff
f64a42ebb5 return quote report 2020-07-06 22:18:22 -07:00
Steve Klebanoff
e79db7de89 new quotereporter type 2020-07-06 22:07:33 -07:00
Steve Klebanoff
e58c25aa18 hold onto maker uris when fetching responses 2020-07-06 21:27:20 -07:00
Steve Klebanoff
8ec44b63b1 WIP: add quoteReport response 2020-07-06 21:06:43 -07:00
Lawrence Forman
41907936a1 @0x/contracts-zero-ex: Fix TransformerDeployer.kill() calling the wrong die() interface. 2020-07-06 23:19:35 -04:00
2632 changed files with 96360 additions and 299125 deletions

View File

@@ -1,458 +0,0 @@
version: 2
jobs:
build:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
environment:
CONTRACTS_COMMIT_HASH: '9ed05f5'
working_directory: ~/repo
steps:
- checkout
- run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
# HACK(feuGeneA): commented out this hack as we're changing
# from a circleci-maintained container to a different
# container, and this hack may not apply anymore, as
# suggested by the non-existance of `/home/circleci/.bashrc`
# when running the command below.
# - run:
# # HACK(albrow): Without this, yarn commands will sometimes
# # fail with a "permission denied" error.
# name: Set npm path
# command: npm set prefix=/home/circleci/npm && echo 'export PATH=$HOME/circleci/npm/bin:$PATH' >> /home/circleci/.bashrc
- run:
name: install-yarn
command: npm install --force --global yarn@1.17.0
- run:
name: yarn
command: yarn --frozen-lockfile --ignore-engines install || yarn --frozen-lockfile --ignore-engines install
- setup_remote_docker
- run: yarn build:ci
- run: yarn build:ts
- save_cache:
key: repo-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo
- store_artifacts:
path: ~/repo/packages/abi-gen/test-cli/output
- store_artifacts:
path: ~/repo/packages/contract-wrappers/generated_docs
test-exchange-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-exchange
test-integrations-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-integrations
test-contracts-staking-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-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:
- image: nikolaik/python-nodejs:python3.7-nodejs8
- image: 0xorg/verdaccio
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- 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
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
command: yarn test:generate_docs:circleci
no_output_timeout: 1200
test-rest:
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-test-utils
- run: yarn wsrun test:circleci @0x/abi-gen
- run: yarn wsrun test:circleci @0x/asset-swapper
- run: yarn wsrun test:circleci @0x/contract-artifacts
- run: yarn wsrun test:circleci @0x/assert
- run: yarn wsrun test:circleci @0x/base-contract
- run: yarn wsrun test:circleci @0x/connect
- run: yarn wsrun test:circleci @0x/contract-wrappers-test
- run: yarn wsrun test:circleci @0x/dev-utils
- run: yarn wsrun test:circleci @0x/json-schemas
- run: yarn wsrun test:circleci @0x/order-utils
- run: yarn wsrun test:circleci @0x/orderbook
- run: yarn wsrun test:circleci @0x/sol-compiler
- run: yarn wsrun test:circleci @0x/sol-tracing-utils
- run: yarn wsrun test:circleci @0x/sol-doc
- run: yarn wsrun test:circleci @0x/subproviders
- run: yarn wsrun test:circleci @0x/web3-wrapper
- run: yarn wsrun test:circleci @0x/utils
- run: yarn wsrun test:circleci @0x/instant
- save_cache:
key: coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/abi-gen/coverage/lcov.info
- save_cache:
key: coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/assert/coverage/lcov.info
- save_cache:
key: coverage-asset-swapper-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/asset-swapper/coverage/lcov.info
- save_cache:
key: coverage-base-contract-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/base-contract/coverage/lcov.info
- save_cache:
key: coverage-connect-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/connect/coverage/lcov.info
- save_cache:
key: coverage-contract-wrappers-test-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/contract-wrappers-test/coverage/lcov.info
- save_cache:
key: coverage-dev-utils-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/dev-utils/coverage/lcov.info
- save_cache:
key: coverage-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/json-schemas/coverage/lcov.info
- save_cache:
key: coverage-order-utils-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/order-utils/coverage/lcov.info
- save_cache:
key: coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-compiler/coverage/lcov.info
- save_cache:
key: coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-tracing-utils/coverage/lcov.info
- save_cache:
key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-doc/coverage/lcov.info
- save_cache:
key: coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/subproviders/coverage/lcov.info
- save_cache:
key: coverage-web3-wrapper-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/web3-wrapper/coverage/lcov.info
test-python:
working_directory: ~/repo
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'
ETHEREUM_CHAIN_ID: '1337'
VERBOSITY: 5
BLOCK_POLLING_INTERVAL: '50ms'
ETHEREUM_RPC_MAX_REQUESTS_PER_24_HR_UTC: '1778000'
command: |
sh -c "waitForGanache () { until printf 'POST /\r\nContent-Length: 26\r\n\r\n{\"method\":\"net_listening\"}' | nc localhost 8545 | grep true; do continue; done }; waitForGanache && ./mesh"
- image: 0xorg/launch-kit-backend:v3
environment:
RPC_URL: 'http://localhost:8545'
CHAIN_ID: 1337
WHITELIST_ALL_TOKENS: True
FEE_RECIPIENT: '0x0000000000000000000000000000000000000001'
MAKER_FEE_UNIT_AMOUNT: 0
TAKER_FEE_UNIT_AMOUNT: 0
MESH_ENDPOINT: 'ws://localhost:60557'
command: |
sh -c "waitForMesh () { sleep 30; }; waitForMesh && node_modules/.bin/forever ts/lib/index.js"
steps:
- checkout
- restore_cache:
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
command: |
cd python-packages
python -m ensurepip
./pre_install
./install
- save_cache:
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- '/usr/local/bin'
- '/usr/local/lib/python3.7/site-packages'
- run:
command: |
cd python-packages
./parallel coverage run setup.py test
./build_docs
- run:
command: |
# copy generated wrappers into contract_wrappers/build,
# JUST so CircleCI will persist them as build artifacts.
cd python-packages/contract_wrappers/src/zero_ex
for i in contract_wrappers/[^__]*/; do mkdir -p ../../build/$i; cp $i/__init__.py ../../build/$i; done
- save_cache:
key: coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/contract_addresses/.coverage
- save_cache:
key: coverage-python-contract-artifacts-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/contract_artifacts/.coverage
- save_cache:
key: coverage-python-contract-demo-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/contract_demo/.coverage
- save_cache:
key: coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/json_schemas/.coverage
- save_cache:
key: coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/order_utils/.coverage
- save_cache:
key: coverage-python-sra-client-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/sra_client/.coverage
- store_artifacts:
path: ~/repo/python-packages/contract_addresses/build
- store_artifacts:
path: ~/repo/python-packages/contract_artifacts/build
- store_artifacts:
path: ~/repo/python-packages/contract_wrappers/build
- store_artifacts:
path: ~/repo/python-packages/json_schemas/build
- store_artifacts:
path: ~/repo/python-packages/middlewares/build
- store_artifacts:
path: ~/repo/python-packages/order_utils/build
- store_artifacts:
path: ~/repo/python-packages/sra_client/build
test-rest-python:
working_directory: ~/repo
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
steps:
- checkout
- restore_cache:
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
- run:
command: |
cd python-packages/order_utils
python -m ensurepip
python -m pip install .
- save_cache:
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- '/usr/local/bin'
- '/usr/local/lib/python3.7/site-packages'
- '.eggs'
- '.mypy_cache'
- '.pytest_cache'
- '.tox'
- run:
command: |
cd python-packages/order_utils
tox
static-tests-python:
working_directory: ~/repo
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
steps:
- checkout
- restore_cache:
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
command: |
python -m ensurepip
cd python-packages
./pre_install
./install
./lint
static-tests:
resource_class: large
working_directory: ~/repo
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn lerna run lint
- run: yarn prettier:ci
- run: yarn deps_versions:ci
- run: yarn diff_md_docs:ci
- run: cd packages/0x.js && yarn build:umd:prod
- run: yarn bundlewatch
submit-coverage:
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-asset-swapper-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-base-contract-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-connect-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-contract-wrappers-test-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-dev-utils-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-order-utils-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-web3-wrapper-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-contract-artifacts-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-contract-demo-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-sra-client-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn report_coverage
workflows:
version: 2
main:
jobs:
- build
- test-exchange-ganache:
requires:
- build
- test-integrations-ganache:
requires:
- build
- test-contracts-staking-ganache:
requires:
- build
- test-contracts-rest-ganache:
requires:
- build
- test-rest:
requires:
- build
- static-tests:
requires:
- build
- test-publish:
requires:
- build
- test-doc-generation:
requires:
- build
- submit-coverage:
requires:
- test-contracts-rest-ganache
- test-contracts-staking-ganache
- test-exchange-ganache
- test-rest
- static-tests
- test-python:
requires:
- build
- static-tests-python:
requires:
- build
# skip python tox run for now, as we don't yet have multiple test environments to support.
# - test-rest-python

4
.gitattributes vendored
View File

@@ -2,7 +2,3 @@
# Automatically collapse generated files in GitHub.
*.svg linguist-generated=true
packages/contract-artifacts/artifacts/*json linguist-generated=true
packages/abi-gen-wrappers/src/generated-wrappers/*.ts linguist-generated=true
packages/contract-wrappers/src/generated-wrappers/*.ts linguist-generated=true

18
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1,18 @@
# See https://help.github.com/articles/about-codeowners/
# for more info about CODEOWNERS file
# It uses the same pattern rule for gitignore file
# https://git-scm.com/docs/gitignore#_pattern_format
# Dev tools & setup
.github/ @dekz
packages/contract-addresses/ @dekz @dextracker @kyu-c
packages/contract-artifacts/ @dekz
packages/protocol-utils/ @dekz
# Protocol/smart contracts
contracts/ @dekz @dextracker

View File

@@ -4,17 +4,17 @@ We welcome contributions from anyone on the internet and are grateful for even t
### Getting started
1. Fork `0xproject/0x-monorepo`
1. Fork `0xproject/0x-tools`
2. Clone your fork
3. Follow the [installation & build steps](https://github.com/0xProject/0x-monorepo#install-dependencies) in the repo's top-level README.
3. Follow the [installation & build steps](https://github.com/0xProject/0x-tools#install-dependencies) in the repo's top-level README.
4. Setup the recommended [Development Tooling](#development-tooling).
5. Open a PR with the `[WIP]` flag against the `development` branch and describe the change you are intending to undertake in the PR description. (see [our branch naming conventions](#branch-structure))
5. Open a [draft PR](https://github.blog/2019-02-14-introducing-draft-pull-requests/) against the `development` branch and describe the change you are intending to undertake in the PR description. (see [our branch naming conventions](#branch-structure))
Before removing the `[WIP]` tag and submitting the PR for review, make sure:
Before making the PR "Ready for review", make sure:
- It passes our linter checks (`yarn lint`)
- It is properly formatted with Prettier (`yarn prettier`)
- It passes our continuous integration tests (See: [Enabling code coverage checks on your fork](#enabling-code-coverage-checks-on-your-fork) for instructions on getting the `submit-coverage` test to pass on forks)
- It passes our continuous integration tests (See: [Enabling code coverage checks on your fork](#fix-submit-coverage-ci-failure) for instructions on getting the `submit-coverage` test to pass on forks)
- You've created/updated the corresponding [CHANGELOG](#CHANGELOGs) entries.
- Your changes have sufficient test coverage (e.g regression tests have been added for bug fixes)
@@ -59,16 +59,14 @@ We strongly recommend you use the [VSCode](https://code.visualstudio.com/) text
#### Linter
We use [TSLint](https://palantir.github.io/tslint/) with [custom configs](https://github.com/0xProject/0x-monorepo/tree/development/packages/tslint-config) to keep our code-style consistent.
We use [ESLint](https://eslint.org/docs/latest/) to keep our code-style consistent.
Use `yarn:lint` to lint the entire monorepo, and `PKG={PACKAGE_NAME} yarn lint` to lint a specific package.
If you want to change a rule, or add a custom rule, please make these changes to our [tslint-config](https://github.com/0xProject/0x-monorepo/tree/development/packages/tslint-config) package. All other packages have it as a dependency.
Use `yarn lint` to lint the entire monorepo, and `PKG={PACKAGE_NAME} yarn lint` to lint a specific package.
Integrate it into your text editor:
- VSCode: [vscode-tslint](https://marketplace.visualstudio.com/items?itemName=eg2.tslint)
- Atom: [linter-tslint](https://atom.io/packages/linter-tslint)
- VSCode: [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- Atom: [ESLint](https://atom.io/packages/eslint)
#### Auto-formatter
@@ -91,15 +89,3 @@ A few of our coding conventions are not yet enforced by the linter/auto-formatte
1. If you _must_ cast a variable to any - try to type it back as fast as possible. (e.g., `const cw = ((zeroEx as any)._contractWrappers as ContractWrappers);`). This ensures subsequent code is type-safe.
1. Our enum conventions coincide with the recommended TypeScript conventions, using capitalized keys, and all-caps snake-case values. Eg `GetStats = 'GET_STATS'`
1. All public, exported methods/functions/classes must have associated Javadoc-style comments.
### Fix `submit-coverage` CI failure
If you simply fork the repo and then create a PR from it, your PR will fail the `submit-coverage` check on CI. This is because the 0x CircleCI configuration sets the `COVERALLS_REPO_TOKEN` environment variable to the token for `0xProject/0x-monorepo`, but when running the check against your fork the token needs to match your repo's name `your-username/0x-monorepo`.
To facilitate this check, after creating your fork, but before creating the branch for your PR, do the following:
1. Log in to [coveralls.io](https://coveralls.io/), go to `Add Repos`, and enable your fork. Then go to the settings for that repo, and copy the `Repo Token` identifier.
2. Log in to [CircleCI](https://circleci.com/login), go to `Add Projects`, click the `Set Up Project` button corresponding to your fork, and then click `Start Building`. (Aside from step 3 below, no actual set up is needed, since it will use the `.circleci/config.yml` file in 0x-monorepo, so you can ignore all of the instruction/explanation given on the page with the `Start Building` button.)
3. In CircleCI, configure your project to add an environment variable, with name `COVERALLS_REPO_TOKEN`, and for the value paste in the `Repo Token` you copied in step 1.
Now, when you push to your branch, CircleCI will automatically run all of the checks in your own instance, and the coverage check will work since it has the proper `Repo Token`, and the PR will magically refer to your own checks rather than running them in the 0x CircleCI instance.

View File

@@ -2,15 +2,13 @@
<!--- Before submitting please check to see if this issue was already reported -->
<!--- Prefix your issue title with the package name it relates to (e.g., `0x.js: ` or `general:`) -->
## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a package change/improvement, tell us how it should work -->
<!--- If you're suggesting a contract or protocol change/improvement, visit our ZEIPs repo -->
<!--- If you're suggesting a contract or protocol change/improvement, visit our ZEIPs repo https://github.com/0xProject/ZEIPs -->
## Current Behavior
@@ -49,10 +47,9 @@
| Package | Version |
| ------: | :------ |
<!-- For example:
| `0x.js` | 2.0.4 |
| `Exchange Contract` | v2 |
| `protocol-utils` | 2.0.4 |
| `Exchange Contract` | v3 |
-->
| Network |
@@ -61,6 +58,6 @@
<!-- For example:
| mainnet |
| kovan |
| testrpc |
| goerli |
| development |
-->

View File

@@ -20,7 +20,6 @@
<!--- The following points should be used to indicate the progress of your PR. Put an `x` in all the boxes that apply right now, and come back over time and check them off as you make progress. If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] Prefix PR title with `[WIP]` if necessary.
- [ ] Add tests to cover changes as needed.
- [ ] Update documentation as needed.
- [ ] Add new entries to the relevant CHANGELOG.jsons.

View File

@@ -1,33 +1,2 @@
python: ['python-packages']
contracts: ['contracts']
@0x/sol-doc: ['packages/sol-doc']
@0x/sol-resolver: ['packages/sol-resolver']
@0x/contracts-gen: ['packages/contracts-gen']
@0x/sra-spec: ['packages/sra-spec']
@0x/subproviders: ['packages/subproviders']
@0x/contract-addresses: ['packages/contract-addresses']
@0x/migrations: ['packages/migrations']
@0x/web3-wrapper: ['packages/web3-wrapper']
@0x/sol-compiler: ['packages/sol-compiler']
@0x/types: ['packages/types']
@0x/instant: ['packages/instant']
@0x/abi-gen-templates: ['packages/abi-gen-templates']
@0x/abi-gen: ['packages/abi-gen']
@0x/sol-coverage: ['packages/sol-coverage']
@0x/sol-profiler: ['packages/sol-profiler']
@0x/sol-trace: ['packages/sol-trace']
@0x/sol-tracing-utils: ['packages/sol-tracing-utils']
@0x/utils: ['packages/utils']
@0x/tslint-config: ['packages/tslint-config']
@0x/asset-swapper: ['packages/asset-swapper']
@0x/order-utils: ['packages/order-utils']
@0x/assert: ['packages/assert']
@0x/base-contract: ['packages/base-contract']
@0x/typescript-typings: ['packages/typescript-typings']
0x.js: ['packages/0x.js']
@0x/contract-artifacts: ['packages/contract-artifacts']
@0x/dev-utils: ['packages/dev-utils']
@0x/contract-wrappers: ['packages/contract-wrappers']
@0x/json-schemas: ['packages/json-schemas']
@0x/ethereum-types: ['ethereum-types']
@0x/connect: ['packages/connect']
documentation: ['docs']
liquidity integrations: ['contracts/zero-ex/contracts/src/transformers']

7
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
target-branch: "development"

19
.github/stale.yml vendored
View File

@@ -1,19 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 30
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: >
This issue has been automatically closed because no activity occured in 7 days after being marked as stale. If it's still relevant - feel free to reopen. Thank you
for your contributions.

108
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,108 @@
name: Continuous Integration
on:
push:
branches:
- main
- development
pull_request:
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build solution
run: yarn build
- name: Lint typescript
run: yarn lint:ts
- name: Lint solidity
run: yarn lint:contracts
- name: Run prettier
run: yarn prettier:ci
- name: Check dependent packages have consistent versions
run: yarn deps_versions:ci
- name: Check diff in docs
run: yarn diff_md_docs:ci
- name: Check for broken links in markdown files
run: yarn test:links
- name: Test doc generation
run: yarn test:generate_docs:ci
- name: Test @0x/contracts-*
run: |
yarn wsrun \
-p @0x/contracts-multisig \
-p @0x/contracts-utils \
-p @0x/contracts-exchange-libs \
-p @0x/contracts-erc20 \
-p @0x/contracts-erc721 \
-p @0x/contracts-erc1155 \
-p @0x/contracts-asset-proxy \
-p @0x/contracts-broker \
-p @0x/contracts-zero-ex \
-m --serial -c test:ci
- name: Test local @0x/contracts-*
run: |
yarn wsrun \
-p @0x/contracts-test-utils \
-p @0x/contract-addresses \
-p @0x/contract-artifacts \
-p @0x/contract-wrappers-test \
-p @0x/order-utils \
-m --serial -c test:ci
- name: Add foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge build
working-directory: contracts/zero-ex
run: |
forge --version
forge build --sizes
- name: Run Forge tests
working-directory: contracts/zero-ex
env:
ARBITRUM_RPC_URL: ${{ secrets.ARBITRUM_RPC_URL }}
AVALANCHE_RPC_URL: ${{ secrets.AVALANCHE_RPC_URL }}
BSC_RPC_URL: ${{ secrets.BSC_RPC_URL }}
FANTOM_RPC_URL: ${{ secrets.FANTOM_RPC_URL }}
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}
POLYGON_RPC_URL: ${{ secrets.POLYGON_RPC_URL }}
run: |
forge test -vvv --gas-report
- name: Run Forge coverage
working-directory: contracts/zero-ex
run: |
forge coverage --report lcov
- name: Upload the coverage report to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: ./contracts/zero-ex/
path-to-lcov: ./contracts/zero-ex/lcov.info

53
.github/workflows/publish.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
name: publish
on:
workflow_dispatch:
inputs:
ci_status:
description: 'required CI status'
default: 'success'
required: true
prerelease:
description: 'prerelease name'
required: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: 'check successful status'
run: |
REF_STATUS=$(curl -s \
'https://api.github.com/repos/${{ github.repository }}/commits/${{ github.ref }}/status' \
| jq .state)
[[ "${REF_STATUS}" == '"${{ github.event.inputs.ci_status }}"' ]] || \
(echo "::error ::${{ github.ref }} does not have a successful CI status" && false)
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 16
- uses: actions/setup-python@v2
- name: 'configure git'
run: |
git config --global user.email "github-actions@github.com"
git config --global user.name "Github Actions"
- name: 'install dependencies'
run: |
yarn -D
- name: 'build and publish'
run: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
npm run run:publish:gha
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
PUBLISH_PRERELEASE: ${{ github.event.inputs.prerelease }}
- name: 'merge into main branch'
if: github.event.inputs.prerelease == '' # unless it's a prerelease
run: |
git checkout main && \
git merge ${{ github.ref }} && \
git push

40
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,40 @@
name: "Close stale issues and PRs"
on:
schedule:
- cron: "0 8 * * 1-5" # This is in UTC.
# Do a dry-run (debug-only: true) whenever this workflow itself is changed.
pull_request:
paths:
- .github/workflows/stale.yml
types:
- opened
- synchronize
permissions:
issues: write
pull-requests: write
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v7
with:
ascending: true # Spend API operations budget on older, more-likely-to-get-closed issues first
close-issue-message: "" # Leave no comment when closing
close-pr-message: "" # Leave no comment when closing
days-before-issue-stale: 30
days-before-pr-stale: 30
days-before-close: 14
debug-only: ${{ github.event_name == 'pull_request' }} # Dry-run when true.
exempt-issue-labels: bug,enhancement,feature,question
# No actual changes get made in debug-only mode, so we can raise the operations ceiling.
operations-per-run: ${{ github.event_name == 'pull_request' && 100 || 30}}
stale-issue-label: stale
stale-issue-message: "This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions."
stale-pr-label: stale
stale-pr-message: "This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions."
# Time immemorial when in debug-only mode (ie. on pull requests).
# `STALEBOT_START_DATE` otherwise.
# You can use this as a killswitch by setting `STALEBOT_START_DATE` in the far future.
start-date: ${{ github.event_name == 'pull_request' && '1970-01-01T00:00:00Z' || secrets.STALEBOT_START_DATE }} # ISO 8601 or RFC 2822

123
.gitignore vendored
View File

@@ -15,9 +15,6 @@ pids
*.db
*.sqlite
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
@@ -75,118 +72,30 @@ generated_docs/
TODO.md
# VSCode file
# IDE file
.vscode
.idea
# generated contract artifacts/
contracts/broker/generated-artifacts/
contracts/broker/test/generated-artifacts/
contracts/erc20-bridge-sampler/generated-artifacts/
contracts/erc20-bridge-sampler/test/generated-artifacts/
contracts/integrations/generated-artifacts/
contracts/integrations/test/generated-artifacts/
contracts/staking/generated-artifacts/
contracts/staking/test/generated-artifacts/
contracts/coordinator/generated-artifacts/
contracts/coordinator/test/generated-artifacts/
contracts/exchange/generated-artifacts/
contracts/exchange/test/generated-artifacts/
contracts/asset-proxy/generated-artifacts/
contracts/asset-proxy/test/generated-artifacts/
contracts/multisig/generated-artifacts/
contracts/multisig/test/generated-artifacts/
contracts/utils/generated-artifacts/
contracts/utils/test/generated-artifacts/
contracts/exchange-libs/generated-artifacts/
contracts/exchange-libs/test/generated-artifacts/
contracts/erc20/generated-artifacts/
contracts/erc20/test/generated-artifacts/
contracts/erc721/generated-artifacts/
contracts/erc721/test/generated-artifacts/
contracts/erc1155/generated-artifacts/
contracts/erc1155/test/generated-artifacts/
contracts/extensions/generated-artifacts/
contracts/extensions/test/generated-artifacts/
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/
# generated truffle contract artifacts/
contracts/broker/build/
contracts/erc20-bridge-sampler/build/
contracts/staking/build/
contracts/coordinator/build/
contracts/exchange/build/
contracts/asset-proxy/build/
contracts/multisig/build/
contracts/utils/build/
contracts/exchange-libs/build/
contracts/erc20/build/
contracts/erc721/build/
contracts/erc1155/build/
contracts/extensions/build/
contracts/exchange-forwarder/build/
contracts/dev-utils/build/
generated-artifacts/
# generated contract wrappers
contracts/broker/generated-wrappers/
contracts/broker/test/generated-wrappers/
packages/python-contract-wrappers/generated/
contracts/erc20-bridge-sampler/generated-wrappers/
contracts/erc20-bridge-sampler/test/generated-wrappers/
contracts/integrations/generated-wrappers/
contracts/integrations/test/generated-wrappers/
contracts/staking/generated-wrappers/
contracts/staking/test/generated-wrappers/
contracts/coordinator/generated-wrappers/
contracts/coordinator/test/generated-wrappers/
contracts/exchange/generated-wrappers/
contracts/exchange/test/generated-wrappers/
contracts/asset-proxy/generated-wrappers/
contracts/asset-proxy/test/generated-wrappers/
contracts/multisig/generated-wrappers/
contracts/multisig/test/generated-wrappers/
contracts/utils/generated-wrappers/
contracts/utils/test/generated-wrappers/
contracts/exchange-libs/generated-wrappers/
contracts/exchange-libs/test/generated-wrappers/
contracts/erc20/generated-wrappers/
contracts/erc20/test/generated-wrappers/
contracts/erc721/generated-wrappers/
contracts/erc721/test/generated-wrappers/
contracts/erc1155/generated-wrappers/
contracts/erc1155/test/generated-wrappers/
contracts/extensions/generated-wrappers/
contracts/extensions/test/generated-wrappers/
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
generated-wrappers/
# solc-bin in sol-compiler
packages/sol-compiler/solc_bin/
# forge std-lib
contracts/zero-ex/contracts/deps/forge-std
# python stuff
.eggs
.mypy_cache
.tox
python-packages/*/build
python-packages/*/dist
__pycache__
python-packages/*/src/*.egg-info
python-packages/*/.coverage
# foundry artifacts
foundry-artifacts/
# python keeps package-local copies of json schemas and contract addresses
python-packages/json_schemas/src/zero_ex/json_schemas/schemas
python-packages/contract_addresses/src/zero_ex/contract_addresses/addresses.json
# foundry cache
cache/
#foundry output artifacts
out/
# typechain wrappers
contracts/zero-ex/typechain-wrappers/
# Doc README copy
packages/*/docs/README.md

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "contracts/zero-ex/contracts/deps/forge-std"]
path = contracts/zero-ex/contracts/deps/forge-std
url = https://github.com/foundry-rs/forge-std

4
.husky/pre-commit Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged --no-stash

View File

@@ -1,98 +1,10 @@
lib
deps
.nyc_output
/contracts/broker/generated-wrappers
/contracts/broker/test/generated-wrappers
/contracts/broker/generated-artifacts
/contracts/broker/test/generated-artifacts
/contracts/integrations/generated-wrappers
/contracts/integrations/test/generated-wrappers
/contracts/integrations/generated-artifacts
/contracts/integrations/test/generated-artifacts
/contracts/staking/generated-wrappers
/contracts/staking/test/generated-wrappers
/contracts/staking/generated-artifacts
/contracts/staking/test/generated-artifacts
/contracts/coordinator/generated-wrappers
/contracts/coordinator/test/generated-wrappers
/contracts/coordinator/generated-artifacts
/contracts/coordinator/test/generated-artifacts
/contracts/exchange/generated-wrappers
/contracts/exchange/test/generated-wrappers
/contracts/exchange/generated-artifacts
/contracts/exchange/test/generated-artifacts
/contracts/asset-proxy/generated-wrappers
/contracts/asset-proxy/test/generated-wrappers
/contracts/asset-proxy/generated-artifacts
/contracts/asset-proxy/test/generated-artifacts
/contracts/multisig/generated-wrappers
/contracts/multisig/test/generated-wrappers
/contracts/multisig/generated-artifacts
/contracts/multisig/test/generated-artifacts
/contracts/utils/generated-wrappers
/contracts/utils/test/generated-wrappers
/contracts/utils/generated-artifacts
/contracts/utils/test/generated-artifacts
/contracts/exchange-libs/generated-wrappers
/contracts/exchange-libs/test/generated-wrappers
/contracts/exchange-libs/generated-artifacts
/contracts/exchange-libs/test/generated-artifacts
/contracts/erc20/generated-wrappers
/contracts/erc20/test/generated-wrappers
/contracts/erc20/generated-artifacts
/contracts/erc20/test/generated-artifacts
/contracts/erc20-bridge-sampler/generated-wrappers
/contracts/erc20-bridge-sampler/test/generated-wrappers
/contracts/erc20-bridge-sampler/generated-artifacts
/contracts/erc20-bridge-sampler/test/generated-artifacts
/contracts/erc721/generated-wrappers
/contracts/erc721/test/generated-wrappers
/contracts/erc721/generated-artifacts
/contracts/erc721/test/generated-artifacts
/contracts/erc1155/generated-wrappers
/contracts/erc1155/test/generated-wrappers
/contracts/erc1155/generated-artifacts
/contracts/erc1155/test/generated-artifacts
/contracts/extensions/generated-wrappers
/contracts/extensions/test/generated-wrappers
/contracts/extensions/generated-artifacts
/contracts/extensions/test/generated-artifacts
/contracts/exchange-forwarder/generated-wrappers
/contracts/exchange-forwarder/test/generated-wrappers
/contracts/exchange-forwarder/generated-artifacts
/contracts/exchange-forwarder/test/generated-artifacts
/contracts/dev-utils/generated-wrappers
/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/
/contracts/asset-proxy/build/
/contracts/multisig/build/
/contracts/utils/build/
/contracts/exchange-libs/build/
/contracts/erc20/build/
/contracts/erc721/build/
/contracts/erc1155/build/
/contracts/extensions/build/
/contracts/exchange-forwarder/build/
/contracts/dev-utils/build/
/packages/abi-gen/test-cli/output
/packages/json-schemas/schemas
/python-packages/json_schemas/src/zero_ex/json_schemas/schemas
/packages/sra-spec/public/
generated-artifacts/
generated-wrappers/
foundry-artifacts/
out/
cache/
package.json
scripts/postpublish_utils.js
packages/sol-coverage/test/fixtures/artifacts
.pytest_cache
.mypy_cache
.tox
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
packages

View File

@@ -2,5 +2,19 @@
"printWidth": 120,
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "all"
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "avoid",
"overrides": [
{
"files": "**/*.sol",
"options": {
"printWidth": 120,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false
}
}
]
}

23
.readthedocs.yaml Normal file
View File

@@ -0,0 +1,23 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml
# Optionally build your docs in additional formats such as PDF
#formats:
# - pdf
# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt

17
.solhint.json Normal file
View File

@@ -0,0 +1,17 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"avoid-low-level-calls": "off",
"avoid-tx-origin": "warn",
"code-complexity": "off",
"const-name-snakecase": "error",
"function-max-lines": ["error", 350],
"max-line-length": ["error", 120],
"no-inline-assembly": "off",
"quotes": ["error", "double"],
"no-empty-blocks": "off",
"compiler-version": "off"
}
}

9
.solhintignore Normal file
View File

@@ -0,0 +1,9 @@
contracts/erc20/contracts/src/ZRXToken.sol
node_modules/
lib
deps
generated-artifacts/
generated-wrappers/
foundry-artifacts/
out/
cache/

View File

@@ -1,38 +0,0 @@
# See https://help.github.com/articles/about-codeowners/
# for more info about CODEOWNERS file
# It uses the same pattern rule for gitignore file
# https://git-scm.com/docs/gitignore#_pattern_format
# Website
packages/asset-swapper/ @BMillman19 @fragosti @dave4506
packages/instant/ @BMillman19 @fragosti @dave4506
# Dev tools & setup
.circleci/ @LogvinovLeon
packages/abi-gen/ @feuGeneA
packages/base-contract/ @xianny
packages/connect/ @fragosti
packages/abi-gen-templates/ @feuGeneA @xianny
packages/contract-addresses/ @abandeali1
packages/contract-artifacts/ @abandeali1
packages/dev-utils/ @LogvinovLeon @fabioberger
packages/devnet/ @albrow
packages/ethereum-types/ @LogvinovLeon
packages/monorepo-scripts/ @fabioberger
packages/order-utils/ @fabioberger @LogvinovLeon
packages/python-contract-wrappers/ @feuGeneA
packages/sol-compiler/ @LogvinovLeon
packages/sol-coverage/ @LogvinovLeon
packages/sol-profiler/ @LogvinovLeon
packages/sol-trace/ @LogvinovLeon
packages/sol-tracing-utils/ @LogvinovLeon
packages/sol-resolver/ @LogvinovLeon
packages/subproviders/ @fabioberger @dekz
packages/verdaccio/ @albrow
packages/web3-wrapper/ @LogvinovLeon @fabioberger
python-packages/ @feuGeneA
packages/utils/ @hysz
# Protocol/smart contracts
contracts/ @abandeali1 @hysz

View File

@@ -1,4 +1,4 @@
Copyright 2017 ZeroEx Intl.
Copyright 2020 ZeroEx Labs
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

106
README.md
View File

@@ -2,101 +2,41 @@
---
[0x][website-url] is an open protocol that facilitates trustless, low friction exchange of Ethereum-based assets. For more information on how it works, check out the [0x protocol specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
[0x][website-url] is an open protocol that facilitates trustless, low friction exchange of Ethereum-based assets. For more information on how it works, check out the [0x protocol specification](https://protocol.0x.org/).
This repository is a monorepo including the 0x protocol smart contracts and numerous developer tools. Each public sub-package is independently published to NPM.
[website-url]: https://0x.org
[![CircleCI](https://circleci.com/gh/0xProject/0x-monorepo.svg?style=svg&circle-token=61bf7cd8c9b4e11b132089dfcffdd1be277d1e0c)](https://circleci.com/gh/0xProject/0x-monorepo)
[![Coverage Status](https://coveralls.io/repos/github/0xProject/0x-monorepo/badge.svg?branch=development)](https://coveralls.io/github/0xProject/0x-monorepo?branch=development)
[![Coverage Status](https://coveralls.io/repos/github/0xProject/protocol/badge.svg?branch=development)](https://coveralls.io/github/0xProject/protocol?branch=development)
[![Discord](https://img.shields.io/badge/chat-discord.chat-yellow.svg?style=flat)](https://discordapp.com/invite/d3FTX3M)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
## Packages
Visit our [developer portal](https://0x.org/docs/tools/order-utils) for a comprehensive list of core & community maintained packages. All packages maintained with this monorepo are listed below.
### Python Packages
| Package | Version | Description |
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [`0x-contract-addresses`](/python-packages/contract_addresses) | [![PyPI](https://img.shields.io/pypi/v/0x-contract-addresses.svg)](https://pypi.org/project/0x-contract-addresses/) | A tiny utility library for getting known deployed contract addresses for a particular network |
| [`0x-contract-artifacts`](/python-packages/contract_artifacts) | [![PyPI](https://img.shields.io/pypi/v/0x-contract-artifacts.svg)](https://pypi.org/project/0x-contract-artifacts/) | 0x smart contract compilation artifacts |
| [`0x-contract-wrappers`](/python-packages/contract_wrappers) | [![PyPI](https://img.shields.io/pypi/v/0x-contract-wrappers.svg)](https://pypi.org/project/0x-contract-wrappers/) | 0x smart contract wrappers |
| [`0x-json-schemas`](/python-packages/json_schemas) | [![PyPI](https://img.shields.io/pypi/v/0x-json-schemas.svg)](https://pypi.org/project/0x-json-schemas/) | 0x-related JSON schemas |
| [`0x-order-utils`](/python-packages/order_utils) | [![PyPI](https://img.shields.io/pypi/v/0x-order-utils.svg)](https://pypi.org/project/0x-order-utils/) | A set of utilities for generating, parsing, signing and validating 0x orders |
| [`0x-sra-client`](/python-packages/sra_client) | [![PyPI](https://img.shields.io/pypi/v/0x-sra-client.svg)](https://pypi.org/project/0x-sra-client/) | A Python client for interacting with servers conforming to the Standard Relayer API specification |
Visit our [developer portal](https://0x.org/docs/) for a comprehensive list of core & community maintained packages. All packages maintained with this monorepo are listed below.
### Solidity Packages
These packages are all under development. See [/contracts/README.md](/contracts/README.md) for a list of deployed packages.
| Package | Version | Description |
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`@0x/contracts-asset-proxy`](/contracts/asset-proxy) | [![npm](https://img.shields.io/npm/v/@0x/contracts-asset-proxy.svg)](https://www.npmjs.com/package/@0x/contracts-asset-proxy) | [`AssetProxy`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#assetproxy) contracts used within the protocol |
| [`@0x/contracts-erc20`](/contracts/erc20) | [![npm](https://img.shields.io/npm/v/@0x/contracts-erc20.svg)](https://www.npmjs.com/package/@0x/contracts-erc20) | Implementations of various ERC20 tokens |
| [`@0x/contracts-erc721`](/contracts/erc721) | [![npm](https://img.shields.io/npm/v/@0x/contracts-erc721.svg)](https://www.npmjs.com/package/@0x/contracts-erc721) | Implementations of various ERC721 tokens |
| [`@0x/contracts-erc1155`](/contracts/erc1155) | [![npm](https://img.shields.io/npm/v/@0x/contracts-erc1155.svg)](https://www.npmjs.com/package/@0x/contracts-erc1155) | Implementations of various ERC1155 tokens |
| [`@0x/contracts-exchange`](/contracts/exchange) | [![npm](https://img.shields.io/npm/v/@0x/contracts-exchange.svg)](https://www.npmjs.com/package/@0x/contracts-exchange) | The [`Exchange`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#exchange) contract used for settling trades within the protocol |
| [`@0x/contracts-exchange-forwarder`](/contracts/exchange-forwarder) | [![npm](https://img.shields.io/npm/v/@0x/contracts-exchange-forwarder.svg)](https://www.npmjs.com/package/@0x/contracts-exchange-forwarder) | A [`Forwarder`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md) contract used to simplify UX for interacting with the protocol |
| [`@0x/contracts-exchange-libs`](/contracts/exchange-libs) | [![npm](https://img.shields.io/npm/v/@0x/contracts-exchange-libs.svg)](https://www.npmjs.com/package/@0x/contracts-exchange-libs) | Protocol specific libraries used within the [`Exchange`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#exchange) contract |
| [`@0x/contracts-extensions`](/contracts/extensions) | [![npm](https://img.shields.io/npm/v/@0x/contracts-extensions.svg)](https://www.npmjs.com/package/@0x/contracts-extensions) | Contracts that interact with and extend the functionality of the core protocol |
| [`@0x/contracts-multisig`](/contracts/multisig) | [![npm](https://img.shields.io/npm/v/@0x/contracts-multisig.svg)](https://www.npmjs.com/package/@0x/contracts-multisig) | Various implementations of multisignature wallets, including the [`AssetProxyOwner`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#assetproxyowner) contract that has permissions to upgrade the protocol |
| [`@0x/contracts-test-utils`](/contracts/test-utils) | [![npm](https://img.shields.io/npm/v/@0x/contracts-test-utils.svg)](https://www.npmjs.com/package/@0x/contracts-test-utils) | TypeScript/Javascript shared utilities used for testing contracts |
| [`@0x/contracts-utils`](/contracts/utils) | [![npm](https://img.shields.io/npm/v/@0x/contracts-utils.svg)](https://www.npmjs.com/package/@0x/contracts-utils) | Generic libraries and utilities used throughout all of the contracts |
| [`@0x/contracts-coordinator`](/contracts/coordinator) | [![npm](https://img.shields.io/npm/v/@0x/contracts-coordinator.svg)](https://www.npmjs.com/package/@0x/contracts-coordinator) | A contract that allows users to execute 0x transactions with permission from a Coordinator |
| [`@0x/contracts-dev-utils`](/contracts/dev-utils) | [![npm](https://img.shields.io/npm/v/@0x/contracts-dev-utils.svg)](https://www.npmjs.com/package/@0x/contracts-dev-utils) | A contract contains utility functions for developers (such as validating many orders using a single eth_call) |
| [`@0x/contracts-staking`](/contracts/staking) | [![npm](https://img.shields.io/npm/v/@0x/contracts-staking.svg)](https://www.npmjs.com/package/@0x/contracts-staking) | Implements the stake-based liquidity incentives defined by [`ZEIP-31`](https://github.com/0xProject/ZEIPs/issues/31) |
| Package | Version | Description |
| --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| [`@0x/contracts-zero-ex`](/contracts/zero-ex) | [![npm](https://img.shields.io/npm/v/@0x/contracts-zero-ex.svg)](https://www.npmjs.com/package/@0x/contracts-zero-ex) | The contracts used for settling trades within the protocol |
| [`@0x/contracts-erc20`](/contracts/erc20) | [![npm](https://img.shields.io/npm/v/@0x/contracts-erc20.svg)](https://www.npmjs.com/package/@0x/contracts-erc20) | Implementations of various ERC20 tokens |
| [`@0x/contracts-test-utils`](/contracts/test-utils) | [![npm](https://img.shields.io/npm/v/@0x/contracts-test-utils.svg)](https://www.npmjs.com/package/@0x/contracts-test-utils) | TypeScript/Javascript shared utilities used for testing contracts |
| [`@0x/contracts-utils`](/contracts/utils) | [![npm](https://img.shields.io/npm/v/@0x/contracts-utils.svg)](https://www.npmjs.com/package/@0x/contracts-utils) | Generic libraries and utilities used throughout all of the contracts |
### TypeScript/Javascript Packages
#### 0x-specific packages
| Package | Version | Description |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [`0x.js`](/packages/0x.js) | [![npm](https://img.shields.io/npm/v/0x.js.svg)](https://www.npmjs.com/package/0x.js) | An aggregate package combining many smaller utility packages for interacting with the 0x protocol |
| [`@0x/contract-addresses`](/packages/contract-addresses) | [![npm](https://img.shields.io/npm/v/@0x/contract-addresses.svg)](https://www.npmjs.com/package/@0x/contract-addresses) | A tiny utility library for getting known deployed contract addresses for a particular network. |
| [`@0x/contract-wrappers`](/packages/contract-wrappers) | [![npm](https://img.shields.io/npm/v/@0x/contract-wrappers.svg)](https://www.npmjs.com/package/@0x/contract-wrappers) | JS/TS wrappers for interacting with the 0x smart contracts |
| [`@0x/order-utils`](/packages/order-utils) | [![npm](https://img.shields.io/npm/v/@0x/order-utils.svg)](https://www.npmjs.com/package/@0x/order-utils) | A set of utilities for generating, parsing, signing and validating 0x orders |
| [`@0x/json-schemas`](/packages/json-schemas) | [![npm](https://img.shields.io/npm/v/@0x/json-schemas.svg)](https://www.npmjs.com/package/@0x/json-schemas) | 0x-related JSON schemas | |
| [`@0x/migrations`](/packages/migrations) | [![npm](https://img.shields.io/npm/v/@0x/migrations.svg)](https://www.npmjs.com/package/@0x/migrations) | Migration tool for deploying 0x smart contracts on private testnets |
| [`@0x/contract-artifacts`](/packages/contract-artifacts) | [![npm](https://img.shields.io/npm/v/@0x/contract-artifacts.svg)](https://www.npmjs.com/package/@0x/contract-artifacts) | 0x smart contract compilation artifacts | |
| [`@0x/sra-spec`](/packages/sra-spec) | [![npm](https://img.shields.io/npm/v/@0x/sra-spec.svg)](https://www.npmjs.com/package/@0x/sra-spec) | OpenAPI specification for the Standard Relayer API |
| [`@0x/connect`](/packages/connect) | [![npm](https://img.shields.io/npm/v/@0x/connect.svg)](https://www.npmjs.com/package/@0x/connect) | An HTTP/WS client for interacting with the Standard Relayer API |
| [`@0x/asset-swapper`](/packages/asset-swapper) | [![npm](https://img.shields.io/npm/v/@0x/asset-swapper.svg)](https://www.npmjs.com/package/@0x/asset-swapper) | Convenience package for discovering and performing swaps for any ERC20 Assets |
#### Ethereum tooling
| Package | Version | Description |
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`@0x/web3-wrapper`](/packages/web3-wrapper) | [![npm](https://img.shields.io/npm/v/@0x/web3-wrapper.svg)](https://www.npmjs.com/package/@0x/web3-wrapper) | An Ethereum JSON RPC client |
| [`@0x/sol-compiler`](/packages/sol-compiler) | [![npm](https://img.shields.io/npm/v/@0x/sol-compiler.svg)](https://www.npmjs.com/package/@0x/sol-compiler) | A wrapper around solc-js that adds smart re-compilation, ability to compile an entire project, Solidity version specific compilation, standard input description support and much more. |
| [`@0x/sol-coverage`](/packages/sol-coverage) | [![npm](https://img.shields.io/npm/v/@0x/sol-coverage.svg)](https://www.npmjs.com/package/@0x/sol-coverage) | A solidity test coverage tool |
| [`@0x/sol-profiler`](/packages/sol-profiler) | [![npm](https://img.shields.io/npm/v/@0x/sol-profiler.svg)](https://www.npmjs.com/package/@0x/sol-profiler) | A solidity gas cost profiler |
| [`@0x/sol-trace`](/packages/sol-trace) | [![npm](https://img.shields.io/npm/v/@0x/sol-trace.svg)](https://www.npmjs.com/package/@0x/sol-trace) | A solidity stack trace tool |
| [`@0x/sol-resolver`](/packages/sol-resolver) | [![npm](https://img.shields.io/npm/v/@0x/sol-resolver.svg)](https://www.npmjs.com/package/@0x/sol-resolver) | Import resolver for smart contracts dependencies |
| [`@0x/subproviders`](/packages/subproviders) | [![npm](https://img.shields.io/npm/v/@0x/subproviders.svg)](https://www.npmjs.com/package/@0x/subproviders) | Web3 provider middlewares (e.g. LedgerSubprovider) |
| [`@0x/sol-doc`](/packages/sol-doc) | [![npm](https://img.shields.io/npm/v/@0x/sol-doc.svg)](https://www.npmjs.com/package/@0x/sol-doc) | Solidity documentation generator |
#### Utilities
| Package | Version | Description |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [`@0x/abi-gen`](/packages/abi-gen) | [![npm](https://img.shields.io/npm/v/@0x/abi-gen.svg)](https://www.npmjs.com/package/@0x/abi-gen) | Tool to generate TS wrappers from smart contract ABIs |
| [`@0x/tslint-config`](/packages/tslint-config) | [![npm](https://img.shields.io/npm/v/@0x/tslint-config.svg)](https://www.npmjs.com/package/@0x/tslint-config) | Custom TSLint rules used by the 0x core team |
| [`@0x/types`](/packages/types) | [![npm](https://img.shields.io/npm/v/@0x/types.svg)](https://www.npmjs.com/package/@0x/types) | Shared type declarations |
| [`@0x/typescript-typings`](/packages/typescript-typings) | [![npm](https://img.shields.io/npm/v/@0x/typescript-typings.svg)](https://www.npmjs.com/package/@0x/typescript-typings) | Repository of types for external packages |
| [`@0x/utils`](/packages/utils) | [![npm](https://img.shields.io/npm/v/@0x/utils.svg)](https://www.npmjs.com/package/@0x/utils) | Shared utilities |
| [`@0x/assert`](/packages/assert) | [![npm](https://img.shields.io/npm/v/@0x/assert.svg)](https://www.npmjs.com/package/@0x/assert) | Type and schema assertions used by our packages |
| [`@0x/base-contract`](/packages/base-contract) | [![npm](https://img.shields.io/npm/v/@0x/base-contract.svg)](https://www.npmjs.com/package/@0x/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts |
| [`@0x/dev-utils`](/packages/dev-utils) | [![npm](https://img.shields.io/npm/v/@0x/dev-utils.svg)](https://www.npmjs.com/package/@0x/dev-utils) | Dev utils to be shared across 0x packages |
#### Private Packages
| Package | Description |
| ---------------------------------- | -------------------------------------------------------------------------------- |
| [`@0x/instant`](/packages/instant) | A free and flexible way to offer simple crypto purchasing in any app or website. |
| Package | Version | Description |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| [`@0x/protocol-utils`](/packages/protocol-utils) | [![npm](https://img.shields.io/npm/v/@0x/protocol-utils.svg)](https://www.npmjs.com/package/@0x/protocol-utils) | A set of utilities for generating, parsing, signing and validating 0x orders |
| [`@0x/contract-addresses`](/packages/contract-addresses) | [![npm](https://img.shields.io/npm/v/@0x/contract-addresses.svg)](https://www.npmjs.com/package/@0x/contract-addresses) | A tiny utility library for getting known deployed contract addresses for a particular network. |
| [`@0x/contract-wrappers`](/packages/contract-wrappers) | [![npm](https://img.shields.io/npm/v/@0x/contract-wrappers.svg)](https://www.npmjs.com/package/@0x/contract-wrappers) | JS/TS wrappers for interacting with the 0x smart contracts |
| [`@0x/contract-artifacts`](/packages/contract-artifacts) | [![npm](https://img.shields.io/npm/v/@0x/contract-artifacts.svg)](https://www.npmjs.com/package/@0x/contract-artifacts) | 0x smart contract compilation artifacts | |
## Usage
@@ -113,7 +53,7 @@ You can include those by prepending the `@0x/typescript-typings` package to your
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
#### Read our [contribution guidelines](./CONTRIBUTING.md).
#### Read our [contribution guidelines](.github/CONTRIBUTING.md).
### Install dependencies
@@ -129,8 +69,6 @@ Then install dependencies
yarn install
```
You will also need to have Python 3 installed, in order to build and run the tests of `abi-gen`'s command-line interface, which is integrated with the yarn build, yarn test, and yarn lint commands described below. More specifically, your local pip should resolve to the Python 3 version of pip, not a Python 2.x version.
### Build
To build all packages:
@@ -142,7 +80,7 @@ yarn build
To build a specific package:
```bash
PKG=@0x/web3-wrapper yarn build
PKG=@0x/protocol-utils yarn build
```
To build all contracts packages:
@@ -165,7 +103,7 @@ To watch a specific package and all it's dependent packages:
PKG=[NPM_PACKAGE_NAME] yarn watch
e.g
PKG=@0x/web3-wrapper yarn watch
PKG=@0x/protocol-utils yarn watch
```
### Clean
@@ -179,7 +117,7 @@ yarn clean
Clean a specific package
```bash
PKG=0x.js yarn clean
PKG=@0x/protocol-utils yarn clean
```
### Rebuild
@@ -193,7 +131,7 @@ yarn rebuild
To re-build (clean & build) a specific package & it's deps:
```bash
PKG=0x.js yarn rebuild
PKG=@0x/protocol-utils yarn rebuild
```
### Lint
@@ -207,7 +145,7 @@ yarn lint
Lint a specific package:
```bash
PKG=0x.js yarn lint
PKG=@0x/protocol-utils yarn lint
```
### Run Tests
@@ -221,7 +159,7 @@ yarn test
Run a specific package's test:
```bash
PKG=@0x/web3-wrapper yarn test
PKG=@0x/protocol-utils yarn test
```
Run all contracts packages tests:

View File

@@ -1,21 +0,0 @@
{
"extends": "default",
"rules": {
"avoid-low-level-calls": false,
"avoid-tx-origin": "warn",
"bracket-align": false,
"code-complexity": false,
"compiler-fixed": false,
"const-name-snakecase": "error",
"expression-indent": "error",
"function-max-lines": false,
"func-order": "error",
"indent": ["error", 4],
"max-line-length": ["warn", 160],
"no-inline-assembly": false,
"quotes": ["error", "double"],
"separate-by-one-line-in-contract": "error",
"space-after-comma": "error",
"statement-indent": "error"
}
}

View File

@@ -1,16 +1,3 @@
#### Deployed Contract Packages
| Contract | Package | Version | Git Tag |
| --------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| AssetProxyOwner | [`@0x/contracts-multisig`](/contracts/multisig) | [v1.0.2](https://www.npmjs.com/package/@0x/contracts-multisig/v/1.0.2) | [@0x/contracts-multisig@1.0.2](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-multisig@1.0.2) |
| ERC20Proxy | [`@0x/contracts-asset-proxy`](/contracts/asset-proxy) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-asset-proxy/v/1.0.1) | [@0x/contracts-asset-proxy@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-asset-proxy@1.0.1) |
| ERC721Proxy | [`@0x/contracts-asset-proxy`](/contracts/asset-proxy) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-asset-proxy/v/1.0.1) | [@0x/contracts-asset-proxy@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-asset-proxy@1.0.1) |
| Exchange | [`@0x/contracts-exchange`](/contracts/exchange) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-exchange/v/1.0.1) | [@0x/contracts-exchange@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-exchange@1.0.1) |
| DutchAuction | [`@0x/contracts-extensions`](/contracts/extensions) | [v1.0.2](https://www.npmjs.com/package/@0x/contracts-extensions/v/1.0.2) | [@0x/contracts-extensions@1.0.2](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-extensions@1.0.2) |
| Forwarder | [`@0x/contracts-exchange-forwarder`](/contracts/exchange-forwarder) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-exchange-forwarder/v/1.0.1) | [@0x/contracts-exchange-forwarder@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-exchange-forwarder@1.0.1) |
| MultiAssetProxy | [`@0x/contracts-asset-proxy`](/contracts/asset-proxy) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-asset-proxy/v/1.0.1) | [@0x/contracts-asset-proxy@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-asset-proxy@1.0.1) |
| ZRXToken | [`@0x/contracts-erc20`](/contracts/erc20) | [v1.0.1](https://www.npmjs.com/package/@0x/contracts-erc20/v/1.0.1) | [@0x/contracts-erc20@1.0.1](https://github.com/0xProject/0x-monorepo/releases/tag/@0x/contracts-erc20@1.0.1) |
#### Development
Building solidity files will update the contract artifact in `{package-name}/generated-artifacts/{contract}.json`, but does not automatically update the `contract-artifacts` or `contract-wrappers` packages, which are generated from the artifact JSON. See `contract-artifacts/README.md` for instructions on updating these packages.

View File

@@ -1,48 +0,0 @@
# Contracts testing options
## Revert stack traces
If you want to see helpful stack traces (incl. line number, code snippet) for smart contract reverts, run the tests with:
```
yarn test:trace
```
**Note:** This currently slows down the test runs and is therefore not enabled by default.
## Backing Ethereum node
By default, our tests run against an in-process [Ganache](https://github.com/trufflesuite/ganache-core) instance. In order to run the tests against [Geth](https://github.com/ethereum/go-ethereum), first follow the instructions in the README for the devnet package to start the devnet Geth node. Then run:
```bash
TEST_PROVIDER=geth yarn test
```
## Code coverage
In order to see the Solidity code coverage output generated by `@0x/sol-coverage`, run:
```
yarn test:coverage
```
## Gas profiler
In order to profile the gas costs for a specific smart contract call/transaction, you can run the tests in `profiler` mode.
**Note:** Traces emitted by ganache have incorrect gas costs so we recommend using Geth for profiling.
```
TEST_PROVIDER=geth yarn test:profiler
```
You'll see a warning that you need to explicitly enable and disable the profiler before and after the block of code you want to profile.
```typescript
import { profiler } from './utils/profiler';
profiler.start();
// Some call to a smart contract
profiler.stop();
```
Without explicitly starting and stopping the profiler, the profiler output will be too busy, and therefore unusable.

View File

@@ -1,2 +0,0 @@
# solhint can't parse `abi.decode` syntax.
contracts/src/ERC1155Proxy.sol

View File

@@ -1,590 +0,0 @@
[
{
"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",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1581748629,
"version": "3.2.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.2.0",
"changes": [
{
"note": "Add more types and functions to `IDydx`",
"pr": 2466
},
{
"note": "Rename `DydxBrigeAction.accountId` to `DydxBridgeAction.accountIdx`",
"pr": 2466
},
{
"note": "Fix broken tests.",
"pr": 2462
},
{
"note": "Remove dependency on `@0x/contracts-dev-utils`",
"pr": 2462
},
{
"note": "Add asset data decoding functions",
"pr": 2462
},
{
"note": "Add `setOperators()` to `IDydx`",
"pr": 2462
}
],
"timestamp": 1581204851
},
{
"timestamp": 1580988106,
"version": "3.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1580811564,
"version": "3.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1579682890,
"version": "3.1.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.1.0",
"changes": [
{
"note": "Integration tests for DydxBridge with ERC20BridgeProxy.",
"pr": 2401
},
{
"note": "Fix `UniswapBridge` token -> token transfer call.",
"pr": 2412
},
{
"note": "Fix `KyberBridge` incorrect `minConversionRate` calculation.",
"pr": 2412
}
],
"timestamp": 1578272714
},
{
"timestamp": 1576540892,
"version": "3.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1575931811,
"version": "3.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.0.0",
"changes": [
{
"note": "Implement `KyberBridge`.",
"pr": 2352
},
{
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
"pr": 2330
},
{
"note": "ERC20Wrapper and ERC1155ProxyWrapper constructors now require an instance of DevUtilsContract",
"pr": 2034
},
{
"note": "Disallow the zero address from being made an authorized address in MixinAuthorizable, and created an archive directory that includes an old version of Ownable",
"pr": 2019
},
{
"note": "Remove `LibAssetProxyIds` contract",
"pr": 2055
},
{
"note": "Compile and export all contracts, artifacts, and wrappers by default",
"pr": 2055
},
{
"note": "Remove unused dependency on IAuthorizable in IAssetProxy",
"pr": 1910
},
{
"note": "Add `ERC20BridgeProxy`",
"pr": 2220
},
{
"note": "Add `Eth2DaiBridge`",
"pr": 2221
},
{
"note": "Add `UniswapBridge`",
"pr": 2233
},
{
"note": "Replaced `SafeMath` with `LibSafeMath`",
"pr": 2254
}
],
"timestamp": 1575296764
},
{
"version": "2.3.0-beta.4",
"changes": [
{
"note": "Implement `KyberBridge`.",
"pr": 2352
},
{
"note": "Implement `DydxBridge`.",
"pr": 2365
}
],
"timestamp": 1575290197
},
{
"version": "2.3.0-beta.3",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1574238768
},
{
"version": "2.3.0-beta.2",
"changes": [
{
"note": "Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils",
"pr": 2330
}
],
"timestamp": 1574030254
},
{
"version": "2.3.0-beta.1",
"changes": [
{
"note": "ERC20Wrapper and ERC1155ProxyWrapper constructors now require an instance of DevUtilsContract",
"pr": 2034
}
],
"timestamp": 1573159180
},
{
"version": "2.3.0-beta.0",
"changes": [
{
"note": "Disallow the zero address from being made an authorized address in MixinAuthorizable, and created an archive directory that includes an old version of Ownable",
"pr": 2019
},
{
"note": "Remove `LibAssetProxyIds` contract",
"pr": 2055
},
{
"note": "Compile and export all contracts, artifacts, and wrappers by default",
"pr": 2055
},
{
"note": "Remove unused dependency on IAuthorizable in IAssetProxy",
"pr": 1910
},
{
"note": "Add `ERC20BridgeProxy`",
"pr": 2220
},
{
"note": "Add `Eth2DaiBridge`",
"pr": 2221
},
{
"note": "Add `UniswapBridge`",
"pr": 2233
},
{
"note": "Replaced `SafeMath` with `LibSafeMath`",
"pr": 2254
}
],
"timestamp": 1570135330
},
{
"timestamp": 1568744790,
"version": "2.2.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1567521715,
"version": "2.2.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1566446343,
"version": "2.2.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1565296576,
"version": "2.2.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.2.4",
"changes": [
{
"note": "Updated calls to <contract wrapper>.deployFrom0xArtifactAsync to include artifact dependencies.",
"pr": 1995
}
],
"timestamp": 1564607468
},
{
"timestamp": 1563957393,
"version": "2.2.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1563193019,
"version": "2.2.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1563047529,
"version": "2.2.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.2.0",
"changes": [
{
"note": "Add `LibAssetProxyIds` contract",
"pr": 1835
},
{
"note": "Updated ERC1155 Asset Proxy. Less optimization. More explicit handling of edge cases.",
"pr": 1852
},
{
"note": "Implement StaticCallProxy",
"pr": 1863
}
],
"timestamp": 1563006338
},
{
"timestamp": 1558712885,
"version": "2.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "2.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557799313,
"version": "2.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.1.2",
"changes": [
{
"note": "Update tests to use contract-built-in `awaitTransactionSuccessAsync`",
"pr": 1797
},
{
"note": "Make `ERC721Wrapper.setApprovalForAll()` take an owner address instead of a token ID",
"pr": 1819
},
{
"note": "Automatically set unlimited proxy allowances in `ERC721.setBalancesAndAllowancesAsync()`",
"pr": 1819
},
{
"note": "Add `setProxyAllowanceForAllAsync()` to `ERC1155ProxyWrapper`.",
"pr": 1819
}
],
"timestamp": 1557507213
},
{
"version": "2.1.1",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1554997931
},
{
"version": "2.1.0",
"changes": [
{
"note": "Run Web3ProviderEngine without excess block polling",
"pr": 1695
}
],
"timestamp": 1553183790
},
{
"version": "2.0.0",
"changes": [
{
"note": "Do not reexport external dependencies",
"pr": 1682
},
{
"note": "Add ERC1155Proxy",
"pr": 1661
},
{
"note": "Bumped solidity version to ^0.5.5",
"pr": 1701
},
{
"note": "Integration testing for ERC1155Proxy",
"pr": 1673
}
],
"timestamp": 1553091633
},
{
"timestamp": 1551479279,
"version": "1.0.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1551299797,
"version": "1.0.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1551220833,
"version": "1.0.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1551130135,
"version": "1.0.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1549733923,
"version": "1.0.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.4",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1549547375
},
{
"version": "1.0.3",
"changes": [
{
"note": "Fake publish to enable pinning"
}
],
"timestamp": 1549504360
},
{
"timestamp": 1549452781,
"version": "1.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1549373905,
"version": "1.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.0",
"changes": [
{
"note": "Move all AssetProxy contracts out of contracts-protocol to new package",
"pr": 1539
}
]
}
]

View File

@@ -1,230 +0,0 @@
<!--
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
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
## v3.2.1 - _February 15, 2020_
* Dependencies updated
## v3.2.0 - _February 8, 2020_
* Add more types and functions to `IDydx` (#2466)
* Rename `DydxBrigeAction.accountId` to `DydxBridgeAction.accountIdx` (#2466)
* Fix broken tests. (#2462)
* Remove dependency on `@0x/contracts-dev-utils` (#2462)
* Add asset data decoding functions (#2462)
* Add `setOperators()` to `IDydx` (#2462)
## v3.1.3 - _February 6, 2020_
* Dependencies updated
## v3.1.2 - _February 4, 2020_
* Dependencies updated
## v3.1.1 - _January 22, 2020_
* Dependencies updated
## v3.1.0 - _January 6, 2020_
* Integration tests for DydxBridge with ERC20BridgeProxy. (#2401)
* Fix `UniswapBridge` token -> token transfer call. (#2412)
* Fix `KyberBridge` incorrect `minConversionRate` calculation. (#2412)
## v3.0.2 - _December 17, 2019_
* Dependencies updated
## v3.0.1 - _December 9, 2019_
* Dependencies updated
## v3.0.0 - _December 2, 2019_
* Implement `KyberBridge`. (#2352)
* Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330)
* ERC20Wrapper and ERC1155ProxyWrapper constructors now require an instance of DevUtilsContract (#2034)
* Disallow the zero address from being made an authorized address in MixinAuthorizable, and created an archive directory that includes an old version of Ownable (#2019)
* Remove `LibAssetProxyIds` contract (#2055)
* Compile and export all contracts, artifacts, and wrappers by default (#2055)
* Remove unused dependency on IAuthorizable in IAssetProxy (#1910)
* Add `ERC20BridgeProxy` (#2220)
* Add `Eth2DaiBridge` (#2221)
* Add `UniswapBridge` (#2233)
* Replaced `SafeMath` with `LibSafeMath` (#2254)
## v2.3.0-beta.4 - _December 2, 2019_
* Implement `KyberBridge`. (#2352)
* Implement `DydxBridge`. (#2365)
## v2.3.0-beta.3 - _November 20, 2019_
* Dependencies updated
## v2.3.0-beta.2 - _November 17, 2019_
* Drastically reduced bundle size by adding .npmignore, only exporting specific artifacts/wrappers/utils (#2330)
## v2.3.0-beta.1 - _November 7, 2019_
* ERC20Wrapper and ERC1155ProxyWrapper constructors now require an instance of DevUtilsContract (#2034)
## v2.3.0-beta.0 - _October 3, 2019_
* Disallow the zero address from being made an authorized address in MixinAuthorizable, and created an archive directory that includes an old version of Ownable (#2019)
* Remove `LibAssetProxyIds` contract (#2055)
* Compile and export all contracts, artifacts, and wrappers by default (#2055)
* Remove unused dependency on IAuthorizable in IAssetProxy (#1910)
* Add `ERC20BridgeProxy` (#2220)
* Add `Eth2DaiBridge` (#2221)
* Add `UniswapBridge` (#2233)
* Replaced `SafeMath` with `LibSafeMath` (#2254)
## v2.2.8 - _September 17, 2019_
* Dependencies updated
## v2.2.7 - _September 3, 2019_
* Dependencies updated
## v2.2.6 - _August 22, 2019_
* Dependencies updated
## v2.2.5 - _August 8, 2019_
* Dependencies updated
## v2.2.4 - _July 31, 2019_
* Updated calls to <contract wrapper>.deployFrom0xArtifactAsync to include artifact dependencies. (#1995)
## v2.2.3 - _July 24, 2019_
* Dependencies updated
## v2.2.2 - _July 15, 2019_
* Dependencies updated
## v2.2.1 - _July 13, 2019_
* Dependencies updated
## v2.2.0 - _July 13, 2019_
* Add `LibAssetProxyIds` contract (#1835)
* Updated ERC1155 Asset Proxy. Less optimization. More explicit handling of edge cases. (#1852)
* Implement StaticCallProxy (#1863)
## v2.1.5 - _May 24, 2019_
* Dependencies updated
## v2.1.4 - _May 15, 2019_
* Dependencies updated
## v2.1.3 - _May 14, 2019_
* Dependencies updated
## v2.1.2 - _May 10, 2019_
* Update tests to use contract-built-in `awaitTransactionSuccessAsync` (#1797)
* Make `ERC721Wrapper.setApprovalForAll()` take an owner address instead of a token ID (#1819)
* Automatically set unlimited proxy allowances in `ERC721.setBalancesAndAllowancesAsync()` (#1819)
* Add `setProxyAllowanceForAllAsync()` to `ERC1155ProxyWrapper`. (#1819)
## v2.1.1 - _April 11, 2019_
* Dependencies updated
## v2.1.0 - _March 21, 2019_
* Run Web3ProviderEngine without excess block polling (#1695)
## v2.0.0 - _March 20, 2019_
* Do not reexport external dependencies (#1682)
* Add ERC1155Proxy (#1661)
* Bumped solidity version to ^0.5.5 (#1701)
* Integration testing for ERC1155Proxy (#1673)
## v1.0.9 - _March 1, 2019_
* Dependencies updated
## v1.0.8 - _February 27, 2019_
* Dependencies updated
## v1.0.7 - _February 26, 2019_
* Dependencies updated
## v1.0.6 - _February 25, 2019_
* Dependencies updated
## v1.0.5 - _February 9, 2019_
* Dependencies updated
## v1.0.4 - _February 7, 2019_
* Dependencies updated
## v1.0.3 - _February 7, 2019_
* Fake publish to enable pinning
## v1.0.2 - _February 6, 2019_
* Dependencies updated
## v1.0.1 - _February 5, 2019_
* Dependencies updated
## v1.0.0 - _Invalid date_
* Move all AssetProxy contracts out of contracts-protocol to new package (#1539)

View File

@@ -1,47 +0,0 @@
[
{
"name": "MultiAssetProxy",
"version": "1.0.0",
"changes": [
{
"note": "Add MultiAssetProxy implementation",
"pr": 1224,
"networks": {
"3": "0xab8fbd189c569ccdee3a4d929bb7f557be4028f6",
"4": "0xb34cde0ad3a83d04abebc0b66e75196f22216621",
"42": "0xf6313a772c222f51c28f2304c0703b8cf5428fd8"
}
}
]
},
{
"name": "ERC20Proxy",
"version": "1.0.0",
"changes": [
{
"note": "protocol v2 deploy",
"networks": {
"1": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
"3": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
"4": "0x3e809c563c15a295e832e37053798ddc8d6c8dab",
"42": "0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e"
}
}
]
},
{
"name": "ERC721Proxy",
"version": "1.0.0",
"changes": [
{
"note": "protocol v2 deploy",
"networks": {
"1": "0x208e41fb445f1bb1b6780d58356e81405f3e6127",
"3": "0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4",
"4": "0x8e1ff02637cb5e39f2fa36c14706aa348b065b09",
"42": "0x2a9127c745688a165106c11cd4d647d2220af821"
}
}
]
}
]

View File

@@ -1,73 +0,0 @@
## AssetProxy
This package contains the implementations of all of the [`AssetProxy`](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#assetproxy) contracts available within the 0x protocol. These contracts are responsible for decoding the `assetData` sent to them and performing the actual transfer of assets. Addresses of the deployed contracts can be found in this 0x [guide](https://0x.org/docs/guides/0x-cheat-sheet) or the [DEPLOYS](./DEPLOYS.json) file within this package.
## Installation
**Install**
```bash
npm install @0x/contracts-asset-proxy --save
```
## Bug bounty
A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0x.org/docs/guides/bug-bounty-program).
## Contributing
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
```bash
PKG=@0x/contracts-asset-proxy yarn build
```
Or continuously rebuild on change:
```bash
PKG=@0x/contracts-asset-proxy yarn watch
```
### Clean
```bash
yarn clean
```
### Lint
```bash
yarn lint
```
### Run Tests
```bash
yarn test
```
#### Testing options
Contracts testing options like coverage, profiling, revert traces or backing node choosing - are described [here](../TESTING.md).

View File

@@ -1,27 +0,0 @@
{
"artifactsDir": "./test/generated-artifacts",
"contractsDir": "./contracts",
"useDockerisedSolc": false,
"isOfflineMode": false,
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": {
"enabled": true,
"runs": 1000000,
"details": { "yul": true, "deduplicate": true, "cse": true, "constantOptimizer": true }
},
"outputSelection": {
"*": {
"*": [
"abi",
"devdoc",
"evm.bytecode.object",
"evm.bytecode.sourceMap",
"evm.deployedBytecode.object",
"evm.deployedBytecode.sourceMap"
]
}
}
}
}

View File

@@ -1,172 +0,0 @@
/*
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;
import "../archive/Ownable.sol";
import "../src/interfaces/IAssetProxy.sol";
import "../src/interfaces/IAssetProxyDispatcher.sol";
contract MixinAssetProxyDispatcher is
Ownable,
IAssetProxyDispatcher
{
// Mapping from Asset Proxy Id's to their respective Asset Proxy
mapping (bytes4 => address) public assetProxies;
/// @dev Registers an asset proxy to its asset proxy id.
/// Once an asset proxy is registered, it cannot be unregistered.
/// @param assetProxy Address of new asset proxy to register.
function registerAssetProxy(address assetProxy)
external
onlyOwner
{
// Ensure that no asset proxy exists with current id.
bytes4 assetProxyId = IAssetProxy(assetProxy).getProxyId();
address currentAssetProxy = assetProxies[assetProxyId];
require(
currentAssetProxy == address(0),
"ASSET_PROXY_ALREADY_EXISTS"
);
// Add asset proxy and log registration.
assetProxies[assetProxyId] = assetProxy;
emit AssetProxyRegistered(
assetProxyId,
assetProxy
);
}
/// @dev Gets an asset proxy.
/// @param assetProxyId Id of the asset proxy.
/// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered.
function getAssetProxy(bytes4 assetProxyId)
external
view
returns (address)
{
return assetProxies[assetProxyId];
}
/// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.
/// @param assetData Byte array encoded for the asset.
/// @param from Address to transfer token from.
/// @param to Address to transfer token to.
/// @param amount Amount of token to transfer.
function _dispatchTransferFrom(
bytes memory assetData,
address from,
address to,
uint256 amount
)
internal
{
// Do nothing if no amount should be transferred.
if (amount > 0 && from != to) {
// Ensure assetData length is valid
require(
assetData.length > 3,
"LENGTH_GREATER_THAN_3_REQUIRED"
);
// Lookup assetProxy. We do not use `LibBytes.readBytes4` for gas efficiency reasons.
bytes4 assetProxyId;
assembly {
assetProxyId := and(mload(
add(assetData, 32)),
0xFFFFFFFF00000000000000000000000000000000000000000000000000000000
)
}
address assetProxy = assetProxies[assetProxyId];
// Ensure that assetProxy exists
require(
assetProxy != address(0),
"ASSET_PROXY_DOES_NOT_EXIST"
);
// We construct calldata for the `assetProxy.transferFrom` ABI.
// The layout of this calldata is in the table below.
//
// | Area | Offset | Length | Contents |
// | -------- |--------|---------|-------------------------------------------- |
// | Header | 0 | 4 | function selector |
// | Params | | 4 * 32 | function parameters: |
// | | 4 | | 1. offset to assetData (*) |
// | | 36 | | 2. from |
// | | 68 | | 3. to |
// | | 100 | | 4. amount |
// | Data | | | assetData: |
// | | 132 | 32 | assetData Length |
// | | 164 | ** | assetData Contents |
assembly {
/////// Setup State ///////
// `cdStart` is the start of the calldata for `assetProxy.transferFrom` (equal to free memory ptr).
let cdStart := mload(64)
// `dataAreaLength` is the total number of words needed to store `assetData`
// As-per the ABI spec, this value is padded up to the nearest multiple of 32,
// and includes 32-bytes for length.
let dataAreaLength := and(add(mload(assetData), 63), 0xFFFFFFFFFFFE0)
// `cdEnd` is the end of the calldata for `assetProxy.transferFrom`.
let cdEnd := add(cdStart, add(132, dataAreaLength))
/////// Setup Header Area ///////
// This area holds the 4-byte `transferFromSelector`.
// bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
mstore(cdStart, 0xa85e59e400000000000000000000000000000000000000000000000000000000)
/////// Setup Params Area ///////
// Each parameter is padded to 32-bytes. The entire Params Area is 128 bytes.
// Notes:
// 1. The offset to `assetData` is the length of the Params Area (128 bytes).
// 2. A 20-byte mask is applied to addresses to zero-out the unused bytes.
mstore(add(cdStart, 4), 128)
mstore(add(cdStart, 36), and(from, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(add(cdStart, 68), and(to, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(add(cdStart, 100), amount)
/////// Setup Data Area ///////
// This area holds `assetData`.
let dataArea := add(cdStart, 132)
// solhint-disable-next-line no-empty-blocks
for {} lt(dataArea, cdEnd) {} {
mstore(dataArea, mload(assetData))
dataArea := add(dataArea, 32)
assetData := add(assetData, 32)
}
/////// Call `assetProxy.transferFrom` using the constructed calldata ///////
let success := call(
gas, // forward all gas
assetProxy, // call address of asset proxy
0, // don't send any ETH
cdStart, // pointer to start of input
sub(cdEnd, cdStart), // length of input
cdStart, // write output over input
512 // reserve 512 bytes for output
)
if iszero(success) {
revert(cdStart, returndatasize())
}
}
}
}
}

View File

@@ -1,117 +0,0 @@
/*
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;
import "../archive/Ownable.sol";
import "../src/interfaces/IAuthorizable.sol";
contract MixinAuthorizable is
Ownable,
IAuthorizable
{
/// @dev Only authorized addresses can invoke functions with this modifier.
modifier onlyAuthorized {
require(
authorized[msg.sender],
"SENDER_NOT_AUTHORIZED"
);
_;
}
mapping (address => bool) public authorized;
address[] public authorities;
/// @dev Authorizes an address.
/// @param target Address to authorize.
function addAuthorizedAddress(address target)
external
onlyOwner
{
require(
!authorized[target],
"TARGET_ALREADY_AUTHORIZED"
);
authorized[target] = true;
authorities.push(target);
emit AuthorizedAddressAdded(target, msg.sender);
}
/// @dev Removes authorizion of an address.
/// @param target Address to remove authorization from.
function removeAuthorizedAddress(address target)
external
onlyOwner
{
require(
authorized[target],
"TARGET_NOT_AUTHORIZED"
);
delete authorized[target];
for (uint256 i = 0; i < authorities.length; i++) {
if (authorities[i] == target) {
authorities[i] = authorities[authorities.length - 1];
authorities.length -= 1;
break;
}
}
emit AuthorizedAddressRemoved(target, msg.sender);
}
/// @dev Removes authorizion of an address.
/// @param target Address to remove authorization from.
/// @param index Index of target in authorities array.
function removeAuthorizedAddressAtIndex(
address target,
uint256 index
)
external
onlyOwner
{
require(
authorized[target],
"TARGET_NOT_AUTHORIZED"
);
require(
index < authorities.length,
"INDEX_OUT_OF_BOUNDS"
);
require(
authorities[index] == target,
"AUTHORIZED_ADDRESS_MISMATCH"
);
delete authorized[target];
authorities[index] = authorities[authorities.length - 1];
authorities.length -= 1;
emit AuthorizedAddressRemoved(target, msg.sender);
}
/// @dev Gets all authorized addresses.
/// @return Array of authorized addresses.
function getAuthorizedAddresses()
external
view
returns (address[] memory)
{
return authorities;
}
}

View File

@@ -1,33 +0,0 @@
pragma solidity ^0.5.9;
import "@0x/contracts-utils/contracts/src/interfaces/IOwnable.sol";
contract Ownable is
IOwnable
{
address public owner;
constructor ()
public
{
owner = msg.sender;
}
modifier onlyOwner() {
require(
msg.sender == owner,
"ONLY_CONTRACT_OWNER"
);
_;
}
function transferOwnership(address newOwner)
public
onlyOwner
{
if (newOwner != address(0)) {
owner = newOwner;
}
}
}

View File

@@ -1,97 +0,0 @@
/*
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;
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
import "@0x/contracts-erc1155/contracts/src/interfaces/IERC1155.sol";
import "../archive/MixinAuthorizable.sol";
import "./interfaces/IAssetProxy.sol";
contract ERC1155Proxy is
MixinAuthorizable,
IAssetProxy
{
using LibBytes for bytes;
using LibSafeMath for uint256;
// Id of this proxy.
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC1155Assets(address,uint256[],uint256[],bytes)"));
/// @dev Transfers batch of ERC1155 assets. Either succeeds or throws.
/// @param assetData Byte array encoded with ERC1155 token address, array of ids, array of values, and callback data.
/// @param from Address to transfer assets from.
/// @param to Address to transfer assets to.
/// @param amount Amount that will be multiplied with each element of `assetData.values` to scale the
/// values that will be transferred.
function transferFrom(
bytes calldata assetData,
address from,
address to,
uint256 amount
)
external
onlyAuthorized
{
// Decode params from `assetData`
// solhint-disable indent
(
address erc1155TokenAddress,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) = abi.decode(
assetData.sliceDestructive(4, assetData.length),
(address, uint256[], uint256[], bytes)
);
// solhint-enable indent
// Scale values up by `amount`
uint256 length = values.length;
uint256[] memory scaledValues = new uint256[](length);
for (uint256 i = 0; i != length; i++) {
// We write the scaled values to an unused location in memory in order
// to avoid copying over `ids` or `data`. This is possible if they are
// identical to `values` and the offsets for each are pointing to the
// same location in the ABI encoded calldata.
scaledValues[i] = values[i].safeMul(amount);
}
// Execute `safeBatchTransferFrom` call
// Either succeeds or throws
IERC1155(erc1155TokenAddress).safeBatchTransferFrom(
from,
to,
ids,
scaledValues,
data
);
}
/// @dev Gets the proxy id associated with the proxy address.
/// @return Proxy id.
function getProxyId()
external
pure
returns (bytes4)
{
return PROXY_ID;
}
}

View File

@@ -1,126 +0,0 @@
/*
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-utils/contracts/src/LibBytes.sol";
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
import "@0x/contracts-utils/contracts/src/Authorizable.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "./interfaces/IAssetProxy.sol";
import "./interfaces/IERC20Bridge.sol";
contract ERC20BridgeProxy is
IAssetProxy,
Authorizable
{
using LibBytes for bytes;
using LibSafeMath for uint256;
// @dev Id of this proxy. Also the result of a successful bridge call.
// bytes4(keccak256("ERC20Bridge(address,address,bytes)"))
bytes4 constant private PROXY_ID = 0xdc1600f3;
/// @dev Calls a bridge contract to transfer `amount` of ERC20 from `from`
/// to `to`. Asserts that the balance of `to` has increased by `amount`.
/// @param assetData Abi-encoded data for this asset proxy encoded as:
/// abi.encodeWithSelector(
/// bytes4 PROXY_ID,
/// address tokenAddress,
/// address bridgeAddress,
/// bytes bridgeData
/// )
/// @param from Address to transfer asset from.
/// @param to Address to transfer asset to.
/// @param amount Amount of asset to transfer.
function transferFrom(
bytes calldata assetData,
address from,
address to,
uint256 amount
)
external
onlyAuthorized
{
// Extract asset data fields.
(
address tokenAddress,
address bridgeAddress,
bytes memory bridgeData
) = abi.decode(
assetData.sliceDestructive(4, assetData.length),
(address, address, bytes)
);
// Remember the balance of `to` before calling the bridge.
uint256 balanceBefore = balanceOf(tokenAddress, to);
// Call the bridge, who should transfer `amount` of `tokenAddress` to
// `to`.
bytes4 success = IERC20Bridge(bridgeAddress).bridgeTransferFrom(
tokenAddress,
from,
to,
amount,
bridgeData
);
// Bridge must return the proxy ID to indicate success.
require(success == PROXY_ID, "BRIDGE_FAILED");
// Ensure that the balance of `to` has increased by at least `amount`.
require(
balanceBefore.safeAdd(amount) <= balanceOf(tokenAddress, to),
"BRIDGE_UNDERPAY"
);
}
/// @dev Gets the proxy id associated with this asset proxy.
/// @return proxyId The proxy id.
function getProxyId()
external
pure
returns (bytes4 proxyId)
{
return PROXY_ID;
}
/// @dev Retrieves the balance of `owner` for this asset.
/// @return balance The balance of the ERC20 token being transferred by this
/// asset proxy.
function balanceOf(bytes calldata assetData, address owner)
external
view
returns (uint256 balance)
{
(address tokenAddress) = abi.decode(
assetData.sliceDestructive(4, assetData.length),
(address)
);
return balanceOf(tokenAddress, owner);
}
/// @dev Retrieves the balance of `owner` given an ERC20 address.
/// @return balance The balance of the ERC20 token for `owner`.
function balanceOf(address tokenAddress, address owner)
private
view
returns (uint256 balance)
{
return IERC20Token(tokenAddress).balanceOf(owner);
}
}

View File

@@ -1,184 +0,0 @@
/*
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;
import "../archive/MixinAuthorizable.sol";
contract ERC20Proxy is
MixinAuthorizable
{
// Id of this proxy.
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC20Token(address)"));
// solhint-disable-next-line payable-fallback
function ()
external
{
assembly {
// The first 4 bytes of calldata holds the function selector
let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)
// `transferFrom` will be called with the following parameters:
// assetData Encoded byte array.
// from Address to transfer asset from.
// to Address to transfer asset to.
// amount Amount of asset to transfer.
// bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {
// To lookup a value in a mapping, we load from the storage location keccak256(k, p),
// where k is the key left padded to 32 bytes and p is the storage slot
let start := mload(64)
mstore(start, and(caller, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(add(start, 32), authorized_slot)
// Revert if authorized[msg.sender] == false
if iszero(sload(keccak256(start, 64))) {
// Revert with `Error("SENDER_NOT_AUTHORIZED")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)
mstore(96, 0)
revert(0, 100)
}
// `transferFrom`.
// The function is marked `external`, so no abi decodeding is done for
// us. Instead, we expect the `calldata` memory to contain the
// following:
//
// | Area | Offset | Length | Contents |
// |----------|--------|---------|-------------------------------------|
// | Header | 0 | 4 | function selector |
// | Params | | 4 * 32 | function parameters: |
// | | 4 | | 1. offset to assetData (*) |
// | | 36 | | 2. from |
// | | 68 | | 3. to |
// | | 100 | | 4. amount |
// | Data | | | assetData: |
// | | 132 | 32 | assetData Length |
// | | 164 | ** | assetData Contents |
//
// (*): offset is computed from start of function parameters, so offset
// by an additional 4 bytes in the calldata.
//
// (**): see table below to compute length of assetData Contents
//
// WARNING: The ABIv2 specification allows additional padding between
// the Params and Data section. This will result in a larger
// offset to assetData.
// Asset data itself is encoded as follows:
//
// | Area | Offset | Length | Contents |
// |----------|--------|---------|-------------------------------------|
// | Header | 0 | 4 | function selector |
// | Params | | 1 * 32 | function parameters: |
// | | 4 | 12 + 20 | 1. token address |
// We construct calldata for the `token.transferFrom` ABI.
// The layout of this calldata is in the table below.
//
// | Area | Offset | Length | Contents |
// |----------|--------|---------|-------------------------------------|
// | Header | 0 | 4 | function selector |
// | Params | | 3 * 32 | function parameters: |
// | | 4 | | 1. from |
// | | 36 | | 2. to |
// | | 68 | | 3. amount |
/////// Read token address from calldata ///////
// * The token address is stored in `assetData`.
//
// * The "offset to assetData" is stored at offset 4 in the calldata (table 1).
// [assetDataOffsetFromParams = calldataload(4)]
//
// * Notes that the "offset to assetData" is relative to the "Params" area of calldata;
// add 4 bytes to account for the length of the "Header" area (table 1).
// [assetDataOffsetFromHeader = assetDataOffsetFromParams + 4]
//
// * The "token address" is offset 32+4=36 bytes into "assetData" (tables 1 & 2).
// [tokenOffset = assetDataOffsetFromHeader + 36 = calldataload(4) + 4 + 36]
let token := calldataload(add(calldataload(4), 40))
/////// Setup Header Area ///////
// This area holds the 4-byte `transferFrom` selector.
// Any trailing data in transferFromSelector will be
// overwritten in the next `mstore` call.
mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
/////// Setup Params Area ///////
// We copy the fields `from`, `to` and `amount` in bulk
// from our own calldata to the new calldata.
calldatacopy(4, 36, 96)
/////// Call `token.transferFrom` using the calldata ///////
let success := call(
gas, // forward all gas
token, // call address of token contract
0, // don't send any ETH
0, // pointer to start of input
100, // length of input
0, // write output over input
32 // output size should be 32 bytes
)
/////// Check return data. ///////
// If there is no return data, we assume the token incorrectly
// does not return a bool. In this case we expect it to revert
// on failure, which was handled above.
// If the token does return data, we require that it is a single
// nonzero 32 bytes value.
// So the transfer succeeded if the call succeeded and either
// returned nothing, or returned a non-zero 32 byte value.
success := and(success, or(
iszero(returndatasize),
and(
eq(returndatasize, 32),
gt(mload(0), 0)
)
))
if success {
return(0, 0)
}
// Revert with `Error("TRANSFER_FAILED")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
mstore(96, 0)
revert(0, 100)
}
// Revert if undefined function is called
revert(0, 0)
}
}
/// @dev Gets the proxy id associated with the proxy address.
/// @return Proxy id.
function getProxyId()
external
pure
returns (bytes4)
{
return PROXY_ID;
}
}

View File

@@ -1,171 +0,0 @@
/*
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;
import "../archive/MixinAuthorizable.sol";
contract ERC721Proxy is
MixinAuthorizable
{
// Id of this proxy.
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC721Token(address,uint256)"));
// solhint-disable-next-line payable-fallback
function ()
external
{
assembly {
// The first 4 bytes of calldata holds the function selector
let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)
// `transferFrom` will be called with the following parameters:
// assetData Encoded byte array.
// from Address to transfer asset from.
// to Address to transfer asset to.
// amount Amount of asset to transfer.
// bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {
// To lookup a value in a mapping, we load from the storage location keccak256(k, p),
// where k is the key left padded to 32 bytes and p is the storage slot
let start := mload(64)
mstore(start, and(caller, 0xffffffffffffffffffffffffffffffffffffffff))
mstore(add(start, 32), authorized_slot)
// Revert if authorized[msg.sender] == false
if iszero(sload(keccak256(start, 64))) {
// Revert with `Error("SENDER_NOT_AUTHORIZED")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)
mstore(96, 0)
revert(0, 100)
}
// `transferFrom`.
// The function is marked `external`, so no abi decodeding is done for
// us. Instead, we expect the `calldata` memory to contain the
// following:
//
// | Area | Offset | Length | Contents |
// |----------|--------|---------|-------------------------------------|
// | Header | 0 | 4 | function selector |
// | Params | | 4 * 32 | function parameters: |
// | | 4 | | 1. offset to assetData (*) |
// | | 36 | | 2. from |
// | | 68 | | 3. to |
// | | 100 | | 4. amount |
// | Data | | | assetData: |
// | | 132 | 32 | assetData Length |
// | | 164 | ** | assetData Contents |
//
// (*): offset is computed from start of function parameters, so offset
// by an additional 4 bytes in the calldata.
//
// (**): see table below to compute length of assetData Contents
//
// WARNING: The ABIv2 specification allows additional padding between
// the Params and Data section. This will result in a larger
// offset to assetData.
// Asset data itself is encoded as follows:
//
// | Area | Offset | Length | Contents |
// |----------|--------|---------|-------------------------------------|
// | Header | 0 | 4 | function selector |
// | Params | | 2 * 32 | function parameters: |
// | | 4 | 12 + 20 | 1. token address |
// | | 36 | | 2. tokenId |
// We construct calldata for the `token.transferFrom` ABI.
// The layout of this calldata is in the table below.
//
// | Area | Offset | Length | Contents |
// |----------|--------|---------|-------------------------------------|
// | Header | 0 | 4 | function selector |
// | Params | | 3 * 32 | function parameters: |
// | | 4 | | 1. from |
// | | 36 | | 2. to |
// | | 68 | | 3. tokenId |
// There exists only 1 of each token.
// require(amount == 1, "INVALID_AMOUNT")
if sub(calldataload(100), 1) {
// Revert with `Error("INVALID_AMOUNT")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000000e494e56414c49445f414d4f554e540000000000000000000000000000)
mstore(96, 0)
revert(0, 100)
}
/////// Setup Header Area ///////
// This area holds the 4-byte `transferFrom` selector.
// Any trailing data in transferFromSelector will be
// overwritten in the next `mstore` call.
mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
/////// Setup Params Area ///////
// We copy the fields `from` and `to` in bulk
// from our own calldata to the new calldata.
calldatacopy(4, 36, 64)
// Copy `tokenId` field from our own calldata to the new calldata.
let assetDataOffset := calldataload(4)
calldatacopy(68, add(assetDataOffset, 72), 32)
/////// Call `token.transferFrom` using the calldata ///////
let token := calldataload(add(assetDataOffset, 40))
let success := call(
gas, // forward all gas
token, // call address of token contract
0, // don't send any ETH
0, // pointer to start of input
100, // length of input
0, // write output to null
0 // output size is 0 bytes
)
if success {
return(0, 0)
}
// Revert with `Error("TRANSFER_FAILED")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)
mstore(96, 0)
revert(0, 100)
}
// Revert if undefined function is called
revert(0, 0)
}
}
/// @dev Gets the proxy id associated with the proxy address.
/// @return Proxy id.
function getProxyId()
external
pure
returns (bytes4)
{
return PROXY_ID;
}
}

View File

@@ -1,335 +0,0 @@
/*
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;
import "../archive/MixinAssetProxyDispatcher.sol";
import "../archive/MixinAuthorizable.sol";
contract MultiAssetProxy is
MixinAssetProxyDispatcher,
MixinAuthorizable
{
// Id of this proxy.
bytes4 constant internal PROXY_ID = bytes4(keccak256("MultiAsset(uint256[],bytes[])"));
// solhint-disable-next-line payable-fallback
function ()
external
{
// NOTE: The below assembly assumes that clients do some input validation and that the input is properly encoded according to the AbiV2 specification.
// It is technically possible for inputs with very large lengths and offsets to cause overflows. However, this would make the calldata prohibitively
// expensive and we therefore do not check for overflows in these scenarios.
assembly {
// The first 4 bytes of calldata holds the function selector
let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)
// `transferFrom` will be called with the following parameters:
// assetData Encoded byte array.
// from Address to transfer asset from.
// to Address to transfer asset to.
// amount Amount of asset to transfer.
// bytes4(keccak256("transferFrom(bytes,address,address,uint256)")) = 0xa85e59e4
if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {
// To lookup a value in a mapping, we load from the storage location keccak256(k, p),
// where k is the key left padded to 32 bytes and p is the storage slot
mstore(0, caller)
mstore(32, authorized_slot)
// Revert if authorized[msg.sender] == false
if iszero(sload(keccak256(0, 64))) {
// Revert with `Error("SENDER_NOT_AUTHORIZED")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)
mstore(96, 0)
revert(0, 100)
}
// `transferFrom`.
// The function is marked `external`, so no abi decoding is done for
// us. Instead, we expect the `calldata` memory to contain the
// following:
//
// | Area | Offset | Length | Contents |
// |----------|--------|---------|-------------------------------------|
// | Header | 0 | 4 | function selector |
// | Params | | 4 * 32 | function parameters: |
// | | 4 | | 1. offset to assetData (*) |
// | | 36 | | 2. from |
// | | 68 | | 3. to |
// | | 100 | | 4. amount |
// | Data | | | assetData: |
// | | 132 | 32 | assetData Length |
// | | 164 | ** | assetData Contents |
//
// (*): offset is computed from start of function parameters, so offset
// by an additional 4 bytes in the calldata.
//
// (**): see table below to compute length of assetData Contents
//
// WARNING: The ABIv2 specification allows additional padding between
// the Params and Data section. This will result in a larger
// offset to assetData.
// Load offset to `assetData`
let assetDataOffset := add(calldataload(4), 4)
// Load length in bytes of `assetData`
let assetDataLength := calldataload(assetDataOffset)
// Asset data itself is encoded as follows:
//
// | Area | Offset | Length | Contents |
// |----------|-------------|---------|-------------------------------------|
// | Header | 0 | 4 | assetProxyId |
// | Params | | 2 * 32 | function parameters: |
// | | 4 | | 1. offset to amounts (*) |
// | | 36 | | 2. offset to nestedAssetData (*) |
// | Data | | | amounts: |
// | | 68 | 32 | amounts Length |
// | | 100 | a | amounts Contents |
// | | | | nestedAssetData: |
// | | 100 + a | 32 | nestedAssetData Length |
// | | 132 + a | b | nestedAssetData Contents (offsets) |
// | | 132 + a + b | | nestedAssetData[0, ..., len] |
// Assert that the length of asset data:
// 1. Must be at least 68 bytes (see table above)
// 2. Must be a multiple of 32 (excluding the 4-byte selector)
if or(lt(assetDataLength, 68), mod(sub(assetDataLength, 4), 32)) {
// Revert with `Error("INVALID_ASSET_DATA_LENGTH")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x00000019494e56414c49445f41535345545f444154415f4c454e475448000000)
mstore(96, 0)
revert(0, 100)
}
// End of asset data in calldata
// assetDataOffset
// + 32 (assetData len)
let assetDataEnd := add(assetDataOffset, add(assetDataLength, 32))
if gt(assetDataEnd, calldatasize()) {
// Revert with `Error("INVALID_ASSET_DATA_END")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x00000016494e56414c49445f41535345545f444154415f454e44000000000000)
mstore(96, 0)
revert(0, 100)
}
// In order to find the offset to `amounts`, we must add:
// assetDataOffset
// + 32 (assetData len)
// + 4 (assetProxyId)
let amountsOffset := calldataload(add(assetDataOffset, 36))
// In order to find the offset to `nestedAssetData`, we must add:
// assetDataOffset
// + 32 (assetData len)
// + 4 (assetProxyId)
// + 32 (amounts offset)
let nestedAssetDataOffset := calldataload(add(assetDataOffset, 68))
// In order to find the start of the `amounts` contents, we must add:
// assetDataOffset
// + 32 (assetData len)
// + 4 (assetProxyId)
// + amountsOffset
// + 32 (amounts len)
let amountsContentsStart := add(assetDataOffset, add(amountsOffset, 68))
// Load number of elements in `amounts`
let amountsLen := calldataload(sub(amountsContentsStart, 32))
// In order to find the start of the `nestedAssetData` contents, we must add:
// assetDataOffset
// + 32 (assetData len)
// + 4 (assetProxyId)
// + nestedAssetDataOffset
// + 32 (nestedAssetData len)
let nestedAssetDataContentsStart := add(assetDataOffset, add(nestedAssetDataOffset, 68))
// Load number of elements in `nestedAssetData`
let nestedAssetDataLen := calldataload(sub(nestedAssetDataContentsStart, 32))
// Revert if number of elements in `amounts` differs from number of elements in `nestedAssetData`
if sub(amountsLen, nestedAssetDataLen) {
// Revert with `Error("LENGTH_MISMATCH")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000000f4c454e4754485f4d49534d4154434800000000000000000000000000)
mstore(96, 0)
revert(0, 100)
}
// Copy `transferFrom` selector, offset to `assetData`, `from`, and `to` from calldata to memory
calldatacopy(
0, // memory can safely be overwritten from beginning
0, // start of calldata
100 // length of selector (4) and 3 params (32 * 3)
)
// Overwrite existing offset to `assetData` with our own
mstore(4, 128)
// Load `amount`
let amount := calldataload(100)
// Calculate number of bytes in `amounts` contents
let amountsByteLen := mul(amountsLen, 32)
// Initialize `assetProxyId` and `assetProxy` to 0
let assetProxyId := 0
let assetProxy := 0
// Loop through `amounts` and `nestedAssetData`, calling `transferFrom` for each respective element
for {let i := 0} lt(i, amountsByteLen) {i := add(i, 32)} {
// Calculate the total amount
let amountsElement := calldataload(add(amountsContentsStart, i))
let totalAmount := mul(amountsElement, amount)
// Revert if `amount` != 0 and multiplication resulted in an overflow
if iszero(or(
iszero(amount),
eq(div(totalAmount, amount), amountsElement)
)) {
// Revert with `Error("UINT256_OVERFLOW")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000001055494e543235365f4f564552464c4f57000000000000000000000000)
mstore(96, 0)
revert(0, 100)
}
// Write `totalAmount` to memory
mstore(100, totalAmount)
// Load offset to `nestedAssetData[i]`
let nestedAssetDataElementOffset := calldataload(add(nestedAssetDataContentsStart, i))
// In order to find the start of the `nestedAssetData[i]` contents, we must add:
// assetDataOffset
// + 32 (assetData len)
// + 4 (assetProxyId)
// + nestedAssetDataOffset
// + 32 (nestedAssetData len)
// + nestedAssetDataElementOffset
// + 32 (nestedAssetDataElement len)
let nestedAssetDataElementContentsStart := add(
assetDataOffset,
add(
nestedAssetDataOffset,
add(nestedAssetDataElementOffset, 100)
)
)
// Load length of `nestedAssetData[i]`
let nestedAssetDataElementLenStart := sub(nestedAssetDataElementContentsStart, 32)
let nestedAssetDataElementLen := calldataload(nestedAssetDataElementLenStart)
// Revert if the `nestedAssetData` does not contain a 4 byte `assetProxyId`
if lt(nestedAssetDataElementLen, 4) {
// Revert with `Error("LENGTH_GREATER_THAN_3_REQUIRED")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000001e4c454e4754485f475245415445525f5448414e5f335f524551554952)
mstore(96, 0x4544000000000000000000000000000000000000000000000000000000000000)
revert(0, 100)
}
// Load AssetProxy id
let currentAssetProxyId := and(
calldataload(nestedAssetDataElementContentsStart),
0xffffffff00000000000000000000000000000000000000000000000000000000
)
// Only load `assetProxy` if `currentAssetProxyId` does not equal `assetProxyId`
// We do not need to check if `currentAssetProxyId` is 0 since `assetProxy` is also initialized to 0
if sub(currentAssetProxyId, assetProxyId) {
// Update `assetProxyId`
assetProxyId := currentAssetProxyId
// To lookup a value in a mapping, we load from the storage location keccak256(k, p),
// where k is the key left padded to 32 bytes and p is the storage slot
mstore(132, assetProxyId)
mstore(164, assetProxies_slot)
assetProxy := sload(keccak256(132, 64))
}
// Revert if AssetProxy with given id does not exist
if iszero(assetProxy) {
// Revert with `Error("ASSET_PROXY_DOES_NOT_EXIST")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
mstore(64, 0x0000001a41535345545f50524f58595f444f45535f4e4f545f45584953540000)
mstore(96, 0)
revert(0, 100)
}
// Copy `nestedAssetData[i]` from calldata to memory
calldatacopy(
132, // memory slot after `amounts[i]`
nestedAssetDataElementLenStart, // location of `nestedAssetData[i]` in calldata
add(nestedAssetDataElementLen, 32) // `nestedAssetData[i].length` plus 32 byte length
)
// call `assetProxy.transferFrom`
let success := call(
gas, // forward all gas
assetProxy, // call address of asset proxy
0, // don't send any ETH
0, // pointer to start of input
add(164, nestedAssetDataElementLen), // length of input
0, // write output over memory that won't be reused
0 // don't copy output to memory
)
// Revert with reason given by AssetProxy if `transferFrom` call failed
if iszero(success) {
returndatacopy(
0, // copy to memory at 0
0, // copy from return data at 0
returndatasize() // copy all return data
)
revert(0, returndatasize())
}
}
// Return if no `transferFrom` calls reverted
return(0, 0)
}
// Revert if undefined function is called
revert(0, 0)
}
}
/// @dev Gets the proxy id associated with the proxy address.
/// @return Proxy id.
function getProxyId()
external
pure
returns (bytes4)
{
return PROXY_ID;
}
}

View File

@@ -1,83 +0,0 @@
/*
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;
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
// solhint-disable no-unused-vars
contract StaticCallProxy {
using LibBytes for bytes;
// Id of this proxy.
bytes4 constant internal PROXY_ID = bytes4(keccak256("StaticCall(address,bytes,bytes32)"));
/// @dev Makes a staticcall to a target address and verifies that the data returned matches the expected return data.
/// @param assetData Byte array encoded with staticCallTarget, staticCallData, and expectedCallResultHash
/// @param from This value is ignored.
/// @param to This value is ignored.
/// @param amount This value is ignored.
function transferFrom(
bytes calldata assetData,
address from,
address to,
uint256 amount
)
external
view
{
// Decode params from `assetData`
(
address staticCallTarget,
bytes memory staticCallData,
bytes32 expectedReturnDataHash
) = abi.decode(
assetData.sliceDestructive(4, assetData.length),
(address, bytes, bytes32)
);
// Execute staticcall
(bool success, bytes memory returnData) = staticCallTarget.staticcall(staticCallData);
// Revert with returned data if staticcall is unsuccessful
if (!success) {
assembly {
revert(add(returnData, 32), mload(returnData))
}
}
// Revert if hash of return data is not as expected
bytes32 returnDataHash = keccak256(returnData);
require(
expectedReturnDataHash == returnDataHash,
"UNEXPECTED_STATIC_CALL_RESULT"
);
}
/// @dev Gets the proxy id associated with the proxy address.
/// @return Proxy id.
function getProxyId()
external
pure
returns (bytes4)
{
return PROXY_ID;
}
}

View File

@@ -1,103 +0,0 @@
/*
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

@@ -1,75 +0,0 @@
/*
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 "../interfaces/IERC20Bridge.sol";
import "../interfaces/IChai.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
// solhint-disable space-after-comma
contract ChaiBridge is
IERC20Bridge,
DeploymentConstants
{
/// @dev Withdraws `amount` of `from` address's Dai from the Chai contract.
/// Transfers `amount` of Dai to `to` address.
/// @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 `0xdc1600f3` if successful.
function bridgeTransferFrom(
address /* tokenAddress */,
address from,
address to,
uint256 amount,
bytes calldata /* bridgeData */
)
external
returns (bytes4 success)
{
// Ensure that only the `ERC20BridgeProxy` can call this function.
require(
msg.sender == _getERC20BridgeProxyAddress(),
"ChaiBridge/ONLY_CALLABLE_BY_ERC20_BRIDGE_PROXY"
);
// Withdraw `from` address's Dai.
// NOTE: This contract must be approved to spend Chai on behalf of `from`.
bytes memory drawCalldata = abi.encodeWithSelector(
IChai(address(0)).draw.selector,
from,
amount
);
(bool success,) = _getChaiAddress().call(drawCalldata);
require(
success,
"ChaiBridge/DRAW_DAI_FAILED"
);
// Transfer Dai to `to`
// This will never fail if the `draw` call was successful
IERC20Token(_getDaiAddress()).transfer(to, amount);
return BRIDGE_SUCCESS;
}
}

View File

@@ -1,128 +0,0 @@
/*
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-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/ICurve.sol";
import "./MixinGasToken.sol";
// solhint-disable not-rely-on-time
// solhint-disable space-after-comma
contract CurveBridge is
IERC20Bridge,
IWallet,
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 to,
uint256 amount,
bytes calldata bridgeData
)
external
freesGasTokensFromCollector
returns (bytes4 success)
{
// Decode the bridge data to get the Curve metadata.
CurveBridgeData memory data = abi.decode(bridgeData, (CurveBridgeData));
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.approveIfBelow(fromTokenAddress, data.curveAddress, fromTokenBalance);
// Try to sell all of this contract's `fromTokenAddress` token balance.
if (data.version == 0) {
ICurve(data.curveAddress).exchange_underlying(
data.fromCoinIdx,
data.toCoinIdx,
// dx
fromTokenBalance,
// min dy
amount,
// expires
block.timestamp + 1
);
} else {
ICurve(data.curveAddress).exchange_underlying(
data.fromCoinIdx,
data.toCoinIdx,
// dx
fromTokenBalance,
// min dy
amount
);
}
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;
}
/// @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

@@ -1,200 +0,0 @@
/*
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

@@ -1,242 +0,0 @@
/*
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-utils/contracts/src/DeploymentConstants.sol";
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/IDydxBridge.sol";
import "../interfaces/IDydx.sol";
contract DydxBridge is
IERC20Bridge,
IDydxBridge,
DeploymentConstants
{
using LibSafeMath for uint256;
/// @dev Callback for `IERC20Bridge`. Deposits or withdraws tokens from a dydx account.
/// Notes:
/// 1. This bridge must be set as an operator of the input dydx account.
/// 2. This function may only be called in the context of the 0x Exchange.
/// 3. The maker or taker of the 0x order must be the dydx account owner.
/// 4. Deposits into dydx are made from the `from` address.
/// 5. Withdrawals from dydx are made to the `to` address.
/// 6. Calling this function must always withdraw at least `amount`,
/// otherwise the `ERC20Bridge` will revert.
/// @param from The sender of the tokens and owner of the dydx account.
/// @param to The recipient of the tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to deposit or withdraw.
/// @param encodedBridgeData An abi-encoded `BridgeData` struct.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address, /* toTokenAddress */
address from,
address to,
uint256 amount,
bytes calldata encodedBridgeData
)
external
returns (bytes4 success)
{
// Ensure that only the `ERC20BridgeProxy` can call this function.
require(
msg.sender == _getERC20BridgeProxyAddress(),
"DydxBridge/ONLY_CALLABLE_BY_ERC20_BRIDGE_PROXY"
);
// Decode bridge data.
(BridgeData memory bridgeData) = abi.decode(encodedBridgeData, (BridgeData));
// The dydx accounts are owned by the `from` address.
IDydx.AccountInfo[] memory accounts = _createAccounts(from, bridgeData);
// Create dydx actions to run on the dydx accounts.
IDydx.ActionArgs[] memory actions = _createActions(
from,
to,
amount,
bridgeData
);
// Run operation. This will revert on failure.
IDydx(_getDydxAddress()).operate(accounts, actions);
return BRIDGE_SUCCESS;
}
/// @dev Creates an array of accounts for dydx to operate on.
/// All accounts must belong to the same owner.
/// @param accountOwner Owner of the dydx account.
/// @param bridgeData A `BridgeData` struct.
function _createAccounts(
address accountOwner,
BridgeData memory bridgeData
)
internal
returns (IDydx.AccountInfo[] memory accounts)
{
uint256[] memory accountNumbers = bridgeData.accountNumbers;
uint256 nAccounts = accountNumbers.length;
accounts = new IDydx.AccountInfo[](nAccounts);
for (uint256 i = 0; i < nAccounts; ++i) {
accounts[i] = IDydx.AccountInfo({
owner: accountOwner,
number: accountNumbers[i]
});
}
}
/// @dev Creates an array of actions to carry out on dydx.
/// @param depositFrom Deposit value from this address (owner of the dydx account).
/// @param withdrawTo Withdraw value to this address.
/// @param amount The amount of value available to operate on.
/// @param bridgeData A `BridgeData` struct.
function _createActions(
address depositFrom,
address withdrawTo,
uint256 amount,
BridgeData memory bridgeData
)
internal
returns (IDydx.ActionArgs[] memory actions)
{
BridgeAction[] memory bridgeActions = bridgeData.actions;
uint256 nBridgeActions = bridgeActions.length;
actions = new IDydx.ActionArgs[](nBridgeActions);
for (uint256 i = 0; i < nBridgeActions; ++i) {
// Cache current bridge action.
BridgeAction memory bridgeAction = bridgeActions[i];
// Scale amount, if conversion rate is set.
uint256 scaledAmount;
if (bridgeAction.conversionRateDenominator > 0) {
scaledAmount = LibMath.safeGetPartialAmountFloor(
bridgeAction.conversionRateNumerator,
bridgeAction.conversionRateDenominator,
amount
);
} else {
scaledAmount = amount;
}
// Construct dydx action.
if (bridgeAction.actionType == BridgeActionType.Deposit) {
// Deposit tokens from the account owner into their dydx account.
actions[i] = _createDepositAction(
depositFrom,
scaledAmount,
bridgeAction
);
} else if (bridgeAction.actionType == BridgeActionType.Withdraw) {
// Withdraw tokens from dydx to the `otherAccount`.
actions[i] = _createWithdrawAction(
withdrawTo,
scaledAmount,
bridgeAction
);
} else {
// If all values in the `Action` enum are handled then this
// revert is unreachable: Solidity will revert when casting
// from `uint8` to `Action`.
revert("DydxBridge/UNRECOGNIZED_BRIDGE_ACTION");
}
}
}
/// @dev Returns a dydx `DepositAction`.
/// @param depositFrom Deposit tokens from this address who is also the account owner.
/// @param amount of tokens to deposit.
/// @param bridgeAction A `BridgeAction` struct.
/// @return depositAction The encoded dydx action.
function _createDepositAction(
address depositFrom,
uint256 amount,
BridgeAction memory bridgeAction
)
internal
pure
returns (
IDydx.ActionArgs memory depositAction
)
{
// Create dydx amount.
IDydx.AssetAmount memory dydxAmount = IDydx.AssetAmount({
sign: true, // true if positive.
denomination: IDydx.AssetDenomination.Wei, // Wei => actual token amount held in account.
ref: IDydx.AssetReference.Delta, // Delta => a relative amount.
value: amount // amount to deposit.
});
// Create dydx deposit action.
depositAction = IDydx.ActionArgs({
actionType: IDydx.ActionType.Deposit, // deposit tokens.
amount: dydxAmount, // amount to deposit.
accountIdx: bridgeAction.accountIdx, // index in the `accounts` when calling `operate`.
primaryMarketId: bridgeAction.marketId, // indicates which token to deposit.
otherAddress: depositFrom, // deposit from the account owner.
// unused parameters
secondaryMarketId: 0,
otherAccountIdx: 0,
data: hex''
});
}
/// @dev Returns a dydx `WithdrawAction`.
/// @param withdrawTo Withdraw tokens to this address.
/// @param amount of tokens to withdraw.
/// @param bridgeAction A `BridgeAction` struct.
/// @return withdrawAction The encoded dydx action.
function _createWithdrawAction(
address withdrawTo,
uint256 amount,
BridgeAction memory bridgeAction
)
internal
pure
returns (
IDydx.ActionArgs memory withdrawAction
)
{
// Create dydx amount.
IDydx.AssetAmount memory amountToWithdraw = IDydx.AssetAmount({
sign: false, // false if negative.
denomination: IDydx.AssetDenomination.Wei, // Wei => actual token amount held in account.
ref: IDydx.AssetReference.Delta, // Delta => a relative amount.
value: amount // amount to withdraw.
});
// Create withdraw action.
withdrawAction = IDydx.ActionArgs({
actionType: IDydx.ActionType.Withdraw, // withdraw tokens.
amount: amountToWithdraw, // amount to withdraw.
accountIdx: bridgeAction.accountIdx, // index in the `accounts` when calling `operate`.
primaryMarketId: bridgeAction.marketId, // indicates which token to withdraw.
otherAddress: withdrawTo, // withdraw tokens to this address.
// unused parameters
secondaryMarketId: 0,
otherAccountIdx: 0,
data: hex''
});
}
}

View File

@@ -1,98 +0,0 @@
/*
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-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/IEth2Dai.sol";
// solhint-disable space-after-comma
contract Eth2DaiBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the opposing asset
/// (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 to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// Decode the bridge data to get the `fromTokenAddress`.
(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.approveIfBelow(fromTokenAddress, address(exchange), fromTokenBalance);
// Try to sell all of this contract's `fromTokenAddress` token balance.
uint256 boughtAmount = exchange.sellAllAmount(
fromTokenAddress,
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;
}
/// @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

@@ -1,176 +0,0 @@
/*
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-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/DeploymentConstants.sol";
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/IKyberNetworkProxy.sol";
// solhint-disable space-after-comma
contract KyberBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
using LibSafeMath for uint256;
// @dev Structure used internally to get around stack limits.
struct TradeState {
IKyberNetworkProxy kyber;
IEtherToken weth;
address fromTokenAddress;
uint256 fromTokenBalance;
uint256 payableAmount;
uint256 conversionRate;
}
/// @dev Kyber ETH pseudo-address.
address constant public KYBER_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @dev `bridgeTransferFrom()` failure result.
bytes4 constant private BRIDGE_FAILED = 0x0;
/// @dev Precision of Kyber rates.
uint256 constant private KYBER_RATE_BASE = 10 ** 18;
// solhint-disable no-empty-blocks
/// @dev Payable fallback to receive ETH from Kyber.
function ()
external
payable
{}
/// @dev Callback for `IKyberBridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the opposing asset
/// 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 to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
TradeState memory state;
state.kyber = IKyberNetworkProxy(_getKyberNetworkProxyAddress());
state.weth = IEtherToken(_getWethAddress());
// Decode the bridge data to get the `fromTokenAddress`.
(state.fromTokenAddress) = abi.decode(bridgeData, (address));
// Query the balance of "from" tokens.
state.fromTokenBalance = IERC20Token(state.fromTokenAddress).balanceOf(address(this));
if (state.fromTokenBalance == 0) {
// Return failure if no input tokens.
return BRIDGE_FAILED;
}
// Compute the conversion rate, expressed in 18 decimals.
// The sequential notation is to get around stack limits.
state.conversionRate = KYBER_RATE_BASE;
state.conversionRate = state.conversionRate.safeMul(amount);
state.conversionRate = state.conversionRate.safeMul(
10 ** uint256(LibERC20Token.decimals(state.fromTokenAddress))
);
state.conversionRate = state.conversionRate.safeDiv(state.fromTokenBalance);
state.conversionRate = state.conversionRate.safeDiv(
10 ** uint256(LibERC20Token.decimals(toTokenAddress))
);
if (state.fromTokenAddress == toTokenAddress) {
// Just transfer the tokens if they're the same.
LibERC20Token.transfer(state.fromTokenAddress, to, state.fromTokenBalance);
return BRIDGE_SUCCESS;
} else if (state.fromTokenAddress != address(state.weth)) {
// If the input token is not WETH, grant an allowance to the exchange
// to spend them.
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;
state.payableAmount = state.fromTokenBalance;
state.weth.withdraw(state.fromTokenBalance);
}
bool isToTokenWeth = toTokenAddress == address(state.weth);
// Try to sell all of this contract's input token balance through
// `KyberNetworkProxy.trade()`.
uint256 boughtAmount = state.kyber.trade.value(state.payableAmount)(
// Input token.
state.fromTokenAddress,
// Sell amount.
state.fromTokenBalance,
// Output token.
isToTokenWeth ? KYBER_ETH_ADDRESS : toTokenAddress,
// Transfer to this contract if converting to ETH, otherwise
// transfer directly to the recipient.
isToTokenWeth ? address(uint160(address(this))) : address(uint160(to)),
// Buy as much as possible.
uint256(-1),
// Compute the minimum conversion rate, which is expressed in units with
// 18 decimal places.
state.conversionRate,
// No affiliate address.
address(0)
);
// Wrap ETH output and transfer to recipient.
if (isToTokenWeth) {
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;
}
/// @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

@@ -1,55 +0,0 @@
/*
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

@@ -1,220 +0,0 @@
/*
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-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/DeploymentConstants.sol";
import "../interfaces/IUniswapExchangeFactory.sol";
import "../interfaces/IUniswapExchange.sol";
import "../interfaces/IERC20Bridge.sol";
// solhint-disable space-after-comma
// solhint-disable not-rely-on-time
contract UniswapBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
// Struct to hold `bridgeTransferFrom()` local variables in memory and to avoid
// stack overflows.
struct TransferState {
IUniswapExchange exchange;
uint256 fromTokenBalance;
IEtherToken weth;
uint256 boughtAmount;
}
// solhint-disable no-empty-blocks
/// @dev Payable fallback to receive ETH from uniswap.
function ()
external
payable
{}
/// @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 "from" token address.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// State memory object to avoid stack overflows.
TransferState memory state;
// Decode the bridge data to get the `fromTokenAddress`.
(address fromTokenAddress) = abi.decode(bridgeData, (address));
// Just transfer the tokens if they're the same.
if (fromTokenAddress == toTokenAddress) {
LibERC20Token.transfer(fromTokenAddress, to, amount);
return BRIDGE_SUCCESS;
}
// Get the exchange for the token pair.
state.exchange = _getUniswapExchangeForTokenPair(
fromTokenAddress,
toTokenAddress
);
// Get our balance of `fromTokenAddress` token.
state.fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
// Get the weth contract.
state.weth = IEtherToken(_getWethAddress());
// Convert from WETH to a token.
if (fromTokenAddress == address(state.weth)) {
// Unwrap the WETH.
state.weth.withdraw(state.fromTokenBalance);
// Buy as much of `toTokenAddress` token with ETH as possible and
// transfer it to `to`.
state.boughtAmount = state.exchange.ethToTokenTransferInput.value(state.fromTokenBalance)(
// Minimum buy amount.
amount,
// Expires after this block.
block.timestamp,
// Recipient is `to`.
to
);
// Convert from a token to WETH.
} else if (toTokenAddress == address(state.weth)) {
// Grant the exchange an allowance.
_grantExchangeAllowance(state.exchange, fromTokenAddress, state.fromTokenBalance);
// Buy as much ETH with `fromTokenAddress` token as possible.
state.boughtAmount = state.exchange.tokenToEthSwapInput(
// Sell all tokens we hold.
state.fromTokenBalance,
// Minimum buy amount.
amount,
// Expires after this block.
block.timestamp
);
// Wrap the ETH.
state.weth.deposit.value(state.boughtAmount)();
// Transfer the WETH to `to`.
IEtherToken(toTokenAddress).transfer(to, state.boughtAmount);
// Convert from one token to another.
} else {
// Grant the exchange an allowance.
_grantExchangeAllowance(state.exchange, fromTokenAddress, state.fromTokenBalance);
// Buy as much `toTokenAddress` token with `fromTokenAddress` token
// and transfer it to `to`.
state.boughtAmount = state.exchange.tokenToTokenTransferInput(
// Sell all tokens we hold.
state.fromTokenBalance,
// Minimum buy amount.
amount,
// Must buy at least 1 intermediate ETH.
1,
// Expires after this block.
block.timestamp,
// Recipient is `to`.
to,
// Convert to `toTokenAddress`.
toTokenAddress
);
}
emit ERC20BridgeTransfer(
fromTokenAddress,
toTokenAddress,
state.fromTokenBalance,
state.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 Success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
/// @dev Grants an unlimited allowance to the exchange for its token
/// on behalf of this contract.
/// @param exchange The Uniswap token exchange.
/// @param tokenAddress The token address for the exchange.
/// @param minimumAllowance The minimum necessary allowance.
function _grantExchangeAllowance(
IUniswapExchange exchange,
address tokenAddress,
uint256 minimumAllowance
)
private
{
LibERC20Token.approveIfBelow(
tokenAddress,
address(exchange),
minimumAllowance
);
}
/// @dev Retrieves the uniswap exchange for a given token pair.
/// In the case of a WETH-token exchange, this will be the non-WETH token.
/// In th ecase of a token-token exchange, this will be the first token.
/// @param fromTokenAddress The address of the token we are converting from.
/// @param toTokenAddress The address of the token we are converting to.
/// @return exchange The uniswap exchange.
function _getUniswapExchangeForTokenPair(
address fromTokenAddress,
address toTokenAddress
)
private
view
returns (IUniswapExchange exchange)
{
address exchangeTokenAddress = fromTokenAddress;
// Whichever isn't WETH is the exchange token.
if (fromTokenAddress == _getWethAddress()) {
exchangeTokenAddress = toTokenAddress;
}
exchange = IUniswapExchange(
IUniswapExchangeFactory(_getUniswapExchangeFactoryAddress())
.getExchange(exchangeTokenAddress)
);
require(address(exchange) != address(0), "NO_UNISWAP_EXCHANGE_FOR_TOKEN");
return exchange;
}
}

View File

@@ -1,135 +0,0 @@
/*
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

@@ -1,88 +0,0 @@
/*
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.
*/
// solhint-disable
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
// @dev Interface of the asset proxy's assetData.
// The asset proxies take an ABI encoded `bytes assetData` as argument.
// This argument is ABI encoded as one of the methods of this interface.
interface IAssetData {
/// @dev Function signature for encoding ERC20 assetData.
/// @param tokenAddress Address of ERC20Token contract.
function ERC20Token(address tokenAddress)
external;
/// @dev Function signature for encoding ERC721 assetData.
/// @param tokenAddress Address of ERC721 token contract.
/// @param tokenId Id of ERC721 token to be transferred.
function ERC721Token(
address tokenAddress,
uint256 tokenId
)
external;
/// @dev Function signature for encoding ERC1155 assetData.
/// @param tokenAddress Address of ERC1155 token contract.
/// @param tokenIds Array of ids of tokens to be transferred.
/// @param values Array of values that correspond to each token id to be transferred.
/// Note that each value will be multiplied by the amount being filled in the order before transferring.
/// @param callbackData Extra data to be passed to receiver's `onERC1155Received` callback function.
function ERC1155Assets(
address tokenAddress,
uint256[] calldata tokenIds,
uint256[] calldata values,
bytes calldata callbackData
)
external;
/// @dev Function signature for encoding MultiAsset assetData.
/// @param values Array of amounts that correspond to each asset to be transferred.
/// Note that each value will be multiplied by the amount being filled in the order before transferring.
/// @param nestedAssetData Array of assetData fields that will be be dispatched to their correspnding AssetProxy contract.
function MultiAsset(
uint256[] calldata values,
bytes[] calldata nestedAssetData
)
external;
/// @dev Function signature for encoding StaticCall assetData.
/// @param staticCallTargetAddress Address that will execute the staticcall.
/// @param staticCallData Data that will be executed via staticcall on the staticCallTargetAddress.
/// @param expectedReturnDataHash Keccak-256 hash of the expected staticcall return data.
function StaticCall(
address staticCallTargetAddress,
bytes calldata staticCallData,
bytes32 expectedReturnDataHash
)
external;
/// @dev Function signature for encoding ERC20Bridge assetData.
/// @param tokenAddress Address of token to transfer.
/// @param bridgeAddress Address of the bridge contract.
/// @param bridgeData Arbitrary data to be passed to the bridge contract.
function ERC20Bridge(
address tokenAddress,
address bridgeAddress,
bytes calldata bridgeData
)
external;
}

View File

@@ -1,43 +0,0 @@
/*
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;
contract IAssetProxy {
/// @dev Transfers assets. Either succeeds or throws.
/// @param assetData Byte array encoded for the respective asset proxy.
/// @param from Address to transfer asset from.
/// @param to Address to transfer asset to.
/// @param amount Amount of asset to transfer.
function transferFrom(
bytes calldata assetData,
address from,
address to,
uint256 amount
)
external;
/// @dev Gets the proxy id associated with the proxy address.
/// @return Proxy id.
function getProxyId()
external
pure
returns (bytes4);
}

View File

@@ -1,43 +0,0 @@
/*
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;
contract IAssetProxyDispatcher {
// Logs registration of new asset proxy
event AssetProxyRegistered(
bytes4 id, // Id of new registered AssetProxy.
address assetProxy // Address of new registered AssetProxy.
);
/// @dev Registers an asset proxy to its asset proxy id.
/// Once an asset proxy is registered, it cannot be unregistered.
/// @param assetProxy Address of new asset proxy to register.
function registerAssetProxy(address assetProxy)
external;
/// @dev Gets an asset proxy.
/// @param assetProxyId Id of the asset proxy.
/// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered.
function getAssetProxy(bytes4 assetProxyId)
external
view
returns (address);
}

View File

@@ -1,64 +0,0 @@
/*
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;
import "@0x/contracts-utils/contracts/src/interfaces/IOwnable.sol";
contract IAuthorizable is
IOwnable
{
// Event logged when a new address is authorized.
event AuthorizedAddressAdded(
address indexed target,
address indexed caller
);
// Event logged when a currently authorized address is unauthorized.
event AuthorizedAddressRemoved(
address indexed target,
address indexed caller
);
/// @dev Authorizes an address.
/// @param target Address to authorize.
function addAuthorizedAddress(address target)
external;
/// @dev Removes authorizion of an address.
/// @param target Address to remove authorization from.
function removeAuthorizedAddress(address target)
external;
/// @dev Removes authorizion of an address.
/// @param target Address to remove authorization from.
/// @param index Index of target in authorities array.
function removeAuthorizedAddressAtIndex(
address target,
uint256 index
)
external;
/// @dev Gets all authorized addresses.
/// @return Array of authorized addresses.
function getAuthorizedAddresses()
external
view
returns (address[] memory);
}

View File

@@ -1,39 +0,0 @@
/*
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

@@ -1,66 +0,0 @@
/*
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;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
contract PotLike {
function chi() external returns (uint256);
function rho() external returns (uint256);
function drip() external returns (uint256);
function join(uint256) external;
function exit(uint256) external;
}
// The actual Chai contract can be found here: https://github.com/dapphub/chai
contract IChai is
IERC20Token
{
/// @dev Withdraws Dai owned by `src`
/// @param src Address that owns Dai.
/// @param wad Amount of Dai to withdraw.
function draw(
address src,
uint256 wad
)
external;
/// @dev Queries Dai balance of Chai holder.
/// @param usr Address of Chai holder.
/// @return Dai balance.
function dai(address usr)
external
returns (uint256);
/// @dev Queries the Pot contract used by the Chai contract.
function pot()
external
returns (PotLike);
/// @dev Deposits Dai in exchange for Chai
/// @param dst Address to receive Chai.
/// @param wad Amount of Dai to deposit.
function join(
address dst,
uint256 wad
)
external;
}

View File

@@ -1,86 +0,0 @@
/*
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;
// solhint-disable func-name-mixedcase
interface ICurve {
/// @dev Sell `sellAmount` of `fromToken` token and receive `toToken` token.
/// This function exists on early versions of Curve (USDC/DAI)
/// @param i The token index being sold.
/// @param j The token index being bought.
/// @param sellAmount The amount of token being bought.
/// @param minBuyAmount The minimum buy amount of the token being bought.
/// @param deadline The time in seconds when this operation should expire.
function exchange_underlying(
int128 i,
int128 j,
uint256 sellAmount,
uint256 minBuyAmount,
uint256 deadline
)
external;
/// @dev Sell `sellAmount` of `fromToken` token and receive `toToken` token.
/// 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 sellAmount The amount of token being bought.
/// @param minBuyAmount The minimum buy amount of the token being bought.
function exchange_underlying(
int128 i,
int128 j,
uint256 sellAmount,
uint256 minBuyAmount
)
external;
/// @dev Get the amount of `toToken` by selling `sellAmount` of `fromToken`
/// @param i The token index being sold.
/// @param j The token index being bought.
/// @param sellAmount The amount of token being bought.
function get_dy_underlying(
int128 i,
int128 j,
uint256 sellAmount
)
external
returns (uint256 dy);
/// @dev Get the amount of `fromToken` by buying `buyAmount` of `toToken`
/// @param i The token index being sold.
/// @param j The token index being bought.
/// @param buyAmount The amount of token being bought.
function get_dx_underlying(
int128 i,
int128 j,
uint256 buyAmount
)
external
returns (uint256 dx);
/// @dev Get the underlying token address from the token index
/// @param i The token index.
function underlying_coins(
int128 i
)
external
returns (address tokenAddress);
}

View File

@@ -1,192 +0,0 @@
/*
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;
interface IDydx {
/// @dev Represents the unique key that specifies an account
struct AccountInfo {
address owner; // The address that owns the account
uint256 number; // A nonce that allows a single address to control many accounts
}
enum ActionType {
Deposit, // supply tokens
Withdraw, // borrow tokens
Transfer, // transfer balance between accounts
Buy, // buy an amount of some token (externally)
Sell, // sell an amount of some token (externally)
Trade, // trade tokens against another account
Liquidate, // liquidate an undercollateralized or expiring account
Vaporize, // use excess tokens to zero-out a completely negative account
Call // send arbitrary data to an address
}
/// @dev Arguments that are passed to Solo in an ordered list as part of a single operation.
/// Each ActionArgs has an actionType which specifies which action struct that this data will be
/// parsed into before being processed.
struct ActionArgs {
ActionType actionType;
uint256 accountIdx;
AssetAmount amount;
uint256 primaryMarketId;
uint256 secondaryMarketId;
address otherAddress;
uint256 otherAccountIdx;
bytes data;
}
enum AssetDenomination {
Wei, // the amount is denominated in wei
Par // the amount is denominated in par
}
enum AssetReference {
Delta, // the amount is given as a delta from the current value
Target // the amount is given as an exact number to end up at
}
struct AssetAmount {
bool sign; // true if positive
AssetDenomination denomination;
AssetReference ref;
uint256 value;
}
struct D256 {
uint256 value;
}
struct Value {
uint256 value;
}
struct Price {
uint256 value;
}
struct OperatorArg {
address operator;
bool trusted;
}
/// @dev The global risk parameters that govern the health and security of the system
struct RiskParams {
// Required ratio of over-collateralization
D256 marginRatio;
// Percentage penalty incurred by liquidated accounts
D256 liquidationSpread;
// Percentage of the borrower's interest fee that gets passed to the suppliers
D256 earningsRate;
// The minimum absolute borrow value of an account
// There must be sufficient incentivize to liquidate undercollateralized accounts
Value minBorrowedValue;
}
/// @dev The main entry-point to Solo that allows users and contracts to manage accounts.
/// Take one or more actions on one or more accounts. The msg.sender must be the owner or
/// operator of all accounts except for those being liquidated, vaporized, or traded with.
/// One call to operate() is considered a singular "operation". Account collateralization is
/// ensured only after the completion of the entire operation.
/// @param accounts A list of all accounts that will be used in this operation. Cannot contain
/// duplicates. In each action, the relevant account will be referred-to by its
/// index in the list.
/// @param actions An ordered list of all actions that will be taken in this operation. The
/// actions will be processed in order.
function operate(
AccountInfo[] calldata accounts,
ActionArgs[] calldata actions
)
external;
// @dev Approves/disapproves any number of operators. An operator is an external address that has the
// same permissions to manipulate an account as the owner of the account. Operators are simply
// addresses and therefore may either be externally-owned Ethereum accounts OR smart contracts.
// Operators are also able to act as AutoTrader contracts on behalf of the account owner if the
// operator is a smart contract and implements the IAutoTrader interface.
// @param args A list of OperatorArgs which have an address and a boolean. The boolean value
// denotes whether to approve (true) or revoke approval (false) for that address.
function setOperators(OperatorArg[] calldata args) external;
/// @dev Return true if a particular address is approved as an operator for an owner's accounts.
/// Approved operators can act on the accounts of the owner as if it were the operator's own.
/// @param owner The owner of the accounts
/// @param operator The possible operator
/// @return isLocalOperator True if operator is approved for owner's accounts
function getIsLocalOperator(
address owner,
address operator
)
external
view
returns (bool isLocalOperator);
/// @dev Get the ERC20 token address for a market.
/// @param marketId The market to query
/// @return tokenAddress The token address
function getMarketTokenAddress(
uint256 marketId
)
external
view
returns (address tokenAddress);
/// @dev Get all risk parameters in a single struct.
/// @return riskParams All global risk parameters
function getRiskParams()
external
view
returns (RiskParams memory riskParams);
/// @dev Get the price of the token for a market.
/// @param marketId The market to query
/// @return price The price of each atomic unit of the token
function getMarketPrice(
uint256 marketId
)
external
view
returns (Price memory price);
/// @dev Get the margin premium for a market. A margin premium makes it so that any positions that
/// include the market require a higher collateralization to avoid being liquidated.
/// @param marketId The market to query
/// @return premium The market's margin premium
function getMarketMarginPremium(uint256 marketId)
external
view
returns (D256 memory premium);
/// @dev Get the total supplied and total borrowed values of an account adjusted by the marginPremium
/// of each market. Supplied values are divided by (1 + marginPremium) for each market and
/// borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
/// adjusted values gives the margin-ratio of the account which will be compared to the global
/// margin-ratio when determining if the account can be liquidated.
/// @param account The account to query
/// @return supplyValue The supplied value of the account (adjusted for marginPremium)
/// @return borrowValue The borrowed value of the account (adjusted for marginPremium)
function getAdjustedAccountValues(
AccountInfo calldata account
)
external
view
returns (Value memory supplyValue, Value memory borrowValue);
}

View File

@@ -1,42 +0,0 @@
/*
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 IDydxBridge {
/// @dev This is the subset of `IDydx.ActionType` that are supported by the bridge.
enum BridgeActionType {
Deposit, // Deposit tokens into dydx account.
Withdraw // Withdraw tokens from dydx account.
}
struct BridgeAction {
BridgeActionType actionType; // Action to run on dydx account.
uint256 accountIdx; // Index in `BridgeData.accountNumbers` for this action.
uint256 marketId; // Market to operate on.
uint256 conversionRateNumerator; // Optional. If set, transfer amount is scaled by (conversionRateNumerator/conversionRateDenominator).
uint256 conversionRateDenominator; // Optional. If set, transfer amount is scaled by (conversionRateNumerator/conversionRateDenominator).
}
struct BridgeData {
uint256[] accountNumbers; // Account number used to identify the owner's specific account.
BridgeAction[] actions; // Actions to carry out on the owner's accounts.
}
}

View File

@@ -1,59 +0,0 @@
/*
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;
contract IERC20Bridge {
/// @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 `0xdc1600f3` if successful.
function bridgeTransferFrom(
address tokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success);
}

View File

@@ -1,38 +0,0 @@
/*
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 IEth2Dai {
/// @dev Sell `sellAmount` of `fromToken` token and receive `toToken` token.
/// @param fromToken The token being sold.
/// @param sellAmount The amount of `fromToken` token being sold.
/// @param toToken The token being bought.
/// @param minFillAmount Minimum amount of `toToken` token to buy.
/// @return fillAmount Amount of `toToken` bought.
function sellAllAmount(
address fromToken,
uint256 sellAmount,
address toToken,
uint256 minFillAmount
)
external
returns (uint256 fillAmount);
}

View File

@@ -1,40 +0,0 @@
/*
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

@@ -1,46 +0,0 @@
/*
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 IKyberNetworkProxy {
/// @dev Sells `sellTokenAddress` tokens for `buyTokenAddress` tokens.
/// @param sellTokenAddress Token to sell.
/// @param sellAmount Amount of tokens to sell.
/// @param buyTokenAddress Token to buy.
/// @param recipientAddress Address to send bought tokens to.
/// @param maxBuyTokenAmount A limit on the amount of tokens to buy.
/// @param minConversionRate The minimal conversion rate. If actual rate
/// is lower, trade is canceled.
/// @param walletId The wallet ID to send part of the fees
/// @return boughtAmount Amount of tokens bought.
function trade(
address sellTokenAddress,
uint256 sellAmount,
address buyTokenAddress,
address payable recipientAddress,
uint256 maxBuyTokenAmount,
uint256 minConversionRate,
address walletId
)
external
payable
returns(uint256 boughtAmount);
}

View File

@@ -1,70 +0,0 @@
/*
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 IUniswapExchange {
/// @dev Buys at least `minTokensBought` tokens with ETH and transfer them
/// to `recipient`.
/// @param minTokensBought The minimum number of tokens to buy.
/// @param deadline Time when this order expires.
/// @param recipient Who to transfer the tokens to.
/// @return tokensBought Amount of tokens bought.
function ethToTokenTransferInput(
uint256 minTokensBought,
uint256 deadline,
address recipient
)
external
payable
returns (uint256 tokensBought);
/// @dev Buys at least `minEthBought` ETH with tokens.
/// @param tokensSold Amount of tokens to sell.
/// @param minEthBought The minimum amount of ETH to buy.
/// @param deadline Time when this order expires.
/// @return ethBought Amount of tokens bought.
function tokenToEthSwapInput(
uint256 tokensSold,
uint256 minEthBought,
uint256 deadline
)
external
returns (uint256 ethBought);
/// @dev Buys at least `minTokensBought` tokens with the exchange token
/// and transfer them to `recipient`.
/// @param minTokensBought The minimum number of tokens to buy.
/// @param minEthBought The minimum amount of intermediate ETH to buy.
/// @param deadline Time when this order expires.
/// @param recipient Who to transfer the tokens to.
/// @param toTokenAddress The token being bought.
/// @return tokensBought Amount of tokens bought.
function tokenToTokenTransferInput(
uint256 tokensSold,
uint256 minTokensBought,
uint256 minEthBought,
uint256 deadline,
address recipient,
address toTokenAddress
)
external
returns (uint256 tokensBought);
}

View File

@@ -1,32 +0,0 @@
/*
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;
import "./IUniswapExchange.sol";
interface IUniswapExchangeFactory {
/// @dev Get the exchange for a token.
/// @param tokenAddress The address of the token contract.
function getExchange(address tokenAddress)
external
view
returns (address);
}

View File

@@ -1,40 +0,0 @@
/*
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

@@ -1,80 +0,0 @@
/*
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 "../src/bridges/ChaiBridge.sol";
import "@0x/contracts-erc20/contracts/src/ERC20Token.sol";
contract TestChaiDai is
ERC20Token
{
address private constant ALWAYS_REVERT_ADDRESS = address(1);
function draw(
address from,
uint256 amount
)
external
{
if (from == ALWAYS_REVERT_ADDRESS) {
revert();
}
balances[msg.sender] += amount;
}
}
contract TestChaiBridge is
ChaiBridge
{
address public testChaiDai;
address private constant ALWAYS_REVERT_ADDRESS = address(1);
constructor()
public
{
testChaiDai = address(new TestChaiDai());
}
function _getDaiAddress()
internal
view
returns (address)
{
return testChaiDai;
}
function _getChaiAddress()
internal
view
returns (address)
{
return testChaiDai;
}
function _getERC20BridgeProxyAddress()
internal
view
returns (address)
{
return msg.sender == ALWAYS_REVERT_ADDRESS ? address(0) : msg.sender;
}
}

View File

@@ -1,244 +0,0 @@
/*
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

@@ -1,246 +0,0 @@
/*
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 "../src/bridges/DydxBridge.sol";
// solhint-disable no-empty-blocks
contract TestDydxBridgeToken {
uint256 private constant INIT_HOLDER_BALANCE = 10 * 10**18; // 10 tokens
mapping (address => uint256) private _balances;
/// @dev Sets initial balance of token holders.
constructor(address[] memory holders)
public
{
for (uint256 i = 0; i != holders.length; ++i) {
_balances[holders[i]] = INIT_HOLDER_BALANCE;
}
_balances[msg.sender] = INIT_HOLDER_BALANCE;
}
/// @dev Basic transferFrom implementation.
function transferFrom(address from, address to, uint256 amount)
external
returns (bool)
{
if (_balances[from] < amount || _balances[to] + amount < _balances[to]) {
return false;
}
_balances[from] -= amount;
_balances[to] += amount;
return true;
}
/// @dev Returns balance of `holder`.
function balanceOf(address holder)
external
view
returns (uint256)
{
return _balances[holder];
}
}
// solhint-disable space-after-comma
contract TestDydxBridge is
IDydx,
DydxBridge
{
address private constant ALWAYS_REVERT_ADDRESS = address(1);
address private _testTokenAddress;
bool private _shouldRevertOnOperate;
event OperateAccount(
address owner,
uint256 number
);
event OperateAction(
ActionType actionType,
uint256 accountIdx,
bool amountSign,
AssetDenomination amountDenomination,
AssetReference amountRef,
uint256 amountValue,
uint256 primaryMarketId,
uint256 secondaryMarketId,
address otherAddress,
uint256 otherAccountId,
bytes data
);
constructor(address[] memory holders)
public
{
// Deploy a test token. This represents the asset being deposited/withdrawn from dydx.
_testTokenAddress = address(new TestDydxBridgeToken(holders));
}
/// @dev Simulates `operate` in dydx contract.
/// Emits events so that arguments can be validated client-side.
function operate(
AccountInfo[] calldata accounts,
ActionArgs[] calldata actions
)
external
{
if (_shouldRevertOnOperate) {
revert("TestDydxBridge/SHOULD_REVERT_ON_OPERATE");
}
for (uint i = 0; i < accounts.length; ++i) {
emit OperateAccount(
accounts[i].owner,
accounts[i].number
);
}
for (uint i = 0; i < actions.length; ++i) {
emit OperateAction(
actions[i].actionType,
actions[i].accountIdx,
actions[i].amount.sign,
actions[i].amount.denomination,
actions[i].amount.ref,
actions[i].amount.value,
actions[i].primaryMarketId,
actions[i].secondaryMarketId,
actions[i].otherAddress,
actions[i].otherAccountIdx,
actions[i].data
);
if (actions[i].actionType == IDydx.ActionType.Withdraw) {
require(
IERC20Token(_testTokenAddress).transferFrom(
address(this),
actions[i].otherAddress,
actions[i].amount.value
),
"TestDydxBridge/WITHDRAW_FAILED"
);
} else if (actions[i].actionType == IDydx.ActionType.Deposit) {
require(
IERC20Token(_testTokenAddress).transferFrom(
actions[i].otherAddress,
address(this),
actions[i].amount.value
),
"TestDydxBridge/DEPOSIT_FAILED"
);
} else {
revert("TestDydxBridge/UNSUPPORTED_ACTION");
}
}
}
/// @dev If `true` then subsequent calls to `operate` will revert.
function setRevertOnOperate(bool shouldRevert)
external
{
_shouldRevertOnOperate = shouldRevert;
}
/// @dev Returns test token.
function getTestToken()
external
returns (address)
{
return _testTokenAddress;
}
/// @dev Unused.
function setOperators(OperatorArg[] calldata args) external {}
/// @dev Unused.
function getIsLocalOperator(
address owner,
address operator
)
external
view
returns (bool isLocalOperator)
{}
/// @dev Unused.
function getMarketTokenAddress(
uint256 marketId
)
external
view
returns (address tokenAddress)
{}
/// @dev Unused.
function getRiskParams()
external
view
returns (RiskParams memory riskParams)
{}
/// @dev Unsused.
function getMarketPrice(
uint256 marketId
)
external
view
returns (Price memory price)
{}
/// @dev Unsused
function getMarketMarginPremium(uint256 marketId)
external
view
returns (IDydx.D256 memory premium)
{}
/// @dev Unused.
function getAdjustedAccountValues(
AccountInfo calldata account
)
external
view
returns (Value memory supplyValue, Value memory borrowValue)
{}
/// @dev overrides `_getDydxAddress()` from `DeploymentConstants` to return this address.
function _getDydxAddress()
internal
view
returns (address)
{
return address(this);
}
/// @dev overrides `_getERC20BridgeProxyAddress()` from `DeploymentConstants` for testing.
function _getERC20BridgeProxyAddress()
internal
view
returns (address)
{
return msg.sender == ALWAYS_REVERT_ADDRESS ? address(0) : msg.sender;
}
}

View File

@@ -1,108 +0,0 @@
/*
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 "../src/interfaces/IERC20Bridge.sol";
/// @dev Test bridge token
contract TestERC20BridgeToken {
mapping (address => uint256) private _balances;
function addBalance(address owner, int256 amount)
external
{
setBalance(owner, uint256(int256(balanceOf(owner)) + amount));
}
function setBalance(address owner, uint256 balance)
public
{
_balances[owner] = balance;
}
function balanceOf(address owner)
public
view
returns (uint256)
{
return _balances[owner];
}
}
/// @dev Test bridge contract.
contract TestERC20Bridge is
IERC20Bridge
{
TestERC20BridgeToken public testToken;
event BridgeWithdrawTo(
address tokenAddress,
address from,
address to,
uint256 amount,
bytes bridgeData
);
constructor() public {
testToken = new TestERC20BridgeToken();
}
function setTestTokenBalance(address owner, uint256 balance)
external
{
testToken.setBalance(owner, balance);
}
function bridgeTransferFrom(
address tokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4)
{
emit BridgeWithdrawTo(
tokenAddress,
from,
to,
amount,
bridgeData
);
// Unpack the bridgeData.
(
int256 transferAmount,
bytes memory revertData,
bytes memory returnData
) = abi.decode(bridgeData, (int256, bytes, bytes));
// If `revertData` is set, revert.
if (revertData.length != 0) {
assembly { revert(add(revertData, 0x20), mload(revertData)) }
}
// Increase `to`'s balance by `transferAmount`.
TestERC20BridgeToken(tokenAddress).addBalance(to, transferAmount);
// Return `returnData`.
assembly { return(add(returnData, 0x20), mload(returnData)) }
}
}

View File

@@ -1,206 +0,0 @@
/*
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 "../src/bridges/Eth2DaiBridge.sol";
import "../src/interfaces/IEth2Dai.sol";
// solhint-disable no-simple-event-func-name
contract TestEvents {
event TokenTransfer(
address token,
address from,
address to,
uint256 amount
);
event TokenApprove(
address token,
address spender,
uint256 allowance
);
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(msg.sender, spender, allowance);
}
}
/// @dev A minimalist ERC20 token.
contract TestToken {
mapping (address => uint256) public balances;
string private _nextTransferRevertReason;
bytes private _nextTransferReturnData;
/// @dev Just calls `raiseTokenTransfer()` on the caller.
function transfer(address to, uint256 amount)
external
returns (bool)
{
TestEvents(msg.sender).raiseTokenTransfer(msg.sender, to, amount);
if (bytes(_nextTransferRevertReason).length != 0) {
revert(_nextTransferRevertReason);
}
bytes memory returnData = _nextTransferReturnData;
assembly { return(add(returnData, 0x20), mload(returnData)) }
}
/// @dev Set the balance for `owner`.
function setBalance(address owner, uint256 balance)
external
{
balances[owner] = balance;
}
/// @dev Set the behavior of the `transfer()` call.
function setTransferBehavior(
string calldata revertReason,
bytes calldata returnData
)
external
{
_nextTransferRevertReason = revertReason;
_nextTransferReturnData = returnData;
}
/// @dev Just calls `raiseTokenApprove()` on the caller.
function approve(address spender, uint256 allowance)
external
returns (bool)
{
TestEvents(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 Eth2DaiBridge overridden to mock tokens and
/// implement IEth2Dai.
contract TestEth2DaiBridge is
TestEvents,
IEth2Dai,
Eth2DaiBridge
{
event SellAllAmount(
address sellToken,
uint256 sellTokenAmount,
address buyToken,
uint256 minimumFillAmount
);
mapping (address => TestToken) public testTokens;
string private _nextRevertReason;
uint256 private _nextFillAmount;
/// @dev Create a token and set this contract's balance.
function createToken(uint256 balance)
external
returns (address tokenAddress)
{
TestToken token = new TestToken();
testTokens[address(token)] = token;
token.setBalance(address(this), balance);
return address(token);
}
/// @dev Set the behavior for `IEth2Dai.sellAllAmount()`.
function setFillBehavior(string calldata revertReason, uint256 fillAmount)
external
{
_nextRevertReason = revertReason;
_nextFillAmount = fillAmount;
}
/// @dev Set the behavior of a token's `transfer()`.
function setTransferBehavior(
address tokenAddress,
string calldata revertReason,
bytes calldata returnData
)
external
{
testTokens[tokenAddress].setTransferBehavior(revertReason, returnData);
}
/// @dev Implementation of `IEth2Dai.sellAllAmount()`
function sellAllAmount(
address sellTokenAddress,
uint256 sellTokenAmount,
address buyTokenAddress,
uint256 minimumFillAmount
)
external
returns (uint256 fillAmount)
{
emit SellAllAmount(
sellTokenAddress,
sellTokenAmount,
buyTokenAddress,
minimumFillAmount
);
if (bytes(_nextRevertReason).length != 0) {
revert(_nextRevertReason);
}
return _nextFillAmount;
}
// @dev This contract will double as the Eth2Dai contract.
function _getEth2DaiAddress()
internal
view
returns (address)
{
return address(this);
}
}

View File

@@ -1,328 +0,0 @@
/*
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 "../src/bridges/KyberBridge.sol";
import "../src/interfaces/IKyberNetworkProxy.sol";
// solhint-disable no-simple-event-func-name
interface ITestContract {
function wethWithdraw(
address payable ownerAddress,
uint256 amount
)
external;
function wethDeposit(
address ownerAddress
)
external
payable;
function tokenTransfer(
address ownerAddress,
address recipientAddress,
uint256 amount
)
external
returns (bool success);
function tokenApprove(
address ownerAddress,
address spenderAddress,
uint256 allowance
)
external
returns (bool success);
function tokenBalanceOf(
address ownerAddress
)
external
view
returns (uint256 balance);
}
/// @dev A minimalist ERC20/WETH token.
contract TestToken {
uint8 public decimals;
ITestContract private _testContract;
constructor(uint8 decimals_) public {
decimals = decimals_;
_testContract = ITestContract(msg.sender);
}
function approve(address spender, uint256 allowance)
external
returns (bool)
{
return _testContract.tokenApprove(
msg.sender,
spender,
allowance
);
}
function transfer(address recipient, uint256 amount)
external
returns (bool)
{
return _testContract.tokenTransfer(
msg.sender,
recipient,
amount
);
}
function withdraw(uint256 amount)
external
{
return _testContract.wethWithdraw(msg.sender, amount);
}
function deposit()
external
payable
{
return _testContract.wethDeposit.value(msg.value)(msg.sender);
}
function allowance(address, address) external view returns (uint256) {
return 0;
}
function balanceOf(address owner)
external
view
returns (uint256)
{
return _testContract.tokenBalanceOf(owner);
}
}
/// @dev KyberBridge overridden to mock tokens and implement IKyberBridge.
contract TestKyberBridge is
KyberBridge,
ITestContract,
IKyberNetworkProxy
{
event KyberBridgeTrade(
uint256 msgValue,
address sellTokenAddress,
uint256 sellAmount,
address buyTokenAddress,
address payable recipientAddress,
uint256 maxBuyTokenAmount,
uint256 minConversionRate,
address walletId
);
event KyberBridgeWethWithdraw(
address ownerAddress,
uint256 amount
);
event KyberBridgeWethDeposit(
uint256 msgValue,
address ownerAddress,
uint256 amount
);
event KyberBridgeTokenApprove(
address tokenAddress,
address ownerAddress,
address spenderAddress,
uint256 allowance
);
event KyberBridgeTokenTransfer(
address tokenAddress,
address ownerAddress,
address recipientAddress,
uint256 amount
);
IEtherToken public weth;
mapping (address => mapping (address => uint256)) private _tokenBalances;
uint256 private _nextFillAmount;
constructor() public {
weth = IEtherToken(address(new TestToken(18)));
}
/// @dev Implementation of `IKyberNetworkProxy.trade()`
function trade(
address sellTokenAddress,
uint256 sellAmount,
address buyTokenAddress,
address payable recipientAddress,
uint256 maxBuyTokenAmount,
uint256 minConversionRate,
address walletId
)
external
payable
returns(uint256 boughtAmount)
{
emit KyberBridgeTrade(
msg.value,
sellTokenAddress,
sellAmount,
buyTokenAddress,
recipientAddress,
maxBuyTokenAmount,
minConversionRate,
walletId
);
return _nextFillAmount;
}
function createToken(uint8 decimals)
external
returns (address tokenAddress)
{
return address(new TestToken(decimals));
}
function setNextFillAmount(uint256 amount)
external
payable
{
if (msg.value != 0) {
require(amount == msg.value, "VALUE_AMOUNT_MISMATCH");
grantTokensTo(address(weth), address(this), msg.value);
}
_nextFillAmount = amount;
}
function wethDeposit(
address ownerAddress
)
external
payable
{
require(msg.sender == address(weth), "ONLY_WETH");
grantTokensTo(address(weth), ownerAddress, msg.value);
emit KyberBridgeWethDeposit(
msg.value,
ownerAddress,
msg.value
);
}
function wethWithdraw(
address payable ownerAddress,
uint256 amount
)
external
{
require(msg.sender == address(weth), "ONLY_WETH");
_tokenBalances[address(weth)][ownerAddress] -= amount;
ownerAddress.transfer(amount);
emit KyberBridgeWethWithdraw(
ownerAddress,
amount
);
}
function tokenApprove(
address ownerAddress,
address spenderAddress,
uint256 allowance
)
external
returns (bool success)
{
emit KyberBridgeTokenApprove(
msg.sender,
ownerAddress,
spenderAddress,
allowance
);
return true;
}
function tokenTransfer(
address ownerAddress,
address recipientAddress,
uint256 amount
)
external
returns (bool success)
{
_tokenBalances[msg.sender][ownerAddress] -= amount;
_tokenBalances[msg.sender][recipientAddress] += amount;
emit KyberBridgeTokenTransfer(
msg.sender,
ownerAddress,
recipientAddress,
amount
);
return true;
}
function tokenBalanceOf(
address ownerAddress
)
external
view
returns (uint256 balance)
{
return _tokenBalances[msg.sender][ownerAddress];
}
function grantTokensTo(address tokenAddress, address ownerAddress, uint256 amount)
public
payable
{
_tokenBalances[tokenAddress][ownerAddress] += amount;
if (tokenAddress != address(weth)) {
// Send back ether if not WETH.
msg.sender.transfer(msg.value);
} else {
require(msg.value == amount, "VALUE_AMOUNT_MISMATCH");
}
}
// @dev overridden to point to this contract.
function _getKyberNetworkProxyAddress()
internal
view
returns (address)
{
return address(this);
}
// @dev overridden to point to test WETH.
function _getWethAddress()
internal
view
returns (address)
{
return address(weth);
}
}

View File

@@ -1,82 +0,0 @@
/*
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;
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
contract TestStaticCallTarget {
using LibBytes for bytes;
uint256 internal _state;
function updateState()
external
{
_state++;
}
function assertEvenNumber(uint256 target)
external
pure
{
require(
target % 2 == 0,
"TARGET_NOT_EVEN"
);
}
function isOddNumber(uint256 target)
external
pure
returns (bool isOdd)
{
isOdd = target % 2 == 1;
return isOdd;
}
function noInputFunction()
external
pure
{
assert(msg.data.length == 4 && msg.data.readBytes4(0) == bytes4(keccak256("noInputFunction()")));
}
function dynamicInputFunction(bytes calldata a)
external
pure
{
bytes memory abiEncodedData = abi.encodeWithSignature("dynamicInputFunction(bytes)", a);
assert(msg.data.equals(abiEncodedData));
}
function returnComplexType(uint256 a, uint256 b)
external
view
returns (bytes memory result)
{
result = abi.encodePacked(
address(this),
a,
b
);
return result;
}
}

View File

@@ -1,436 +0,0 @@
/*
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 "../src/bridges/UniswapBridge.sol";
import "../src/interfaces/IUniswapExchangeFactory.sol";
import "../src/interfaces/IUniswapExchange.sol";
// solhint-disable no-simple-event-func-name
contract TestEventsRaiser {
event TokenTransfer(
address token,
address from,
address to,
uint256 amount
);
event TokenApprove(
address spender,
uint256 allowance
);
event WethDeposit(
uint256 amount
);
event WethWithdraw(
uint256 amount
);
event EthToTokenTransferInput(
address exchange,
uint256 minTokensBought,
uint256 deadline,
address recipient
);
event TokenToEthSwapInput(
address exchange,
uint256 tokensSold,
uint256 minEthBought,
uint256 deadline
);
event TokenToTokenTransferInput(
address exchange,
uint256 tokensSold,
uint256 minTokensBought,
uint256 minEthBought,
uint256 deadline,
address recipient,
address toTokenAddress
);
function raiseEthToTokenTransferInput(
uint256 minTokensBought,
uint256 deadline,
address recipient
)
external
{
emit EthToTokenTransferInput(
msg.sender,
minTokensBought,
deadline,
recipient
);
}
function raiseTokenToEthSwapInput(
uint256 tokensSold,
uint256 minEthBought,
uint256 deadline
)
external
{
emit TokenToEthSwapInput(
msg.sender,
tokensSold,
minEthBought,
deadline
);
}
function raiseTokenToTokenTransferInput(
uint256 tokensSold,
uint256 minTokensBought,
uint256 minEthBought,
uint256 deadline,
address recipient,
address toTokenAddress
)
external
{
emit TokenToTokenTransferInput(
msg.sender,
tokensSold,
minTokensBought,
minEthBought,
deadline,
recipient,
toTokenAddress
);
}
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 raiseWethDeposit(uint256 amount)
external
{
emit WethDeposit(amount);
}
function raiseWethWithdraw(uint256 amount)
external
{
emit WethWithdraw(amount);
}
}
/// @dev A minimalist ERC20/WETH 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)
external
payable
{
balances[owner] = msg.value;
}
/// @dev Set the revert reason for `transfer()`,
/// `deposit()`, and `withdraw()`.
function setRevertReason(string calldata reason)
external
{
_nextRevertReason = reason;
}
/// @dev Just calls `raiseTokenTransfer()` on the caller.
function transfer(address to, uint256 amount)
external
returns (bool)
{
_revertIfReasonExists();
TestEventsRaiser(msg.sender).raiseTokenTransfer(msg.sender, to, amount);
return true;
}
/// @dev Just calls `raiseTokenApprove()` on the caller.
function approve(address spender, uint256 allowance)
external
returns (bool)
{
TestEventsRaiser(msg.sender).raiseTokenApprove(spender, allowance);
return true;
}
/// @dev `IWETH.deposit()` that increases balances and calls
/// `raiseWethDeposit()` on the caller.
function deposit()
external
payable
{
_revertIfReasonExists();
balances[msg.sender] += balances[msg.sender].safeAdd(msg.value);
TestEventsRaiser(msg.sender).raiseWethDeposit(msg.value);
}
/// @dev `IWETH.withdraw()` that just reduces balances and calls
/// `raiseWethWithdraw()` on the caller.
function withdraw(uint256 amount)
external
{
_revertIfReasonExists();
balances[msg.sender] = balances[msg.sender].safeSub(amount);
msg.sender.transfer(amount);
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
returns (uint256)
{
return balances[owner];
}
function _revertIfReasonExists()
private
view
{
if (bytes(_nextRevertReason).length != 0) {
revert(_nextRevertReason);
}
}
}
contract TestExchange is
IUniswapExchange
{
address public tokenAddress;
string private _nextRevertReason;
constructor(address _tokenAddress) public {
tokenAddress = _tokenAddress;
}
function setFillBehavior(
string calldata revertReason
)
external
payable
{
_nextRevertReason = revertReason;
}
function ethToTokenTransferInput(
uint256 minTokensBought,
uint256 deadline,
address recipient
)
external
payable
returns (uint256 tokensBought)
{
TestEventsRaiser(msg.sender).raiseEthToTokenTransferInput(
minTokensBought,
deadline,
recipient
);
_revertIfReasonExists();
return address(this).balance;
}
function tokenToEthSwapInput(
uint256 tokensSold,
uint256 minEthBought,
uint256 deadline
)
external
returns (uint256 ethBought)
{
TestEventsRaiser(msg.sender).raiseTokenToEthSwapInput(
tokensSold,
minEthBought,
deadline
);
_revertIfReasonExists();
uint256 fillAmount = address(this).balance;
msg.sender.transfer(fillAmount);
return fillAmount;
}
function tokenToTokenTransferInput(
uint256 tokensSold,
uint256 minTokensBought,
uint256 minEthBought,
uint256 deadline,
address recipient,
address toTokenAddress
)
external
returns (uint256 tokensBought)
{
TestEventsRaiser(msg.sender).raiseTokenToTokenTransferInput(
tokensSold,
minTokensBought,
minEthBought,
deadline,
recipient,
toTokenAddress
);
_revertIfReasonExists();
return address(this).balance;
}
function toTokenAddress()
external
view
returns (address _tokenAddress)
{
return tokenAddress;
}
function _revertIfReasonExists()
private
view
{
if (bytes(_nextRevertReason).length != 0) {
revert(_nextRevertReason);
}
}
}
/// @dev UniswapBridge overridden to mock tokens and implement IUniswapExchangeFactory.
contract TestUniswapBridge is
IUniswapExchangeFactory,
TestEventsRaiser,
UniswapBridge
{
TestToken public wethToken;
// Token address to TestToken instance.
mapping (address => TestToken) private _testTokens;
// Token address to TestExchange instance.
mapping (address => TestExchange) private _testExchanges;
constructor() public {
wethToken = new TestToken();
_testTokens[address(wethToken)] = wethToken;
}
/// @dev Sets the balance of this contract for an existing token.
/// The wei attached will be the balance.
function setTokenBalance(address tokenAddress)
external
payable
{
TestToken token = _testTokens[tokenAddress];
token.deposit.value(msg.value)();
}
/// @dev Sets the revert reason for an existing token.
function setTokenRevertReason(address tokenAddress, string calldata revertReason)
external
{
TestToken token = _testTokens[tokenAddress];
token.setRevertReason(revertReason);
}
/// @dev Create a token and exchange (if they don't exist) for a new token
/// and sets the exchange revert and fill behavior. The wei attached
/// will be the fill amount for the exchange.
/// @param tokenAddress The token address. If zero, one will be created.
/// @param revertReason The revert reason for exchange operations.
function createTokenAndExchange(
address tokenAddress,
string calldata revertReason
)
external
payable
returns (TestToken token, TestExchange exchange)
{
token = TestToken(tokenAddress);
if (tokenAddress == address(0)) {
token = new TestToken();
}
_testTokens[address(token)] = token;
exchange = _testExchanges[address(token)];
if (address(exchange) == address(0)) {
_testExchanges[address(token)] = exchange = new TestExchange(address(token));
}
exchange.setFillBehavior.value(msg.value)(revertReason);
return (token, exchange);
}
/// @dev `IUniswapExchangeFactory.getExchange`
function getExchange(address tokenAddress)
external
view
returns (address)
{
return address(_testExchanges[tokenAddress]);
}
// @dev Use `wethToken`.
function _getWethAddress()
internal
view
returns (address)
{
return address(wethToken);
}
// @dev This contract will double as the Uniswap contract.
function _getUniswapExchangeFactoryAddress()
internal
view
returns (address)
{
return address(this);
}
}

View File

@@ -1,253 +0,0 @@
/*
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,99 +0,0 @@
{
"name": "@0x/contracts-asset-proxy",
"version": "3.4.0",
"engines": {
"node": ">=6.12"
},
"description": "Smart contract components of 0x protocol",
"main": "lib/src/index.js",
"directories": {
"test": "test"
},
"scripts": {
"build": "yarn pre_build && tsc -b",
"build:ci": "yarn build",
"pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s build test",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html",
"test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
"compile": "sol-compiler",
"watch": "sol-compiler -w",
"clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers",
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers",
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
"coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html",
"profiler:report:html": "istanbul report html && open coverage/index.html",
"coverage:report:lcov": "istanbul report lcov",
"test:circleci": "yarn test",
"contracts:gen": "contracts-gen generate",
"contracts:copy": "contracts-gen copy",
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol",
"compile:truffle": "truffle compile",
"docs:md": "ts-doc-gen --sourceDir='$PROJECT_FILES' --output=$MD_FILE_DIR --fileExtension=mdx --tsconfig=./typedoc-tsconfig.json",
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"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": {
"type": "git",
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
"devDependencies": {
"@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.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"ethereumjs-util": "^5.1.1",
"make-promises-safe": "^1.1.0",
"mocha": "^6.2.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typedoc": "^0.15.0",
"typescript": "3.0.1"
},
"dependencies": {
"@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

@@ -1,97 +0,0 @@
/*
* -----------------------------------------------------------------------------
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
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';
import * as ERC20Proxy from '../generated-artifacts/ERC20Proxy.json';
import * as ERC721Proxy from '../generated-artifacts/ERC721Proxy.json';
import * as Eth2DaiBridge from '../generated-artifacts/Eth2DaiBridge.json';
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,
Ownable: Ownable as ContractArtifact,
ERC1155Proxy: ERC1155Proxy as ContractArtifact,
ERC20BridgeProxy: ERC20BridgeProxy as ContractArtifact,
ERC20Proxy: ERC20Proxy as ContractArtifact,
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

@@ -1,112 +0,0 @@
import { AssetProxyId } from '@0x/types';
import { BigNumber, hexUtils } from '@0x/utils';
import { IAssetDataContract } from './wrappers';
const assetDataIface = new IAssetDataContract('0x0000000000000000000000000000000000000000', { isEIP1193: true } as any);
/**
* Get the proxy ID from encoded asset data.
*/
export function getAssetDataProxyId(encoded: string): AssetProxyId {
// tslint:disable-next-line: no-unnecessary-type-assertion
return hexUtils.slice(encoded, 0, 4) as AssetProxyId;
}
/**
* Decode ERC20 asset data.
*/
export function decodeERC20AssetData(encoded: string): string {
return assetDataIface.getABIDecodedTransactionData<string>('ERC20Token', encoded);
}
/**
* Decode ERC721 asset data.
*/
export function decodeERC721AssetData(encoded: string): [string, BigNumber] {
return assetDataIface.getABIDecodedTransactionData<[string, BigNumber]>('ERC721Token', encoded);
}
/**
* Decode ERC1155 asset data.
*/
export function decodeERC1155AssetData(encoded: string): [string, BigNumber[], BigNumber[], string] {
return assetDataIface.getABIDecodedTransactionData<[string, BigNumber[], BigNumber[], string]>(
'ERC1155Assets',
encoded,
);
}
/**
* Decode MultiAsset asset data.
*/
export function decodeMultiAssetData(encoded: string): [BigNumber[], string[]] {
return assetDataIface.getABIDecodedTransactionData<[BigNumber[], string[]]>('MultiAsset', encoded);
}
/**
* Decode StaticCall asset data.
*/
export function decodeStaticCallAssetData(encoded: string): [string, string, string] {
return assetDataIface.getABIDecodedTransactionData<[string, string, string]>('StaticCall', encoded);
}
/**
* Decode ERC20Bridge asset data.
*/
export function decodeERC20BridgeAssetData(encoded: string): [string, string, string] {
return assetDataIface.getABIDecodedTransactionData<[string, string, string]>('ERC20Bridge', encoded);
}
/**
* Encode ERC20 asset data.
*/
export function encodeERC20AssetData(tokenAddress: string): string {
return assetDataIface.ERC20Token(tokenAddress).getABIEncodedTransactionData();
}
/**
* Encode ERC721 asset data.
*/
export function encodeERC721AssetData(tokenAddress: string, tokenId: BigNumber): string {
return assetDataIface.ERC721Token(tokenAddress, tokenId).getABIEncodedTransactionData();
}
/**
* Encode ERC1155 asset data.
*/
export function encodeERC1155AssetData(
tokenAddress: string,
tokenIds: BigNumber[],
values: BigNumber[],
callbackData: string,
): string {
return assetDataIface.ERC1155Assets(tokenAddress, tokenIds, values, callbackData).getABIEncodedTransactionData();
}
/**
* Encode MultiAsset asset data.
*/
export function encodeMultiAssetData(values: BigNumber[], nestedAssetData: string[]): string {
return assetDataIface.MultiAsset(values, nestedAssetData).getABIEncodedTransactionData();
}
/**
* Encode StaticCall asset data.
*/
export function encodeStaticCallAssetData(
staticCallTargetAddress: string,
staticCallData: string,
expectedReturnDataHash: string,
): string {
return assetDataIface
.StaticCall(staticCallTargetAddress, staticCallData, expectedReturnDataHash)
.getABIEncodedTransactionData();
}
/**
* Encode ERC20Bridge asset data.
*/
export function encodeERC20BridgeAssetData(tokenAddress: string, bridgeAddress: string, bridgeData: string): string {
return assetDataIface.ERC20Bridge(tokenAddress, bridgeAddress, bridgeData).getABIEncodedTransactionData();
}

View File

@@ -1,27 +0,0 @@
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,40 +0,0 @@
import { AbiEncoder, BigNumber } from '@0x/utils';
export enum DydxBridgeActionType {
Deposit,
Withdraw,
}
export interface DydxBridgeAction {
actionType: DydxBridgeActionType;
accountIdx: BigNumber;
marketId: BigNumber;
conversionRateNumerator: BigNumber;
conversionRateDenominator: BigNumber;
}
export interface DydxBridgeData {
accountNumbers: BigNumber[];
actions: DydxBridgeAction[];
}
export const dydxBridgeDataEncoder = AbiEncoder.create([
{
name: 'bridgeData',
type: 'tuple',
components: [
{ name: 'accountNumbers', type: 'uint256[]' },
{
name: 'actions',
type: 'tuple[]',
components: [
{ name: 'actionType', type: 'uint8' },
{ name: 'accountIdx', type: 'uint256' },
{ name: 'marketId', type: 'uint256' },
{ name: 'conversionRateNumerator', type: 'uint256' },
{ name: 'conversionRateDenominator', type: 'uint256' },
],
},
],
},
]);

View File

@@ -1,410 +0,0 @@
import { artifacts as erc1155Artifacts, ERC1155MintableContract, Erc1155Wrapper } from '@0x/contracts-erc1155';
import {
constants,
ERC1155FungibleHoldingsByOwner,
ERC1155HoldingsByOwner,
ERC1155NonFungibleHoldingsByOwner,
LogDecoder,
txDefaults,
} from '@0x/contracts-test-utils';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import { ERC1155ProxyContract, IAssetDataContract, IAssetProxyContract } from './wrappers';
export class ERC1155ProxyWrapper {
private readonly _tokenOwnerAddresses: string[];
private readonly _fungibleTokenIds: string[];
private readonly _nonFungibleTokenIds: string[];
private readonly _nfts: Array<{ id: BigNumber; tokenId: BigNumber }>;
private readonly _contractOwnerAddress: string;
private readonly _web3Wrapper: Web3Wrapper;
private readonly _provider: Provider;
private readonly _logDecoder: LogDecoder;
private readonly _dummyTokenWrappers: Erc1155Wrapper[];
private readonly _assetProxyInterface: IAssetProxyContract;
private readonly _assetDataInterface: IAssetDataContract;
private _proxyContract?: ERC1155ProxyContract;
private _proxyIdIfExists?: string;
private _initialTokenIdsByOwner: ERC1155HoldingsByOwner = { fungible: {}, nonFungible: {} };
constructor(provider: Provider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._web3Wrapper = new Web3Wrapper(provider);
this._provider = provider;
const allArtifacts = _.merge(artifacts, erc1155Artifacts);
this._logDecoder = new LogDecoder(this._web3Wrapper, allArtifacts);
this._dummyTokenWrappers = [];
this._assetProxyInterface = new IAssetProxyContract(constants.NULL_ADDRESS, provider);
this._assetDataInterface = new IAssetDataContract(constants.NULL_ADDRESS, provider);
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
this._fungibleTokenIds = [];
this._nonFungibleTokenIds = [];
this._nfts = [];
}
/**
* @dev Deploys dummy ERC1155 contracts
* @return An array of ERC1155 wrappers; one for each deployed contract.
*/
public async deployDummyContractsAsync(): Promise<Erc1155Wrapper[]> {
// tslint:disable-next-line:no-unused-variable
for (const i of _.times(constants.NUM_DUMMY_ERC1155_CONTRACTS_TO_DEPLOY)) {
const erc1155Contract = await ERC1155MintableContract.deployFrom0xArtifactAsync(
erc1155Artifacts.ERC1155Mintable,
this._provider,
txDefaults,
artifacts,
);
const erc1155Wrapper = new Erc1155Wrapper(erc1155Contract, this._contractOwnerAddress);
this._dummyTokenWrappers.push(erc1155Wrapper);
}
return this._dummyTokenWrappers;
}
/**
* @dev Deploys the ERC1155 proxy
* @return Deployed ERC1155 proxy contract instance
*/
public async deployProxyAsync(): Promise<ERC1155ProxyContract> {
this._proxyContract = await ERC1155ProxyContract.deployFrom0xArtifactAsync(
artifacts.ERC1155Proxy,
this._provider,
txDefaults,
artifacts,
);
this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync();
return this._proxyContract;
}
/**
* @dev Gets the ERC1155 proxy id
*/
public getProxyId(): string {
this._validateProxyContractExistsOrThrow();
return this._proxyIdIfExists as string;
}
/**
* @dev generates abi-encoded tx data for transferring erc1155 fungible/non-fungible tokens.
* @param from source address
* @param to destination address
* @param contractAddress address of erc155 contract
* @param tokensToTransfer array of erc1155 tokens to transfer
* @param valuesToTransfer array of corresponding values for each erc1155 token to transfer
* @param valueMultiplier each value in `valuesToTransfer` is multiplied by this
* @param receiverCallbackData callback data if `to` is a contract
* @param authorizedSender sender of `transferFrom` transaction
* @param extraData extra data to append to `transferFrom` transaction. Optional.
* @return abi encoded tx data.
*/
public async getTransferFromAbiEncodedTxDataAsync(
from: string,
to: string,
contractAddress: string,
tokensToTransfer: BigNumber[],
valuesToTransfer: BigNumber[],
valueMultiplier: BigNumber,
receiverCallbackData: string,
authorizedSender: string,
assetData_?: string,
): Promise<string> {
this._validateProxyContractExistsOrThrow();
const assetData =
assetData_ === undefined
? this._assetDataInterface
.ERC1155Assets(contractAddress, tokensToTransfer, valuesToTransfer, receiverCallbackData)
.getABIEncodedTransactionData()
: assetData_;
const data = this._assetProxyInterface
.transferFrom(assetData, from, to, valueMultiplier)
.getABIEncodedTransactionData();
return data;
}
/**
* @dev transfers erc1155 fungible/non-fungible tokens.
* @param txData: abi-encoded tx data
* @param authorizedSender sender of `transferFrom` transaction
*/
public async transferFromRawAsync(
txData: string,
authorizedSender: string,
): Promise<TransactionReceiptWithDecodedLogs> {
const txHash = await this._web3Wrapper.sendTransactionAsync({
to: (this._proxyContract as ERC1155ProxyContract).address,
data: txData,
from: authorizedSender,
gas: 300000,
});
const txReceipt = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return txReceipt;
}
/**
* @dev transfers erc1155 fungible/non-fungible tokens.
* @param from source address
* @param to destination address
* @param contractAddress address of erc155 contract
* @param tokensToTransfer array of erc1155 tokens to transfer
* @param valuesToTransfer array of corresponding values for each erc1155 token to transfer
* @param valueMultiplier each value in `valuesToTransfer` is multiplied by this
* @param receiverCallbackData callback data if `to` is a contract
* @param authorizedSender sender of `transferFrom` transaction
* @param extraData extra data to append to `transferFrom` transaction. Optional.
* @return tranasction hash.
*/
public async transferFromAsync(
from: string,
to: string,
contractAddress: string,
tokensToTransfer: BigNumber[],
valuesToTransfer: BigNumber[],
valueMultiplier: BigNumber,
receiverCallbackData: string,
authorizedSender: string,
assetData_?: string,
): Promise<TransactionReceiptWithDecodedLogs> {
this._validateProxyContractExistsOrThrow();
const assetData =
assetData_ === undefined
? this._assetDataInterface
.ERC1155Assets(contractAddress, tokensToTransfer, valuesToTransfer, receiverCallbackData)
.getABIEncodedTransactionData()
: assetData_;
const data = this._assetProxyInterface
.transferFrom(assetData, from, to, valueMultiplier)
.getABIEncodedTransactionData();
const txHash = await this._web3Wrapper.sendTransactionAsync({
to: (this._proxyContract as ERC1155ProxyContract).address,
data,
from: authorizedSender,
gas: 300000,
});
const txReceipt = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return txReceipt;
}
/**
* @dev For each deployed ERC1155 contract, this function mints a set of fungible/non-fungible
* tokens for each token owner address (`_tokenOwnerAddresses`).
* @return Balances of each token owner, across all ERC1155 contracts and tokens.
*/
public async setBalancesAndAllowancesAsync(): Promise<ERC1155HoldingsByOwner> {
this._validateDummyTokenContractsExistOrThrow();
this._validateProxyContractExistsOrThrow();
this._initialTokenIdsByOwner = {
fungible: {},
nonFungible: {},
};
const fungibleHoldingsByOwner: ERC1155FungibleHoldingsByOwner = {};
const nonFungibleHoldingsByOwner: ERC1155NonFungibleHoldingsByOwner = {};
// Set balances accordingly
for (const dummyWrapper of this._dummyTokenWrappers) {
const dummyAddress = dummyWrapper.getContract().address;
// tslint:disable-next-line:no-unused-variable
for (const i of _.times(constants.NUM_ERC1155_FUNGIBLE_TOKENS_MINT)) {
// Create a fungible token
const tokenId = await dummyWrapper.mintFungibleTokensAsync(
this._tokenOwnerAddresses,
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE,
);
const tokenIdAsString = tokenId.toString();
this._fungibleTokenIds.push(tokenIdAsString);
// Mint tokens for each owner for this token
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
// tslint:disable-next-line:no-unused-variable
if (fungibleHoldingsByOwner[tokenOwnerAddress] === undefined) {
fungibleHoldingsByOwner[tokenOwnerAddress] = {};
}
if (fungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] === undefined) {
fungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] = {};
}
fungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString] =
constants.INITIAL_ERC1155_FUNGIBLE_BALANCE;
await dummyWrapper.setApprovalForAllAsync(
tokenOwnerAddress,
(this._proxyContract as ERC1155ProxyContract).address,
true,
);
}
}
// Non-fungible tokens
// tslint:disable-next-line:no-unused-variable
for (const j of _.times(constants.NUM_ERC1155_NONFUNGIBLE_TOKENS_MINT)) {
const [tokenId, nftIds] = await dummyWrapper.mintNonFungibleTokensAsync(this._tokenOwnerAddresses);
const tokenIdAsString = tokenId.toString();
this._nonFungibleTokenIds.push(tokenIdAsString);
_.each(this._tokenOwnerAddresses, async (tokenOwnerAddress: string, i: number) => {
if (nonFungibleHoldingsByOwner[tokenOwnerAddress] === undefined) {
nonFungibleHoldingsByOwner[tokenOwnerAddress] = {};
}
if (nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] === undefined) {
nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] = {};
}
if (nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString] === undefined) {
nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString] = [];
}
this._nfts.push({ id: nftIds[i], tokenId });
nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString].push(nftIds[i]);
await dummyWrapper.setApprovalForAllAsync(
tokenOwnerAddress,
(this._proxyContract as ERC1155ProxyContract).address,
true,
);
});
}
}
this._initialTokenIdsByOwner = {
fungible: fungibleHoldingsByOwner,
nonFungible: nonFungibleHoldingsByOwner,
};
return this._initialTokenIdsByOwner;
}
/**
* @dev For each deployed ERC1155 contract, this function quieries the set of fungible/non-fungible
* tokens for each token owner address (`_tokenOwnerAddresses`).
* @return Balances of each token owner, across all ERC1155 contracts and tokens.
*/
public async getBalancesAsync(): Promise<ERC1155HoldingsByOwner> {
this._validateDummyTokenContractsExistOrThrow();
this._validateBalancesAndAllowancesSetOrThrow();
const tokenHoldingsByOwner: ERC1155FungibleHoldingsByOwner = {};
const nonFungibleHoldingsByOwner: ERC1155NonFungibleHoldingsByOwner = {};
for (const dummyTokenWrapper of this._dummyTokenWrappers) {
const tokenContract = dummyTokenWrapper.getContract();
const tokenAddress = tokenContract.address;
// Construct batch balance call
const tokenOwners: string[] = [];
const tokenIds: BigNumber[] = [];
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
for (const tokenId of this._fungibleTokenIds) {
tokenOwners.push(tokenOwnerAddress);
tokenIds.push(new BigNumber(tokenId));
}
for (const nft of this._nfts) {
tokenOwners.push(tokenOwnerAddress);
tokenIds.push(nft.id);
}
}
const balances = await dummyTokenWrapper.getBalancesAsync(tokenOwners, tokenIds);
// Parse out balances into fungible / non-fungible token holdings
let i = 0;
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
// Fungible tokens
for (const tokenId of this._fungibleTokenIds) {
if (tokenHoldingsByOwner[tokenOwnerAddress] === undefined) {
tokenHoldingsByOwner[tokenOwnerAddress] = {};
}
if (tokenHoldingsByOwner[tokenOwnerAddress][tokenAddress] === undefined) {
tokenHoldingsByOwner[tokenOwnerAddress][tokenAddress] = {};
}
tokenHoldingsByOwner[tokenOwnerAddress][tokenAddress][tokenId] = balances[i++];
}
// Non-fungible tokens
for (const nft of this._nfts) {
if (nonFungibleHoldingsByOwner[tokenOwnerAddress] === undefined) {
nonFungibleHoldingsByOwner[tokenOwnerAddress] = {};
}
if (nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress] === undefined) {
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress] = {};
}
if (
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress][nft.tokenId.toString()] ===
undefined
) {
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress][nft.tokenId.toString()] = [];
}
const isOwner = balances[i++];
if (isOwner.isEqualTo(1)) {
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress][nft.tokenId.toString()].push(
nft.id,
);
}
}
}
}
const holdingsByOwner = {
fungible: tokenHoldingsByOwner,
nonFungible: nonFungibleHoldingsByOwner,
};
return holdingsByOwner;
}
/**
* @dev Set the approval for the proxy on behalf of `userAddress` .
* @param userAddress owner of ERC1155 tokens.
* @param contractAddress address of ERC1155 contract.
* @param isApproved Whether to approve the proxy for all or not.
*/
public async setProxyAllowanceForAllAsync(
userAddress: string,
contractAddress: string,
isApproved: boolean,
): Promise<void> {
this._validateProxyContractExistsOrThrow();
const tokenWrapper = this.getContractWrapper(contractAddress);
const operator = (this._proxyContract as ERC1155ProxyContract).address;
await tokenWrapper.setApprovalForAllAsync(userAddress, operator, isApproved);
}
/**
* @dev Checks if proxy is approved to transfer tokens on behalf of `userAddress`.
* @param userAddress owner of ERC1155 tokens.
* @param contractAddress address of ERC1155 contract.
* @return True iff the proxy is approved for all. False otherwise.
*/
public async isProxyApprovedForAllAsync(userAddress: string, contractAddress: string): Promise<boolean> {
this._validateProxyContractExistsOrThrow();
const tokenContract = this._getContractFromAddress(contractAddress);
const operator = (this._proxyContract as ERC1155ProxyContract).address;
const didApproveAll = await tokenContract.isApprovedForAll(userAddress, operator).callAsync();
return didApproveAll;
}
public getFungibleTokenIds(): BigNumber[] {
const fungibleTokenIds = _.map(this._fungibleTokenIds, (tokenIdAsString: string) => {
return new BigNumber(tokenIdAsString);
});
return fungibleTokenIds;
}
public getNonFungibleTokenIds(): BigNumber[] {
const nonFungibleTokenIds = _.map(this._nonFungibleTokenIds, (tokenIdAsString: string) => {
return new BigNumber(tokenIdAsString);
});
return nonFungibleTokenIds;
}
public getTokenOwnerAddresses(): string[] {
return this._tokenOwnerAddresses;
}
public getContractWrapper(contractAddress: string): Erc1155Wrapper {
const tokenWrapper = _.find(this._dummyTokenWrappers, (wrapper: Erc1155Wrapper) => {
return wrapper.getContract().address === contractAddress;
});
if (tokenWrapper === undefined) {
throw new Error(`Contract: ${contractAddress} was not deployed through ERC1155ProxyWrapper`);
}
return tokenWrapper;
}
private _getContractFromAddress(tokenAddress: string): ERC1155MintableContract {
const tokenContractIfExists = _.find(this._dummyTokenWrappers, c => c.getContract().address === tokenAddress);
if (tokenContractIfExists === undefined) {
throw new Error(`Token: ${tokenAddress} was not deployed through ERC1155ProxyWrapper`);
}
return tokenContractIfExists.getContract();
}
private _validateDummyTokenContractsExistOrThrow(): void {
if (this._dummyTokenWrappers === undefined) {
throw new Error('Dummy ERC1155 tokens not yet deployed, please call "deployDummyTokensAsync"');
}
}
private _validateProxyContractExistsOrThrow(): void {
if (this._proxyContract === undefined) {
throw new Error('ERC1155 proxy contract not yet deployed, please call "deployProxyAsync"');
}
}
private _validateBalancesAndAllowancesSetOrThrow(): void {
if (
_.keys(this._initialTokenIdsByOwner.fungible).length === 0 ||
_.keys(this._initialTokenIdsByOwner.nonFungible).length === 0
) {
throw new Error(
'Dummy ERC1155 balances and allowances not yet set, please call "setBalancesAndAllowancesAsync"',
);
}
}
}

View File

@@ -1,164 +0,0 @@
import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contracts-erc20';
import { constants, ERC20BalancesByOwner, txDefaults } from '@0x/contracts-test-utils';
import { BigNumber } from '@0x/utils';
import { ZeroExProvider } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import { ERC20ProxyContract, IAssetDataContract } from './wrappers';
export class ERC20Wrapper {
private readonly _tokenOwnerAddresses: string[];
private readonly _contractOwnerAddress: string;
private readonly _provider: ZeroExProvider;
private readonly _dummyTokenContracts: DummyERC20TokenContract[];
private readonly _assetDataInterface: IAssetDataContract;
private _proxyContract?: ERC20ProxyContract;
private _proxyIdIfExists?: string;
/**
* Instanitates an ERC20Wrapper
* @param provider Web3 provider to use for all JSON RPC requests
* @param tokenOwnerAddresses Addresses that we want to endow as owners for dummy ERC20 tokens
* @param contractOwnerAddress Desired owner of the contract
* Instance of ERC20Wrapper
*/
constructor(provider: ZeroExProvider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._dummyTokenContracts = [];
this._provider = provider;
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
this._assetDataInterface = new IAssetDataContract(constants.NULL_ADDRESS, provider);
}
public async deployDummyTokensAsync(
numberToDeploy: number,
decimals: BigNumber,
): Promise<DummyERC20TokenContract[]> {
for (let i = 0; i < numberToDeploy; i++) {
this._dummyTokenContracts.push(
await DummyERC20TokenContract.deployFrom0xArtifactAsync(
erc20Artifacts.DummyERC20Token,
this._provider,
txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL,
decimals,
constants.DUMMY_TOKEN_TOTAL_SUPPLY,
),
);
}
return this._dummyTokenContracts;
}
public async deployProxyAsync(): Promise<ERC20ProxyContract> {
this._proxyContract = await ERC20ProxyContract.deployFrom0xArtifactAsync(
artifacts.ERC20Proxy,
this._provider,
txDefaults,
artifacts,
);
this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync();
return this._proxyContract;
}
public getProxyId(): string {
this._validateProxyContractExistsOrThrow();
return this._proxyIdIfExists as string;
}
public async setBalancesAndAllowancesAsync(): Promise<void> {
this._validateDummyTokenContractsExistOrThrow();
this._validateProxyContractExistsOrThrow();
for (const dummyTokenContract of this._dummyTokenContracts) {
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
await dummyTokenContract
.setBalance(tokenOwnerAddress, constants.INITIAL_ERC20_BALANCE)
.awaitTransactionSuccessAsync({ from: this._contractOwnerAddress });
await dummyTokenContract
.approve((this._proxyContract as ERC20ProxyContract).address, constants.INITIAL_ERC20_ALLOWANCE)
.awaitTransactionSuccessAsync({ from: tokenOwnerAddress });
}
}
}
public async getBalanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData);
const balance = new BigNumber(await tokenContract.balanceOf(userAddress).callAsync());
return balance;
}
public async setBalanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData);
await tokenContract
.setBalance(userAddress, amount)
.awaitTransactionSuccessAsync(
{ from: this._contractOwnerAddress },
{ pollingIntervalMs: constants.AWAIT_TRANSACTION_MINED_MS },
);
}
public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData);
const proxyAddress = (this._proxyContract as ERC20ProxyContract).address;
const allowance = new BigNumber(await tokenContract.allowance(userAddress, proxyAddress).callAsync());
return allowance;
}
public async setAllowanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
const tokenContract = await this._getTokenContractFromAssetDataAsync(assetData);
const proxyAddress = (this._proxyContract as ERC20ProxyContract).address;
await tokenContract.approve(proxyAddress, amount).awaitTransactionSuccessAsync({ from: userAddress });
}
public async getBalancesAsync(): Promise<ERC20BalancesByOwner> {
this._validateDummyTokenContractsExistOrThrow();
const balancesByOwner: ERC20BalancesByOwner = {};
const balances: BigNumber[] = [];
const balanceInfo: Array<{ tokenOwnerAddress: string; tokenAddress: string }> = [];
for (const dummyTokenContract of this._dummyTokenContracts) {
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
balances.push(await dummyTokenContract.balanceOf(tokenOwnerAddress).callAsync());
balanceInfo.push({
tokenOwnerAddress,
tokenAddress: dummyTokenContract.address,
});
}
}
_.forEach(balances, (balance, balanceIndex) => {
const tokenAddress = balanceInfo[balanceIndex].tokenAddress;
const tokenOwnerAddress = balanceInfo[balanceIndex].tokenOwnerAddress;
if (balancesByOwner[tokenOwnerAddress] === undefined) {
balancesByOwner[tokenOwnerAddress] = {};
}
const wrappedBalance = new BigNumber(balance);
balancesByOwner[tokenOwnerAddress][tokenAddress] = wrappedBalance;
});
return balancesByOwner;
}
public addDummyTokenContract(dummy: DummyERC20TokenContract): void {
if (this._dummyTokenContracts !== undefined) {
this._dummyTokenContracts.push(dummy);
}
}
public addTokenOwnerAddress(address: string): void {
this._tokenOwnerAddresses.push(address);
}
public getTokenOwnerAddresses(): string[] {
return this._tokenOwnerAddresses;
}
public getTokenAddresses(): string[] {
const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
return tokenAddresses;
}
private async _getTokenContractFromAssetDataAsync(assetData: string): Promise<DummyERC20TokenContract> {
const tokenAddress = this._assetDataInterface.getABIDecodedTransactionData<string>('ERC20Token', assetData); // tslint:disable-line:no-unused-variable
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
if (tokenContractIfExists === undefined) {
throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`);
}
return tokenContractIfExists;
}
private _validateDummyTokenContractsExistOrThrow(): void {
if (this._dummyTokenContracts === undefined) {
throw new Error('Dummy ERC20 tokens not yet deployed, please call "deployDummyTokensAsync"');
}
}
private _validateProxyContractExistsOrThrow(): void {
if (this._proxyContract === undefined) {
throw new Error('ERC20 proxy contract not yet deployed, please call "deployProxyAsync"');
}
}
}

View File

@@ -1,220 +0,0 @@
import { artifacts as erc721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721';
import { constants, ERC721TokenIdsByOwner, txDefaults } from '@0x/contracts-test-utils';
import { generatePseudoRandomSalt } from '@0x/order-utils';
import { BigNumber } from '@0x/utils';
import { ZeroExProvider } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import { ERC721ProxyContract } from './wrappers';
export class ERC721Wrapper {
private readonly _tokenOwnerAddresses: string[];
private readonly _contractOwnerAddress: string;
private readonly _provider: ZeroExProvider;
private readonly _dummyTokenContracts: DummyERC721TokenContract[];
private _proxyContract?: ERC721ProxyContract;
private _proxyIdIfExists?: string;
private _initialTokenIdsByOwner: ERC721TokenIdsByOwner = {};
constructor(provider: ZeroExProvider, tokenOwnerAddresses: string[], contractOwnerAddress: string) {
this._provider = provider;
this._dummyTokenContracts = [];
this._tokenOwnerAddresses = tokenOwnerAddresses;
this._contractOwnerAddress = contractOwnerAddress;
}
public async deployDummyTokensAsync(): Promise<DummyERC721TokenContract[]> {
// tslint:disable-next-line:no-unused-variable
for (const i of _.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY)) {
this._dummyTokenContracts.push(
await DummyERC721TokenContract.deployFrom0xArtifactAsync(
erc721Artifacts.DummyERC721Token,
this._provider,
txDefaults,
artifacts,
constants.DUMMY_TOKEN_NAME,
constants.DUMMY_TOKEN_SYMBOL,
),
);
}
return this._dummyTokenContracts;
}
public async deployProxyAsync(): Promise<ERC721ProxyContract> {
this._proxyContract = await ERC721ProxyContract.deployFrom0xArtifactAsync(
artifacts.ERC721Proxy,
this._provider,
txDefaults,
artifacts,
);
this._proxyIdIfExists = await this._proxyContract.getProxyId().callAsync();
return this._proxyContract;
}
public getProxyId(): string {
this._validateProxyContractExistsOrThrow();
return this._proxyIdIfExists as string;
}
public async setBalancesAndAllowancesAsync(): Promise<void> {
this._validateDummyTokenContractsExistOrThrow();
this._validateProxyContractExistsOrThrow();
this._initialTokenIdsByOwner = {};
for (const dummyTokenContract of this._dummyTokenContracts) {
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
// tslint:disable-next-line:no-unused-variable
for (const i of _.times(constants.NUM_ERC721_TOKENS_TO_MINT)) {
const tokenId = generatePseudoRandomSalt();
await this.mintAsync(dummyTokenContract.address, tokenId, tokenOwnerAddress);
if (this._initialTokenIdsByOwner[tokenOwnerAddress] === undefined) {
this._initialTokenIdsByOwner[tokenOwnerAddress] = {
[dummyTokenContract.address]: [],
};
}
if (this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address] === undefined) {
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address] = [];
}
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address].push(tokenId);
await this.approveProxyForAllAsync(dummyTokenContract.address, tokenOwnerAddress, true);
}
}
}
}
public async doesTokenExistAsync(tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const owner = await tokenContract.ownerOf(tokenId).callAsync();
const doesExist = owner !== constants.NULL_ADDRESS;
return doesExist;
}
public async approveProxyAsync(tokenAddress: string, tokenId: BigNumber): Promise<void> {
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
await this.approveAsync(proxyAddress, tokenAddress, tokenId);
}
public async approveProxyForAllAsync(
tokenAddress: string,
ownerAddress: string,
isApproved: boolean,
): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
await tokenContract.setApprovalForAll(proxyAddress, isApproved).awaitTransactionSuccessAsync({
from: ownerAddress,
});
}
public async approveAsync(to: string, tokenAddress: string, tokenId: BigNumber): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId);
await tokenContract.approve(to, tokenId).awaitTransactionSuccessAsync({ from: tokenOwner });
}
public async transferFromAsync(
tokenAddress: string,
tokenId: BigNumber,
currentOwner: string,
userAddress: string,
): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
await tokenContract.transferFrom(currentOwner, userAddress, tokenId).awaitTransactionSuccessAsync({
from: currentOwner,
});
}
public async mintAsync(tokenAddress: string, tokenId: BigNumber, userAddress: string): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
await tokenContract.mint(userAddress, tokenId).awaitTransactionSuccessAsync({
from: this._contractOwnerAddress,
});
}
public async burnAsync(tokenAddress: string, tokenId: BigNumber, owner: string): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
await tokenContract.burn(owner, tokenId).awaitTransactionSuccessAsync({ from: this._contractOwnerAddress });
}
public async ownerOfAsync(tokenAddress: string, tokenId: BigNumber): Promise<string> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const owner = await tokenContract.ownerOf(tokenId).callAsync();
return owner;
}
public async isOwnerAsync(userAddress: string, tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const tokenOwner = await tokenContract.ownerOf(tokenId).callAsync();
const isOwner = tokenOwner === userAddress;
return isOwner;
}
public async isProxyApprovedForAllAsync(userAddress: string, tokenAddress: string): Promise<boolean> {
this._validateProxyContractExistsOrThrow();
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const operator = (this._proxyContract as ERC721ProxyContract).address;
const didApproveAll = await tokenContract.isApprovedForAll(userAddress, operator).callAsync();
return didApproveAll;
}
public async isProxyApprovedAsync(tokenAddress: string, tokenId: BigNumber): Promise<boolean> {
this._validateProxyContractExistsOrThrow();
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const approvedAddress = await tokenContract.getApproved(tokenId).callAsync();
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
const isProxyAnApprovedOperator = approvedAddress === proxyAddress;
return isProxyAnApprovedOperator;
}
public async getBalancesAsync(): Promise<ERC721TokenIdsByOwner> {
this._validateDummyTokenContractsExistOrThrow();
this._validateBalancesAndAllowancesSetOrThrow();
const tokenIdsByOwner: ERC721TokenIdsByOwner = {};
const tokenOwnerAddresses: string[] = [];
const tokenInfo: Array<{ tokenId: BigNumber; tokenAddress: string }> = [];
for (const dummyTokenContract of this._dummyTokenContracts) {
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
const initialTokenOwnerIds = this._initialTokenIdsByOwner[tokenOwnerAddress][
dummyTokenContract.address
];
for (const tokenId of initialTokenOwnerIds) {
tokenOwnerAddresses.push(await dummyTokenContract.ownerOf(tokenId).callAsync());
tokenInfo.push({
tokenId,
tokenAddress: dummyTokenContract.address,
});
}
}
}
_.forEach(tokenOwnerAddresses, (tokenOwnerAddress, ownerIndex) => {
const tokenAddress = tokenInfo[ownerIndex].tokenAddress;
const tokenId = tokenInfo[ownerIndex].tokenId;
if (tokenIdsByOwner[tokenOwnerAddress] === undefined) {
tokenIdsByOwner[tokenOwnerAddress] = {
[tokenAddress]: [],
};
}
if (tokenIdsByOwner[tokenOwnerAddress][tokenAddress] === undefined) {
tokenIdsByOwner[tokenOwnerAddress][tokenAddress] = [];
}
tokenIdsByOwner[tokenOwnerAddress][tokenAddress].push(tokenId);
});
return tokenIdsByOwner;
}
public getTokenOwnerAddresses(): string[] {
return this._tokenOwnerAddresses;
}
public getTokenAddresses(): string[] {
const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
return tokenAddresses;
}
private _getTokenContractFromAssetData(tokenAddress: string): DummyERC721TokenContract {
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
if (tokenContractIfExists === undefined) {
throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`);
}
return tokenContractIfExists;
}
private _validateDummyTokenContractsExistOrThrow(): void {
if (this._dummyTokenContracts === undefined) {
throw new Error('Dummy ERC721 tokens not yet deployed, please call "deployDummyTokensAsync"');
}
}
private _validateProxyContractExistsOrThrow(): void {
if (this._proxyContract === undefined) {
throw new Error('ERC721 proxy contract not yet deployed, please call "deployProxyAsync"');
}
}
private _validateBalancesAndAllowancesSetOrThrow(): void {
if (_.keys(this._initialTokenIdsByOwner).length === 0) {
throw new Error(
'Dummy ERC721 balances and allowances not yet set, please call "setBalancesAndAllowancesAsync"',
);
}
}
}

View File

@@ -1,92 +0,0 @@
export { artifacts } from './artifacts';
export {
BalancerBridgeContract,
ChaiBridgeContract,
ERC1155ProxyContract,
ERC20BridgeProxyContract,
ERC20ProxyContract,
ERC721ProxyContract,
Eth2DaiBridgeContract,
DydxBridgeContract,
IAssetDataContract,
IAssetProxyContract,
IChaiContract,
IDydxContract,
KyberBridgeContract,
MultiAssetProxyContract,
StaticCallProxyContract,
TestDydxBridgeContract,
TestStaticCallTargetContract,
UniswapBridgeContract,
} from './wrappers';
export { ERC20Wrapper } from './erc20_wrapper';
export { ERC721Wrapper } from './erc721_wrapper';
export { ERC1155ProxyWrapper } from './erc1155_proxy_wrapper';
export { ERC1155MintableContract, Erc1155Wrapper } from '@0x/contracts-erc1155';
export { DummyERC20TokenContract } from '@0x/contracts-erc20';
export { DummyERC721TokenContract } from '@0x/contracts-erc721';
export { AssetProxyId } from '@0x/types';
export {
ERC1155HoldingsByOwner,
ERC20BalancesByOwner,
ERC721TokenIdsByOwner,
ERC1155FungibleHoldingsByOwner,
ERC1155NonFungibleHoldingsByOwner,
} from '@0x/contracts-test-utils';
export {
TransactionReceiptWithDecodedLogs,
Provider,
ZeroExProvider,
JSONRPCRequestPayload,
JSONRPCErrorCallback,
TransactionReceiptStatus,
JSONRPCResponsePayload,
JSONRPCResponseError,
ContractArtifact,
ContractChains,
CompilerOpts,
StandardContractOutput,
CompilerSettings,
ContractChainData,
ContractAbi,
DevdocOutput,
EvmOutput,
CompilerSettingsMetadata,
OptimizerSettings,
OutputField,
ParamDescription,
EvmBytecodeOutput,
EvmBytecodeOutputLinkReferences,
AbiDefinition,
FunctionAbi,
EventAbi,
RevertErrorAbi,
EventParameter,
DataItem,
MethodAbi,
ConstructorAbi,
FallbackAbi,
ConstructorStateMutability,
TupleDataItem,
StateMutability,
} from 'ethereum-types';
export {
decodeERC1155AssetData,
decodeERC20AssetData,
decodeERC20BridgeAssetData,
decodeERC721AssetData,
decodeMultiAssetData,
decodeStaticCallAssetData,
encodeERC1155AssetData,
encodeERC20AssetData,
encodeERC20BridgeAssetData,
encodeERC721AssetData,
encodeMultiAssetData,
encodeStaticCallAssetData,
getAssetDataProxyId,
} from './asset_data';
export * from './dydx_bridge_encoder';
export * from './dex_forwarder_bridge';

View File

@@ -1,49 +0,0 @@
/*
* -----------------------------------------------------------------------------
* 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';
export * from '../generated-wrappers/erc20_proxy';
export * from '../generated-wrappers/erc721_proxy';
export * from '../generated-wrappers/eth2_dai_bridge';
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

@@ -1,97 +0,0 @@
/*
* -----------------------------------------------------------------------------
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
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';
import * as ERC20Proxy from '../test/generated-artifacts/ERC20Proxy.json';
import * as ERC721Proxy from '../test/generated-artifacts/ERC721Proxy.json';
import * as Eth2DaiBridge from '../test/generated-artifacts/Eth2DaiBridge.json';
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,
Ownable: Ownable as ContractArtifact,
ERC1155Proxy: ERC1155Proxy as ContractArtifact,
ERC20BridgeProxy: ERC20BridgeProxy as ContractArtifact,
ERC20Proxy: ERC20Proxy as ContractArtifact,
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

@@ -1,128 +0,0 @@
import { blockchainTests, expect, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
import { RevertReason } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { artifacts } from './artifacts';
import { MixinAuthorizableContract } from './wrappers';
blockchainTests.resets('Authorizable', () => {
let owner: string;
let notOwner: string;
let address: string;
let authorizable: MixinAuthorizableContract;
before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
[owner, address, notOwner] = accounts.slice(0, 3);
authorizable = await MixinAuthorizableContract.deployFrom0xArtifactAsync(
artifacts.MixinAuthorizable,
provider,
txDefaults,
artifacts,
);
});
describe('addAuthorizedAddress', () => {
it('should revert if not called by owner', async () => {
const tx = authorizable.addAuthorizedAddress(notOwner).sendTransactionAsync({ from: notOwner });
return expect(tx).to.revertWith(RevertReason.OnlyContractOwner);
});
it('should allow owner to add an authorized address', async () => {
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
const isAuthorized = await authorizable.authorized(address).callAsync();
expect(isAuthorized).to.be.true();
});
it('should revert if owner attempts to authorize a duplicate address', async () => {
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
const tx = authorizable.addAuthorizedAddress(address).sendTransactionAsync({ from: owner });
return expect(tx).to.revertWith(RevertReason.TargetAlreadyAuthorized);
});
});
describe('removeAuthorizedAddress', () => {
it('should revert if not called by owner', async () => {
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
const tx = authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: notOwner });
return expect(tx).to.revertWith(RevertReason.OnlyContractOwner);
});
it('should allow owner to remove an authorized address', async () => {
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
const isAuthorized = await authorizable.authorized(address).callAsync();
expect(isAuthorized).to.be.false();
});
it('should revert if owner attempts to remove an address that is not authorized', async () => {
const tx = authorizable.removeAuthorizedAddress(address).sendTransactionAsync({ from: owner });
return expect(tx).to.revertWith(RevertReason.TargetNotAuthorized);
});
});
describe('removeAuthorizedAddressAtIndex', () => {
it('should revert if not called by owner', async () => {
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
const index = new BigNumber(0);
const tx = authorizable
.removeAuthorizedAddressAtIndex(address, index)
.sendTransactionAsync({ from: notOwner });
return expect(tx).to.revertWith(RevertReason.OnlyContractOwner);
});
it('should revert if index is >= authorities.length', async () => {
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
const index = new BigNumber(1);
const tx = authorizable
.removeAuthorizedAddressAtIndex(address, index)
.sendTransactionAsync({ from: owner });
return expect(tx).to.revertWith(RevertReason.IndexOutOfBounds);
});
it('should revert if owner attempts to remove an address that is not authorized', async () => {
const index = new BigNumber(0);
const tx = authorizable
.removeAuthorizedAddressAtIndex(address, index)
.sendTransactionAsync({ from: owner });
return expect(tx).to.revertWith(RevertReason.TargetNotAuthorized);
});
it('should revert if address at index does not match target', async () => {
const address1 = address;
const address2 = notOwner;
await authorizable.addAuthorizedAddress(address1).awaitTransactionSuccessAsync({ from: owner });
await authorizable.addAuthorizedAddress(address2).awaitTransactionSuccessAsync({ from: owner });
const address1Index = new BigNumber(0);
const tx = authorizable
.removeAuthorizedAddressAtIndex(address2, address1Index)
.sendTransactionAsync({ from: owner });
return expect(tx).to.revertWith(RevertReason.AuthorizedAddressMismatch);
});
it('should allow owner to remove an authorized address', async () => {
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
const index = new BigNumber(0);
await authorizable.removeAuthorizedAddressAtIndex(address, index).awaitTransactionSuccessAsync({
from: owner,
});
const isAuthorized = await authorizable.authorized(address).callAsync();
expect(isAuthorized).to.be.false();
});
});
describe('getAuthorizedAddresses', () => {
it('should return all authorized addresses', async () => {
const initial = await authorizable.getAuthorizedAddresses().callAsync();
expect(initial).to.have.length(0);
await authorizable.addAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
const afterAdd = await authorizable.getAuthorizedAddresses().callAsync();
expect(afterAdd).to.have.length(1);
expect(afterAdd).to.include(address);
await authorizable.removeAuthorizedAddress(address).awaitTransactionSuccessAsync({ from: owner });
const afterRemove = await authorizable.getAuthorizedAddresses().callAsync();
expect(afterRemove).to.have.length(0);
});
});
});

View File

@@ -1,60 +0,0 @@
import { ERC20TokenContract } from '@0x/contracts-erc20';
import { blockchainTests, constants, expect, randomAddress } from '@0x/contracts-test-utils';
import { AssetProxyId, RevertReason } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { artifacts } from './artifacts';
import { TestChaiBridgeContract } from './wrappers';
blockchainTests.resets('ChaiBridge unit tests', env => {
let chaiBridgeContract: TestChaiBridgeContract;
let testDaiContract: ERC20TokenContract;
let fromAddress: string;
let toAddress: string;
const alwaysRevertAddress = '0x0000000000000000000000000000000000000001';
const amount = new BigNumber(1);
before(async () => {
[fromAddress, toAddress] = await env.getAccountAddressesAsync();
chaiBridgeContract = await TestChaiBridgeContract.deployFrom0xArtifactAsync(
artifacts.TestChaiBridge,
env.provider,
env.txDefaults,
artifacts,
);
const testChaiDaiAddress = await chaiBridgeContract.testChaiDai().callAsync();
testDaiContract = new ERC20TokenContract(testChaiDaiAddress, env.provider, env.txDefaults);
});
describe('bridgeTransferFrom()', () => {
it('fails if not called by ERC20BridgeProxy', async () => {
return expect(
chaiBridgeContract
.bridgeTransferFrom(randomAddress(), fromAddress, toAddress, amount, constants.NULL_BYTES)
.awaitTransactionSuccessAsync({ from: alwaysRevertAddress }),
).to.revertWith(RevertReason.ChaiBridgeOnlyCallableByErc20BridgeProxy);
});
it('returns magic bytes upon success', async () => {
const magicBytes = await chaiBridgeContract
.bridgeTransferFrom(randomAddress(), fromAddress, toAddress, amount, constants.NULL_BYTES)
.callAsync();
expect(magicBytes).to.eq(AssetProxyId.ERC20Bridge);
});
it('should increase the Dai balance of `toAddress` by `amount` if successful', async () => {
const initialBalance = await testDaiContract.balanceOf(toAddress).callAsync();
await chaiBridgeContract
.bridgeTransferFrom(randomAddress(), fromAddress, toAddress, amount, constants.NULL_BYTES)
.awaitTransactionSuccessAsync();
const endBalance = await testDaiContract.balanceOf(toAddress).callAsync();
expect(endBalance).to.bignumber.eq(initialBalance.plus(amount));
});
it('fails if the `chai.draw` call fails', async () => {
return expect(
chaiBridgeContract
.bridgeTransferFrom(randomAddress(), alwaysRevertAddress, toAddress, amount, constants.NULL_BYTES)
.awaitTransactionSuccessAsync(),
).to.revertWith(RevertReason.ChaiBridgeDrawDaiFailed);
});
});
});

View File

@@ -1,354 +0,0 @@
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

@@ -1,399 +0,0 @@
import { LibMathRevertErrors } from '@0x/contracts-exchange-libs';
import { blockchainTests, constants, expect, verifyEventsFromLogs } from '@0x/contracts-test-utils';
import { AssetProxyId, RevertReason } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import { DydxBridgeActionType, DydxBridgeData, dydxBridgeDataEncoder } from '../src/dydx_bridge_encoder';
import { ERC20BridgeProxyContract, IAssetDataContract } from '../src/wrappers';
import { artifacts } from './artifacts';
import { TestDydxBridgeContract, TestDydxBridgeEvents } from './wrappers';
blockchainTests.resets('DydxBridge unit tests', env => {
const defaultAccountNumber = new BigNumber(1);
const marketId = new BigNumber(2);
const defaultAmount = new BigNumber(4);
const notAuthorized = '0x0000000000000000000000000000000000000001';
const defaultDepositAction = {
actionType: DydxBridgeActionType.Deposit,
accountIdx: constants.ZERO_AMOUNT,
marketId,
conversionRateNumerator: constants.ZERO_AMOUNT,
conversionRateDenominator: constants.ZERO_AMOUNT,
};
const defaultWithdrawAction = {
actionType: DydxBridgeActionType.Withdraw,
accountIdx: constants.ZERO_AMOUNT,
marketId,
conversionRateNumerator: constants.ZERO_AMOUNT,
conversionRateDenominator: constants.ZERO_AMOUNT,
};
let testContract: TestDydxBridgeContract;
let testProxyContract: ERC20BridgeProxyContract;
let assetDataEncoder: IAssetDataContract;
let owner: string;
let authorized: string;
let accountOwner: string;
let receiver: string;
before(async () => {
// Get accounts
const accounts = await env.web3Wrapper.getAvailableAddressesAsync();
[owner, authorized, accountOwner, receiver] = accounts;
// Deploy dydx bridge
testContract = await TestDydxBridgeContract.deployFrom0xArtifactAsync(
artifacts.TestDydxBridge,
env.provider,
env.txDefaults,
artifacts,
[accountOwner, receiver],
);
// Deploy test erc20 bridge proxy
testProxyContract = await ERC20BridgeProxyContract.deployFrom0xArtifactAsync(
artifacts.ERC20BridgeProxy,
env.provider,
env.txDefaults,
artifacts,
);
await testProxyContract.addAuthorizedAddress(authorized).awaitTransactionSuccessAsync({ from: owner });
// Setup asset data encoder
assetDataEncoder = new IAssetDataContract(constants.NULL_ADDRESS, env.provider);
});
describe('bridgeTransferFrom()', () => {
const callBridgeTransferFrom = async (
from: string,
to: string,
amount: BigNumber,
bridgeData: DydxBridgeData,
sender: string,
): Promise<string> => {
const returnValue = await testContract
.bridgeTransferFrom(
constants.NULL_ADDRESS,
from,
to,
amount,
dydxBridgeDataEncoder.encode({ bridgeData }),
)
.callAsync({ from: sender });
return returnValue;
};
const executeBridgeTransferFromAndVerifyEvents = async (
from: string,
to: string,
amount: BigNumber,
bridgeData: DydxBridgeData,
sender: string,
): Promise<void> => {
// Execute transaction.
const txReceipt = await testContract
.bridgeTransferFrom(
constants.NULL_ADDRESS,
from,
to,
amount,
dydxBridgeDataEncoder.encode({ bridgeData }),
)
.awaitTransactionSuccessAsync({ from: sender });
// Verify `OperateAccount` event.
const expectedOperateAccountEvents = [];
for (const accountNumber of bridgeData.accountNumbers) {
expectedOperateAccountEvents.push({
owner: accountOwner,
number: accountNumber,
});
}
verifyEventsFromLogs(txReceipt.logs, expectedOperateAccountEvents, TestDydxBridgeEvents.OperateAccount);
// Verify `OperateAction` event.
const weiDenomination = 0;
const deltaAmountRef = 0;
const expectedOperateActionEvents = [];
for (const action of bridgeData.actions) {
expectedOperateActionEvents.push({
actionType: action.actionType as number,
accountIdx: action.accountIdx,
amountSign: action.actionType === DydxBridgeActionType.Deposit ? true : false,
amountDenomination: weiDenomination,
amountRef: deltaAmountRef,
amountValue: action.conversionRateDenominator.gt(0)
? amount
.times(action.conversionRateNumerator)
.dividedToIntegerBy(action.conversionRateDenominator)
: amount,
primaryMarketId: marketId,
secondaryMarketId: constants.ZERO_AMOUNT,
otherAddress: action.actionType === DydxBridgeActionType.Deposit ? from : to,
otherAccountId: constants.ZERO_AMOUNT,
data: '0x',
});
}
verifyEventsFromLogs(txReceipt.logs, expectedOperateActionEvents, TestDydxBridgeEvents.OperateAction);
};
it('succeeds when calling with zero amount', async () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [defaultDepositAction],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
constants.ZERO_AMOUNT,
bridgeData,
authorized,
);
});
it('succeeds when calling with no accounts', async () => {
const bridgeData = {
accountNumbers: [],
actions: [defaultDepositAction],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
});
it('succeeds when calling with no actions', async () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
});
it('succeeds when calling `operate` with the `deposit` action and a single account', async () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [defaultDepositAction],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
});
it('succeeds when calling `operate` with the `deposit` action and multiple accounts', async () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber, defaultAccountNumber.plus(1)],
actions: [defaultDepositAction],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
});
it('succeeds when calling `operate` with the `withdraw` action and a single account', async () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [defaultWithdrawAction],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
});
it('succeeds when calling `operate` with the `withdraw` action and multiple accounts', async () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber, defaultAccountNumber.plus(1)],
actions: [defaultWithdrawAction],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
});
it('succeeds when calling `operate` with the `deposit` action and multiple accounts', async () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber, defaultAccountNumber.plus(1)],
actions: [defaultWithdrawAction, defaultDepositAction],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
});
it('succeeds when calling `operate` with multiple actions under a single account', async () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [defaultWithdrawAction, defaultDepositAction],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
});
it('succeeds when scaling the `amount` to deposit', async () => {
const conversionRateNumerator = new BigNumber(1);
const conversionRateDenominator = new BigNumber(2);
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [
defaultWithdrawAction,
{
...defaultDepositAction,
conversionRateNumerator,
conversionRateDenominator,
},
],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
});
it('succeeds when scaling the `amount` to withdraw', async () => {
const conversionRateNumerator = new BigNumber(1);
const conversionRateDenominator = new BigNumber(2);
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [
defaultDepositAction,
{
...defaultWithdrawAction,
conversionRateNumerator,
conversionRateDenominator,
},
],
};
await executeBridgeTransferFromAndVerifyEvents(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
});
it('reverts if not called by the ERC20 Bridge Proxy', async () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [defaultDepositAction],
};
const callBridgeTransferFromPromise = callBridgeTransferFrom(
accountOwner,
receiver,
defaultAmount,
bridgeData,
notAuthorized,
);
const expectedError = RevertReason.DydxBridgeOnlyCallableByErc20BridgeProxy;
return expect(callBridgeTransferFromPromise).to.revertWith(expectedError);
});
it('should return magic bytes if call succeeds', async () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [defaultDepositAction],
};
const returnValue = await callBridgeTransferFrom(
accountOwner,
receiver,
defaultAmount,
bridgeData,
authorized,
);
expect(returnValue).to.equal(AssetProxyId.ERC20Bridge);
});
it('should revert when `Operate` reverts', async () => {
// Set revert flag.
await testContract.setRevertOnOperate(true).awaitTransactionSuccessAsync();
// Execute transfer.
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [defaultDepositAction],
};
const tx = callBridgeTransferFrom(accountOwner, receiver, defaultAmount, bridgeData, authorized);
const expectedError = 'TestDydxBridge/SHOULD_REVERT_ON_OPERATE';
return expect(tx).to.revertWith(expectedError);
});
it('should revert when there is a rounding error', async () => {
// Setup a rounding error
const conversionRateNumerator = new BigNumber(5318);
const conversionRateDenominator = new BigNumber(47958);
const amount = new BigNumber(9000);
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [
defaultDepositAction,
{
...defaultWithdrawAction,
conversionRateNumerator,
conversionRateDenominator,
},
],
};
// Execute transfer and assert error.
const tx = callBridgeTransferFrom(accountOwner, receiver, amount, bridgeData, authorized);
const expectedError = new LibMathRevertErrors.RoundingError(
conversionRateNumerator,
conversionRateDenominator,
amount,
);
return expect(tx).to.revertWith(expectedError);
});
});
describe('ERC20BridgeProxy.transferFrom()', () => {
const bridgeData = {
accountNumbers: [defaultAccountNumber],
actions: [defaultWithdrawAction],
};
let assetData: string;
before(async () => {
const testTokenAddress = await testContract.getTestToken().callAsync();
assetData = assetDataEncoder
.ERC20Bridge(testTokenAddress, testContract.address, dydxBridgeDataEncoder.encode({ bridgeData }))
.getABIEncodedTransactionData();
});
it('should succeed if `bridgeTransferFrom` succeeds', async () => {
await testProxyContract
.transferFrom(assetData, accountOwner, receiver, defaultAmount)
.awaitTransactionSuccessAsync({ from: authorized });
});
it('should revert if `bridgeTransferFrom` reverts', async () => {
// Set revert flag.
await testContract.setRevertOnOperate(true).awaitTransactionSuccessAsync();
const tx = testProxyContract
.transferFrom(assetData, accountOwner, receiver, defaultAmount)
.awaitTransactionSuccessAsync({ from: authorized });
const expectedError = 'TestDydxBridge/SHOULD_REVERT_ON_OPERATE';
return expect(tx).to.revertWith(expectedError);
});
});
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,287 +0,0 @@
import {
blockchainTests,
constants,
expect,
getRandomInteger,
Numberish,
randomAddress,
} from '@0x/contracts-test-utils';
import { AuthorizableRevertErrors } from '@0x/contracts-utils';
import { AssetProxyId } from '@0x/types';
import { AbiEncoder, BigNumber, hexUtils, StringRevertError } from '@0x/utils';
import { DecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import { ERC20BridgeProxyContract, TestERC20BridgeContract } from './wrappers';
blockchainTests.resets('ERC20BridgeProxy unit tests', env => {
const PROXY_ID = AssetProxyId.ERC20Bridge;
const BRIDGE_SUCCESS_RETURN_DATA = hexUtils.rightPad(PROXY_ID);
let owner: string;
let badCaller: string;
let assetProxy: ERC20BridgeProxyContract;
let bridgeContract: TestERC20BridgeContract;
let testTokenAddress: string;
before(async () => {
[owner, badCaller] = await env.getAccountAddressesAsync();
assetProxy = await ERC20BridgeProxyContract.deployFrom0xArtifactAsync(
artifacts.ERC20BridgeProxy,
env.provider,
env.txDefaults,
artifacts,
);
bridgeContract = await TestERC20BridgeContract.deployFrom0xArtifactAsync(
artifacts.TestERC20Bridge,
env.provider,
env.txDefaults,
artifacts,
);
testTokenAddress = await bridgeContract.testToken().callAsync();
await assetProxy.addAuthorizedAddress(owner).awaitTransactionSuccessAsync();
});
interface AssetDataOpts {
tokenAddress: string;
bridgeAddress: string;
bridgeData: BridgeDataOpts;
}
interface BridgeDataOpts {
transferAmount: Numberish;
revertError?: string;
returnData: string;
}
function createAssetData(opts?: Partial<AssetDataOpts>): AssetDataOpts {
return _.merge(
{
tokenAddress: testTokenAddress,
bridgeAddress: bridgeContract.address,
bridgeData: createBridgeData(),
},
opts,
);
}
function createBridgeData(opts?: Partial<BridgeDataOpts>): BridgeDataOpts {
return _.merge(
{
transferAmount: constants.ZERO_AMOUNT,
returnData: BRIDGE_SUCCESS_RETURN_DATA,
},
opts,
);
}
function encodeAssetData(opts: AssetDataOpts): string {
const encoder = AbiEncoder.createMethod('ERC20BridgeProxy', [
{ name: 'tokenAddress', type: 'address' },
{ name: 'bridgeAddress', type: 'address' },
{ name: 'bridgeData', type: 'bytes' },
]);
return encoder.encode([opts.tokenAddress, opts.bridgeAddress, encodeBridgeData(opts.bridgeData)]);
}
function encodeBridgeData(opts: BridgeDataOpts): string {
const encoder = AbiEncoder.create([
{ name: 'transferAmount', type: 'int256' },
{ name: 'revertData', type: 'bytes' },
{ name: 'returnData', type: 'bytes' },
]);
const revertErrorBytes =
opts.revertError !== undefined ? new StringRevertError(opts.revertError).encode() : '0x';
return encoder.encode([new BigNumber(opts.transferAmount), revertErrorBytes, opts.returnData]);
}
async function setTestTokenBalanceAsync(_owner: string, balance: Numberish): Promise<void> {
await bridgeContract.setTestTokenBalance(_owner, new BigNumber(balance)).awaitTransactionSuccessAsync();
}
describe('transferFrom()', () => {
interface TransferFromOpts {
assetData: AssetDataOpts;
from: string;
to: string;
amount: Numberish;
}
function createTransferFromOpts(opts?: Partial<TransferFromOpts>): TransferFromOpts {
const transferAmount = _.get(opts, ['amount'], getRandomInteger(1, 100e18)) as BigNumber;
return _.merge(
{
assetData: createAssetData({
bridgeData: createBridgeData({
transferAmount,
}),
}),
from: randomAddress(),
to: randomAddress(),
amount: transferAmount,
},
opts,
);
}
async function transferFromAsync(opts?: Partial<TransferFromOpts>, caller?: string): Promise<DecodedLogs> {
const _opts = createTransferFromOpts(opts);
const { logs } = await assetProxy
.transferFrom(encodeAssetData(_opts.assetData), _opts.from, _opts.to, new BigNumber(_opts.amount))
.awaitTransactionSuccessAsync({ from: caller });
return (logs as any) as DecodedLogs;
}
it('succeeds if the bridge succeeds and balance increases by `amount`', async () => {
const tx = transferFromAsync();
return expect(tx).to.be.fulfilled('');
});
it('succeeds if balance increases more than `amount`', async () => {
const amount = getRandomInteger(1, 100e18);
const tx = transferFromAsync({
amount,
assetData: createAssetData({
bridgeData: createBridgeData({
transferAmount: amount.plus(1),
}),
}),
});
return expect(tx).to.be.fulfilled('');
});
it('passes the correct arguments to the bridge contract', async () => {
const opts = createTransferFromOpts();
const logs = await transferFromAsync(opts);
expect(logs.length).to.eq(1);
const args = logs[0].args;
expect(args.tokenAddress).to.eq(opts.assetData.tokenAddress);
expect(args.from).to.eq(opts.from);
expect(args.to).to.eq(opts.to);
expect(args.amount).to.bignumber.eq(opts.amount);
expect(args.bridgeData).to.eq(encodeBridgeData(opts.assetData.bridgeData));
});
it('fails if not called by an authorized address', async () => {
const tx = transferFromAsync({}, badCaller);
return expect(tx).to.revertWith(new AuthorizableRevertErrors.SenderNotAuthorizedError(badCaller));
});
it('fails if asset data is truncated', async () => {
const opts = createTransferFromOpts();
const truncatedAssetData = hexUtils.slice(encodeAssetData(opts.assetData), 0, -1);
const tx = assetProxy
.transferFrom(truncatedAssetData, opts.from, opts.to, new BigNumber(opts.amount))
.awaitTransactionSuccessAsync();
return expect(tx).to.be.rejected();
});
it('fails if bridge returns nothing', async () => {
const tx = transferFromAsync({
assetData: createAssetData({
bridgeData: createBridgeData({
returnData: '0x',
}),
}),
});
// This will actually revert when the AP tries to decode the return
// value.
return expect(tx).to.be.rejected();
});
it('fails if bridge returns true', async () => {
const tx = transferFromAsync({
assetData: createAssetData({
bridgeData: createBridgeData({
returnData: hexUtils.leftPad('0x1'),
}),
}),
});
// This will actually revert when the AP tries to decode the return
// value.
return expect(tx).to.be.rejected();
});
it('fails if bridge returns 0x1', async () => {
const tx = transferFromAsync({
assetData: createAssetData({
bridgeData: createBridgeData({
returnData: hexUtils.rightPad('0x1'),
}),
}),
});
return expect(tx).to.revertWith('BRIDGE_FAILED');
});
it('fails if bridge is an EOA', async () => {
const tx = transferFromAsync({
assetData: createAssetData({
bridgeAddress: randomAddress(),
}),
});
// This will actually revert when the AP tries to decode the return
// value.
return expect(tx).to.be.rejected();
});
it('fails if bridge reverts', async () => {
const revertError = 'FOOBAR';
const tx = transferFromAsync({
assetData: createAssetData({
bridgeData: createBridgeData({
revertError,
}),
}),
});
return expect(tx).to.revertWith(revertError);
});
it('fails if balance of `to` increases by less than `amount`', async () => {
const amount = getRandomInteger(1, 100e18);
const tx = transferFromAsync({
amount,
assetData: createAssetData({
bridgeData: createBridgeData({
transferAmount: amount.minus(1),
}),
}),
});
return expect(tx).to.revertWith('BRIDGE_UNDERPAY');
});
it('fails if balance of `to` decreases', async () => {
const toAddress = randomAddress();
await setTestTokenBalanceAsync(toAddress, 1e18);
const tx = transferFromAsync({
to: toAddress,
assetData: createAssetData({
bridgeData: createBridgeData({
transferAmount: -1,
}),
}),
});
return expect(tx).to.revertWith('BRIDGE_UNDERPAY');
});
});
describe('balanceOf()', () => {
it('retrieves the balance of the encoded token', async () => {
const _owner = randomAddress();
const balance = getRandomInteger(1, 100e18);
await bridgeContract.setTestTokenBalance(_owner, balance).awaitTransactionSuccessAsync();
const assetData = createAssetData({
tokenAddress: testTokenAddress,
});
const actualBalance = await assetProxy.balanceOf(encodeAssetData(assetData), _owner).callAsync();
expect(actualBalance).to.bignumber.eq(balance);
});
});
describe('getProxyId()', () => {
it('returns the correct proxy ID', async () => {
const proxyId = await assetProxy.getProxyId().callAsync();
expect(proxyId).to.eq(PROXY_ID);
});
});
});

View File

@@ -1,191 +0,0 @@
import {
blockchainTests,
constants,
expect,
filterLogsToArguments,
getRandomInteger,
Numberish,
randomAddress,
} from '@0x/contracts-test-utils';
import { AssetProxyId } from '@0x/types';
import { BigNumber, hexUtils, RawRevertError } from '@0x/utils';
import { DecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import {
TestEth2DaiBridgeContract,
TestEth2DaiBridgeEvents,
TestEth2DaiBridgeSellAllAmountEventArgs,
TestEth2DaiBridgeTokenApproveEventArgs,
TestEth2DaiBridgeTokenTransferEventArgs,
} from './wrappers';
blockchainTests.resets('Eth2DaiBridge unit tests', env => {
let testContract: TestEth2DaiBridgeContract;
before(async () => {
testContract = await TestEth2DaiBridgeContract.deployFrom0xArtifactAsync(
artifacts.TestEth2DaiBridge,
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 WithdrawToOpts {
toTokenAddress?: string;
fromTokenAddress?: string;
toAddress: string;
amount: Numberish;
fromTokenBalance: Numberish;
revertReason: string;
fillAmount: Numberish;
toTokentransferRevertReason: string;
toTokenTransferReturnData: string;
}
interface WithdrawToResult {
opts: WithdrawToOpts;
result: string;
logs: DecodedLogs;
}
function createWithdrawToOpts(opts?: Partial<WithdrawToOpts>): WithdrawToOpts {
return {
toAddress: randomAddress(),
amount: getRandomInteger(1, 100e18),
revertReason: '',
fillAmount: getRandomInteger(1, 100e18),
fromTokenBalance: getRandomInteger(1, 100e18),
toTokentransferRevertReason: '',
toTokenTransferReturnData: hexUtils.leftPad(1),
...opts,
};
}
async function withdrawToAsync(opts?: Partial<WithdrawToOpts>): Promise<WithdrawToResult> {
const _opts = createWithdrawToOpts(opts);
// Set the fill behavior.
await testContract
.setFillBehavior(_opts.revertReason, new BigNumber(_opts.fillAmount))
.awaitTransactionSuccessAsync();
// Create tokens and balances.
if (_opts.fromTokenAddress === undefined) {
const createTokenFn = testContract.createToken(new BigNumber(_opts.fromTokenBalance));
_opts.fromTokenAddress = await createTokenFn.callAsync();
await createTokenFn.awaitTransactionSuccessAsync();
}
if (_opts.toTokenAddress === undefined) {
const createTokenFn = testContract.createToken(constants.ZERO_AMOUNT);
_opts.toTokenAddress = await createTokenFn.callAsync();
await createTokenFn.awaitTransactionSuccessAsync();
}
// Set the transfer behavior of `toTokenAddress`.
await testContract
.setTransferBehavior(
_opts.toTokenAddress,
_opts.toTokentransferRevertReason,
_opts.toTokenTransferReturnData,
)
.awaitTransactionSuccessAsync();
// Call bridgeTransferFrom().
const bridgeTransferFromFn = testContract.bridgeTransferFrom(
// "to" token address
_opts.toTokenAddress,
// Random from address.
randomAddress(),
// To address.
_opts.toAddress,
new BigNumber(_opts.amount),
// ABI-encode the "from" token address as the bridge data.
hexUtils.leftPad(_opts.fromTokenAddress as string),
);
const result = await bridgeTransferFromFn.callAsync();
const { logs } = await bridgeTransferFromFn.awaitTransactionSuccessAsync();
return {
opts: _opts,
result,
logs: (logs as any) as DecodedLogs,
};
}
it('returns magic bytes on success', async () => {
const BRIDGE_SUCCESS_RETURN_DATA = AssetProxyId.ERC20Bridge;
const { result } = await withdrawToAsync();
expect(result).to.eq(BRIDGE_SUCCESS_RETURN_DATA);
});
it('calls `Eth2Dai.sellAllAmount()`', async () => {
const { opts, logs } = await withdrawToAsync();
const transfers = filterLogsToArguments<TestEth2DaiBridgeSellAllAmountEventArgs>(
logs,
TestEth2DaiBridgeEvents.SellAllAmount,
);
expect(transfers.length).to.eq(1);
expect(transfers[0].sellToken).to.eq(opts.fromTokenAddress);
expect(transfers[0].buyToken).to.eq(opts.toTokenAddress);
expect(transfers[0].sellTokenAmount).to.bignumber.eq(opts.fromTokenBalance);
expect(transfers[0].minimumFillAmount).to.bignumber.eq(opts.amount);
});
it('sets an unlimited allowance on the `fromTokenAddress` token', async () => {
const { opts, logs } = await withdrawToAsync();
const approvals = filterLogsToArguments<TestEth2DaiBridgeTokenApproveEventArgs>(
logs,
TestEth2DaiBridgeEvents.TokenApprove,
);
expect(approvals.length).to.eq(1);
expect(approvals[0].token).to.eq(opts.fromTokenAddress);
expect(approvals[0].spender).to.eq(testContract.address);
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
});
it('transfers filled amount to `to`', async () => {
const { opts, logs } = await withdrawToAsync();
const transfers = filterLogsToArguments<TestEth2DaiBridgeTokenTransferEventArgs>(
logs,
TestEth2DaiBridgeEvents.TokenTransfer,
);
expect(transfers.length).to.eq(1);
expect(transfers[0].token).to.eq(opts.toTokenAddress);
expect(transfers[0].from).to.eq(testContract.address);
expect(transfers[0].to).to.eq(opts.toAddress);
expect(transfers[0].amount).to.bignumber.eq(opts.fillAmount);
});
it('fails if `Eth2Dai.sellAllAmount()` reverts', async () => {
const opts = createWithdrawToOpts({ revertReason: 'FOOBAR' });
const tx = withdrawToAsync(opts);
return expect(tx).to.revertWith(opts.revertReason);
});
it('fails if `toTokenAddress.transfer()` reverts', async () => {
const opts = createWithdrawToOpts({ toTokentransferRevertReason: 'FOOBAR' });
const tx = withdrawToAsync(opts);
return expect(tx).to.revertWith(opts.toTokentransferRevertReason);
});
it('fails if `toTokenAddress.transfer()` returns false', async () => {
const opts = createWithdrawToOpts({ toTokenTransferReturnData: hexUtils.leftPad(0) });
const tx = withdrawToAsync(opts);
return expect(tx).to.revertWith(new RawRevertError(hexUtils.leftPad(0)));
});
it('succeeds if `toTokenAddress.transfer()` returns true', async () => {
await withdrawToAsync({ toTokenTransferReturnData: hexUtils.leftPad(1) });
});
});
});

View File

@@ -1,19 +0,0 @@
import { env, EnvVars } from '@0x/dev-utils';
import { coverage, profiler, provider } from '@0x/contracts-test-utils';
import { providerUtils } from '@0x/utils';
before('start web3 provider', () => {
providerUtils.startProviderEngine(provider);
});
after('generate coverage report', async () => {
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
await coverageSubprovider.writeCoverageAsync();
}
if (env.parseBoolean(EnvVars.SolidityProfiler)) {
const profilerSubprovider = profiler.getProfilerSubproviderSingleton();
await profilerSubprovider.writeProfilerOutputAsync();
}
provider.stop();
});

View File

@@ -1,283 +0,0 @@
import {
blockchainTests,
constants,
expect,
getRandomInteger,
getRandomPortion,
randomAddress,
verifyEventsFromLogs,
} from '@0x/contracts-test-utils';
import { AssetProxyId } from '@0x/types';
import { BigNumber, hexUtils } from '@0x/utils';
import { DecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import { TestKyberBridgeContract, TestKyberBridgeEvents } from './wrappers';
blockchainTests.resets('KyberBridge unit tests', env => {
const KYBER_ETH_ADDRESS = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
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);
const WETH_BASE = new BigNumber(10).pow(18);
const KYBER_RATE_BASE = WETH_BASE;
let testContract: TestKyberBridgeContract;
before(async () => {
testContract = await TestKyberBridgeContract.deployFrom0xArtifactAsync(
artifacts.TestKyberBridge,
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()', () => {
let fromTokenAddress: string;
let toTokenAddress: string;
let wethAddress: string;
before(async () => {
wethAddress = await testContract.weth().callAsync();
fromTokenAddress = await testContract.createToken(FROM_TOKEN_DECIMALS).callAsync();
await testContract.createToken(FROM_TOKEN_DECIMALS).awaitTransactionSuccessAsync();
toTokenAddress = await testContract.createToken(TO_TOKEN_DECIMALS).callAsync();
await testContract.createToken(TO_TOKEN_DECIMALS).awaitTransactionSuccessAsync();
});
const STATIC_KYBER_TRADE_ARGS = {
maxBuyTokenAmount: constants.MAX_UINT256,
walletId: constants.NULL_ADDRESS,
};
interface TransferFromOpts {
toTokenAddress: string;
fromTokenAddress: string;
toAddress: string;
// Amount to pass into `bridgeTransferFrom()`
amount: BigNumber;
// Amount to convert in `trade()`.
fillAmount: BigNumber;
// Token balance of the bridge.
fromTokenBalance: BigNumber;
}
interface TransferFromResult {
opts: TransferFromOpts;
result: string;
logs: DecodedLogs;
}
function createTransferFromOpts(opts?: Partial<TransferFromOpts>): TransferFromOpts {
const amount = getRandomInteger(1, TO_TOKEN_BASE.times(100));
return {
fromTokenAddress,
toTokenAddress,
amount,
toAddress: randomAddress(),
fillAmount: getRandomPortion(amount),
fromTokenBalance: getRandomInteger(1, FROM_TOKEN_BASE.times(100)),
...opts,
};
}
async function withdrawToAsync(opts?: Partial<TransferFromOpts>): Promise<TransferFromResult> {
const _opts = createTransferFromOpts(opts);
// Fund the contract with input tokens.
await testContract
.grantTokensTo(_opts.fromTokenAddress, testContract.address, _opts.fromTokenBalance)
.awaitTransactionSuccessAsync({ value: _opts.fromTokenBalance });
// Fund the contract with output tokens.
await testContract.setNextFillAmount(_opts.fillAmount).awaitTransactionSuccessAsync({
value: _opts.toTokenAddress === wethAddress ? _opts.fillAmount : constants.ZERO_AMOUNT,
});
// Call bridgeTransferFrom().
const bridgeTransferFromFn = testContract.bridgeTransferFrom(
// Output token
_opts.toTokenAddress,
// Random maker address.
randomAddress(),
// Recipient address.
_opts.toAddress,
// Transfer amount.
_opts.amount,
// ABI-encode the input token address as the bridge data.
hexUtils.leftPad(_opts.fromTokenAddress),
);
const result = await bridgeTransferFromFn.callAsync();
const { logs } = await bridgeTransferFromFn.awaitTransactionSuccessAsync();
return {
opts: _opts,
result,
logs: (logs as any) as DecodedLogs,
};
}
function getMinimumConversionRate(opts: TransferFromOpts): BigNumber {
const fromBase = opts.fromTokenAddress === wethAddress ? WETH_BASE : FROM_TOKEN_BASE;
const toBase = opts.toTokenAddress === wethAddress ? WETH_BASE : TO_TOKEN_BASE;
return opts.amount
.div(toBase)
.div(opts.fromTokenBalance.div(fromBase))
.times(KYBER_RATE_BASE)
.integerValue(BigNumber.ROUND_DOWN);
}
it('returns magic bytes on success', async () => {
const BRIDGE_SUCCESS_RETURN_DATA = AssetProxyId.ERC20Bridge;
const { result } = await withdrawToAsync();
expect(result).to.eq(BRIDGE_SUCCESS_RETURN_DATA);
});
it('can trade token -> token', async () => {
const { opts, logs } = await withdrawToAsync();
verifyEventsFromLogs(
logs,
[
{
sellTokenAddress: opts.fromTokenAddress,
buyTokenAddress: opts.toTokenAddress,
sellAmount: opts.fromTokenBalance,
recipientAddress: opts.toAddress,
minConversionRate: getMinimumConversionRate(opts),
msgValue: constants.ZERO_AMOUNT,
...STATIC_KYBER_TRADE_ARGS,
},
],
TestKyberBridgeEvents.KyberBridgeTrade,
);
});
it('can trade token -> ETH', async () => {
const { opts, logs } = await withdrawToAsync({
toTokenAddress: wethAddress,
});
verifyEventsFromLogs(
logs,
[
{
sellTokenAddress: opts.fromTokenAddress,
buyTokenAddress: KYBER_ETH_ADDRESS,
sellAmount: opts.fromTokenBalance,
recipientAddress: testContract.address,
minConversionRate: getMinimumConversionRate(opts),
msgValue: constants.ZERO_AMOUNT,
...STATIC_KYBER_TRADE_ARGS,
},
],
TestKyberBridgeEvents.KyberBridgeTrade,
);
});
it('can trade ETH -> token', async () => {
const { opts, logs } = await withdrawToAsync({
fromTokenAddress: wethAddress,
});
verifyEventsFromLogs(
logs,
[
{
sellTokenAddress: KYBER_ETH_ADDRESS,
buyTokenAddress: opts.toTokenAddress,
sellAmount: opts.fromTokenBalance,
recipientAddress: opts.toAddress,
minConversionRate: getMinimumConversionRate(opts),
msgValue: opts.fromTokenBalance,
...STATIC_KYBER_TRADE_ARGS,
},
],
TestKyberBridgeEvents.KyberBridgeTrade,
);
});
it('does nothing if bridge has no token balance', async () => {
const { logs } = await withdrawToAsync({
fromTokenBalance: constants.ZERO_AMOUNT,
});
expect(logs).to.be.length(0);
});
it('only transfers the token if trading the same token', async () => {
const { opts, logs } = await withdrawToAsync({
toTokenAddress: fromTokenAddress,
});
verifyEventsFromLogs(
logs,
[
{
tokenAddress: fromTokenAddress,
ownerAddress: testContract.address,
recipientAddress: opts.toAddress,
amount: opts.fromTokenBalance,
},
],
TestKyberBridgeEvents.KyberBridgeTokenTransfer,
);
});
it('grants Kyber an allowance when selling non-WETH', async () => {
const { opts, logs } = await withdrawToAsync();
verifyEventsFromLogs(
logs,
[
{
tokenAddress: opts.fromTokenAddress,
ownerAddress: testContract.address,
spenderAddress: testContract.address,
allowance: constants.MAX_UINT256,
},
],
TestKyberBridgeEvents.KyberBridgeTokenApprove,
);
});
it('does not grant Kyber an allowance when selling WETH', async () => {
const { logs } = await withdrawToAsync({
fromTokenAddress: wethAddress,
});
verifyEventsFromLogs(logs, [], TestKyberBridgeEvents.KyberBridgeTokenApprove);
});
it('withdraws WETH and passes it to Kyber when selling WETH', async () => {
const { opts, logs } = await withdrawToAsync({
fromTokenAddress: wethAddress,
});
expect(logs[0].event).to.eq(TestKyberBridgeEvents.KyberBridgeWethWithdraw);
expect(logs[0].args).to.deep.eq({
ownerAddress: testContract.address,
amount: opts.fromTokenBalance,
});
expect(logs[1].event).to.eq(TestKyberBridgeEvents.KyberBridgeTrade);
expect(logs[1].args.msgValue).to.bignumber.eq(opts.fromTokenBalance);
});
it('wraps WETH and transfers it to the recipient when buyng WETH', async () => {
const { opts, logs } = await withdrawToAsync({
toTokenAddress: wethAddress,
});
expect(logs[0].event).to.eq(TestKyberBridgeEvents.KyberBridgeTokenApprove);
expect(logs[0].args.tokenAddress).to.eq(opts.fromTokenAddress);
expect(logs[1].event).to.eq(TestKyberBridgeEvents.KyberBridgeTrade);
expect(logs[1].args.recipientAddress).to.eq(testContract.address);
expect(logs[2].event).to.eq(TestKyberBridgeEvents.KyberBridgeWethDeposit);
expect(logs[2].args).to.deep.eq({
msgValue: opts.fillAmount,
ownerAddress: testContract.address,
amount: opts.fillAmount,
});
});
});
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,245 +0,0 @@
import {
chaiSetup,
constants,
expectTransactionFailedWithoutReasonAsync,
provider,
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { AssetProxyId, RevertReason } from '@0x/types';
import { AbiEncoder, BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as ethUtil from 'ethereumjs-util';
import { artifacts } from './artifacts';
import {
IAssetDataContract,
IAssetProxyContract,
StaticCallProxyContract,
TestStaticCallTargetContract,
} from './wrappers';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('StaticCallProxy', () => {
const amount = constants.ZERO_AMOUNT;
let fromAddress: string;
let toAddress: string;
let assetDataInterface: IAssetDataContract;
let staticCallProxy: IAssetProxyContract;
let staticCallTarget: TestStaticCallTargetContract;
before(async () => {
await blockchainLifecycle.startAsync();
});
after(async () => {
await blockchainLifecycle.revertAsync();
});
before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
[fromAddress, toAddress] = accounts.slice(0, 2);
const staticCallProxyWithoutTransferFrom = await StaticCallProxyContract.deployFrom0xArtifactAsync(
artifacts.StaticCallProxy,
provider,
txDefaults,
artifacts,
);
assetDataInterface = new IAssetDataContract(constants.NULL_ADDRESS, provider);
staticCallProxy = new IAssetProxyContract(
staticCallProxyWithoutTransferFrom.address,
provider,
txDefaults,
{},
StaticCallProxyContract.deployedBytecode,
);
staticCallTarget = await TestStaticCallTargetContract.deployFrom0xArtifactAsync(
artifacts.TestStaticCallTarget,
provider,
txDefaults,
artifacts,
);
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
});
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('general', () => {
it('should revert if undefined function is called', async () => {
const undefinedSelector = '0x01020304';
await expectTransactionFailedWithoutReasonAsync(
web3Wrapper.sendTransactionAsync({
from: fromAddress,
to: staticCallProxy.address,
value: constants.ZERO_AMOUNT,
data: undefinedSelector,
}),
);
});
it('should have an id of 0xc339d10a', async () => {
const proxyId = await staticCallProxy.getProxyId().callAsync();
const expectedProxyId = AssetProxyId.StaticCall;
expect(proxyId).to.equal(expectedProxyId);
});
});
describe('transferFrom', () => {
it('should revert if assetData lies outside the bounds of calldata', async () => {
const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData();
const expectedResultHash = constants.KECCAK256_NULL;
const assetData = assetDataInterface
.StaticCall(staticCallTarget.address, staticCallData, expectedResultHash)
.getABIEncodedTransactionData();
const txData = staticCallProxy
.transferFrom(assetData, fromAddress, toAddress, amount)
.getABIEncodedTransactionData();
const offsetToAssetData = '0000000000000000000000000000000000000000000000000000000000000080';
const txDataEndBuffer = ethUtil.toBuffer((txData.length - 2) / 2 - 4);
const paddedTxDataEndBuffer = ethUtil.setLengthLeft(txDataEndBuffer, 32);
const invalidOffsetToAssetData = ethUtil.bufferToHex(paddedTxDataEndBuffer).slice(2);
const newAssetData = '0000000000000000000000000000000000000000000000000000000000000304';
const badTxData = `${txData.replace(offsetToAssetData, invalidOffsetToAssetData)}${newAssetData}`;
await expectTransactionFailedWithoutReasonAsync(
web3Wrapper.sendTransactionAsync({
to: staticCallProxy.address,
from: fromAddress,
data: badTxData,
}),
);
});
it('should revert if the length of assetData is less than 100 bytes', async () => {
const staticCallData = constants.NULL_BYTES;
const expectedResultHash = constants.KECCAK256_NULL;
const assetData = assetDataInterface
.StaticCall(staticCallTarget.address, staticCallData, expectedResultHash)
.getABIEncodedTransactionData()
.slice(0, -128);
const assetDataByteLen = (assetData.length - 2) / 2;
expect((assetDataByteLen - 4) % 32).to.equal(0);
await expectTransactionFailedWithoutReasonAsync(
staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(),
);
});
it('should revert if the offset to `staticCallData` points to outside of assetData', async () => {
const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData();
const expectedResultHash = constants.KECCAK256_NULL;
const assetData = assetDataInterface
.StaticCall(staticCallTarget.address, staticCallData, expectedResultHash)
.getABIEncodedTransactionData();
const offsetToStaticCallData = '0000000000000000000000000000000000000000000000000000000000000060';
const assetDataEndBuffer = ethUtil.toBuffer((assetData.length - 2) / 2 - 4);
const paddedAssetDataEndBuffer = ethUtil.setLengthLeft(assetDataEndBuffer, 32);
const invalidOffsetToStaticCallData = ethUtil.bufferToHex(paddedAssetDataEndBuffer).slice(2);
const newStaticCallData = '0000000000000000000000000000000000000000000000000000000000000304';
const badAssetData = `${assetData.replace(
offsetToStaticCallData,
invalidOffsetToStaticCallData,
)}${newStaticCallData}`;
await expectTransactionFailedWithoutReasonAsync(
staticCallProxy.transferFrom(badAssetData, fromAddress, toAddress, amount).sendTransactionAsync(),
);
});
it('should revert if the callTarget attempts to write to state', async () => {
const staticCallData = staticCallTarget.updateState().getABIEncodedTransactionData();
const expectedResultHash = constants.KECCAK256_NULL;
const assetData = assetDataInterface
.StaticCall(staticCallTarget.address, staticCallData, expectedResultHash)
.getABIEncodedTransactionData();
await expectTransactionFailedWithoutReasonAsync(
staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).sendTransactionAsync(),
);
});
it('should revert with data provided by the callTarget if the staticcall reverts', async () => {
const staticCallData = staticCallTarget.assertEvenNumber(new BigNumber(1)).getABIEncodedTransactionData();
const expectedResultHash = constants.KECCAK256_NULL;
const assetData = assetDataInterface
.StaticCall(staticCallTarget.address, staticCallData, expectedResultHash)
.getABIEncodedTransactionData();
return expect(
staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).awaitTransactionSuccessAsync(),
).to.revertWith(RevertReason.TargetNotEven);
});
it('should revert if the hash of the output is different than expected expected', async () => {
const staticCallData = staticCallTarget.isOddNumber(new BigNumber(0)).getABIEncodedTransactionData();
const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001');
const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer));
const assetData = assetDataInterface
.StaticCall(staticCallTarget.address, staticCallData, expectedResultHash)
.getABIEncodedTransactionData();
return expect(
staticCallProxy.transferFrom(assetData, fromAddress, toAddress, amount).awaitTransactionSuccessAsync(),
).to.revertWith(RevertReason.UnexpectedStaticCallResult);
});
it('should be successful if a function call with no inputs and no outputs is successful', async () => {
const staticCallData = staticCallTarget.noInputFunction().getABIEncodedTransactionData();
const expectedResultHash = constants.KECCAK256_NULL;
const assetData = assetDataInterface
.StaticCall(staticCallTarget.address, staticCallData, expectedResultHash)
.getABIEncodedTransactionData();
await staticCallProxy
.transferFrom(assetData, fromAddress, toAddress, amount)
.awaitTransactionSuccessAsync();
});
it('should be successful if the staticCallTarget is not a contract and no return value is expected', async () => {
const staticCallData = '0x0102030405060708';
const expectedResultHash = constants.KECCAK256_NULL;
const assetData = assetDataInterface
.StaticCall(toAddress, staticCallData, expectedResultHash)
.getABIEncodedTransactionData();
await staticCallProxy
.transferFrom(assetData, fromAddress, toAddress, amount)
.awaitTransactionSuccessAsync();
});
it('should be successful if a function call with one static input returns the correct value', async () => {
const staticCallData = staticCallTarget.isOddNumber(new BigNumber(1)).getABIEncodedTransactionData();
const trueAsBuffer = ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000001');
const expectedResultHash = ethUtil.bufferToHex(ethUtil.sha3(trueAsBuffer));
const assetData = assetDataInterface
.StaticCall(staticCallTarget.address, staticCallData, expectedResultHash)
.getABIEncodedTransactionData();
await staticCallProxy
.transferFrom(assetData, fromAddress, toAddress, amount)
.awaitTransactionSuccessAsync();
});
it('should be successful if a function with one dynamic input is successful', async () => {
const dynamicInput = '0x0102030405060708';
const staticCallData = staticCallTarget.dynamicInputFunction(dynamicInput).getABIEncodedTransactionData();
const expectedResultHash = constants.KECCAK256_NULL;
const assetData = assetDataInterface
.StaticCall(staticCallTarget.address, staticCallData, expectedResultHash)
.getABIEncodedTransactionData();
await staticCallProxy
.transferFrom(assetData, fromAddress, toAddress, amount)
.awaitTransactionSuccessAsync();
});
it('should be successful if a function call returns a complex type', async () => {
const a = new BigNumber(1);
const b = new BigNumber(2);
const staticCallData = staticCallTarget.returnComplexType(a, b).getABIEncodedTransactionData();
const abiEncoder = new AbiEncoder.DynamicBytes({
name: '',
type: 'bytes',
});
const aHex = '0000000000000000000000000000000000000000000000000000000000000001';
const bHex = '0000000000000000000000000000000000000000000000000000000000000002';
const expectedResults = `${staticCallTarget.address}${aHex}${bHex}`;
const offset = '0000000000000000000000000000000000000000000000000000000000000020';
const encodedExpectedResultWithOffset = `0x${offset}${abiEncoder.encode(expectedResults).slice(2)}`;
const expectedResultHash = ethUtil.bufferToHex(
ethUtil.sha3(ethUtil.toBuffer(encodedExpectedResultWithOffset)),
);
const assetData = assetDataInterface
.StaticCall(staticCallTarget.address, staticCallData, expectedResultHash)
.getABIEncodedTransactionData();
await staticCallProxy
.transferFrom(assetData, fromAddress, toAddress, amount)
.awaitTransactionSuccessAsync();
});
});
});

View File

@@ -1,370 +0,0 @@
import {
blockchainTests,
constants,
expect,
filterLogs,
filterLogsToArguments,
getRandomInteger,
Numberish,
randomAddress,
} from '@0x/contracts-test-utils';
import { AssetProxyId } from '@0x/types';
import { BigNumber, hexUtils } from '@0x/utils';
import { DecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import {
TestUniswapBridgeContract,
TestUniswapBridgeEthToTokenTransferInputEventArgs as EthToTokenTransferInputArgs,
TestUniswapBridgeEvents as ContractEvents,
TestUniswapBridgeTokenApproveEventArgs as TokenApproveArgs,
TestUniswapBridgeTokenToEthSwapInputEventArgs as TokenToEthSwapInputArgs,
TestUniswapBridgeTokenToTokenTransferInputEventArgs as TokenToTokenTransferInputArgs,
TestUniswapBridgeTokenTransferEventArgs as TokenTransferArgs,
TestUniswapBridgeWethDepositEventArgs as WethDepositArgs,
TestUniswapBridgeWethWithdrawEventArgs as WethWithdrawArgs,
} from './wrappers';
blockchainTests.resets('UniswapBridge unit tests', env => {
let testContract: TestUniswapBridgeContract;
let wethTokenAddress: string;
before(async () => {
testContract = await TestUniswapBridgeContract.deployFrom0xArtifactAsync(
artifacts.TestUniswapBridge,
env.provider,
env.txDefaults,
artifacts,
);
wethTokenAddress = await testContract.wethToken().callAsync();
});
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 WithdrawToOpts {
fromTokenAddress: string;
toTokenAddress: string;
fromTokenBalance: Numberish;
toAddress: string;
amount: Numberish;
exchangeRevertReason: string;
exchangeFillAmount: Numberish;
toTokenRevertReason: string;
fromTokenRevertReason: string;
}
function createWithdrawToOpts(opts?: Partial<WithdrawToOpts>): WithdrawToOpts {
return {
fromTokenAddress: constants.NULL_ADDRESS,
toTokenAddress: constants.NULL_ADDRESS,
fromTokenBalance: getRandomInteger(1, 1e18),
toAddress: randomAddress(),
amount: getRandomInteger(1, 1e18),
exchangeRevertReason: '',
exchangeFillAmount: getRandomInteger(1, 1e18),
toTokenRevertReason: '',
fromTokenRevertReason: '',
...opts,
};
}
interface WithdrawToResult {
opts: WithdrawToOpts;
result: string;
logs: DecodedLogs;
blockTime: number;
}
async function withdrawToAsync(opts?: Partial<WithdrawToOpts>): Promise<WithdrawToResult> {
const _opts = createWithdrawToOpts(opts);
const callData = { value: new BigNumber(_opts.exchangeFillAmount) };
// Create the "from" token and exchange.
const createFromTokenFn = testContract.createTokenAndExchange(
_opts.fromTokenAddress,
_opts.exchangeRevertReason,
);
[_opts.fromTokenAddress] = await createFromTokenFn.callAsync(callData);
await createFromTokenFn.awaitTransactionSuccessAsync(callData);
// Create the "to" token and exchange.
const createToTokenFn = testContract.createTokenAndExchange(
_opts.toTokenAddress,
_opts.exchangeRevertReason,
);
[_opts.toTokenAddress] = await createToTokenFn.callAsync(callData);
await createToTokenFn.awaitTransactionSuccessAsync(callData);
await testContract
.setTokenRevertReason(_opts.toTokenAddress, _opts.toTokenRevertReason)
.awaitTransactionSuccessAsync();
await testContract
.setTokenRevertReason(_opts.fromTokenAddress, _opts.fromTokenRevertReason)
.awaitTransactionSuccessAsync();
// Set the token balance for the token we're converting from.
await testContract.setTokenBalance(_opts.fromTokenAddress).awaitTransactionSuccessAsync({
value: new BigNumber(_opts.fromTokenBalance),
});
// Call bridgeTransferFrom().
const bridgeTransferFromFn = testContract.bridgeTransferFrom(
// The "to" token address.
_opts.toTokenAddress,
// The "from" address.
randomAddress(),
// The "to" address.
_opts.toAddress,
// The amount to transfer to "to"
new BigNumber(_opts.amount),
// ABI-encoded "from" token address.
hexUtils.leftPad(_opts.fromTokenAddress),
);
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),
};
}
async function getExchangeForTokenAsync(tokenAddress: string): Promise<string> {
return testContract.getExchange(tokenAddress).callAsync();
}
it('returns magic bytes on success', async () => {
const { result } = await withdrawToAsync();
expect(result).to.eq(AssetProxyId.ERC20Bridge);
});
it('just transfers tokens to `to` if the same tokens are in play', async () => {
const createTokenFn = await testContract.createTokenAndExchange(constants.NULL_ADDRESS, '');
const [tokenAddress] = await createTokenFn.callAsync();
await createTokenFn.awaitTransactionSuccessAsync();
const { opts, result, logs } = await withdrawToAsync({
fromTokenAddress: tokenAddress,
toTokenAddress: tokenAddress,
});
expect(result).to.eq(AssetProxyId.ERC20Bridge);
const transfers = filterLogsToArguments<TokenTransferArgs>(logs, ContractEvents.TokenTransfer);
expect(transfers.length).to.eq(1);
expect(transfers[0].token).to.eq(tokenAddress);
expect(transfers[0].from).to.eq(testContract.address);
expect(transfers[0].to).to.eq(opts.toAddress);
expect(transfers[0].amount).to.bignumber.eq(opts.amount);
});
describe('token -> token', () => {
it('calls `IUniswapExchange.tokenToTokenTransferInput()', async () => {
const { opts, logs, blockTime } = await withdrawToAsync();
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
const calls = filterLogsToArguments<TokenToTokenTransferInputArgs>(
logs,
ContractEvents.TokenToTokenTransferInput,
);
expect(calls.length).to.eq(1);
expect(calls[0].exchange).to.eq(exchangeAddress);
expect(calls[0].tokensSold).to.bignumber.eq(opts.fromTokenBalance);
expect(calls[0].minTokensBought).to.bignumber.eq(opts.amount);
expect(calls[0].minEthBought).to.bignumber.eq(1);
expect(calls[0].deadline).to.bignumber.eq(blockTime);
expect(calls[0].recipient).to.eq(opts.toAddress);
expect(calls[0].toTokenAddress).to.eq(opts.toTokenAddress);
});
it('sets allowance for "from" token', async () => {
const { opts, logs } = await withdrawToAsync();
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
expect(approvals.length).to.eq(1);
expect(approvals[0].spender).to.eq(exchangeAddress);
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
});
it('sets allowance for "from" token on subsequent calls', async () => {
const { opts } = await withdrawToAsync();
const { logs } = await withdrawToAsync(opts);
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
expect(approvals.length).to.eq(1);
expect(approvals[0].spender).to.eq(exchangeAddress);
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
});
it('fails if "from" token does not exist', async () => {
const tx = testContract
.bridgeTransferFrom(
randomAddress(),
randomAddress(),
randomAddress(),
getRandomInteger(1, 1e18),
hexUtils.leftPad(randomAddress()),
)
.awaitTransactionSuccessAsync();
return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN');
});
it('fails if the exchange fails', async () => {
const revertReason = 'FOOBAR';
const tx = withdrawToAsync({
exchangeRevertReason: revertReason,
});
return expect(tx).to.eventually.be.rejectedWith(revertReason);
});
});
describe('token -> ETH', () => {
it('calls `IUniswapExchange.tokenToEthSwapInput()`, `WETH.deposit()`, then `transfer()`', async () => {
const { opts, logs, blockTime } = await withdrawToAsync({
toTokenAddress: wethTokenAddress,
});
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
let calls: any = filterLogs<TokenToEthSwapInputArgs>(logs, ContractEvents.TokenToEthSwapInput);
expect(calls.length).to.eq(1);
expect(calls[0].args.exchange).to.eq(exchangeAddress);
expect(calls[0].args.tokensSold).to.bignumber.eq(opts.fromTokenBalance);
expect(calls[0].args.minEthBought).to.bignumber.eq(opts.amount);
expect(calls[0].args.deadline).to.bignumber.eq(blockTime);
calls = filterLogs<WethDepositArgs>(
logs.slice(calls[0].logIndex as number),
ContractEvents.WethDeposit,
);
expect(calls.length).to.eq(1);
expect(calls[0].args.amount).to.bignumber.eq(opts.exchangeFillAmount);
calls = filterLogs<TokenTransferArgs>(
logs.slice(calls[0].logIndex as number),
ContractEvents.TokenTransfer,
);
expect(calls.length).to.eq(1);
expect(calls[0].args.token).to.eq(opts.toTokenAddress);
expect(calls[0].args.from).to.eq(testContract.address);
expect(calls[0].args.to).to.eq(opts.toAddress);
expect(calls[0].args.amount).to.bignumber.eq(opts.exchangeFillAmount);
});
it('sets allowance for "from" token', async () => {
const { opts, logs } = await withdrawToAsync({
toTokenAddress: wethTokenAddress,
});
const transfers = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
expect(transfers.length).to.eq(1);
expect(transfers[0].spender).to.eq(exchangeAddress);
expect(transfers[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
});
it('sets allowance for "from" token on subsequent calls', async () => {
const { opts } = await withdrawToAsync({
toTokenAddress: wethTokenAddress,
});
const { logs } = await withdrawToAsync(opts);
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
const exchangeAddress = await getExchangeForTokenAsync(opts.fromTokenAddress);
expect(approvals.length).to.eq(1);
expect(approvals[0].spender).to.eq(exchangeAddress);
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
});
it('fails if "from" token does not exist', async () => {
const tx = testContract
.bridgeTransferFrom(
randomAddress(),
randomAddress(),
randomAddress(),
getRandomInteger(1, 1e18),
hexUtils.leftPad(wethTokenAddress),
)
.awaitTransactionSuccessAsync();
return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN');
});
it('fails if `WETH.deposit()` fails', async () => {
const revertReason = 'FOOBAR';
const tx = withdrawToAsync({
toTokenAddress: wethTokenAddress,
toTokenRevertReason: revertReason,
});
return expect(tx).to.eventually.be.rejectedWith(revertReason);
});
it('fails if the exchange fails', async () => {
const revertReason = 'FOOBAR';
const tx = withdrawToAsync({
toTokenAddress: wethTokenAddress,
exchangeRevertReason: revertReason,
});
return expect(tx).to.eventually.be.rejectedWith(revertReason);
});
});
describe('ETH -> token', () => {
it('calls `WETH.withdraw()`, then `IUniswapExchange.ethToTokenTransferInput()`', async () => {
const { opts, logs, blockTime } = await withdrawToAsync({
fromTokenAddress: wethTokenAddress,
});
const exchangeAddress = await getExchangeForTokenAsync(opts.toTokenAddress);
let calls: any = filterLogs<WethWithdrawArgs>(logs, ContractEvents.WethWithdraw);
expect(calls.length).to.eq(1);
expect(calls[0].args.amount).to.bignumber.eq(opts.fromTokenBalance);
calls = filterLogs<EthToTokenTransferInputArgs>(
logs.slice(calls[0].logIndex as number),
ContractEvents.EthToTokenTransferInput,
);
expect(calls.length).to.eq(1);
expect(calls[0].args.exchange).to.eq(exchangeAddress);
expect(calls[0].args.minTokensBought).to.bignumber.eq(opts.amount);
expect(calls[0].args.deadline).to.bignumber.eq(blockTime);
expect(calls[0].args.recipient).to.eq(opts.toAddress);
});
it('does not set any allowance', async () => {
const { logs } = await withdrawToAsync({
fromTokenAddress: wethTokenAddress,
});
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
expect(approvals).to.be.empty('');
});
it('fails if "to" token does not exist', async () => {
const tx = testContract
.bridgeTransferFrom(
wethTokenAddress,
randomAddress(),
randomAddress(),
getRandomInteger(1, 1e18),
hexUtils.leftPad(randomAddress()),
)
.awaitTransactionSuccessAsync();
return expect(tx).to.eventually.be.rejectedWith('NO_UNISWAP_EXCHANGE_FOR_TOKEN');
});
it('fails if the `WETH.withdraw()` fails', async () => {
const revertReason = 'FOOBAR';
const tx = withdrawToAsync({
fromTokenAddress: wethTokenAddress,
fromTokenRevertReason: revertReason,
});
return expect(tx).to.eventually.be.rejectedWith(revertReason);
});
it('fails if the exchange fails', async () => {
const revertReason = 'FOOBAR';
const tx = withdrawToAsync({
fromTokenAddress: wethTokenAddress,
exchangeRevertReason: revertReason,
});
return expect(tx).to.eventually.be.rejectedWith(revertReason);
});
});
});
});

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