From 9f30823d707c5df9f6497e24709a9e8d6774f1c6 Mon Sep 17 00:00:00 2001 From: Elena Date: Sun, 19 Feb 2023 20:04:24 +0200 Subject: [PATCH] Migrate erc20-contracts to foundry (#664) * Strip erc20 package of legacy nonsense and add foundry basics * Make foundry build * Remove obsoleted test/UntransferrableDummyERC20Token.sol contract * Remove obsoleted ERC20 lib variant contracts * Remove obsoleted DummyMultipleReturnERC20Token and DummyNoReturnERC20Token contracts * Move test contract to dedicated folder and remove obsoleted TypeScript contract wrappers * Remove src/interfaces/IEtherToken.sol only used in v3 staking which is being obsoleted [skip ci] * Add foundry test for token * Migrate ZRX token tests to foundry * Fix paths to erc20 contracts * Remove obsoleted references * Pin erc20-contracts package on treasury * Ignore foundry imports in link checker * Run only forge tests for erc20 contracts * Remove DummyERC20Token and its dependencies * Merge IERC20TokenV06 and IERC20TokenV08 into range pragma to cover solidity 0.6.5 to 0.8.x * Merge IEtherTokenV06 and IEtherTokenV08 into range pragma to cover solidity 0.6.5 to 0.8.x * Migrate weth9 tests to foundry * Upload code coverage for erc20 package * Update changelog * Fix review comments Co-authored-by: duncancmt <1207590+duncancmt@users.noreply.github.com> --------- Co-authored-by: duncancmt <1207590+duncancmt@users.noreply.github.com> --- .github/workflows/ci.yml | 30 +- .gitmodules | 3 + .solhintignore | 2 +- contracts/erc20/.eslintrc | 25 -- contracts/erc20/CHANGELOG.md | 4 + contracts/erc20/compiler.json | 28 -- contracts/erc20/contracts/src/ERC20Token.sol | 93 ----- .../erc20/contracts/src/LibERC20Token.sol | 136 ------- .../contracts/src/MintableERC20Token.sol | 46 --- .../src/UnlimitedAllowanceERC20Token.sol | 48 --- .../contracts/src/interfaces/IERC20Token.sol | 57 --- .../contracts/src/interfaces/IEtherToken.sol | 27 -- .../src/v06/MintableERC20TokenV06.sol | 117 ------ .../contracts/src/v08/IERC20TokenV08.sol | 63 ---- .../contracts/src/v08/IEtherTokenV08.sol | 30 -- .../erc20/contracts/test/DummyERC20Token.sol | 61 ---- .../test/DummyMultipleReturnERC20Token.sol | 46 --- .../test/DummyNoReturnERC20Token.sol | 69 ---- .../contracts/test/TestLibERC20Token.sol | 73 ---- .../test/TestLibERC20TokenTarget.sol | 69 ---- .../test/UntransferrableDummyERC20Token.sol | 38 -- contracts/erc20/foundry.toml | 18 + contracts/erc20/lib/forge-std | 1 + contracts/erc20/package.json | 61 +--- .../IERC20Token.sol} | 6 +- .../IEtherToken.sol} | 4 +- contracts/erc20/{contracts => }/src/WETH9.sol | 0 .../erc20/{contracts => }/src/ZRXToken.sol | 0 contracts/erc20/src/artifacts.ts | 21 -- contracts/erc20/src/index.ts | 47 --- .../src/v06/LibERC20TokenV06.sol | 24 +- .../{contracts => }/src/v06/WETH9V06.sol | 0 .../src/v08/LibERC20TokenV08.sol | 24 +- contracts/erc20/src/wrappers.ts | 11 - contracts/erc20/test/WETH9V06Test.t.sol | 76 ++++ contracts/erc20/test/ZRXTokenTest.t.sol | 117 ++++++ contracts/erc20/test/artifacts.ts | 51 --- contracts/erc20/test/lib_erc20_token.ts | 335 ------------------ .../erc20/test/unlimited_allowance_token.ts | 187 ---------- contracts/erc20/test/weth9.ts | 149 -------- contracts/erc20/test/wrappers.ts | 26 -- contracts/erc20/test/zrx_token.ts | 210 ----------- contracts/erc20/tsconfig.json | 35 -- contracts/erc20/typedoc-tsconfig.json | 7 - .../contracts/src/DefaultPoolOperator.sol | 6 +- contracts/treasury/package.json | 2 +- contracts/zero-ex/contracts/deps/forge-std | 2 +- .../contracts/src/external/FeeCollector.sol | 6 +- .../src/external/FeeCollectorController.sol | 6 +- .../external/ILiquidityProviderSandbox.sol | 10 +- .../src/external/LiquidityProviderSandbox.sol | 10 +- .../src/features/FundRecoveryFeature.sol | 4 +- .../src/features/LiquidityProviderFeature.sol | 9 +- .../src/features/MetaTransactionsFeature.sol | 4 +- .../src/features/NativeOrdersFeature.sol | 2 +- .../src/features/OtcOrdersFeature.sol | 6 +- .../src/features/PancakeSwapFeature.sol | 12 +- .../src/features/TransformERC20Feature.sol | 12 +- .../contracts/src/features/UniswapFeature.sol | 12 +- .../src/features/UniswapV3Feature.sol | 28 +- .../interfaces/IERC1155OrdersFeature.sol | 6 +- .../interfaces/IERC721OrdersFeature.sol | 6 +- .../interfaces/IFundRecoveryFeature.sol | 4 +- .../interfaces/ILiquidityProviderFeature.sol | 10 +- .../interfaces/IMetaTransactionsFeature.sol | 4 +- .../features/interfaces/IMultiplexFeature.sol | 14 +- .../interfaces/INativeOrdersEvents.sol | 1 - .../interfaces/INativeOrdersFeature.sol | 30 +- .../interfaces/IPancakeSwapFeature.sol | 4 +- .../interfaces/ITokenSpenderFeature.sol | 6 +- .../interfaces/ITransformERC20Feature.sol | 10 +- .../features/interfaces/IUniswapFeature.sol | 4 +- .../features/interfaces/IUniswapV3Feature.sol | 2 - .../src/features/libs/LibNFTOrder.sol | 8 +- .../src/features/libs/LibNativeOrder.sol | 14 +- .../features/multiplex/MultiplexFeature.sol | 26 +- .../multiplex/MultiplexLiquidityProvider.sol | 10 +- .../features/multiplex/MultiplexUniswapV2.sol | 6 +- .../features/multiplex/MultiplexUniswapV3.sol | 1 - .../NativeOrdersCancellation.sol | 38 +- .../native_orders/NativeOrdersInfo.sol | 4 +- .../NativeOrdersProtocolFees.sol | 4 +- .../native_orders/NativeOrdersSettlement.sol | 18 +- .../nft_orders/ERC1155OrdersFeature.sol | 4 +- .../nft_orders/ERC721OrdersFeature.sol | 4 +- .../src/features/nft_orders/NFTOrders.sol | 7 +- .../src/fixins/FixinProtocolFees.sol | 6 +- .../src/fixins/FixinTokenSpender.sol | 8 +- .../CurveLiquidityProvider.sol | 22 +- .../MooniswapLiquidityProvider.sol | 34 +- .../transformers/AffiliateFeeTransformer.sol | 8 +- .../src/transformers/FillQuoteTransformer.sol | 12 +- .../src/transformers/IERC20Transformer.sol | 2 - .../src/transformers/LibERC20Transformer.sol | 16 +- .../src/transformers/PayTakerTransformer.sol | 8 +- .../PositiveSlippageFeeTransformer.sol | 8 +- .../src/transformers/WethTransformer.sol | 10 +- .../bridges/AbstractBridgeAdapter.sol | 10 +- .../bridges/ArbitrumBridgeAdapter.sol | 6 +- .../bridges/AvalancheBridgeAdapter.sol | 6 +- .../transformers/bridges/BSCBridgeAdapter.sol | 6 +- .../transformers/bridges/BridgeProtocols.sol | 2 +- .../bridges/CeloBridgeAdapter.sol | 4 +- .../bridges/EthereumBridgeAdapter.sol | 6 +- .../bridges/FantomBridgeAdapter.sol | 6 +- .../transformers/bridges/IBridgeAdapter.sol | 10 +- .../bridges/OptimismBridgeAdapter.sol | 6 +- .../bridges/PolygonBridgeAdapter.sol | 6 +- .../bridges/mixins/MixinAaveV2.sol | 10 +- .../bridges/mixins/MixinAaveV3.sol | 10 +- .../bridges/mixins/MixinBalancer.sol | 14 +- .../bridges/mixins/MixinBalancerV2Batch.sol | 12 +- .../bridges/mixins/MixinBancor.sol | 18 +- .../bridges/mixins/MixinBancorV3.sol | 18 +- .../bridges/mixins/MixinCompound.sol | 16 +- .../bridges/mixins/MixinCryptoCom.sol | 10 +- .../bridges/mixins/MixinCurve.sol | 16 +- .../bridges/mixins/MixinCurveV2.sol | 10 +- .../transformers/bridges/mixins/MixinDodo.sol | 8 +- .../bridges/mixins/MixinDodoV2.sol | 8 +- .../transformers/bridges/mixins/MixinGMX.sol | 10 +- .../bridges/mixins/MixinKyberDmm.sol | 10 +- .../transformers/bridges/mixins/MixinLido.sol | 26 +- .../bridges/mixins/MixinMStable.sol | 14 +- .../bridges/mixins/MixinMakerPSM.sol | 10 +- .../bridges/mixins/MixinMooniswap.sol | 26 +- .../bridges/mixins/MixinNerve.sol | 8 +- .../bridges/mixins/MixinPlatypus.sol | 10 +- .../bridges/mixins/MixinShell.sol | 16 +- .../bridges/mixins/MixinSolidly.sol | 10 +- .../bridges/mixins/MixinUniswap.sol | 26 +- .../bridges/mixins/MixinUniswapV2.sol | 12 +- .../bridges/mixins/MixinUniswapV3.sol | 8 +- .../bridges/mixins/MixinWOOFi.sol | 14 +- .../bridges/mixins/MixinZeroExBridge.sol | 10 +- .../src/vendor/ILiquidityProvider.sol | 18 +- .../contracts/src/vendor/IMooniswapPool.sol | 10 +- .../contracts/test/TestFixinProtocolFees.sol | 2 +- .../contracts/test/TestFixinTokenSpender.sol | 6 +- ...estMetaTransactionsNativeOrdersFeature.sol | 2 +- ...tMetaTransactionsTransformERC20Feature.sol | 8 +- .../test/TestMintTokenERC20Transformer.sol | 6 +- .../contracts/test/TestNFTOrderPresigner.sol | 4 +- .../test/TestNativeOrdersFeature.sol | 2 +- ...tOrderSignerRegistryWithContractWallet.sol | 4 +- .../zero-ex/contracts/test/TestStaking.sol | 6 +- .../contracts/test/TestTransformerHost.sol | 4 +- .../contracts/test/TestUniswapV3Feature.sol | 2 +- .../contracts/test/integration/TestCurve.sol | 6 +- .../integration/TestLiquidityProvider.sol | 14 +- .../test/integration/TestMooniswap.sol | 19 +- .../test/integration/TestUniswapV2Factory.sol | 12 +- .../test/integration/TestUniswapV2Pool.sol | 10 +- .../test/integration/TestUniswapV3Factory.sol | 16 +- .../test/integration/TestUniswapV3Pool.sol | 10 +- contracts/zero-ex/tests/ForkUtils.t.sol | 2 +- contracts/zero-ex/tests/WrapEth.t.sol | 6 +- .../zero-ex/tests/forked/RfqtV2Test.t.sol | 8 +- .../tests/forked/SwapEthForERC20Test.t.sol | 16 +- .../zero-ex/tests/forked/WrapEthTest.t.sol | 6 +- .../AffiliateFeeTransformerTest.t.sol | 21 +- .../PositiveSlippageFeeTransformerTest.t.sol | 10 +- .../zero-ex/tests/utils/DeployZeroEx.sol | 10 +- contracts/zero-ex/tests/utils/ForkUtils.sol | 52 ++- docs/advanced/erc20_transformations.rst | 20 +- docs/advanced/mtx.rst | 2 +- docs/advanced/uniswap.rst | 4 +- docs/basics/events.rst | 12 +- docs/basics/functions.rst | 58 +-- package.json | 2 +- tsconfig.json | 4 +- yarn.lock | 14 +- 172 files changed, 945 insertions(+), 2876 deletions(-) delete mode 100644 contracts/erc20/.eslintrc delete mode 100644 contracts/erc20/compiler.json delete mode 100644 contracts/erc20/contracts/src/ERC20Token.sol delete mode 100644 contracts/erc20/contracts/src/LibERC20Token.sol delete mode 100644 contracts/erc20/contracts/src/MintableERC20Token.sol delete mode 100644 contracts/erc20/contracts/src/UnlimitedAllowanceERC20Token.sol delete mode 100644 contracts/erc20/contracts/src/interfaces/IERC20Token.sol delete mode 100644 contracts/erc20/contracts/src/interfaces/IEtherToken.sol delete mode 100644 contracts/erc20/contracts/src/v06/MintableERC20TokenV06.sol delete mode 100644 contracts/erc20/contracts/src/v08/IERC20TokenV08.sol delete mode 100644 contracts/erc20/contracts/src/v08/IEtherTokenV08.sol delete mode 100644 contracts/erc20/contracts/test/DummyERC20Token.sol delete mode 100644 contracts/erc20/contracts/test/DummyMultipleReturnERC20Token.sol delete mode 100644 contracts/erc20/contracts/test/DummyNoReturnERC20Token.sol delete mode 100644 contracts/erc20/contracts/test/TestLibERC20Token.sol delete mode 100644 contracts/erc20/contracts/test/TestLibERC20TokenTarget.sol delete mode 100644 contracts/erc20/contracts/test/UntransferrableDummyERC20Token.sol create mode 100644 contracts/erc20/foundry.toml create mode 160000 contracts/erc20/lib/forge-std rename contracts/erc20/{contracts/src/v06/IERC20TokenV06.sol => src/IERC20Token.sol} (96%) rename contracts/erc20/{contracts/src/v06/IEtherTokenV06.sol => src/IEtherToken.sol} (91%) rename contracts/erc20/{contracts => }/src/WETH9.sol (100%) rename contracts/erc20/{contracts => }/src/ZRXToken.sol (100%) delete mode 100644 contracts/erc20/src/artifacts.ts delete mode 100644 contracts/erc20/src/index.ts rename contracts/erc20/{contracts => }/src/v06/LibERC20TokenV06.sol (86%) rename contracts/erc20/{contracts => }/src/v06/WETH9V06.sol (100%) rename contracts/erc20/{contracts => }/src/v08/LibERC20TokenV08.sol (86%) delete mode 100644 contracts/erc20/src/wrappers.ts create mode 100644 contracts/erc20/test/WETH9V06Test.t.sol create mode 100644 contracts/erc20/test/ZRXTokenTest.t.sol delete mode 100644 contracts/erc20/test/artifacts.ts delete mode 100644 contracts/erc20/test/lib_erc20_token.ts delete mode 100644 contracts/erc20/test/unlimited_allowance_token.ts delete mode 100644 contracts/erc20/test/weth9.ts delete mode 100644 contracts/erc20/test/wrappers.ts delete mode 100644 contracts/erc20/test/zrx_token.ts delete mode 100644 contracts/erc20/tsconfig.json delete mode 100644 contracts/erc20/typedoc-tsconfig.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 858ed3566a..030f179d78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,6 @@ jobs: -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 \ @@ -84,18 +83,41 @@ jobs: with: version: nightly - - name: Run Forge build + - name: Run Forge build for erc20 + working-directory: contracts/erc20 + run: | + forge --version + forge build --sizes + + - name: Run Forge tests for erc20 + working-directory: contracts/erc20 + run: | + forge test -vvv --gas-report + + - name: Run Forge coverage for erc20 + working-directory: contracts/erc20 + run: | + forge coverage --report summary --report lcov + + - name: Upload the coverage report to Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + base-path: ./contracts/erc20/ + path-to-lcov: ./contracts/erc20/lcov.info + + - name: Run Forge build for zero-ex working-directory: contracts/zero-ex run: | forge --version forge build --sizes - - name: Run Forge tests + - name: Run Forge tests for zero-ex working-directory: contracts/zero-ex run: | forge test -vvv --gas-report - - name: Run Forge coverage + - name: Run Forge coverage for zero-ex working-directory: contracts/zero-ex run: | forge coverage --report summary --report lcov diff --git a/.gitmodules b/.gitmodules index a82cad9211..0e1391b9ff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "contracts/zero-ex/contracts/deps/forge-std"] path = contracts/zero-ex/contracts/deps/forge-std url = https://github.com/foundry-rs/forge-std +[submodule "contracts/erc20/lib/forge-std"] + path = contracts/erc20/lib/forge-std + url = https://github.com/foundry-rs/forge-std diff --git a/.solhintignore b/.solhintignore index af8dcc797f..4e459ac348 100644 --- a/.solhintignore +++ b/.solhintignore @@ -1,4 +1,4 @@ -contracts/erc20/contracts/src/ZRXToken.sol +contracts/erc20/src/ZRXToken.sol node_modules/ lib deps diff --git a/contracts/erc20/.eslintrc b/contracts/erc20/.eslintrc deleted file mode 100644 index a1d8ef286c..0000000000 --- a/contracts/erc20/.eslintrc +++ /dev/null @@ -1,25 +0,0 @@ -{ - "env": { - "es2021": true, - "node": true - }, - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"], - "overrides": [], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "./tsconfig.json", - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": ["@typescript-eslint"], - "ignorePatterns": [ - "lib/**/*", - "contracts/**/*", - "generated-wrappers/**/*", - "generated-artifacts/**/*", - "test/generated-wrappers/**/*", - "test/generated-artifacts/**/*" - - ], - "rules": {} -} \ No newline at end of file diff --git a/contracts/erc20/CHANGELOG.md b/contracts/erc20/CHANGELOG.md index 964d00192c..fb1fe6bcfa 100644 --- a/contracts/erc20/CHANGELOG.md +++ b/contracts/erc20/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v4.0.0 - _February 16, 2023_ + + * Migrated package to foundry + ## v3.3.57 - _February 1, 2023_ * Dependencies updated diff --git a/contracts/erc20/compiler.json b/contracts/erc20/compiler.json deleted file mode 100644 index 64a722d2f4..0000000000 --- a/contracts/erc20/compiler.json +++ /dev/null @@ -1,28 +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", - "devdoc" - ] - } - } - } -} diff --git a/contracts/erc20/contracts/src/ERC20Token.sol b/contracts/erc20/contracts/src/ERC20Token.sol deleted file mode 100644 index 6be781bd45..0000000000 --- a/contracts/erc20/contracts/src/ERC20Token.sol +++ /dev/null @@ -1,93 +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 "./interfaces/IERC20Token.sol"; - -contract ERC20Token is IERC20Token { - mapping(address => uint256) internal balances; - mapping(address => mapping(address => uint256)) internal allowed; - - uint256 internal _totalSupply; - - /// @dev send `value` token to `to` from `msg.sender` - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - /// @return True if transfer was successful - function transfer(address _to, uint256 _value) external returns (bool) { - require(balances[msg.sender] >= _value, "ERC20_INSUFFICIENT_BALANCE"); - require(balances[_to] + _value >= balances[_to], "UINT256_OVERFLOW"); - - balances[msg.sender] -= _value; - balances[_to] += _value; - - emit Transfer(msg.sender, _to, _value); - - return true; - } - - /// @dev send `value` token to `to` from `from` on the condition it is approved by `from` - /// @param _from The address of the sender - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - /// @return True if transfer was successful - function transferFrom(address _from, address _to, uint256 _value) external returns (bool) { - require(balances[_from] >= _value, "ERC20_INSUFFICIENT_BALANCE"); - require(allowed[_from][msg.sender] >= _value, "ERC20_INSUFFICIENT_ALLOWANCE"); - require(balances[_to] + _value >= balances[_to], "UINT256_OVERFLOW"); - - balances[_to] += _value; - balances[_from] -= _value; - allowed[_from][msg.sender] -= _value; - - emit Transfer(_from, _to, _value); - - return true; - } - - /// @dev `msg.sender` approves `_spender` to spend `_value` tokens - /// @param _spender The address of the account able to transfer the tokens - /// @param _value The amount of wei to be approved for transfer - /// @return Always true if the call has enough gas to complete execution - function approve(address _spender, uint256 _value) external returns (bool) { - allowed[msg.sender][_spender] = _value; - emit Approval(msg.sender, _spender, _value); - return true; - } - - /// @dev Query total supply of token - /// @return Total supply of token - function totalSupply() external view returns (uint256) { - return _totalSupply; - } - - /// @dev Query the balance of owner - /// @param _owner The address from which the balance will be retrieved - /// @return Balance of owner - function balanceOf(address _owner) external view returns (uint256) { - return balances[_owner]; - } - - /// @param _owner The address of the account owning tokens - /// @param _spender The address of the account able to transfer the tokens - /// @return Amount of remaining tokens allowed to spent - function allowance(address _owner, address _spender) external view returns (uint256) { - return allowed[_owner][_spender]; - } -} diff --git a/contracts/erc20/contracts/src/LibERC20Token.sol b/contracts/erc20/contracts/src/LibERC20Token.sol deleted file mode 100644 index 5b11cebac2..0000000000 --- a/contracts/erc20/contracts/src/LibERC20Token.sol +++ /dev/null @@ -1,136 +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/LibRichErrors.sol"; -import "@0x/contracts-utils/contracts/src/LibBytes.sol"; -import "../src/interfaces/IERC20Token.sol"; - -library LibERC20Token { - bytes private constant DECIMALS_CALL_DATA = hex"313ce567"; - - /// @dev Calls `IERC20Token(token).approve()`. - /// Reverts if `false` is returned or if the return - /// data length is nonzero and not 32 bytes. - /// @param token The address of the token contract. - /// @param spender The address that receives an allowance. - /// @param allowance The allowance to set. - function approve(address token, address spender, uint256 allowance) internal { - bytes memory callData = abi.encodeWithSelector(IERC20Token(0).approve.selector, spender, allowance); - _callWithOptionalBooleanResult(token, callData); - } - - /// @dev Calls `IERC20Token(token).approve()` and sets the allowance to the - /// maximum if the current approval is not already >= an amount. - /// Reverts if `false` is returned or if the return - /// data length is nonzero and not 32 bytes. - /// @param token The address of the token contract. - /// @param spender The address that receives an allowance. - /// @param amount The minimum allowance needed. - function approveIfBelow(address token, address spender, uint256 amount) internal { - if (IERC20Token(token).allowance(address(this), spender) < amount) { - approve(token, spender, uint256(-1)); - } - } - - /// @dev Calls `IERC20Token(token).transfer()`. - /// Reverts if `false` is returned or if the return - /// data length is nonzero and not 32 bytes. - /// @param token The address of the token contract. - /// @param to The address that receives the tokens - /// @param amount Number of tokens to transfer. - function transfer(address token, address to, uint256 amount) internal { - bytes memory callData = abi.encodeWithSelector(IERC20Token(0).transfer.selector, to, amount); - _callWithOptionalBooleanResult(token, callData); - } - - /// @dev Calls `IERC20Token(token).transferFrom()`. - /// Reverts if `false` is returned or if the return - /// data length is nonzero and not 32 bytes. - /// @param token The address of the token contract. - /// @param from The owner of the tokens. - /// @param to The address that receives the tokens - /// @param amount Number of tokens to transfer. - function transferFrom(address token, address from, address to, uint256 amount) internal { - bytes memory callData = abi.encodeWithSelector(IERC20Token(0).transferFrom.selector, from, to, amount); - _callWithOptionalBooleanResult(token, callData); - } - - /// @dev Retrieves the number of decimals for a token. - /// Returns `18` if the call reverts. - /// @param token The address of the token contract. - /// @return tokenDecimals The number of decimals places for the token. - function decimals(address token) internal view returns (uint8 tokenDecimals) { - tokenDecimals = 18; - (bool didSucceed, bytes memory resultData) = token.staticcall(DECIMALS_CALL_DATA); - if (didSucceed && resultData.length == 32) { - tokenDecimals = uint8(LibBytes.readUint256(resultData, 0)); - } - } - - /// @dev Retrieves the allowance for a token, owner, and spender. - /// Returns `0` if the call reverts. - /// @param token The address of the token contract. - /// @param owner The owner of the tokens. - /// @param spender The address the spender. - /// @return allowance The allowance for a token, owner, and spender. - function allowance(address token, address owner, address spender) internal view returns (uint256 allowance_) { - (bool didSucceed, bytes memory resultData) = token.staticcall( - abi.encodeWithSelector(IERC20Token(0).allowance.selector, owner, spender) - ); - if (didSucceed && resultData.length == 32) { - allowance_ = LibBytes.readUint256(resultData, 0); - } - } - - /// @dev Retrieves the balance for a token owner. - /// Returns `0` if the call reverts. - /// @param token The address of the token contract. - /// @param owner The owner of the tokens. - /// @return balance The token balance of an owner. - function balanceOf(address token, address owner) internal view returns (uint256 balance) { - (bool didSucceed, bytes memory resultData) = token.staticcall( - abi.encodeWithSelector(IERC20Token(0).balanceOf.selector, owner) - ); - if (didSucceed && resultData.length == 32) { - balance = LibBytes.readUint256(resultData, 0); - } - } - - /// @dev Executes a call on address `target` with calldata `callData` - /// and asserts that either nothing was returned or a single boolean - /// was returned equal to `true`. - /// @param target The call target. - /// @param callData The abi-encoded call data. - function _callWithOptionalBooleanResult(address target, bytes memory callData) private { - (bool didSucceed, bytes memory resultData) = target.call(callData); - if (didSucceed) { - if (resultData.length == 0) { - return; - } - if (resultData.length == 32) { - uint256 result = LibBytes.readUint256(resultData, 0); - if (result == 1) { - return; - } - } - } - LibRichErrors.rrevert(resultData); - } -} diff --git a/contracts/erc20/contracts/src/MintableERC20Token.sol b/contracts/erc20/contracts/src/MintableERC20Token.sol deleted file mode 100644 index 0a5c317652..0000000000 --- a/contracts/erc20/contracts/src/MintableERC20Token.sol +++ /dev/null @@ -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; - -import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; -import "./UnlimitedAllowanceERC20Token.sol"; - -contract MintableERC20Token is UnlimitedAllowanceERC20Token { - using LibSafeMath for uint256; - - /// @dev Mints new tokens - /// @param _to Address of the beneficiary that will own the minted token - /// @param _value Amount of tokens to mint - function _mint(address _to, uint256 _value) internal { - balances[_to] = _value.safeAdd(balances[_to]); - _totalSupply = _totalSupply.safeAdd(_value); - - emit Transfer(address(0), _to, _value); - } - - /// @dev Mints new tokens - /// @param _owner Owner of tokens that will be burned - /// @param _value Amount of tokens to burn - function _burn(address _owner, uint256 _value) internal { - balances[_owner] = balances[_owner].safeSub(_value); - _totalSupply = _totalSupply.safeSub(_value); - - emit Transfer(_owner, address(0), _value); - } -} diff --git a/contracts/erc20/contracts/src/UnlimitedAllowanceERC20Token.sol b/contracts/erc20/contracts/src/UnlimitedAllowanceERC20Token.sol deleted file mode 100644 index 0b8d57cb94..0000000000 --- a/contracts/erc20/contracts/src/UnlimitedAllowanceERC20Token.sol +++ /dev/null @@ -1,48 +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 "./ERC20Token.sol"; - -contract UnlimitedAllowanceERC20Token is ERC20Token { - uint256 internal constant MAX_UINT = 2 ** 256 - 1; - - /// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. - // See https://github.com/ethereum/EIPs/issues/717 - /// @param _from Address to transfer from. - /// @param _to Address to transfer to. - /// @param _value Amount to transfer. - /// @return Success of transfer. - function transferFrom(address _from, address _to, uint256 _value) external returns (bool) { - uint256 allowance = allowed[_from][msg.sender]; - require(balances[_from] >= _value, "ERC20_INSUFFICIENT_BALANCE"); - require(allowance >= _value, "ERC20_INSUFFICIENT_ALLOWANCE"); - require(balances[_to] + _value >= balances[_to], "UINT256_OVERFLOW"); - - balances[_to] += _value; - balances[_from] -= _value; - if (allowance < MAX_UINT) { - allowed[_from][msg.sender] -= _value; - } - - emit Transfer(_from, _to, _value); - - return true; - } -} diff --git a/contracts/erc20/contracts/src/interfaces/IERC20Token.sol b/contracts/erc20/contracts/src/interfaces/IERC20Token.sol deleted file mode 100644 index 5edbec3168..0000000000 --- a/contracts/erc20/contracts/src/interfaces/IERC20Token.sol +++ /dev/null @@ -1,57 +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 IERC20Token { - event Transfer(address indexed _from, address indexed _to, uint256 _value); - - event Approval(address indexed _owner, address indexed _spender, uint256 _value); - - /// @dev send `value` token to `to` from `msg.sender` - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - /// @return True if transfer was successful - function transfer(address _to, uint256 _value) external returns (bool); - - /// @dev send `value` token to `to` from `from` on the condition it is approved by `from` - /// @param _from The address of the sender - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - /// @return True if transfer was successful - function transferFrom(address _from, address _to, uint256 _value) external returns (bool); - - /// @dev `msg.sender` approves `_spender` to spend `_value` tokens - /// @param _spender The address of the account able to transfer the tokens - /// @param _value The amount of wei to be approved for transfer - /// @return Always true if the call has enough gas to complete execution - function approve(address _spender, uint256 _value) external returns (bool); - - /// @dev Query total supply of token - /// @return Total supply of token - function totalSupply() external view returns (uint256); - - /// @param _owner The address from which the balance will be retrieved - /// @return Balance of owner - function balanceOf(address _owner) external view returns (uint256); - - /// @param _owner The address of the account owning tokens - /// @param _spender The address of the account able to transfer the tokens - /// @return Amount of remaining tokens allowed to spent - function allowance(address _owner, address _spender) external view returns (uint256); -} diff --git a/contracts/erc20/contracts/src/interfaces/IEtherToken.sol b/contracts/erc20/contracts/src/interfaces/IEtherToken.sol deleted file mode 100644 index e14b58e89b..0000000000 --- a/contracts/erc20/contracts/src/interfaces/IEtherToken.sol +++ /dev/null @@ -1,27 +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 "./IERC20Token.sol"; - -contract IEtherToken is IERC20Token { - function deposit() public payable; - - function withdraw(uint256 amount) public; -} diff --git a/contracts/erc20/contracts/src/v06/MintableERC20TokenV06.sol b/contracts/erc20/contracts/src/v06/MintableERC20TokenV06.sol deleted file mode 100644 index defd9643f1..0000000000 --- a/contracts/erc20/contracts/src/v06/MintableERC20TokenV06.sol +++ /dev/null @@ -1,117 +0,0 @@ -/* - - Copyright 2023 ZeroEx Intl. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ - -pragma solidity ^0.6.5; - -import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; -import "./IERC20TokenV06.sol"; - -contract MintableERC20TokenV06 is IERC20TokenV06 { - using LibSafeMathV06 for uint256; - - uint8 public override decimals = 18; - mapping(address => uint256) internal balances; - mapping(address => mapping(address => uint256)) internal allowed; - - uint256 internal _totalSupply; - - /// @dev send `value` token to `to` from `msg.sender` - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - /// @return True if transfer was successful - function transfer(address _to, uint256 _value) external override returns (bool) { - require(balances[msg.sender] >= _value, "ERC20_INSUFFICIENT_BALANCE"); - require(balances[_to].safeAdd(_value) >= balances[_to], "UINT256_OVERFLOW"); - - balances[msg.sender] = balances[msg.sender].safeSub(_value); - balances[_to] = balances[_to].safeAdd(_value); - - emit Transfer(msg.sender, _to, _value); - - return true; - } - - /// @dev send `value` token to `to` from `from` on the condition it is approved by `from` - /// @param _from The address of the sender - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - /// @return True if transfer was successful - function transferFrom(address _from, address _to, uint256 _value) external override returns (bool) { - require(balances[_from] >= _value, "ERC20_INSUFFICIENT_BALANCE"); - require(allowed[_from][msg.sender] >= _value, "ERC20_INSUFFICIENT_ALLOWANCE"); - require(balances[_to].safeAdd(_value) >= balances[_to], "UINT256_OVERFLOW"); - - balances[_to] = balances[_to].safeAdd(_value); - balances[_from] = balances[_from].safeSub(_value); - allowed[_from][msg.sender] = allowed[_from][msg.sender].safeSub(_value); - - emit Transfer(_from, _to, _value); - - return true; - } - - /// @dev `msg.sender` approves `_spender` to spend `_value` tokens - /// @param _spender The address of the account able to transfer the tokens - /// @param _value The amount of wei to be approved for transfer - /// @return Always true if the call has enough gas to complete execution - function approve(address _spender, uint256 _value) external override returns (bool) { - allowed[msg.sender][_spender] = _value; - emit Approval(msg.sender, _spender, _value); - return true; - } - - /// @dev Query total supply of token - /// @return Total supply of token - function totalSupply() external view override returns (uint256) { - return _totalSupply; - } - - /// @dev Query the balance of owner - /// @param _owner The address from which the balance will be retrieved - /// @return Balance of owner - function balanceOf(address _owner) external view override returns (uint256) { - return balances[_owner]; - } - - /// @param _owner The address of the account owning tokens - /// @param _spender The address of the account able to transfer the tokens - /// @return Amount of remaining tokens allowed to spent - function allowance(address _owner, address _spender) external view override returns (uint256) { - return allowed[_owner][_spender]; - } - - /// @dev Mints new tokens - /// @param _to Address of the beneficiary that will own the minted token - /// @param _value Amount of tokens to mint - function _mint(address _to, uint256 _value) internal { - balances[_to] = _value.safeAdd(balances[_to]); - _totalSupply = _totalSupply.safeAdd(_value); - - emit Transfer(address(0), _to, _value); - } - - /// @dev Mints new tokens - /// @param _owner Owner of tokens that will be burned - /// @param _value Amount of tokens to burn - function _burn(address _owner, uint256 _value) internal { - balances[_owner] = balances[_owner].safeSub(_value); - _totalSupply = _totalSupply.safeSub(_value); - - emit Transfer(_owner, address(0), _value); - } -} diff --git a/contracts/erc20/contracts/src/v08/IERC20TokenV08.sol b/contracts/erc20/contracts/src/v08/IERC20TokenV08.sol deleted file mode 100644 index da2eb35311..0000000000 --- a/contracts/erc20/contracts/src/v08/IERC20TokenV08.sol +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: Apache-2.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.8.0; - -interface IERC20TokenV08 { - event Transfer(address indexed from, address indexed to, uint256 value); - - event Approval(address indexed owner, address indexed spender, uint256 value); - - /// @dev send `value` token to `to` from `msg.sender` - /// @param to The address of the recipient - /// @param value The amount of token to be transferred - /// @return True if transfer was successful - function transfer(address to, uint256 value) external returns (bool); - - /// @dev send `value` token to `to` from `from` on the condition it is approved by `from` - /// @param from The address of the sender - /// @param to The address of the recipient - /// @param value The amount of token to be transferred - /// @return True if transfer was successful - function transferFrom(address from, address to, uint256 value) external returns (bool); - - /// @dev `msg.sender` approves `spender` to spend `value` tokens - /// @param spender The address of the account able to transfer the tokens - /// @param value The amount of wei to be approved for transfer - /// @return Always true if the call has enough gas to complete execution - function approve(address spender, uint256 value) external returns (bool); - - /// @dev Query total supply of token - /// @return Total supply of token - function totalSupply() external view returns (uint256); - - /// @dev Get the balance of `owner`. - /// @param owner The address from which the balance will be retrieved - /// @return Balance of owner - function balanceOf(address owner) external view returns (uint256); - - /// @dev Get the allowance for `spender` to spend from `owner`. - /// @param owner The address of the account owning tokens - /// @param spender The address of the account able to transfer the tokens - /// @return Amount of remaining tokens allowed to spent - function allowance(address owner, address spender) external view returns (uint256); - - /// @dev Get the number of decimals this token has. - function decimals() external view returns (uint8); -} diff --git a/contracts/erc20/contracts/src/v08/IEtherTokenV08.sol b/contracts/erc20/contracts/src/v08/IEtherTokenV08.sol deleted file mode 100644 index 9dff977e69..0000000000 --- a/contracts/erc20/contracts/src/v08/IEtherTokenV08.sol +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: Apache-2.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.8.0; - -import "./IERC20TokenV08.sol"; - -interface IEtherTokenV08 is IERC20TokenV08 { - /// @dev Wrap ether. - function deposit() external payable; - - /// @dev Unwrap ether. - function withdraw(uint256 amount) external; -} diff --git a/contracts/erc20/contracts/test/DummyERC20Token.sol b/contracts/erc20/contracts/test/DummyERC20Token.sol deleted file mode 100644 index b079bd4dc8..0000000000 --- a/contracts/erc20/contracts/test/DummyERC20Token.sol +++ /dev/null @@ -1,61 +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.5; - -import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; -import "@0x/contracts-utils/contracts/src/Ownable.sol"; -import "../src/MintableERC20Token.sol"; - -contract DummyERC20Token is Ownable, MintableERC20Token { - using LibSafeMath for uint256; - - string public name; - string public symbol; - uint256 public decimals; - uint256 public constant MAX_MINT_AMOUNT = 10000000000000000000000; - - constructor(string memory _name, string memory _symbol, uint256 _decimals, uint256 _totalSupply) public { - name = _name; - symbol = _symbol; - decimals = _decimals; - _totalSupply = _totalSupply; - balances[msg.sender] = _totalSupply; - } - - /// @dev Sets the balance of target address - /// @param _target Address or which balance will be updated - /// @param _value New balance of target address - function setBalance(address _target, uint256 _value) external onlyOwner { - uint256 currBalance = balances[_target]; - if (_value < currBalance) { - _totalSupply = _totalSupply.safeSub(currBalance.safeSub(_value)); - } else { - _totalSupply = _totalSupply.safeAdd(_value.safeSub(currBalance)); - } - balances[_target] = _value; - } - - /// @dev Mints new tokens for sender - /// @param _value Amount of tokens to mint - function mint(uint256 _value) external { - require(_value <= MAX_MINT_AMOUNT, "VALUE_TOO_LARGE"); - - _mint(msg.sender, _value); - } -} diff --git a/contracts/erc20/contracts/test/DummyMultipleReturnERC20Token.sol b/contracts/erc20/contracts/test/DummyMultipleReturnERC20Token.sol deleted file mode 100644 index b14809cce3..0000000000 --- a/contracts/erc20/contracts/test/DummyMultipleReturnERC20Token.sol +++ /dev/null @@ -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.5; - -import "./DummyERC20Token.sol"; - -contract DummyMultipleReturnERC20Token is DummyERC20Token { - constructor( - string memory _name, - string memory _symbol, - uint256 _decimals, - uint256 _totalSupply - ) public DummyERC20Token(_name, _symbol, _decimals, _totalSupply) {} - - /// @dev send `value` token to `to` from `from` on the condition it is approved by `from` - /// @param _from The address of the sender - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - function transferFrom(address _from, address _to, uint256 _value) external returns (bool) { - emit Transfer(_from, _to, _value); - - // HACK: This contract will not compile if we remove `returns (bool)`, so we manually return 64 bytes - // (equiavalent to true, true) - assembly { - mstore(0, 1) - mstore(32, 1) - return(0, 64) - } - } -} diff --git a/contracts/erc20/contracts/test/DummyNoReturnERC20Token.sol b/contracts/erc20/contracts/test/DummyNoReturnERC20Token.sol deleted file mode 100644 index 67b19724d3..0000000000 --- a/contracts/erc20/contracts/test/DummyNoReturnERC20Token.sol +++ /dev/null @@ -1,69 +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.5; - -import "./DummyERC20Token.sol"; - -contract DummyNoReturnERC20Token is DummyERC20Token { - constructor( - string memory _name, - string memory _symbol, - uint256 _decimals, - uint256 _totalSupply - ) public DummyERC20Token(_name, _symbol, _decimals, _totalSupply) {} - - /// @dev send `value` token to `to` from `msg.sender` - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - function transfer(address _to, uint256 _value) external returns (bool) { - require(balances[msg.sender] >= _value, "ERC20_INSUFFICIENT_BALANCE"); - require(balances[_to] + _value >= balances[_to], "UINT256_OVERFLOW"); - - balances[msg.sender] -= _value; - balances[_to] += _value; - - emit Transfer(msg.sender, _to, _value); - - // HACK: This contract will not compile if we remove `returns (bool)`, so we manually return no data - assembly { - return(0, 0) - } - } - - /// @dev send `value` token to `to` from `from` on the condition it is approved by `from` - /// @param _from The address of the sender - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - function transferFrom(address _from, address _to, uint256 _value) external returns (bool) { - require(balances[_from] >= _value, "ERC20_INSUFFICIENT_BALANCE"); - require(allowed[_from][msg.sender] >= _value, "ERC20_INSUFFICIENT_ALLOWANCE"); - require(balances[_to] + _value >= balances[_to], "UINT256_OVERFLOW"); - - balances[_to] += _value; - balances[_from] -= _value; - allowed[_from][msg.sender] -= _value; - - emit Transfer(_from, _to, _value); - - // HACK: This contract will not compile if we remove `returns (bool)`, so we manually return no data - assembly { - return(0, 0) - } - } -} diff --git a/contracts/erc20/contracts/test/TestLibERC20Token.sol b/contracts/erc20/contracts/test/TestLibERC20Token.sol deleted file mode 100644 index edb02dea02..0000000000 --- a/contracts/erc20/contracts/test/TestLibERC20Token.sol +++ /dev/null @@ -1,73 +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 "../src/LibERC20Token.sol"; -import "./TestLibERC20TokenTarget.sol"; - -contract TestLibERC20Token { - TestLibERC20TokenTarget public target; - - constructor() public { - target = new TestLibERC20TokenTarget(); - } - - function testApprove( - bool shouldRevert, - bytes calldata revertData, - bytes calldata returnData, - address spender, - uint256 allowance - ) external { - target.setBehavior(shouldRevert, revertData, returnData); - LibERC20Token.approve(address(target), spender, allowance); - } - - function testTransfer( - bool shouldRevert, - bytes calldata revertData, - bytes calldata returnData, - address to, - uint256 amount - ) external { - target.setBehavior(shouldRevert, revertData, returnData); - LibERC20Token.transfer(address(target), to, amount); - } - - function testTransferFrom( - bool shouldRevert, - bytes calldata revertData, - bytes calldata returnData, - address from, - address to, - uint256 amount - ) external { - target.setBehavior(shouldRevert, revertData, returnData); - LibERC20Token.transferFrom(address(target), from, to, amount); - } - - function testDecimals( - bool shouldRevert, - bytes calldata revertData, - bytes calldata returnData - ) external returns (uint8) { - target.setBehavior(shouldRevert, revertData, returnData); - return LibERC20Token.decimals(address(target)); - } -} diff --git a/contracts/erc20/contracts/test/TestLibERC20TokenTarget.sol b/contracts/erc20/contracts/test/TestLibERC20TokenTarget.sol deleted file mode 100644 index 9f52149cbd..0000000000 --- a/contracts/erc20/contracts/test/TestLibERC20TokenTarget.sol +++ /dev/null @@ -1,69 +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 TestLibERC20TokenTarget { - event ApproveCalled(address spender, uint256 allowance); - - event TransferCalled(address to, uint256 amount); - - event TransferFromCalled(address from, address to, uint256 amount); - - bool private _shouldRevert; - bytes private _revertData; - bytes private _returnData; - - function setBehavior(bool shouldRevert, bytes calldata revertData, bytes calldata returnData) external { - _shouldRevert = shouldRevert; - _revertData = revertData; - _returnData = returnData; - } - - function approve(address spender, uint256 allowance) external returns (bool) { - emit ApproveCalled(spender, allowance); - _execute(); - } - - function transfer(address to, uint256 amount) external returns (bool) { - emit TransferCalled(to, amount); - _execute(); - } - - function transferFrom(address from, address to, uint256 amount) external returns (bool) { - emit TransferFromCalled(from, to, amount); - _execute(); - } - - function decimals() external view returns (uint8) { - _execute(); - } - - function _execute() private view { - if (_shouldRevert) { - bytes memory revertData = _revertData; - assembly { - revert(add(revertData, 0x20), mload(revertData)) - } - } - bytes memory returnData = _returnData; - assembly { - return(add(returnData, 0x20), mload(returnData)) - } - } -} diff --git a/contracts/erc20/contracts/test/UntransferrableDummyERC20Token.sol b/contracts/erc20/contracts/test/UntransferrableDummyERC20Token.sol deleted file mode 100644 index cdb2faf196..0000000000 --- a/contracts/erc20/contracts/test/UntransferrableDummyERC20Token.sol +++ /dev/null @@ -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.5; - -import "./DummyERC20Token.sol"; - -contract UntransferrableDummyERC20Token is DummyERC20Token { - constructor( - string memory _name, - string memory _symbol, - uint256 _decimals, - uint256 _totalSupply - ) public DummyERC20Token(_name, _symbol, _decimals, _totalSupply) {} - - /// @dev send `value` token to `to` from `from` on the condition it is approved by `from` - /// @param _from The address of the sender - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - function transferFrom(address _from, address _to, uint256 _value) external returns (bool) { - require(false, "TRANSFER_DISABLED"); - } -} diff --git a/contracts/erc20/foundry.toml b/contracts/erc20/foundry.toml new file mode 100644 index 0000000000..f49b2049c0 --- /dev/null +++ b/contracts/erc20/foundry.toml @@ -0,0 +1,18 @@ +[profile.default] +src = 'src' +out = 'out' +libs = [ + 'lib', + 'node_modules', +] +remappings = [ + '@0x/contracts-utils/=../utils/' +] +allow_paths = [ + '../utils/' +] + +fs_permissions = [{ access = "read", path = "./out/ZRXToken.sol" }] + +optimizer_runs = 1_000_000 +# See more config options https://github.com/foundry-rs/foundry/tree/master/config diff --git a/contracts/erc20/lib/forge-std b/contracts/erc20/lib/forge-std new file mode 160000 index 0000000000..a2edd39db9 --- /dev/null +++ b/contracts/erc20/lib/forge-std @@ -0,0 +1 @@ +Subproject commit a2edd39db95df7e9dd3f9ef9edc8c55fefddb6df diff --git a/contracts/erc20/package.json b/contracts/erc20/package.json index 9bc7f3b1e0..c10e10e61a 100644 --- a/contracts/erc20/package.json +++ b/contracts/erc20/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contracts-erc20", - "version": "3.3.57", + "version": "4.0.0", "engines": { "node": ">=6.12" }, @@ -10,31 +10,10 @@ "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: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": "eslint src test", - "fix": "eslint --fix src test", - "test:ci": "yarn test", - "contracts:gen": "contracts-gen generate", - "contracts:copy": "contracts-gen copy", + "test:ci": "forge test", "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": { - "publicInterfaceContracts": "DummyERC20Token,ERC20Token,WETH9,ZRXToken,DummyNoReturnERC20Token,DummyMultipleReturnERC20Token", - "abis": "./test/generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IERC20TokenV06|IERC20TokenV08|IEtherToken|IEtherTokenV06|IEtherTokenV08|LibERC20Token|LibERC20TokenV06|LibERC20TokenV08|MintableERC20Token|TestLibERC20Token|TestLibERC20TokenTarget|UnlimitedAllowanceERC20Token|UntransferrableDummyERC20Token|WETH9|WETH9V06|ZRXToken).json", - "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually." - }, "repository": { "type": "git", "url": "https://github.com/0xProject/protocol.git" @@ -43,43 +22,13 @@ "bugs": { "url": "https://github.com/0xProject/protocol/issues" }, - "homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens", + "homepage": "https://github.com/0xProject/protocol", "devDependencies": { - "@0x/abi-gen": "^5.8.1", - "@0x/contracts-gen": "^2.0.48", - "@0x/contracts-test-utils": "^5.4.47", "@0x/contracts-utils": "^4.8.38", - "@0x/dev-utils": "^5.0.0", - "@0x/sol-compiler": "^4.8.2", "@0x/ts-doc-gen": "^0.0.28", - "@0x/types": "^3.3.6", - "@0x/typescript-typings": "^5.3.1", - "@0x/utils": "^7.0.0", - "@0x/web3-wrapper": "^8.0.0", - "@types/lodash": "4.14.104", - "@types/mocha": "^5.2.7", - "@types/node": "12.12.54", - "@typescript-eslint/eslint-plugin": "^5.38.0", - "@typescript-eslint/parser": "^5.38.0", - "chai": "^4.0.1", - "chai-as-promised": "^7.1.0", - "chai-bignumber": "^3.0.0", - "dirty-chai": "^2.0.1", - "eslint": "^8.23.1", - "eslint-config-prettier": "^8.5.0", - "ethereum-types": "^3.7.1", - "lodash": "^4.17.11", - "make-promises-safe": "^1.1.0", - "mocha": "^6.2.0", - "npm-run-all": "^4.1.2", - "shx": "^0.2.2", - "typedoc": "~0.16.11", - "typescript": "4.6.3" - }, - "dependencies": { - "@0x/base-contract": "^7.0.0", - "ethers": "~4.0.4" + "typedoc": "~0.16.11" }, + "dependencies": {}, "publishConfig": { "access": "public" }, diff --git a/contracts/erc20/contracts/src/v06/IERC20TokenV06.sol b/contracts/erc20/src/IERC20Token.sol similarity index 96% rename from contracts/erc20/contracts/src/v06/IERC20TokenV06.sol rename to contracts/erc20/src/IERC20Token.sol index 40d9de2227..6daa962689 100644 --- a/contracts/erc20/contracts/src/v06/IERC20TokenV06.sol +++ b/contracts/erc20/src/IERC20Token.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 /* - Copyright 2020 ZeroEx Intl. + Copyright 2023 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ */ -pragma solidity ^0.6.5; +pragma solidity >=0.6.5 <0.9; -interface IERC20TokenV06 { +interface IERC20Token { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); diff --git a/contracts/erc20/contracts/src/v06/IEtherTokenV06.sol b/contracts/erc20/src/IEtherToken.sol similarity index 91% rename from contracts/erc20/contracts/src/v06/IEtherTokenV06.sol rename to contracts/erc20/src/IEtherToken.sol index 1ccc051541..91dd110c93 100644 --- a/contracts/erc20/contracts/src/v06/IEtherTokenV06.sol +++ b/contracts/erc20/src/IEtherToken.sol @@ -19,9 +19,9 @@ pragma solidity ^0.6.5; -import "./IERC20TokenV06.sol"; +import "./IERC20Token.sol"; -interface IEtherTokenV06 is IERC20TokenV06 { +interface IEtherToken is IERC20Token { /// @dev Wrap ether. function deposit() external payable; diff --git a/contracts/erc20/contracts/src/WETH9.sol b/contracts/erc20/src/WETH9.sol similarity index 100% rename from contracts/erc20/contracts/src/WETH9.sol rename to contracts/erc20/src/WETH9.sol diff --git a/contracts/erc20/contracts/src/ZRXToken.sol b/contracts/erc20/src/ZRXToken.sol similarity index 100% rename from contracts/erc20/contracts/src/ZRXToken.sol rename to contracts/erc20/src/ZRXToken.sol diff --git a/contracts/erc20/src/artifacts.ts b/contracts/erc20/src/artifacts.ts deleted file mode 100644 index d8339aaafb..0000000000 --- a/contracts/erc20/src/artifacts.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Warning: This file is auto-generated by contracts-gen. Don't edit manually. - * ----------------------------------------------------------------------------- - */ -import { ContractArtifact } from 'ethereum-types'; - -import * as DummyERC20Token from '../generated-artifacts/DummyERC20Token.json'; -import * as DummyMultipleReturnERC20Token from '../generated-artifacts/DummyMultipleReturnERC20Token.json'; -import * as DummyNoReturnERC20Token from '../generated-artifacts/DummyNoReturnERC20Token.json'; -import * as ERC20Token from '../generated-artifacts/ERC20Token.json'; -import * as WETH9 from '../generated-artifacts/WETH9.json'; -import * as ZRXToken from '../generated-artifacts/ZRXToken.json'; -export const artifacts = { - DummyERC20Token: DummyERC20Token as ContractArtifact, - ERC20Token: ERC20Token as ContractArtifact, - WETH9: WETH9 as ContractArtifact, - ZRXToken: ZRXToken as any as ContractArtifact, - DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, - DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, -}; diff --git a/contracts/erc20/src/index.ts b/contracts/erc20/src/index.ts deleted file mode 100644 index 53b045165a..0000000000 --- a/contracts/erc20/src/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -export { - DummyERC20TokenContract, - DummyMultipleReturnERC20TokenContract, - DummyNoReturnERC20TokenContract, - WETH9Contract, - WETH9Events, - WETH9DepositEventArgs, - WETH9TransferEventArgs, - WETH9WithdrawalEventArgs, - ZRXTokenContract, - DummyERC20TokenTransferEventArgs, - ERC20TokenEventArgs, - ERC20TokenEvents, - ERC20TokenTransferEventArgs, - ERC20TokenApprovalEventArgs, - ERC20TokenContract, -} from './wrappers'; -export { artifacts } from './artifacts'; -export { - 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'; diff --git a/contracts/erc20/contracts/src/v06/LibERC20TokenV06.sol b/contracts/erc20/src/v06/LibERC20TokenV06.sol similarity index 86% rename from contracts/erc20/contracts/src/v06/LibERC20TokenV06.sol rename to contracts/erc20/src/v06/LibERC20TokenV06.sol index b4495af91d..dd9b4727c1 100644 --- a/contracts/erc20/contracts/src/v06/LibERC20TokenV06.sol +++ b/contracts/erc20/src/v06/LibERC20TokenV06.sol @@ -21,50 +21,50 @@ pragma solidity ^0.6.5; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibBytesV06.sol"; -import "./IERC20TokenV06.sol"; +import "../IERC20Token.sol"; library LibERC20TokenV06 { bytes private constant DECIMALS_CALL_DATA = hex"313ce567"; - /// @dev Calls `IERC20TokenV06(token).approve()`. + /// @dev Calls `IERC20Token(token).approve()`. /// Reverts if the return data is invalid or the call reverts. /// @param token The address of the token contract. /// @param spender The address that receives an allowance. /// @param allowance The allowance to set. - function compatApprove(IERC20TokenV06 token, address spender, uint256 allowance) internal { + function compatApprove(IERC20Token token, address spender, uint256 allowance) internal { bytes memory callData = abi.encodeWithSelector(token.approve.selector, spender, allowance); _callWithOptionalBooleanResult(address(token), callData); } - /// @dev Calls `IERC20TokenV06(token).approve()` and sets the allowance to the + /// @dev Calls `IERC20Token(token).approve()` and sets the allowance to the /// maximum if the current approval is not already >= an amount. /// Reverts if the return data is invalid or the call reverts. /// @param token The address of the token contract. /// @param spender The address that receives an allowance. /// @param amount The minimum allowance needed. - function approveIfBelow(IERC20TokenV06 token, address spender, uint256 amount) internal { + function approveIfBelow(IERC20Token token, address spender, uint256 amount) internal { if (token.allowance(address(this), spender) < amount) { compatApprove(token, spender, uint256(-1)); } } - /// @dev Calls `IERC20TokenV06(token).transfer()`. + /// @dev Calls `IERC20Token(token).transfer()`. /// Reverts if the return data is invalid or the call reverts. /// @param token The address of the token contract. /// @param to The address that receives the tokens /// @param amount Number of tokens to transfer. - function compatTransfer(IERC20TokenV06 token, address to, uint256 amount) internal { + function compatTransfer(IERC20Token token, address to, uint256 amount) internal { bytes memory callData = abi.encodeWithSelector(token.transfer.selector, to, amount); _callWithOptionalBooleanResult(address(token), callData); } - /// @dev Calls `IERC20TokenV06(token).transferFrom()`. + /// @dev Calls `IERC20Token(token).transferFrom()`. /// Reverts if the return data is invalid or the call reverts. /// @param token The address of the token contract. /// @param from The owner of the tokens. /// @param to The address that receives the tokens /// @param amount Number of tokens to transfer. - function compatTransferFrom(IERC20TokenV06 token, address from, address to, uint256 amount) internal { + function compatTransferFrom(IERC20Token token, address from, address to, uint256 amount) internal { bytes memory callData = abi.encodeWithSelector(token.transferFrom.selector, from, to, amount); _callWithOptionalBooleanResult(address(token), callData); } @@ -73,7 +73,7 @@ library LibERC20TokenV06 { /// Returns `18` if the call reverts. /// @param token The address of the token contract. /// @return tokenDecimals The number of decimals places for the token. - function compatDecimals(IERC20TokenV06 token) internal view returns (uint8 tokenDecimals) { + function compatDecimals(IERC20Token token) internal view returns (uint8 tokenDecimals) { tokenDecimals = 18; (bool didSucceed, bytes memory resultData) = address(token).staticcall(DECIMALS_CALL_DATA); if (didSucceed && resultData.length >= 32) { @@ -88,7 +88,7 @@ library LibERC20TokenV06 { /// @param spender The address the spender. /// @return allowance_ The allowance for a token, owner, and spender. function compatAllowance( - IERC20TokenV06 token, + IERC20Token token, address owner, address spender ) internal view returns (uint256 allowance_) { @@ -105,7 +105,7 @@ library LibERC20TokenV06 { /// @param token The address of the token contract. /// @param owner The owner of the tokens. /// @return balance The token balance of an owner. - function compatBalanceOf(IERC20TokenV06 token, address owner) internal view returns (uint256 balance) { + function compatBalanceOf(IERC20Token token, address owner) internal view returns (uint256 balance) { (bool didSucceed, bytes memory resultData) = address(token).staticcall( abi.encodeWithSelector(token.balanceOf.selector, owner) ); diff --git a/contracts/erc20/contracts/src/v06/WETH9V06.sol b/contracts/erc20/src/v06/WETH9V06.sol similarity index 100% rename from contracts/erc20/contracts/src/v06/WETH9V06.sol rename to contracts/erc20/src/v06/WETH9V06.sol diff --git a/contracts/erc20/contracts/src/v08/LibERC20TokenV08.sol b/contracts/erc20/src/v08/LibERC20TokenV08.sol similarity index 86% rename from contracts/erc20/contracts/src/v08/LibERC20TokenV08.sol rename to contracts/erc20/src/v08/LibERC20TokenV08.sol index 716fcc4006..489b4f6b4c 100644 --- a/contracts/erc20/contracts/src/v08/LibERC20TokenV08.sol +++ b/contracts/erc20/src/v08/LibERC20TokenV08.sol @@ -21,50 +21,50 @@ pragma solidity ^0.8.0; import "@0x/contracts-utils/contracts/src/v08/errors/LibRichErrorsV08.sol"; import "@0x/contracts-utils/contracts/src/v08/LibBytesV08.sol"; -import "./IERC20TokenV08.sol"; +import "../IERC20Token.sol"; library LibERC20TokenV08 { bytes private constant DECIMALS_CALL_DATA = hex"313ce567"; - /// @dev Calls `IERC20TokenV08(token).approve()`. + /// @dev Calls `IERC20Token(token).approve()`. /// Reverts if the return data is invalid or the call reverts. /// @param token The address of the token contract. /// @param spender The address that receives an allowance. /// @param allowance The allowance to set. - function compatApprove(IERC20TokenV08 token, address spender, uint256 allowance) internal { + function compatApprove(IERC20Token token, address spender, uint256 allowance) internal { bytes memory callData = abi.encodeCall(token.approve, (spender, allowance)); _callWithOptionalBooleanResult(address(token), callData); } - /// @dev Calls `IERC20TokenV08(token).approve()` and sets the allowance to the + /// @dev Calls `IERC20Token(token).approve()` and sets the allowance to the /// maximum if the current approval is not already >= an amount. /// Reverts if the return data is invalid or the call reverts. /// @param token The address of the token contract. /// @param spender The address that receives an allowance. /// @param amount The minimum allowance needed. - function approveIfBelow(IERC20TokenV08 token, address spender, uint256 amount) internal { + function approveIfBelow(IERC20Token token, address spender, uint256 amount) internal { if (token.allowance(address(this), spender) < amount) { compatApprove(token, spender, type(uint256).max); } } - /// @dev Calls `IERC20TokenV08(token).transfer()`. + /// @dev Calls `IERC20Token(token).transfer()`. /// Reverts if the return data is invalid or the call reverts. /// @param token The address of the token contract. /// @param to The address that receives the tokens /// @param amount Number of tokens to transfer. - function compatTransfer(IERC20TokenV08 token, address to, uint256 amount) internal { + function compatTransfer(IERC20Token token, address to, uint256 amount) internal { bytes memory callData = abi.encodeCall(token.transfer, (to, amount)); _callWithOptionalBooleanResult(address(token), callData); } - /// @dev Calls `IERC20TokenV08(token).transferFrom()`. + /// @dev Calls `IERC20Token(token).transferFrom()`. /// Reverts if the return data is invalid or the call reverts. /// @param token The address of the token contract. /// @param from The owner of the tokens. /// @param to The address that receives the tokens /// @param amount Number of tokens to transfer. - function compatTransferFrom(IERC20TokenV08 token, address from, address to, uint256 amount) internal { + function compatTransferFrom(IERC20Token token, address from, address to, uint256 amount) internal { bytes memory callData = abi.encodeCall(token.transferFrom, (from, to, amount)); _callWithOptionalBooleanResult(address(token), callData); } @@ -73,7 +73,7 @@ library LibERC20TokenV08 { /// Returns `18` if the call reverts. /// @param token The address of the token contract. /// @return tokenDecimals The number of decimals places for the token. - function compatDecimals(IERC20TokenV08 token) internal view returns (uint8 tokenDecimals) { + function compatDecimals(IERC20Token token) internal view returns (uint8 tokenDecimals) { tokenDecimals = 18; (bool didSucceed, bytes memory resultData) = address(token).staticcall(DECIMALS_CALL_DATA); if (didSucceed && resultData.length >= 32) { @@ -88,7 +88,7 @@ library LibERC20TokenV08 { /// @param spender The address the spender. /// @return allowance_ The allowance for a token, owner, and spender. function compatAllowance( - IERC20TokenV08 token, + IERC20Token token, address owner, address spender ) internal view returns (uint256 allowance_) { @@ -105,7 +105,7 @@ library LibERC20TokenV08 { /// @param token The address of the token contract. /// @param owner The owner of the tokens. /// @return balance The token balance of an owner. - function compatBalanceOf(IERC20TokenV08 token, address owner) internal view returns (uint256 balance) { + function compatBalanceOf(IERC20Token token, address owner) internal view returns (uint256 balance) { (bool didSucceed, bytes memory resultData) = address(token).staticcall( abi.encodeCall(token.balanceOf, (owner)) ); diff --git a/contracts/erc20/src/wrappers.ts b/contracts/erc20/src/wrappers.ts deleted file mode 100644 index 738809db4a..0000000000 --- a/contracts/erc20/src/wrappers.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Warning: This file is auto-generated by contracts-gen. Don't edit manually. - * ----------------------------------------------------------------------------- - */ -export * from '../generated-wrappers/dummy_erc20_token'; -export * from '../generated-wrappers/dummy_multiple_return_erc20_token'; -export * from '../generated-wrappers/dummy_no_return_erc20_token'; -export * from '../generated-wrappers/erc20_token'; -export * from '../generated-wrappers/weth9'; -export * from '../generated-wrappers/zrx_token'; diff --git a/contracts/erc20/test/WETH9V06Test.t.sol b/contracts/erc20/test/WETH9V06Test.t.sol new file mode 100644 index 0000000000..4f7939ae22 --- /dev/null +++ b/contracts/erc20/test/WETH9V06Test.t.sol @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: Apache-2.0 +/* + Copyright 2023 ZeroEx Intl. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +pragma solidity ^0.6.5; +pragma experimental ABIEncoderV2; + +import "forge-std/Test.sol"; +import "../src/v06/WETH9V06.sol"; + +contract WETH9V06Test is Test { + address payable internal owner = payable(vm.addr(1)); + address payable internal user = payable(vm.addr(2)); + WETH9V06 internal etherToken; + + function setUp() public { + vm.deal(owner, 1e20); + vm.deal(user, 1e20); + + etherToken = new WETH9V06(); + } + + function testShouldRevertIfCallerAttemptsToDepositMoreThanTheirBalance() public { + vm.prank(user); + vm.expectRevert(); + etherToken.deposit{value: 1e20 + 1}(); + } + + function testShouldConvertDepositedETHToWrappedETH() public { + vm.prank(user); + etherToken.deposit{value: 1e20}(); + vm.stopPrank(); + + assertEq(etherToken.balanceOf(user), 1e20); + assertEq(address(etherToken).balance, 1e20); + } + + function testShouldRevertIfCallerAttemptsToWithdrawMoreThanTheirBalance() public { + vm.prank(user); + etherToken.deposit{value: 1e20}(); + + vm.expectRevert(); + etherToken.withdraw(1e20 + 1); + } + + function testShouldConvertWithdrawWrappedETHToETH() public { + vm.prank(user); + etherToken.deposit{value: 1e20}(); + vm.prank(user); + etherToken.withdraw(100); + vm.stopPrank(); + + assertEq(etherToken.balanceOf(user), 1e20 - 100); + assertEq(address(etherToken).balance, 1e20 - 100); + assertEq(user.balance, 100); + } + + function testShouldConvertSentETHToWrappedETH() public { + vm.prank(user); + address(etherToken).call{value: 1e20}(new bytes(0)); + vm.stopPrank(); + + assertEq(etherToken.balanceOf(user), 1e20); + assertEq(address(etherToken).balance, 1e20); + } +} diff --git a/contracts/erc20/test/ZRXTokenTest.t.sol b/contracts/erc20/test/ZRXTokenTest.t.sol new file mode 100644 index 0000000000..4a2ad56ec9 --- /dev/null +++ b/contracts/erc20/test/ZRXTokenTest.t.sol @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: Apache-2.0 +/* + Copyright 2023 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.8.17; + +import "forge-std/Test.sol"; +import "../src/IERC20Token.sol"; + +contract ZRXTokenTest is Test { + address payable internal owner = payable(vm.addr(1)); + address payable internal user = payable(vm.addr(2)); + address payable internal anotherUser = payable(vm.addr(3)); + uint256 internal totalSupply = 1_000_000_000 * 1e18; + IERC20Token zrxToken; + + function setUp() public { + vm.deal(owner, 1e20); + vm.deal(user, 1e20); + + vm.prank(owner); + bytes memory _bytecode = vm.getCode("./out/ZRXToken.sol/ZRXToken.json"); + address _address; + assembly { + _address := create(0, add(_bytecode, 0x20), mload(_bytecode)) + } + vm.stopPrank(); + zrxToken = IERC20Token(address(_address)); + } + + function testShouldHave18Decimals() public { + assertEq(zrxToken.decimals(), 18); + } + + function testShouldHaveTotalSupplyOf1Billion() public { + assertEq(zrxToken.totalSupply(), totalSupply); + } + + function testShouldInitializeOwnerBalanceToTotalSupply() public { + assertEq(zrxToken.balanceOf(owner), totalSupply); + } + + function testShouldTransferBalanceCorrectly() public { + vm.prank(owner); + zrxToken.transfer(user, 100); + + assertEq(zrxToken.balanceOf(user), 100); + assertEq(zrxToken.balanceOf(owner), totalSupply - 100); + } + + function testShouldReturnTrueOnAZeroValueTransfer() public { + vm.prank(owner); + bool success = zrxToken.transfer(user, 0); + assertTrue(success); + } + + function testShouldReturnTrueOnAZeroValueTransferByUserWithZeroBalance() public { + vm.prank(anotherUser); + bool success = zrxToken.transfer(user, 0); + assertTrue(success); + } + + function testShouldReturnFalseIfSenderHasInsufficientBalance() public { + vm.prank(owner); + zrxToken.approve(user, totalSupply + 1); + vm.stopPrank(); + + bool success = zrxToken.transferFrom(owner, user, totalSupply + 1); + assertEq(success, false); + } + + function testShouldReturnFalseIfRecipientHasInsufficientAllowance() public { + vm.prank(owner); + zrxToken.approve(user, totalSupply - 1); + vm.stopPrank(); + + bool success = zrxToken.transferFrom(owner, user, totalSupply); + assertEq(success, false); + } + + function testShouldReturnTrueOnAZeroValueApprovedTransfer() public { + vm.prank(user); + bool success = zrxToken.transferFrom(owner, user, 0); + assertEq(success, true); + } + + function testShouldNotModifySenderAllowanceIfSetToUINT256Max() public { + vm.prank(owner); + zrxToken.approve(user, type(uint256).max); + vm.stopPrank(); + + zrxToken.transferFrom(owner, user, 100); + assertEq(zrxToken.allowance(owner, user), type(uint256).max); + } + + function testShouldTransferCorrectlyWhenSufficientAllowance() public { + vm.prank(owner); + zrxToken.approve(user, 1000 * 1e18); + vm.stopPrank(); + + vm.prank(user); + zrxToken.transferFrom(owner, user, 100 * 1e18); + assertEq(zrxToken.allowance(owner, user), 900 * 1e18); + assertEq(zrxToken.balanceOf(user), 100 * 1e18); + assertEq(zrxToken.balanceOf(owner), totalSupply - 100 * 1e18); + } +} diff --git a/contracts/erc20/test/artifacts.ts b/contracts/erc20/test/artifacts.ts deleted file mode 100644 index 951aefd7ca..0000000000 --- a/contracts/erc20/test/artifacts.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Warning: This file is auto-generated by contracts-gen. Don't edit manually. - * ----------------------------------------------------------------------------- - */ -import { ContractArtifact } from 'ethereum-types'; - -import * as DummyERC20Token from '../test/generated-artifacts/DummyERC20Token.json'; -import * as DummyMultipleReturnERC20Token from '../test/generated-artifacts/DummyMultipleReturnERC20Token.json'; -import * as DummyNoReturnERC20Token from '../test/generated-artifacts/DummyNoReturnERC20Token.json'; -import * as ERC20Token from '../test/generated-artifacts/ERC20Token.json'; -import * as IERC20Token from '../test/generated-artifacts/IERC20Token.json'; -import * as IERC20TokenV06 from '../test/generated-artifacts/IERC20TokenV06.json'; -import * as IERC20TokenV08 from '../test/generated-artifacts/IERC20TokenV08.json'; -import * as IEtherToken from '../test/generated-artifacts/IEtherToken.json'; -import * as IEtherTokenV06 from '../test/generated-artifacts/IEtherTokenV06.json'; -import * as IEtherTokenV08 from '../test/generated-artifacts/IEtherTokenV08.json'; -import * as LibERC20Token from '../test/generated-artifacts/LibERC20Token.json'; -import * as LibERC20TokenV06 from '../test/generated-artifacts/LibERC20TokenV06.json'; -import * as LibERC20TokenV08 from '../test/generated-artifacts/LibERC20TokenV08.json'; -import * as MintableERC20Token from '../test/generated-artifacts/MintableERC20Token.json'; -import * as TestLibERC20Token from '../test/generated-artifacts/TestLibERC20Token.json'; -import * as TestLibERC20TokenTarget from '../test/generated-artifacts/TestLibERC20TokenTarget.json'; -import * as UnlimitedAllowanceERC20Token from '../test/generated-artifacts/UnlimitedAllowanceERC20Token.json'; -import * as UntransferrableDummyERC20Token from '../test/generated-artifacts/UntransferrableDummyERC20Token.json'; -import * as WETH9 from '../test/generated-artifacts/WETH9.json'; -import * as WETH9V06 from '../test/generated-artifacts/WETH9V06.json'; -import * as ZRXToken from '../test/generated-artifacts/ZRXToken.json'; -export const artifacts = { - ERC20Token: ERC20Token as ContractArtifact, - LibERC20Token: LibERC20Token as ContractArtifact, - MintableERC20Token: MintableERC20Token as ContractArtifact, - UnlimitedAllowanceERC20Token: UnlimitedAllowanceERC20Token as ContractArtifact, - WETH9: WETH9 as ContractArtifact, - ZRXToken: ZRXToken as any as ContractArtifact, - IERC20Token: IERC20Token as ContractArtifact, - IEtherToken: IEtherToken as ContractArtifact, - IERC20TokenV06: IERC20TokenV06 as ContractArtifact, - IEtherTokenV06: IEtherTokenV06 as ContractArtifact, - LibERC20TokenV06: LibERC20TokenV06 as ContractArtifact, - WETH9V06: WETH9V06 as ContractArtifact, - IERC20TokenV08: IERC20TokenV08 as ContractArtifact, - IEtherTokenV08: IEtherTokenV08 as ContractArtifact, - LibERC20TokenV08: LibERC20TokenV08 as ContractArtifact, - DummyERC20Token: DummyERC20Token as ContractArtifact, - DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact, - DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact, - TestLibERC20Token: TestLibERC20Token as ContractArtifact, - TestLibERC20TokenTarget: TestLibERC20TokenTarget as ContractArtifact, - UntransferrableDummyERC20Token: UntransferrableDummyERC20Token as ContractArtifact, -}; diff --git a/contracts/erc20/test/lib_erc20_token.ts b/contracts/erc20/test/lib_erc20_token.ts deleted file mode 100644 index 1f3eee4453..0000000000 --- a/contracts/erc20/test/lib_erc20_token.ts +++ /dev/null @@ -1,335 +0,0 @@ -import { - blockchainTests, - constants, - expect, - getRandomInteger, - randomAddress, - verifyEventsFromLogs, -} from '@0x/contracts-test-utils'; -import { hexUtils, RawRevertError, StringRevertError } from '@0x/utils'; - -import { TestLibERC20TokenContract, TestLibERC20TokenTargetEvents } from './wrappers'; - -import { artifacts } from './artifacts'; - -blockchainTests('LibERC20Token', env => { - let testContract: TestLibERC20TokenContract; - const REVERT_STRING = 'WHOOPSIE'; - const ENCODED_REVERT = new StringRevertError(REVERT_STRING).encode(); - const ENCODED_TRUE = hexUtils.leftPad(1); - const ENCODED_FALSE = hexUtils.leftPad(0); - const ENCODED_TWO = hexUtils.leftPad(2); - const ENCODED_SHORT_TRUE = hexUtils.leftPad(2, 31); - const ENCODED_LONG_TRUE = hexUtils.leftPad(2, 33); - - before(async () => { - testContract = await TestLibERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.TestLibERC20Token, - env.provider, - env.txDefaults, - artifacts, - ); - }); - - describe('approve()', () => { - it('calls the target with the correct arguments', async () => { - const spender = randomAddress(); - const allowance = getRandomInteger(0, 100e18); - const { logs } = await testContract - .testApprove(false, ENCODED_REVERT, ENCODED_TRUE, spender, allowance) - .awaitTransactionSuccessAsync(); - expect(logs).to.be.length(1); - verifyEventsFromLogs(logs, [{ spender, allowance }], TestLibERC20TokenTargetEvents.ApproveCalled); - }); - - it('succeeds if the target returns true', async () => { - const spender = randomAddress(); - const allowance = getRandomInteger(0, 100e18); - await testContract - .testApprove(false, ENCODED_REVERT, ENCODED_TRUE, spender, allowance) - .awaitTransactionSuccessAsync(); - }); - - it('succeeds if the target returns nothing', async () => { - const spender = randomAddress(); - const allowance = getRandomInteger(0, 100e18); - await testContract - .testApprove(false, ENCODED_REVERT, constants.NULL_BYTES, spender, allowance) - .awaitTransactionSuccessAsync(); - }); - - it('fails if the target returns false', async () => { - const spender = randomAddress(); - const allowance = getRandomInteger(0, 100e18); - const tx = testContract - .testApprove(false, ENCODED_REVERT, ENCODED_FALSE, spender, allowance) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_FALSE); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target returns nonzero and not true', async () => { - const spender = randomAddress(); - const allowance = getRandomInteger(0, 100e18); - const tx = testContract - .testApprove(false, ENCODED_REVERT, ENCODED_TWO, spender, allowance) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_TWO); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target returns less than 32 bytes', async () => { - const spender = randomAddress(); - const allowance = getRandomInteger(0, 100e18); - const tx = testContract - .testApprove(false, ENCODED_REVERT, ENCODED_SHORT_TRUE, spender, allowance) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target returns greater than 32 bytes', async () => { - const spender = randomAddress(); - const allowance = getRandomInteger(0, 100e18); - const tx = testContract - .testApprove(false, ENCODED_REVERT, ENCODED_LONG_TRUE, spender, allowance) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_LONG_TRUE); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target reverts', async () => { - const spender = randomAddress(); - const allowance = getRandomInteger(0, 100e18); - const tx = testContract - .testApprove(true, ENCODED_REVERT, ENCODED_TRUE, spender, allowance) - .awaitTransactionSuccessAsync(); - return expect(tx).to.revertWith(REVERT_STRING); - }); - - it('fails if the target reverts with no data', async () => { - const spender = randomAddress(); - const allowance = getRandomInteger(0, 100e18); - const tx = testContract - .testApprove(true, constants.NULL_BYTES, ENCODED_TRUE, spender, allowance) - .awaitTransactionSuccessAsync(); - return expect(tx).to.be.rejectedWith('revert'); - }); - }); - - describe('transfer()', () => { - it('calls the target with the correct arguments', async () => { - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract - .testTransfer(false, ENCODED_REVERT, ENCODED_TRUE, to, amount) - .awaitTransactionSuccessAsync(); - expect(logs).to.be.length(1); - verifyEventsFromLogs(logs, [{ to, amount }], TestLibERC20TokenTargetEvents.TransferCalled); - }); - - it('succeeds if the target returns true', async () => { - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - await testContract - .testTransfer(false, ENCODED_REVERT, ENCODED_TRUE, to, amount) - .awaitTransactionSuccessAsync(); - }); - - it('succeeds if the target returns nothing', async () => { - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - await testContract - .testTransfer(false, ENCODED_REVERT, constants.NULL_BYTES, to, amount) - .awaitTransactionSuccessAsync(); - }); - - it('fails if the target returns false', async () => { - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransfer(false, ENCODED_REVERT, ENCODED_FALSE, to, amount) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_FALSE); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target returns nonzero and not true', async () => { - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransfer(false, ENCODED_REVERT, ENCODED_TWO, to, amount) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_TWO); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target returns less than 32 bytes', async () => { - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransfer(false, ENCODED_REVERT, ENCODED_SHORT_TRUE, to, amount) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target returns greater than 32 bytes', async () => { - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransfer(false, ENCODED_REVERT, ENCODED_LONG_TRUE, to, amount) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_LONG_TRUE); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target reverts', async () => { - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransfer(true, ENCODED_REVERT, ENCODED_TRUE, to, amount) - .awaitTransactionSuccessAsync(); - return expect(tx).to.revertWith(REVERT_STRING); - }); - - it('fails if the target reverts with no data', async () => { - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransfer(true, constants.NULL_BYTES, ENCODED_TRUE, to, amount) - .awaitTransactionSuccessAsync(); - return expect(tx).to.be.rejectedWith('revert'); - }); - }); - - describe('transferFrom()', () => { - it('calls the target with the correct arguments', async () => { - const owner = randomAddress(); - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const { logs } = await testContract - .testTransferFrom(false, ENCODED_REVERT, ENCODED_TRUE, owner, to, amount) - .awaitTransactionSuccessAsync(); - expect(logs).to.be.length(1); - verifyEventsFromLogs(logs, [{ from: owner, to, amount }], TestLibERC20TokenTargetEvents.TransferFromCalled); - }); - - it('succeeds if the target returns true', async () => { - const owner = randomAddress(); - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - await testContract - .testTransferFrom(false, ENCODED_REVERT, ENCODED_TRUE, owner, to, amount) - .awaitTransactionSuccessAsync(); - }); - - it('succeeds if the target returns nothing', async () => { - const owner = randomAddress(); - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - await testContract - .testTransferFrom(false, ENCODED_REVERT, constants.NULL_BYTES, owner, to, amount) - .awaitTransactionSuccessAsync(); - }); - - it('fails if the target returns false', async () => { - const owner = randomAddress(); - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransferFrom(false, ENCODED_REVERT, ENCODED_FALSE, owner, to, amount) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_FALSE); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target returns nonzero and not true', async () => { - const owner = randomAddress(); - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransferFrom(false, ENCODED_REVERT, ENCODED_TWO, owner, to, amount) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_TWO); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target returns less than 32 bytes', async () => { - const owner = randomAddress(); - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransferFrom(false, ENCODED_REVERT, ENCODED_SHORT_TRUE, owner, to, amount) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_SHORT_TRUE); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target returns greater than 32 bytes', async () => { - const owner = randomAddress(); - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransferFrom(false, ENCODED_REVERT, ENCODED_LONG_TRUE, owner, to, amount) - .awaitTransactionSuccessAsync(); - const expectedError = new RawRevertError(ENCODED_LONG_TRUE); - return expect(tx).to.revertWith(expectedError); - }); - - it('fails if the target reverts', async () => { - const owner = randomAddress(); - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransferFrom(true, ENCODED_REVERT, ENCODED_TRUE, owner, to, amount) - .awaitTransactionSuccessAsync(); - return expect(tx).to.revertWith(REVERT_STRING); - }); - - it('fails if the target reverts with no data', async () => { - const owner = randomAddress(); - const to = randomAddress(); - const amount = getRandomInteger(0, 100e18); - const tx = testContract - .testTransferFrom(true, constants.NULL_BYTES, ENCODED_TRUE, owner, to, amount) - .awaitTransactionSuccessAsync(); - return expect(tx).to.be.rejectedWith('revert'); - }); - }); - - describe('decimals()', () => { - const DEFAULT_DECIMALS = 18; - const ENCODED_ZERO = hexUtils.leftPad(0); - const ENCODED_SHORT_ZERO = hexUtils.leftPad(0, 31); - const ENCODED_LONG_ZERO = hexUtils.leftPad(0, 33); - const randomDecimals = () => Math.floor(Math.random() * 256) + 1; - - it('returns the number of decimals defined by the token', async () => { - const decimals = randomDecimals(); - const encodedDecimals = hexUtils.leftPad(decimals); - const result = await testContract.testDecimals(false, ENCODED_REVERT, encodedDecimals).callAsync(); - return expect(result).to.bignumber.eq(decimals); - }); - - it('returns 0 if the token returns 0', async () => { - const result = await testContract.testDecimals(false, ENCODED_REVERT, ENCODED_ZERO).callAsync(); - return expect(result).to.bignumber.eq(0); - }); - - it('returns 18 if the token returns less than 32 bytes', async () => { - const result = await testContract.testDecimals(false, ENCODED_REVERT, ENCODED_SHORT_ZERO).callAsync(); - return expect(result).to.bignumber.eq(DEFAULT_DECIMALS); - }); - - it('returns 18 if the token returns greater than 32 bytes', async () => { - const result = await testContract.testDecimals(false, ENCODED_REVERT, ENCODED_LONG_ZERO).callAsync(); - return expect(result).to.bignumber.eq(DEFAULT_DECIMALS); - }); - - it('returns 18 if the token reverts', async () => { - const result = await testContract.testDecimals(true, ENCODED_REVERT, ENCODED_ZERO).callAsync(); - return expect(result).to.bignumber.eq(DEFAULT_DECIMALS); - }); - }); -}); diff --git a/contracts/erc20/test/unlimited_allowance_token.ts b/contracts/erc20/test/unlimited_allowance_token.ts deleted file mode 100644 index f361e00e6a..0000000000 --- a/contracts/erc20/test/unlimited_allowance_token.ts +++ /dev/null @@ -1,187 +0,0 @@ -import { chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils'; -import { BlockchainLifecycle } from '@0x/dev-utils'; -import { RevertReason } from '@0x/types'; -import { BigNumber } from '@0x/utils'; -import * as chai from 'chai'; - -import { DummyERC20TokenContract } from './wrappers'; - -import { artifacts } from './artifacts'; - -chaiSetup.configure(); -const expect = chai.expect; -const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); - -describe('UnlimitedAllowanceToken', () => { - let owner: string; - let spender: string; - const MAX_MINT_VALUE = new BigNumber(10000000000000000000000); - let token: DummyERC20TokenContract; - - before(async () => { - await blockchainLifecycle.startAsync(); - }); - after(async () => { - await blockchainLifecycle.revertAsync(); - }); - before(async () => { - const accounts = await web3Wrapper.getAvailableAddressesAsync(); - owner = accounts[0]; - spender = accounts[1]; - token = await DummyERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyERC20Token, - provider, - txDefaults, - artifacts, - constants.DUMMY_TOKEN_NAME, - constants.DUMMY_TOKEN_SYMBOL, - constants.DUMMY_TOKEN_DECIMALS, - constants.DUMMY_TOKEN_TOTAL_SUPPLY, - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await token.mint(MAX_MINT_VALUE).sendTransactionAsync({ from: owner }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - }); - beforeEach(async () => { - await blockchainLifecycle.startAsync(); - }); - afterEach(async () => { - await blockchainLifecycle.revertAsync(); - }); - describe('transfer', () => { - it('should revert if owner has insufficient balance', async () => { - const ownerBalance = await token.balanceOf(owner).callAsync(); - const amountToTransfer = ownerBalance.plus(1); - return expect(token.transfer(spender, amountToTransfer).callAsync({ from: owner })).to.revertWith( - RevertReason.Erc20InsufficientBalance, - ); - }); - - it('should transfer balance from sender to receiver', async () => { - const receiver = spender; - const initOwnerBalance = await token.balanceOf(owner).callAsync(); - const amountToTransfer = new BigNumber(1); - await web3Wrapper.awaitTransactionSuccessAsync( - await token.transfer(receiver, amountToTransfer).sendTransactionAsync({ from: owner }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - const finalOwnerBalance = await token.balanceOf(owner).callAsync(); - const finalReceiverBalance = await token.balanceOf(receiver).callAsync(); - - const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer); - const expectedFinalReceiverBalance = amountToTransfer; - expect(finalOwnerBalance).to.be.bignumber.equal(expectedFinalOwnerBalance); - expect(finalReceiverBalance).to.be.bignumber.equal(expectedFinalReceiverBalance); - }); - - it('should return true on a 0 value transfer', async () => { - const didReturnTrue = await token.transfer(spender, new BigNumber(0)).callAsync({ - from: owner, - }); - expect(didReturnTrue).to.be.true(); - }); - }); - - describe('transferFrom', () => { - it('should revert if owner has insufficient balance', async () => { - const ownerBalance = await token.balanceOf(owner).callAsync(); - const amountToTransfer = ownerBalance.plus(1); - await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve(spender, amountToTransfer).sendTransactionAsync({ from: owner }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - return expect( - token.transferFrom(owner, spender, amountToTransfer).callAsync({ - from: spender, - }), - ).to.revertWith(RevertReason.Erc20InsufficientBalance); - }); - - it('should revert if spender has insufficient allowance', async () => { - const ownerBalance = await token.balanceOf(owner).callAsync(); - const amountToTransfer = ownerBalance; - - const spenderAllowance = await token.allowance(owner, spender).callAsync(); - const isSpenderAllowanceInsufficient = spenderAllowance.comparedTo(amountToTransfer) < 0; - expect(isSpenderAllowanceInsufficient).to.be.true(); - - return expect( - token.transferFrom(owner, spender, amountToTransfer).callAsync({ - from: spender, - }), - ).to.revertWith(RevertReason.Erc20InsufficientAllowance); - }); - - it('should return true on a 0 value transfer', async () => { - const amountToTransfer = new BigNumber(0); - const didReturnTrue = await token.transferFrom(owner, spender, amountToTransfer).callAsync({ - from: spender, - }); - expect(didReturnTrue).to.be.true(); - }); - - it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => { - const initOwnerBalance = await token.balanceOf(owner).callAsync(); - const amountToTransfer = initOwnerBalance; - const initSpenderAllowance = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; - await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ - from: spender, - gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, - }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - const newSpenderAllowance = await token.allowance(owner, spender).callAsync(); - expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); - }); - - it('should transfer the correct balances if spender has sufficient allowance', async () => { - const initOwnerBalance = await token.balanceOf(owner).callAsync(); - const amountToTransfer = initOwnerBalance; - const initSpenderAllowance = initOwnerBalance; - await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ - from: spender, - gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, - }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - const newOwnerBalance = await token.balanceOf(owner).callAsync(); - const newSpenderBalance = await token.balanceOf(spender).callAsync(); - - expect(newOwnerBalance).to.be.bignumber.equal(0); - expect(newSpenderBalance).to.be.bignumber.equal(initOwnerBalance); - }); - - it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => { - const initOwnerBalance = await token.balanceOf(owner).callAsync(); - const amountToTransfer = initOwnerBalance; - const initSpenderAllowance = initOwnerBalance; - await web3Wrapper.awaitTransactionSuccessAsync( - await token.approve(spender, initSpenderAllowance).sendTransactionAsync({ from: owner }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await token.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ - from: spender, - gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, - }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - const newSpenderAllowance = await token.allowance(owner, spender).callAsync(); - expect(newSpenderAllowance).to.be.bignumber.equal(0); - }); - }); -}); diff --git a/contracts/erc20/test/weth9.ts b/contracts/erc20/test/weth9.ts deleted file mode 100644 index f6b4f9fd47..0000000000 --- a/contracts/erc20/test/weth9.ts +++ /dev/null @@ -1,149 +0,0 @@ -import { - chaiSetup, - constants, - expectInsufficientFundsAsync, - expectTransactionFailedWithoutReasonAsync, - provider, - txDefaults, - web3Wrapper, -} from '@0x/contracts-test-utils'; -import { BlockchainLifecycle } from '@0x/dev-utils'; -import { BigNumber } from '@0x/utils'; -import { Web3Wrapper } from '@0x/web3-wrapper'; -import * as chai from 'chai'; - -import { WETH9Contract } from './wrappers'; - -import { artifacts } from './artifacts'; - -chaiSetup.configure(); -const expect = chai.expect; -const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); - -describe('EtherToken', () => { - let account: string; - const gasPrice = new BigNumber(constants.DEFAULT_GAS_PRICE); - let etherToken: WETH9Contract; - - before(async () => { - await blockchainLifecycle.startAsync(); - }); - after(async () => { - await blockchainLifecycle.revertAsync(); - }); - before(async () => { - const accounts = await web3Wrapper.getAvailableAddressesAsync(); - account = accounts[0]; - - etherToken = await WETH9Contract.deployFrom0xArtifactAsync( - artifacts.WETH9, - provider, - { - ...txDefaults, - gasPrice, - }, - artifacts, - ); - }); - beforeEach(async () => { - await blockchainLifecycle.startAsync(); - }); - afterEach(async () => { - await blockchainLifecycle.revertAsync(); - }); - describe('deposit', () => { - it('should revert if caller attempts to deposit more Ether than caller balance', async () => { - const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const ethToDeposit = initEthBalance.plus(1); - - return expectInsufficientFundsAsync(etherToken.deposit().sendTransactionAsync({ value: ethToDeposit })); - }); - - it('should convert deposited Ether to wrapped Ether tokens', async () => { - const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); - - const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1))); - - const txHash = await etherToken.deposit().sendTransactionAsync({ value: ethToDeposit }); - const receipt = await web3Wrapper.awaitTransactionSuccessAsync( - txHash, - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - const ethSpentOnGas = gasPrice.times(receipt.gasUsed); - const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); - - expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas))); - expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit)); - }); - }); - - describe('withdraw', () => { - it('should revert if caller attempts to withdraw greater than caller balance', async () => { - const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); - const ethTokensToWithdraw = initEthTokenBalance.plus(1); - - return expectTransactionFailedWithoutReasonAsync( - etherToken.withdraw(ethTokensToWithdraw).sendTransactionAsync(), - ); - }); - - it('should convert ether tokens to ether with sufficient balance', async () => { - const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1))); - await web3Wrapper.awaitTransactionSuccessAsync( - await etherToken.deposit().sendTransactionAsync({ value: ethToDeposit }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); - const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const ethTokensToWithdraw = initEthTokenBalance; - expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0); - const txHash = await etherToken.withdraw(ethTokensToWithdraw).sendTransactionAsync({ - gas: constants.MAX_ETHERTOKEN_WITHDRAW_GAS, - }); - const receipt = await web3Wrapper.awaitTransactionSuccessAsync( - txHash, - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - const ethSpentOnGas = gasPrice.times(receipt.gasUsed); - const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); - - expect(finalEthBalance).to.be.bignumber.equal( - initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)), - ); - expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.minus(ethTokensToWithdraw)); - }); - }); - - describe('fallback', () => { - it('should convert sent ether to ether tokens', async () => { - const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const initEthTokenBalance = await etherToken.balanceOf(account).callAsync(); - - const ethToDeposit = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18); - - const txHash = await web3Wrapper.sendTransactionAsync({ - from: account, - to: etherToken.address, - value: ethToDeposit, - gasPrice, - }); - - const receipt = await web3Wrapper.awaitTransactionSuccessAsync( - txHash, - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - const ethSpentOnGas = gasPrice.times(receipt.gasUsed); - const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); - const finalEthTokenBalance = await etherToken.balanceOf(account).callAsync(); - - expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas))); - expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit)); - }); - }); -}); diff --git a/contracts/erc20/test/wrappers.ts b/contracts/erc20/test/wrappers.ts deleted file mode 100644 index 369a56bb96..0000000000 --- a/contracts/erc20/test/wrappers.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Warning: This file is auto-generated by contracts-gen. Don't edit manually. - * ----------------------------------------------------------------------------- - */ -export * from '../test/generated-wrappers/dummy_erc20_token'; -export * from '../test/generated-wrappers/dummy_multiple_return_erc20_token'; -export * from '../test/generated-wrappers/dummy_no_return_erc20_token'; -export * from '../test/generated-wrappers/erc20_token'; -export * from '../test/generated-wrappers/i_erc20_token'; -export * from '../test/generated-wrappers/i_erc20_token_v06'; -export * from '../test/generated-wrappers/i_erc20_token_v08'; -export * from '../test/generated-wrappers/i_ether_token'; -export * from '../test/generated-wrappers/i_ether_token_v06'; -export * from '../test/generated-wrappers/i_ether_token_v08'; -export * from '../test/generated-wrappers/lib_erc20_token'; -export * from '../test/generated-wrappers/lib_erc20_token_v06'; -export * from '../test/generated-wrappers/lib_erc20_token_v08'; -export * from '../test/generated-wrappers/mintable_erc20_token'; -export * from '../test/generated-wrappers/test_lib_erc20_token'; -export * from '../test/generated-wrappers/test_lib_erc20_token_target'; -export * from '../test/generated-wrappers/unlimited_allowance_erc20_token'; -export * from '../test/generated-wrappers/untransferrable_dummy_erc20_token'; -export * from '../test/generated-wrappers/weth9'; -export * from '../test/generated-wrappers/weth9v06'; -export * from '../test/generated-wrappers/zrx_token'; diff --git a/contracts/erc20/test/zrx_token.ts b/contracts/erc20/test/zrx_token.ts deleted file mode 100644 index 82d7dfc881..0000000000 --- a/contracts/erc20/test/zrx_token.ts +++ /dev/null @@ -1,210 +0,0 @@ -import { chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils'; -import { BlockchainLifecycle } from '@0x/dev-utils'; -import { BigNumber } from '@0x/utils'; -import { Web3Wrapper } from '@0x/web3-wrapper'; -import * as chai from 'chai'; - -import { ZRXTokenContract } from './wrappers'; - -import { artifacts } from './artifacts'; - -chaiSetup.configure(); -const expect = chai.expect; -const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); - -describe('ZRXToken', () => { - let owner: string; - let spender: string; - let MAX_UINT: BigNumber; - let zrxToken: ZRXTokenContract; - - before(async () => { - await blockchainLifecycle.startAsync(); - }); - after(async () => { - await blockchainLifecycle.revertAsync(); - }); - before(async () => { - const accounts = await web3Wrapper.getAvailableAddressesAsync(); - owner = accounts[0]; - spender = accounts[1]; - zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync( - artifacts.ZRXToken, - provider, - txDefaults, - artifacts, - ); - MAX_UINT = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; - }); - beforeEach(async () => { - await blockchainLifecycle.startAsync(); - }); - afterEach(async () => { - await blockchainLifecycle.revertAsync(); - }); - describe('constants', () => { - it('should have 18 decimals', async () => { - const decimals = new BigNumber(await zrxToken.decimals().callAsync()); - const expectedDecimals = 18; - expect(decimals).to.be.bignumber.equal(expectedDecimals); - }); - - it('should have a total supply of 1 billion tokens', async () => { - const totalSupply = new BigNumber(await zrxToken.totalSupply().callAsync()); - const expectedTotalSupply = 1000000000; - expect(Web3Wrapper.toUnitAmount(totalSupply, 18)).to.be.bignumber.equal(expectedTotalSupply); - }); - - it('should be named 0x Protocol Token', async () => { - const name = await zrxToken.name().callAsync(); - const expectedName = '0x Protocol Token'; - expect(name).to.be.equal(expectedName); - }); - - it('should have the symbol ZRX', async () => { - const symbol = await zrxToken.symbol().callAsync(); - const expectedSymbol = 'ZRX'; - expect(symbol).to.be.equal(expectedSymbol); - }); - }); - - describe('constructor', () => { - it('should initialize owner balance to totalSupply', async () => { - const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); - const totalSupply = new BigNumber(await zrxToken.totalSupply().callAsync()); - expect(totalSupply).to.be.bignumber.equal(ownerBalance); - }); - }); - - describe('transfer', () => { - it('should transfer balance from sender to receiver', async () => { - const receiver = spender; - const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); - const amountToTransfer = new BigNumber(1); - await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transfer(receiver, amountToTransfer).sendTransactionAsync({ from: owner }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - const finalOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); - const finalReceiverBalance = await zrxToken.balanceOf(receiver).callAsync(); - - const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer); - const expectedFinalReceiverBalance = amountToTransfer; - expect(finalOwnerBalance).to.be.bignumber.equal(expectedFinalOwnerBalance); - expect(finalReceiverBalance).to.be.bignumber.equal(expectedFinalReceiverBalance); - }); - - it('should return true on a 0 value transfer', async () => { - const didReturnTrue = await zrxToken.transfer(spender, new BigNumber(0)).callAsync({ - from: owner, - }); - expect(didReturnTrue).to.be.true(); - }); - }); - - describe('transferFrom', () => { - it('should return false if owner has insufficient balance', async () => { - const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); - const amountToTransfer = ownerBalance.plus(1); - await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve(spender, amountToTransfer).sendTransactionAsync({ - from: owner, - gas: constants.MAX_TOKEN_APPROVE_GAS, - }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ - from: spender, - }); - expect(didReturnTrue).to.be.false(); - }); - - it('should return false if spender has insufficient allowance', async () => { - const ownerBalance = await zrxToken.balanceOf(owner).callAsync(); - const amountToTransfer = ownerBalance; - - const spenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); - const isSpenderAllowanceInsufficient = spenderAllowance.comparedTo(amountToTransfer) < 0; - expect(isSpenderAllowanceInsufficient).to.be.true(); - - const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ - from: spender, - }); - expect(didReturnTrue).to.be.false(); - }); - - it('should return true on a 0 value transfer', async () => { - const amountToTransfer = new BigNumber(0); - const didReturnTrue = await zrxToken.transferFrom(owner, spender, amountToTransfer).callAsync({ - from: spender, - }); - expect(didReturnTrue).to.be.true(); - }); - - it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => { - const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); - const amountToTransfer = initOwnerBalance; - const initSpenderAllowance = MAX_UINT; - await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve(spender, initSpenderAllowance).sendTransactionAsync({ - from: owner, - gas: constants.MAX_TOKEN_APPROVE_GAS, - }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ - from: spender, - gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, - }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - const newSpenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); - expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); - }); - - it('should transfer the correct balances if spender has sufficient allowance', async () => { - const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); - const initSpenderBalance = await zrxToken.balanceOf(spender).callAsync(); - const amountToTransfer = initOwnerBalance; - const initSpenderAllowance = initOwnerBalance; - await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve(spender, initSpenderAllowance).sendTransactionAsync(), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ - from: spender, - gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, - }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - const newOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); - const newSpenderBalance = await zrxToken.balanceOf(spender).callAsync(); - - expect(newOwnerBalance).to.be.bignumber.equal(0); - expect(newSpenderBalance).to.be.bignumber.equal(initSpenderBalance.plus(initOwnerBalance)); - }); - - it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => { - const initOwnerBalance = await zrxToken.balanceOf(owner).callAsync(); - const amountToTransfer = initOwnerBalance; - await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.approve(spender, amountToTransfer).sendTransactionAsync(), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - await web3Wrapper.awaitTransactionSuccessAsync( - await zrxToken.transferFrom(owner, spender, amountToTransfer).sendTransactionAsync({ - from: spender, - gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, - }), - constants.AWAIT_TRANSACTION_MINED_MS, - ); - - const newSpenderAllowance = await zrxToken.allowance(owner, spender).callAsync(); - expect(newSpenderAllowance).to.be.bignumber.equal(0); - }); - }); -}); diff --git a/contracts/erc20/tsconfig.json b/contracts/erc20/tsconfig.json deleted file mode 100644 index f7a6dccaee..0000000000 --- a/contracts/erc20/tsconfig.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true }, - "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"], - "files": [ - "generated-artifacts/DummyERC20Token.json", - "generated-artifacts/DummyMultipleReturnERC20Token.json", - "generated-artifacts/DummyNoReturnERC20Token.json", - "generated-artifacts/ERC20Token.json", - "generated-artifacts/WETH9.json", - "generated-artifacts/ZRXToken.json", - "test/generated-artifacts/DummyERC20Token.json", - "test/generated-artifacts/DummyMultipleReturnERC20Token.json", - "test/generated-artifacts/DummyNoReturnERC20Token.json", - "test/generated-artifacts/ERC20Token.json", - "test/generated-artifacts/IERC20Token.json", - "test/generated-artifacts/IERC20TokenV06.json", - "test/generated-artifacts/IERC20TokenV08.json", - "test/generated-artifacts/IEtherToken.json", - "test/generated-artifacts/IEtherTokenV06.json", - "test/generated-artifacts/IEtherTokenV08.json", - "test/generated-artifacts/LibERC20Token.json", - "test/generated-artifacts/LibERC20TokenV06.json", - "test/generated-artifacts/LibERC20TokenV08.json", - "test/generated-artifacts/MintableERC20Token.json", - "test/generated-artifacts/TestLibERC20Token.json", - "test/generated-artifacts/TestLibERC20TokenTarget.json", - "test/generated-artifacts/UnlimitedAllowanceERC20Token.json", - "test/generated-artifacts/UntransferrableDummyERC20Token.json", - "test/generated-artifacts/WETH9.json", - "test/generated-artifacts/WETH9V06.json", - "test/generated-artifacts/ZRXToken.json" - ], - "exclude": ["./deploy/solc/solc_bin"] -} diff --git a/contracts/erc20/typedoc-tsconfig.json b/contracts/erc20/typedoc-tsconfig.json deleted file mode 100644 index c9b0af1ae6..0000000000 --- a/contracts/erc20/typedoc-tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../typedoc-tsconfig", - "compilerOptions": { - "outDir": "lib" - }, - "include": ["./src/**/*", "./test/**/*"] -} diff --git a/contracts/treasury/contracts/src/DefaultPoolOperator.sol b/contracts/treasury/contracts/src/DefaultPoolOperator.sol index 0b418b2e43..e53a643542 100644 --- a/contracts/treasury/contracts/src/DefaultPoolOperator.sol +++ b/contracts/treasury/contracts/src/DefaultPoolOperator.sol @@ -20,19 +20,19 @@ pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "./IStaking.sol"; contract DefaultPoolOperator { // Immutables IStaking public immutable stakingProxy; - IERC20TokenV06 public immutable weth; + IERC20Token public immutable weth; bytes32 public immutable poolId; /// @dev Initializes this contract and creates a staking pool. /// @param stakingProxy_ The 0x staking proxy contract. /// @param weth_ The WETH token contract. - constructor(IStaking stakingProxy_, IERC20TokenV06 weth_) public { + constructor(IStaking stakingProxy_, IERC20Token weth_) public { stakingProxy = stakingProxy_; weth = weth_; // operator share = 100% diff --git a/contracts/treasury/package.json b/contracts/treasury/package.json index 2bf4c6d2a5..2bde4297ad 100644 --- a/contracts/treasury/package.json +++ b/contracts/treasury/package.json @@ -48,7 +48,7 @@ "@0x/abi-gen": "^5.8.1", "@0x/contract-addresses": "^8.0.3", "@0x/contracts-asset-proxy": "^3.7.19", - "@0x/contracts-erc20": "^3.3.57", + "@0x/contracts-erc20": "3.3.57", "@0x/contracts-gen": "^2.0.48", "@0x/contracts-staking": "^2.0.45", "@0x/contracts-test-utils": "^5.4.47", diff --git a/contracts/zero-ex/contracts/deps/forge-std b/contracts/zero-ex/contracts/deps/forge-std index 058d2004ac..f8e700ed5d 160000 --- a/contracts/zero-ex/contracts/deps/forge-std +++ b/contracts/zero-ex/contracts/deps/forge-std @@ -1 +1 @@ -Subproject commit 058d2004ac10cc8f194625fb107fb7a87c4e702d +Subproject commit f8e700ed5d605f53f2194dc8df05a0bc3a7c1e43 diff --git a/contracts/zero-ex/contracts/src/external/FeeCollector.sol b/contracts/zero-ex/contracts/src/external/FeeCollector.sol index 0445265180..89459c01d0 100644 --- a/contracts/zero-ex/contracts/src/external/FeeCollector.sol +++ b/contracts/zero-ex/contracts/src/external/FeeCollector.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "@0x/contracts-utils/contracts/src/v06/AuthorizableV06.sol"; import "../vendor/v3/IStaking.sol"; @@ -33,14 +33,14 @@ contract FeeCollector is AuthorizableV06 { /// @param weth The WETH contract. /// @param staking The staking contract. /// @param poolId The pool ID this contract is collecting fees for. - function initialize(IEtherTokenV06 weth, IStaking staking, bytes32 poolId) external onlyAuthorized { + function initialize(IEtherToken weth, IStaking staking, bytes32 poolId) external onlyAuthorized { weth.approve(address(staking), type(uint256).max); staking.joinStakingPoolAsMaker(poolId); } /// @dev Convert all held ether to WETH. Only an authority can call this. /// @param weth The WETH contract. - function convertToWeth(IEtherTokenV06 weth) external onlyAuthorized { + function convertToWeth(IEtherToken weth) external onlyAuthorized { if (address(this).balance > 0) { weth.deposit{value: address(this).balance}(); } diff --git a/contracts/zero-ex/contracts/src/external/FeeCollectorController.sol b/contracts/zero-ex/contracts/src/external/FeeCollectorController.sol index e1de982b0d..8388e3044f 100644 --- a/contracts/zero-ex/contracts/src/external/FeeCollectorController.sol +++ b/contracts/zero-ex/contracts/src/external/FeeCollectorController.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "../vendor/v3/IStaking.sol"; import "./FeeCollector.sol"; import "./LibFeeCollector.sol"; @@ -25,11 +25,11 @@ contract FeeCollectorController { /// @dev Hash of the fee collector init code. bytes32 public immutable FEE_COLLECTOR_INIT_CODE_HASH; /// @dev The WETH contract. - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; /// @dev The staking contract. IStaking private immutable STAKING; - constructor(IEtherTokenV06 weth, IStaking staking) public { + constructor(IEtherToken weth, IStaking staking) public { FEE_COLLECTOR_INIT_CODE_HASH = keccak256(type(FeeCollector).creationCode); WETH = weth; STAKING = staking; diff --git a/contracts/zero-ex/contracts/src/external/ILiquidityProviderSandbox.sol b/contracts/zero-ex/contracts/src/external/ILiquidityProviderSandbox.sol index afb9df39b9..66809fc369 100644 --- a/contracts/zero-ex/contracts/src/external/ILiquidityProviderSandbox.sol +++ b/contracts/zero-ex/contracts/src/external/ILiquidityProviderSandbox.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../vendor/ILiquidityProvider.sol"; interface ILiquidityProviderSandbox { @@ -29,8 +29,8 @@ interface ILiquidityProviderSandbox { /// @param auxiliaryData Auxiliary data supplied to the `provider` contract. function executeSellTokenForToken( ILiquidityProvider provider, - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -45,7 +45,7 @@ interface ILiquidityProviderSandbox { /// @param auxiliaryData Auxiliary data supplied to the `provider` contract. function executeSellEthForToken( ILiquidityProvider provider, - IERC20TokenV06 outputToken, + IERC20Token outputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -60,7 +60,7 @@ interface ILiquidityProviderSandbox { /// @param auxiliaryData Auxiliary data supplied to the `provider` contract. function executeSellTokenForEth( ILiquidityProvider provider, - IERC20TokenV06 inputToken, + IERC20Token inputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData diff --git a/contracts/zero-ex/contracts/src/external/LiquidityProviderSandbox.sol b/contracts/zero-ex/contracts/src/external/LiquidityProviderSandbox.sol index 19a16b365f..574f80d7c3 100644 --- a/contracts/zero-ex/contracts/src/external/LiquidityProviderSandbox.sol +++ b/contracts/zero-ex/contracts/src/external/LiquidityProviderSandbox.sol @@ -17,7 +17,7 @@ pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/errors/LibOwnableRichErrorsV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../vendor/ILiquidityProvider.sol"; import "../vendor/v3/IERC20Bridge.sol"; import "./ILiquidityProviderSandbox.sol"; @@ -52,8 +52,8 @@ contract LiquidityProviderSandbox is ILiquidityProviderSandbox { /// @param auxiliaryData Auxiliary data supplied to the `provider` contract. function executeSellTokenForToken( ILiquidityProvider provider, - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -70,7 +70,7 @@ contract LiquidityProviderSandbox is ILiquidityProviderSandbox { /// @param auxiliaryData Auxiliary data supplied to the `provider` contract. function executeSellEthForToken( ILiquidityProvider provider, - IERC20TokenV06 outputToken, + IERC20Token outputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -87,7 +87,7 @@ contract LiquidityProviderSandbox is ILiquidityProviderSandbox { /// @param auxiliaryData Auxiliary data supplied to the `provider` contract. function executeSellTokenForEth( ILiquidityProvider provider, - IERC20TokenV06 inputToken, + IERC20Token inputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData diff --git a/contracts/zero-ex/contracts/src/features/FundRecoveryFeature.sol b/contracts/zero-ex/contracts/src/features/FundRecoveryFeature.sol index 04bcc18767..08adece678 100644 --- a/contracts/zero-ex/contracts/src/features/FundRecoveryFeature.sol +++ b/contracts/zero-ex/contracts/src/features/FundRecoveryFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../migrations/LibMigrate.sol"; import "../fixins/FixinCommon.sol"; import "./interfaces/IFeature.sol"; @@ -41,7 +41,7 @@ contract FundRecoveryFeature is IFeature, IFundRecoveryFeature, FixinCommon { /// @param amountOut Amount of tokens to withdraw. /// @param recipientWallet Recipient wallet address. function transferTrappedTokensTo( - IERC20TokenV06 erc20, + IERC20Token erc20, uint256 amountOut, address payable recipientWallet ) external override onlyOwner { diff --git a/contracts/zero-ex/contracts/src/features/LiquidityProviderFeature.sol b/contracts/zero-ex/contracts/src/features/LiquidityProviderFeature.sol index daf4c2881d..154077f046 100644 --- a/contracts/zero-ex/contracts/src/features/LiquidityProviderFeature.sol +++ b/contracts/zero-ex/contracts/src/features/LiquidityProviderFeature.sol @@ -15,10 +15,9 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; import "../errors/LibLiquidityProviderRichErrors.sol"; import "../external/ILiquidityProviderSandbox.sol"; import "../external/LiquidityProviderSandbox.sol"; @@ -67,8 +66,8 @@ contract LiquidityProviderFeature is IFeature, ILiquidityProviderFeature, FixinC /// @param auxiliaryData Auxiliary data supplied to the `provider` contract. /// @return boughtAmount The amount of `outputToken` bought. function sellToLiquidityProvider( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, ILiquidityProvider provider, address recipient, uint256 sellAmount, @@ -92,7 +91,7 @@ contract LiquidityProviderFeature is IFeature, ILiquidityProviderFeature, FixinC if (LibERC20Transformer.isTokenETH(inputToken)) { uint256 balanceBefore = outputToken.balanceOf(recipient); sandbox.executeSellEthForToken(provider, outputToken, recipient, minBuyAmount, auxiliaryData); - boughtAmount = IERC20TokenV06(outputToken).balanceOf(recipient).safeSub(balanceBefore); + boughtAmount = IERC20Token(outputToken).balanceOf(recipient).safeSub(balanceBefore); } else if (LibERC20Transformer.isTokenETH(outputToken)) { uint256 balanceBefore = recipient.balance; sandbox.executeSellTokenForEth(provider, inputToken, recipient, minBuyAmount, auxiliaryData); diff --git a/contracts/zero-ex/contracts/src/features/MetaTransactionsFeature.sol b/contracts/zero-ex/contracts/src/features/MetaTransactionsFeature.sol index d000261fb7..72c5a78960 100644 --- a/contracts/zero-ex/contracts/src/features/MetaTransactionsFeature.sol +++ b/contracts/zero-ex/contracts/src/features/MetaTransactionsFeature.sol @@ -63,8 +63,8 @@ contract MetaTransactionsFeature is /// @dev Arguments for a `TransformERC20.transformERC20()` call. struct ExternalTransformERC20Args { - IERC20TokenV06 inputToken; - IERC20TokenV06 outputToken; + IERC20Token inputToken; + IERC20Token outputToken; uint256 inputTokenAmount; uint256 minOutputTokenAmount; ITransformERC20Feature.Transformation[] transformations; diff --git a/contracts/zero-ex/contracts/src/features/NativeOrdersFeature.sol b/contracts/zero-ex/contracts/src/features/NativeOrdersFeature.sol index c23800aba6..29cfee9f70 100644 --- a/contracts/zero-ex/contracts/src/features/NativeOrdersFeature.sol +++ b/contracts/zero-ex/contracts/src/features/NativeOrdersFeature.sol @@ -29,7 +29,7 @@ contract NativeOrdersFeature is IFeature, NativeOrdersSettlement { constructor( address zeroExAddress, - IEtherTokenV06 weth, + IEtherToken weth, IStaking staking, FeeCollectorController feeCollectorController, uint32 protocolFeeMultiplier diff --git a/contracts/zero-ex/contracts/src/features/OtcOrdersFeature.sol b/contracts/zero-ex/contracts/src/features/OtcOrdersFeature.sol index b25a06d08a..3593a25c80 100644 --- a/contracts/zero-ex/contracts/src/features/OtcOrdersFeature.sol +++ b/contracts/zero-ex/contracts/src/features/OtcOrdersFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibMathV06.sol"; import "../errors/LibNativeOrdersRichErrors.sol"; @@ -42,9 +42,9 @@ contract OtcOrdersFeature is IFeature, IOtcOrdersFeature, FixinCommon, FixinEIP7 /// @dev ETH pseudo-token address. address private constant ETH_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; /// @dev The WETH token contract. - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; - constructor(address zeroExAddress, IEtherTokenV06 weth) public FixinEIP712(zeroExAddress) { + constructor(address zeroExAddress, IEtherToken weth) public FixinEIP712(zeroExAddress) { WETH = weth; } diff --git a/contracts/zero-ex/contracts/src/features/PancakeSwapFeature.sol b/contracts/zero-ex/contracts/src/features/PancakeSwapFeature.sol index aa97cdcdf9..74a483ff5c 100644 --- a/contracts/zero-ex/contracts/src/features/PancakeSwapFeature.sol +++ b/contracts/zero-ex/contracts/src/features/PancakeSwapFeature.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "../migrations/LibMigrate.sol"; import "../fixins/FixinCommon.sol"; import "./interfaces/IFeature.sol"; @@ -29,7 +29,7 @@ contract PancakeSwapFeature is IFeature, IPancakeSwapFeature, FixinCommon { /// @dev Version of this feature. uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 0, 2); /// @dev WBNB contract. - IEtherTokenV06 private immutable WBNB; + IEtherToken private immutable WBNB; // 0xFF + address of the PancakeSwap factory contract. uint256 private constant FF_PANCAKESWAP_FACTORY = @@ -112,7 +112,7 @@ contract PancakeSwapFeature is IFeature, IPancakeSwapFeature, FixinCommon { /// @dev Construct this contract. /// @param wbnb The WBNB contract. - constructor(IEtherTokenV06 wbnb) public { + constructor(IEtherToken wbnb) public { WBNB = wbnb; } @@ -131,7 +131,7 @@ contract PancakeSwapFeature is IFeature, IPancakeSwapFeature, FixinCommon { /// @param fork The protocol fork to use. /// @return buyAmount Amount of `tokens[-1]` bought. function sellToPancakeSwap( - IERC20TokenV06[] calldata tokens, + IERC20Token[] calldata tokens, uint256 sellAmount, uint256 minBuyAmount, ProtocolFork fork @@ -139,7 +139,7 @@ contract PancakeSwapFeature is IFeature, IPancakeSwapFeature, FixinCommon { require(tokens.length > 1, "PancakeSwapFeature/InvalidTokensLength"); { // Load immutables onto the stack. - IEtherTokenV06 wbnb = WBNB; + IEtherToken wbnb = WBNB; // Store some vars in memory to get around stack limits. assembly { diff --git a/contracts/zero-ex/contracts/src/features/TransformERC20Feature.sol b/contracts/zero-ex/contracts/src/features/TransformERC20Feature.sol index f729533415..b2bb4a8016 100644 --- a/contracts/zero-ex/contracts/src/features/TransformERC20Feature.sol +++ b/contracts/zero-ex/contracts/src/features/TransformERC20Feature.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibBytesV06.sol"; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; @@ -124,8 +124,8 @@ contract TransformERC20Feature is IFeature, ITransformERC20Feature, FixinCommon, /// in sequence. /// @return outputTokenAmount The amount of `outputToken` received by the sender. function transformERC20( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 inputTokenAmount, uint256 minOutputTokenAmount, Transformation[] memory transformations @@ -301,7 +301,7 @@ contract TransformERC20Feature is IFeature, ITransformERC20Feature, FixinCommon, } function _executeOutputTokenTransfer( - IERC20TokenV06 outputToken, + IERC20Token outputToken, IFlashWallet wallet, address payable recipient ) private returns (uint256 transferAmount) { @@ -311,7 +311,7 @@ contract TransformERC20Feature is IFeature, ITransformERC20Feature, FixinCommon, } else { bytes memory resultData = wallet.executeCall( payable(address(outputToken)), - abi.encodeWithSelector(IERC20TokenV06.transfer.selector, recipient, transferAmount), + abi.encodeWithSelector(IERC20Token.transfer.selector, recipient, transferAmount), 0 ); if (resultData.length == 0) { diff --git a/contracts/zero-ex/contracts/src/features/UniswapFeature.sol b/contracts/zero-ex/contracts/src/features/UniswapFeature.sol index 2318e275b6..60f11285e3 100644 --- a/contracts/zero-ex/contracts/src/features/UniswapFeature.sol +++ b/contracts/zero-ex/contracts/src/features/UniswapFeature.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "../migrations/LibMigrate.sol"; import "../fixins/FixinCommon.sol"; import "./interfaces/IFeature.sol"; @@ -29,7 +29,7 @@ contract UniswapFeature is IFeature, IUniswapFeature, FixinCommon { /// @dev Version of this feature. uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 1, 2); /// @dev WETH contract. - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; // 0xFF + address of the UniswapV2Factory contract. uint256 private constant FF_UNISWAP_FACTORY = 0xFF5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f0000000000000000000000; @@ -75,7 +75,7 @@ contract UniswapFeature is IFeature, IUniswapFeature, FixinCommon { /// @dev Construct this contract. /// @param weth The WETH contract. - constructor(IEtherTokenV06 weth) public { + constructor(IEtherToken weth) public { WETH = weth; } @@ -94,7 +94,7 @@ contract UniswapFeature is IFeature, IUniswapFeature, FixinCommon { /// @param isSushi Use sushiswap if true. /// @return buyAmount Amount of `tokens[-1]` bought. function sellToUniswap( - IERC20TokenV06[] calldata tokens, + IERC20Token[] calldata tokens, uint256 sellAmount, uint256 minBuyAmount, bool isSushi @@ -102,7 +102,7 @@ contract UniswapFeature is IFeature, IUniswapFeature, FixinCommon { require(tokens.length > 1, "UniswapFeature/InvalidTokensLength"); { // Load immutables onto the stack. - IEtherTokenV06 weth = WETH; + IEtherToken weth = WETH; // Store some vars in memory to get around stack limits. assembly { diff --git a/contracts/zero-ex/contracts/src/features/UniswapV3Feature.sol b/contracts/zero-ex/contracts/src/features/UniswapV3Feature.sol index f3fd666a6e..43f77b1e03 100644 --- a/contracts/zero-ex/contracts/src/features/UniswapV3Feature.sol +++ b/contracts/zero-ex/contracts/src/features/UniswapV3Feature.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "../vendor/IUniswapV3Pool.sol"; import "../migrations/LibMigrate.sol"; import "../fixins/FixinCommon.sol"; @@ -31,7 +31,7 @@ contract UniswapV3Feature is IFeature, IUniswapV3Feature, FixinCommon, FixinToke /// @dev Version of this feature. uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 1, 0); /// @dev WETH contract. - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; /// @dev UniswapV3 Factory contract address prepended with '0xff' and left-aligned. bytes32 private immutable UNI_FF_FACTORY_ADDRESS; /// @dev UniswapV3 pool init code hash. @@ -57,7 +57,7 @@ contract UniswapV3Feature is IFeature, IUniswapV3Feature, FixinCommon, FixinToke /// @param weth The WETH contract. /// @param uniFactory The UniswapV3 factory contract. /// @param poolInitCodeHash The UniswapV3 pool init code hash. - constructor(IEtherTokenV06 weth, address uniFactory, bytes32 poolInitCodeHash) public { + constructor(IEtherToken weth, address uniFactory, bytes32 poolInitCodeHash) public { WETH = weth; UNI_FF_FACTORY_ADDRESS = bytes32((uint256(0xff) << 248) | (uint256(uniFactory) << 88)); UNI_POOL_INIT_CODE_HASH = poolInitCodeHash; @@ -163,8 +163,8 @@ contract UniswapV3Feature is IFeature, IUniswapV3Feature, FixinCommon, FixinToke /// @param data Arbitrary data forwarded from swap() caller. An ABI-encoded /// struct of: inputToken, outputToken, fee, payer function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external override { - IERC20TokenV06 token0; - IERC20TokenV06 token1; + IERC20Token token0; + IERC20Token token1; address payer; { uint24 fee; @@ -212,7 +212,7 @@ contract UniswapV3Feature is IFeature, IUniswapV3Feature, FixinCommon, FixinToke bool zeroForOne; IUniswapV3Pool pool; { - (IERC20TokenV06 inputToken, uint24 fee, IERC20TokenV06 outputToken) = _decodeFirstPoolInfoFromPath( + (IERC20Token inputToken, uint24 fee, IERC20Token outputToken) = _decodeFirstPoolInfoFromPath( encodedPath ); pool = _toPool(inputToken, fee, outputToken); @@ -248,7 +248,7 @@ contract UniswapV3Feature is IFeature, IUniswapV3Feature, FixinCommon, FixinToke // Pay tokens from `payer` to `to`, using `transferFrom()` if // `payer` != this contract. - function _pay(IERC20TokenV06 token, address payer, address to, uint256 amount) private { + function _pay(IERC20Token token, address payer, address to, uint256 amount) private { if (payer != address(this)) { _transferERC20TokensFrom(token, payer, to, amount); } else { @@ -259,8 +259,8 @@ contract UniswapV3Feature is IFeature, IUniswapV3Feature, FixinCommon, FixinToke // Update `swapCallbackData` in place with new values. function _updateSwapCallbackData( bytes memory swapCallbackData, - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint24 fee, address payer ) private pure { @@ -275,9 +275,9 @@ contract UniswapV3Feature is IFeature, IUniswapV3Feature, FixinCommon, FixinToke // Compute the pool address given two tokens and a fee. function _toPool( - IERC20TokenV06 inputToken, + IERC20Token inputToken, uint24 fee, - IERC20TokenV06 outputToken + IERC20Token outputToken ) private view returns (IUniswapV3Pool pool) { // address(keccak256(abi.encodePacked( // hex"ff", @@ -287,7 +287,7 @@ contract UniswapV3Feature is IFeature, IUniswapV3Feature, FixinCommon, FixinToke // ))) bytes32 ffFactoryAddress = UNI_FF_FACTORY_ADDRESS; bytes32 poolInitCodeHash = UNI_POOL_INIT_CODE_HASH; - (IERC20TokenV06 token0, IERC20TokenV06 token1) = inputToken < outputToken + (IERC20Token token0, IERC20Token token1) = inputToken < outputToken ? (inputToken, outputToken) : (outputToken, inputToken); assembly { @@ -314,7 +314,7 @@ contract UniswapV3Feature is IFeature, IUniswapV3Feature, FixinCommon, FixinToke // Return the first input token, output token, and fee of an encoded uniswap path. function _decodeFirstPoolInfoFromPath( bytes memory encodedPath - ) private pure returns (IERC20TokenV06 inputToken, uint24 fee, IERC20TokenV06 outputToken) { + ) private pure returns (IERC20Token inputToken, uint24 fee, IERC20Token outputToken) { require(encodedPath.length >= SINGLE_HOP_PATH_SIZE, "UniswapV3Feature/BAD_PATH_ENCODING"); assembly { let p := add(encodedPath, 32) diff --git a/contracts/zero-ex/contracts/src/features/interfaces/IERC1155OrdersFeature.sol b/contracts/zero-ex/contracts/src/features/interfaces/IERC1155OrdersFeature.sol index 79a1976969..760722b43a 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/IERC1155OrdersFeature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/IERC1155OrdersFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../libs/LibNFTOrder.sol"; import "../libs/LibSignature.sol"; import "../../vendor/IERC1155Token.sol"; @@ -39,7 +39,7 @@ interface IERC1155OrdersFeature { address maker, address taker, uint256 nonce, - IERC20TokenV06 erc20Token, + IERC20Token erc20Token, uint256 erc20FillAmount, IERC1155Token erc1155Token, uint256 erc1155TokenId, @@ -60,7 +60,7 @@ interface IERC1155OrdersFeature { address taker, uint256 expiry, uint256 nonce, - IERC20TokenV06 erc20Token, + IERC20Token erc20Token, uint256 erc20TokenAmount, LibNFTOrder.Fee[] fees, IERC1155Token erc1155Token, diff --git a/contracts/zero-ex/contracts/src/features/interfaces/IERC721OrdersFeature.sol b/contracts/zero-ex/contracts/src/features/interfaces/IERC721OrdersFeature.sol index 8fe97f8975..2269f7929b 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/IERC721OrdersFeature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/IERC721OrdersFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../libs/LibNFTOrder.sol"; import "../libs/LibSignature.sol"; import "../../vendor/IERC721Token.sol"; @@ -40,7 +40,7 @@ interface IERC721OrdersFeature { address maker, address taker, uint256 nonce, - IERC20TokenV06 erc20Token, + IERC20Token erc20Token, uint256 erc20TokenAmount, IERC721Token erc721Token, uint256 erc721TokenId, @@ -60,7 +60,7 @@ interface IERC721OrdersFeature { address taker, uint256 expiry, uint256 nonce, - IERC20TokenV06 erc20Token, + IERC20Token erc20Token, uint256 erc20TokenAmount, LibNFTOrder.Fee[] fees, IERC721Token erc721Token, diff --git a/contracts/zero-ex/contracts/src/features/interfaces/IFundRecoveryFeature.sol b/contracts/zero-ex/contracts/src/features/interfaces/IFundRecoveryFeature.sol index e9cfa8c99e..a810d95fe6 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/IFundRecoveryFeature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/IFundRecoveryFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; /// @dev Exchange Proxy Recovery Functions interface IFundRecoveryFeature { @@ -24,5 +24,5 @@ interface IFundRecoveryFeature { /// @param erc20 ERC20 Token Address. /// @param amountOut Amount of tokens to withdraw. /// @param recipientWallet Recipient wallet address. - function transferTrappedTokensTo(IERC20TokenV06 erc20, uint256 amountOut, address payable recipientWallet) external; + function transferTrappedTokensTo(IERC20Token erc20, uint256 amountOut, address payable recipientWallet) external; } diff --git a/contracts/zero-ex/contracts/src/features/interfaces/ILiquidityProviderFeature.sol b/contracts/zero-ex/contracts/src/features/interfaces/ILiquidityProviderFeature.sol index 8c41dc6ce1..269573dde5 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/ILiquidityProviderFeature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/ILiquidityProviderFeature.sol @@ -15,15 +15,15 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../../vendor/ILiquidityProvider.sol"; /// @dev Feature to swap directly with an on-chain liquidity provider. interface ILiquidityProviderFeature { /// @dev Event for data pipeline. event LiquidityProviderSwap( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 inputTokenAmount, uint256 outputTokenAmount, ILiquidityProvider provider, @@ -44,8 +44,8 @@ interface ILiquidityProviderFeature { /// @param auxiliaryData Auxiliary data supplied to the `provider` contract. /// @return boughtAmount The amount of `outputToken` bought. function sellToLiquidityProvider( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, ILiquidityProvider provider, address recipient, uint256 sellAmount, diff --git a/contracts/zero-ex/contracts/src/features/interfaces/IMetaTransactionsFeature.sol b/contracts/zero-ex/contracts/src/features/interfaces/IMetaTransactionsFeature.sol index 93ef027d06..33ec75bc18 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/IMetaTransactionsFeature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/IMetaTransactionsFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../libs/LibSignature.sol"; /// @dev Meta-transactions feature. @@ -39,7 +39,7 @@ interface IMetaTransactionsFeature { // Amount of ETH to attach to the call. uint256 value; // ERC20 fee `signer` pays `sender`. - IERC20TokenV06 feeToken; + IERC20Token feeToken; // ERC20 fee amount. uint256 feeAmount; } diff --git a/contracts/zero-ex/contracts/src/features/interfaces/IMultiplexFeature.sol b/contracts/zero-ex/contracts/src/features/interfaces/IMultiplexFeature.sol index 0a5b25fb4b..eecf260287 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/IMultiplexFeature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/IMultiplexFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; interface IMultiplexFeature { // Identifies the type of subcall. @@ -34,9 +34,9 @@ interface IMultiplexFeature { // Parameters for a batch sell. struct BatchSellParams { // The token being sold. - IERC20TokenV06 inputToken; + IERC20Token inputToken; // The token being bought. - IERC20TokenV06 outputToken; + IERC20Token outputToken; // The amount of `inputToken` to sell. uint256 sellAmount; // The nested calls to perform. @@ -116,7 +116,7 @@ interface IMultiplexFeature { /// must be bought for this function to not revert. /// @return boughtAmount The amount of `outputToken` bought. function multiplexBatchSellEthForToken( - IERC20TokenV06 outputToken, + IERC20Token outputToken, BatchSellSubcall[] calldata calls, uint256 minBuyAmount ) external payable returns (uint256 boughtAmount); @@ -130,7 +130,7 @@ interface IMultiplexFeature { /// must be bought for this function to not revert. /// @return boughtAmount The amount of ETH bought. function multiplexBatchSellTokenForEth( - IERC20TokenV06 inputToken, + IERC20Token inputToken, BatchSellSubcall[] calldata calls, uint256 sellAmount, uint256 minBuyAmount @@ -146,8 +146,8 @@ interface IMultiplexFeature { /// that must be bought for this function to not revert. /// @return boughtAmount The amount of `outputToken` bought. function multiplexBatchSellTokenForToken( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, BatchSellSubcall[] calldata calls, uint256 sellAmount, uint256 minBuyAmount diff --git a/contracts/zero-ex/contracts/src/features/interfaces/INativeOrdersEvents.sol b/contracts/zero-ex/contracts/src/features/interfaces/INativeOrdersEvents.sol index 1fac1b5c47..caf44f9cec 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/INativeOrdersEvents.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/INativeOrdersEvents.sol @@ -15,7 +15,6 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; import "../libs/LibSignature.sol"; import "../libs/LibNativeOrder.sol"; diff --git a/contracts/zero-ex/contracts/src/features/interfaces/INativeOrdersFeature.sol b/contracts/zero-ex/contracts/src/features/interfaces/INativeOrdersFeature.sol index 85b8c65b72..b4260b28d4 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/INativeOrdersFeature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/INativeOrdersFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../libs/LibSignature.sol"; import "../libs/LibNativeOrder.sol"; import "./INativeOrdersEvents.sol"; @@ -150,7 +150,7 @@ interface INativeOrdersFeature is INativeOrdersEvents { /// @param makerToken The maker token. /// @param takerToken The taker token. /// @param minValidSalt The new minimum valid salt. - function cancelPairLimitOrders(IERC20TokenV06 makerToken, IERC20TokenV06 takerToken, uint256 minValidSalt) external; + function cancelPairLimitOrders(IERC20Token makerToken, IERC20Token takerToken, uint256 minValidSalt) external; /// @dev Cancel all limit orders for a given maker and pair with a salt less /// than the value provided. The caller must be a signer registered to the maker. @@ -162,8 +162,8 @@ interface INativeOrdersFeature is INativeOrdersEvents { /// @param minValidSalt The new minimum valid salt. function cancelPairLimitOrdersWithSigner( address maker, - IERC20TokenV06 makerToken, - IERC20TokenV06 takerToken, + IERC20Token makerToken, + IERC20Token takerToken, uint256 minValidSalt ) external; @@ -175,8 +175,8 @@ interface INativeOrdersFeature is INativeOrdersEvents { /// @param takerTokens The taker tokens. /// @param minValidSalts The new minimum valid salts. function batchCancelPairLimitOrders( - IERC20TokenV06[] calldata makerTokens, - IERC20TokenV06[] calldata takerTokens, + IERC20Token[] calldata makerTokens, + IERC20Token[] calldata takerTokens, uint256[] calldata minValidSalts ) external; @@ -190,8 +190,8 @@ interface INativeOrdersFeature is INativeOrdersEvents { /// @param minValidSalts The new minimum valid salts. function batchCancelPairLimitOrdersWithSigner( address maker, - IERC20TokenV06[] memory makerTokens, - IERC20TokenV06[] memory takerTokens, + IERC20Token[] memory makerTokens, + IERC20Token[] memory takerTokens, uint256[] memory minValidSalts ) external; @@ -202,7 +202,7 @@ interface INativeOrdersFeature is INativeOrdersEvents { /// @param makerToken The maker token. /// @param takerToken The taker token. /// @param minValidSalt The new minimum valid salt. - function cancelPairRfqOrders(IERC20TokenV06 makerToken, IERC20TokenV06 takerToken, uint256 minValidSalt) external; + function cancelPairRfqOrders(IERC20Token makerToken, IERC20Token takerToken, uint256 minValidSalt) external; /// @dev Cancel all RFQ orders for a given maker and pair with a salt less /// than the value provided. The caller must be a signer registered to the maker. @@ -214,8 +214,8 @@ interface INativeOrdersFeature is INativeOrdersEvents { /// @param minValidSalt The new minimum valid salt. function cancelPairRfqOrdersWithSigner( address maker, - IERC20TokenV06 makerToken, - IERC20TokenV06 takerToken, + IERC20Token makerToken, + IERC20Token takerToken, uint256 minValidSalt ) external; @@ -227,8 +227,8 @@ interface INativeOrdersFeature is INativeOrdersEvents { /// @param takerTokens The taker tokens. /// @param minValidSalts The new minimum valid salts. function batchCancelPairRfqOrders( - IERC20TokenV06[] calldata makerTokens, - IERC20TokenV06[] calldata takerTokens, + IERC20Token[] calldata makerTokens, + IERC20Token[] calldata takerTokens, uint256[] calldata minValidSalts ) external; @@ -242,8 +242,8 @@ interface INativeOrdersFeature is INativeOrdersEvents { /// @param minValidSalts The new minimum valid salts. function batchCancelPairRfqOrdersWithSigner( address maker, - IERC20TokenV06[] memory makerTokens, - IERC20TokenV06[] memory takerTokens, + IERC20Token[] memory makerTokens, + IERC20Token[] memory takerTokens, uint256[] memory minValidSalts ) external; diff --git a/contracts/zero-ex/contracts/src/features/interfaces/IPancakeSwapFeature.sol b/contracts/zero-ex/contracts/src/features/interfaces/IPancakeSwapFeature.sol index 943d3102d3..61f493eb02 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/IPancakeSwapFeature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/IPancakeSwapFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; /// @dev VIP PancakeSwap (and forks) fill functions. interface IPancakeSwapFeature { @@ -37,7 +37,7 @@ interface IPancakeSwapFeature { /// @param fork The protocol fork to use. /// @return buyAmount Amount of `tokens[-1]` bought. function sellToPancakeSwap( - IERC20TokenV06[] calldata tokens, + IERC20Token[] calldata tokens, uint256 sellAmount, uint256 minBuyAmount, ProtocolFork fork diff --git a/contracts/zero-ex/contracts/src/features/interfaces/ITokenSpenderFeature.sol b/contracts/zero-ex/contracts/src/features/interfaces/ITokenSpenderFeature.sol index fc83b6e85e..9f4be00f23 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/ITokenSpenderFeature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/ITokenSpenderFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; /// @dev Feature that allows spending token allowances. interface ITokenSpenderFeature { @@ -25,14 +25,14 @@ interface ITokenSpenderFeature { /// @param owner The owner of the tokens. /// @param to The recipient of the tokens. /// @param amount The amount of `token` to transfer. - function _spendERC20Tokens(IERC20TokenV06 token, address owner, address to, uint256 amount) external; + function _spendERC20Tokens(IERC20Token token, address owner, address to, uint256 amount) external; /// @dev Gets the maximum amount of an ERC20 token `token` that can be /// pulled from `owner`. /// @param token The token to spend. /// @param owner The owner of the tokens. /// @return amount The amount of tokens that can be pulled. - function getSpendableERC20BalanceOf(IERC20TokenV06 token, address owner) external view returns (uint256 amount); + function getSpendableERC20BalanceOf(IERC20Token token, address owner) external view returns (uint256 amount); /// @dev Get the address of the allowance target. /// @return target The target of token allowances. diff --git a/contracts/zero-ex/contracts/src/features/interfaces/ITransformERC20Feature.sol b/contracts/zero-ex/contracts/src/features/interfaces/ITransformERC20Feature.sol index afe427dc74..1cf7a05341 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/ITransformERC20Feature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/ITransformERC20Feature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../../transformers/IERC20Transformer.sol"; import "../../external/IFlashWallet.sol"; @@ -37,10 +37,10 @@ interface ITransformERC20Feature { address payable taker; // The token being provided by the taker. // If `0xeee...`, ETH is implied and should be provided with the call.` - IERC20TokenV06 inputToken; + IERC20Token inputToken; // The token to be acquired by the taker. // `0xeee...` implies ETH. - IERC20TokenV06 outputToken; + IERC20Token outputToken; // The amount of `inputToken` to take from the taker. // If set to `uint256(-1)`, the entire spendable balance of the taker // will be solt. @@ -112,8 +112,8 @@ interface ITransformERC20Feature { /// in sequence. /// @return outputTokenAmount The amount of `outputToken` received by the sender. function transformERC20( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 inputTokenAmount, uint256 minOutputTokenAmount, Transformation[] calldata transformations diff --git a/contracts/zero-ex/contracts/src/features/interfaces/IUniswapFeature.sol b/contracts/zero-ex/contracts/src/features/interfaces/IUniswapFeature.sol index d8ab30b85e..7df018d03f 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/IUniswapFeature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/IUniswapFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; /// @dev VIP uniswap fill functions. interface IUniswapFeature { @@ -26,7 +26,7 @@ interface IUniswapFeature { /// @param isSushi Use sushiswap if true. /// @return buyAmount Amount of `tokens[-1]` bought. function sellToUniswap( - IERC20TokenV06[] calldata tokens, + IERC20Token[] calldata tokens, uint256 sellAmount, uint256 minBuyAmount, bool isSushi diff --git a/contracts/zero-ex/contracts/src/features/interfaces/IUniswapV3Feature.sol b/contracts/zero-ex/contracts/src/features/interfaces/IUniswapV3Feature.sol index ed784dc898..89588d7fd3 100644 --- a/contracts/zero-ex/contracts/src/features/interfaces/IUniswapV3Feature.sol +++ b/contracts/zero-ex/contracts/src/features/interfaces/IUniswapV3Feature.sol @@ -15,8 +15,6 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; - /// @dev VIP uniswap v3 fill functions. interface IUniswapV3Feature { /// @dev Sell attached ETH directly against uniswap v3. diff --git a/contracts/zero-ex/contracts/src/features/libs/LibNFTOrder.sol b/contracts/zero-ex/contracts/src/features/libs/LibNFTOrder.sol index e9e417185e..67f9ac96f3 100644 --- a/contracts/zero-ex/contracts/src/features/libs/LibNFTOrder.sol +++ b/contracts/zero-ex/contracts/src/features/libs/LibNFTOrder.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../../vendor/IERC1155Token.sol"; import "../../vendor/IERC721Token.sol"; import "../../vendor/IPropertyValidator.sol"; @@ -53,7 +53,7 @@ library LibNFTOrder { address taker; uint256 expiry; uint256 nonce; - IERC20TokenV06 erc20Token; + IERC20Token erc20Token; uint256 erc20TokenAmount; Fee[] fees; address nft; @@ -68,7 +68,7 @@ library LibNFTOrder { address taker; uint256 expiry; uint256 nonce; - IERC20TokenV06 erc20Token; + IERC20Token erc20Token; uint256 erc20TokenAmount; Fee[] fees; IERC721Token erc721Token; @@ -84,7 +84,7 @@ library LibNFTOrder { address taker; uint256 expiry; uint256 nonce; - IERC20TokenV06 erc20Token; + IERC20Token erc20Token; uint256 erc20TokenAmount; Fee[] fees; IERC1155Token erc1155Token; diff --git a/contracts/zero-ex/contracts/src/features/libs/LibNativeOrder.sol b/contracts/zero-ex/contracts/src/features/libs/LibNativeOrder.sol index 93dc083e4f..c90eaaa783 100644 --- a/contracts/zero-ex/contracts/src/features/libs/LibNativeOrder.sol +++ b/contracts/zero-ex/contracts/src/features/libs/LibNativeOrder.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../../errors/LibNativeOrdersRichErrors.sol"; @@ -35,8 +35,8 @@ library LibNativeOrder { /// @dev A standard OTC or OO limit order. struct LimitOrder { - IERC20TokenV06 makerToken; - IERC20TokenV06 takerToken; + IERC20Token makerToken; + IERC20Token takerToken; uint128 makerAmount; uint128 takerAmount; uint128 takerTokenFeeAmount; @@ -51,8 +51,8 @@ library LibNativeOrder { /// @dev An RFQ limit order. struct RfqOrder { - IERC20TokenV06 makerToken; - IERC20TokenV06 takerToken; + IERC20Token makerToken; + IERC20Token takerToken; uint128 makerAmount; uint128 takerAmount; address maker; @@ -65,8 +65,8 @@ library LibNativeOrder { /// @dev An OTC limit order. struct OtcOrder { - IERC20TokenV06 makerToken; - IERC20TokenV06 takerToken; + IERC20Token makerToken; + IERC20Token takerToken; uint128 makerAmount; uint128 takerAmount; address maker; diff --git a/contracts/zero-ex/contracts/src/features/multiplex/MultiplexFeature.sol b/contracts/zero-ex/contracts/src/features/multiplex/MultiplexFeature.sol index 5b1aecfab6..ca6481602a 100644 --- a/contracts/zero-ex/contracts/src/features/multiplex/MultiplexFeature.sol +++ b/contracts/zero-ex/contracts/src/features/multiplex/MultiplexFeature.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../../external/ILiquidityProviderSandbox.sol"; import "../../fixins/FixinCommon.sol"; @@ -54,11 +54,11 @@ contract MultiplexFeature is uint256 private constant LOWER_255_BITS = HIGH_BIT - 1; /// @dev The WETH token contract. - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; constructor( address zeroExAddress, - IEtherTokenV06 weth, + IEtherToken weth, ILiquidityProviderSandbox sandbox, address uniswapFactory, address sushiswapFactory, @@ -94,7 +94,7 @@ contract MultiplexFeature is /// must be bought for this function to not revert. /// @return boughtAmount The amount of `outputToken` bought. function multiplexBatchSellEthForToken( - IERC20TokenV06 outputToken, + IERC20Token outputToken, BatchSellSubcall[] memory calls, uint256 minBuyAmount ) public payable override returns (uint256 boughtAmount) { @@ -125,7 +125,7 @@ contract MultiplexFeature is /// must be bought for this function to not revert. /// @return boughtAmount The amount of ETH bought. function multiplexBatchSellTokenForEth( - IERC20TokenV06 inputToken, + IERC20Token inputToken, BatchSellSubcall[] memory calls, uint256 sellAmount, uint256 minBuyAmount @@ -160,8 +160,8 @@ contract MultiplexFeature is /// that must be bought for this function to not revert. /// @return boughtAmount The amount of `outputToken` bought. function multiplexBatchSellTokenForToken( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, BatchSellSubcall[] memory calls, uint256 sellAmount, uint256 minBuyAmount @@ -327,7 +327,7 @@ contract MultiplexFeature is "MultiplexFeature::_multiplexMultiHopSell/MISMATCHED_ARRAY_LENGTHS" ); // The output token is the last token in the path. - IERC20TokenV06 outputToken = IERC20TokenV06(params.tokens[params.tokens.length - 1]); + IERC20Token outputToken = IERC20Token(params.tokens[params.tokens.length - 1]); // Cache the recipient's balance of the output token. uint256 balanceBefore = outputToken.balanceOf(params.recipient); // Execute the multi-hop sell. @@ -394,12 +394,12 @@ contract MultiplexFeature is // If the input tokens are currently held by `msg.sender` but // the first hop expects them elsewhere, perform a `transferFrom`. if (!params.useSelfBalance && state.from != msg.sender) { - _transferERC20TokensFrom(IERC20TokenV06(params.tokens[0]), msg.sender, state.from, params.sellAmount); + _transferERC20TokensFrom(IERC20Token(params.tokens[0]), msg.sender, state.from, params.sellAmount); } // If the input tokens are currently held by `address(this)` but // the first hop expects them elsewhere, perform a `transfer`. if (params.useSelfBalance && state.from != address(this)) { - _transferERC20Tokens(IERC20TokenV06(params.tokens[0]), state.from, params.sellAmount); + _transferERC20Tokens(IERC20Token(params.tokens[0]), state.from, params.sellAmount); } // Iterate through the calls and execute each one. for (state.hopIndex = 0; state.hopIndex != params.calls.length; state.hopIndex++) { @@ -461,8 +461,8 @@ contract MultiplexFeature is // The input and output tokens of the batch // sell are the current and next tokens in // `params.tokens`, respectively. - batchSellParams.inputToken = IERC20TokenV06(params.tokens[state.hopIndex]); - batchSellParams.outputToken = IERC20TokenV06(params.tokens[state.hopIndex + 1]); + batchSellParams.inputToken = IERC20Token(params.tokens[state.hopIndex]); + batchSellParams.outputToken = IERC20Token(params.tokens[state.hopIndex + 1]); // The `sellAmount` for the batch sell is the // `outputTokenAmount` from the previous hop. batchSellParams.sellAmount = state.outputTokenAmount; diff --git a/contracts/zero-ex/contracts/src/features/multiplex/MultiplexLiquidityProvider.sol b/contracts/zero-ex/contracts/src/features/multiplex/MultiplexLiquidityProvider.sol index 4460549ca6..c880750f19 100644 --- a/contracts/zero-ex/contracts/src/features/multiplex/MultiplexLiquidityProvider.sol +++ b/contracts/zero-ex/contracts/src/features/multiplex/MultiplexLiquidityProvider.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../../external/ILiquidityProviderSandbox.sol"; import "../../fixins/FixinCommon.sol"; @@ -25,7 +25,7 @@ import "../../vendor/ILiquidityProvider.sol"; import "../interfaces/IMultiplexFeature.sol"; abstract contract MultiplexLiquidityProvider is FixinCommon, FixinTokenSpender { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; // Same event fired by LiquidityProviderFeature @@ -125,8 +125,8 @@ abstract contract MultiplexLiquidityProvider is FixinCommon, FixinTokenSpender { IMultiplexFeature.MultiHopSellParams memory params, bytes memory wrappedCallData ) internal { - IERC20TokenV06 inputToken = IERC20TokenV06(params.tokens[state.hopIndex]); - IERC20TokenV06 outputToken = IERC20TokenV06(params.tokens[state.hopIndex + 1]); + IERC20Token inputToken = IERC20Token(params.tokens[state.hopIndex]); + IERC20Token outputToken = IERC20Token(params.tokens[state.hopIndex + 1]); // Decode the provider address and auxiliary data. (address provider, bytes memory auxiliaryData) = abi.decode(wrappedCallData, (address, bytes)); // Cache the recipient's balance of the output token. diff --git a/contracts/zero-ex/contracts/src/features/multiplex/MultiplexUniswapV2.sol b/contracts/zero-ex/contracts/src/features/multiplex/MultiplexUniswapV2.sol index 4848699985..6582e40b0b 100644 --- a/contracts/zero-ex/contracts/src/features/multiplex/MultiplexUniswapV2.sol +++ b/contracts/zero-ex/contracts/src/features/multiplex/MultiplexUniswapV2.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../../fixins/FixinCommon.sol"; import "../../fixins/FixinTokenSpender.sol"; @@ -75,9 +75,9 @@ abstract contract MultiplexUniswapV2 is FixinCommon, FixinTokenSpender { // so we transfer the tokens in now (either from `msg.sender` // or using the Exchange Proxy's balance). if (params.useSelfBalance) { - _transferERC20Tokens(IERC20TokenV06(tokens[0]), firstPairAddress, sellAmount); + _transferERC20Tokens(IERC20Token(tokens[0]), firstPairAddress, sellAmount); } else { - _transferERC20TokensFrom(IERC20TokenV06(tokens[0]), msg.sender, firstPairAddress, sellAmount); + _transferERC20TokensFrom(IERC20Token(tokens[0]), msg.sender, firstPairAddress, sellAmount); } // Execute the Uniswap/Sushiswap trade. return _sellToUniswapV2(tokens, sellAmount, isSushi, firstPairAddress, params.recipient); diff --git a/contracts/zero-ex/contracts/src/features/multiplex/MultiplexUniswapV3.sol b/contracts/zero-ex/contracts/src/features/multiplex/MultiplexUniswapV3.sol index c113f3b7ac..4b34dfd32b 100644 --- a/contracts/zero-ex/contracts/src/features/multiplex/MultiplexUniswapV3.sol +++ b/contracts/zero-ex/contracts/src/features/multiplex/MultiplexUniswapV3.sol @@ -15,7 +15,6 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../../fixins/FixinTokenSpender.sol"; import "../interfaces/IMultiplexFeature.sol"; diff --git a/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersCancellation.sol b/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersCancellation.sol index af4ee9deb0..4efbd2c3a4 100644 --- a/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersCancellation.sol +++ b/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersCancellation.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "../../errors/LibNativeOrdersRichErrors.sol"; import "../../storage/LibNativeOrdersStorage.sol"; @@ -80,7 +80,7 @@ abstract contract NativeOrdersCancellation is INativeOrdersEvents, NativeOrdersI /// @param makerToken The maker token. /// @param takerToken The taker token. /// @param minValidSalt The new minimum valid salt. - function cancelPairLimitOrders(IERC20TokenV06 makerToken, IERC20TokenV06 takerToken, uint256 minValidSalt) public { + function cancelPairLimitOrders(IERC20Token makerToken, IERC20Token takerToken, uint256 minValidSalt) public { _cancelPairLimitOrders(msg.sender, makerToken, takerToken, minValidSalt); } @@ -94,8 +94,8 @@ abstract contract NativeOrdersCancellation is INativeOrdersEvents, NativeOrdersI /// @param minValidSalt The new minimum valid salt. function cancelPairLimitOrdersWithSigner( address maker, - IERC20TokenV06 makerToken, - IERC20TokenV06 takerToken, + IERC20Token makerToken, + IERC20Token takerToken, uint256 minValidSalt ) public { // verify that the signer is authorized for the maker @@ -114,8 +114,8 @@ abstract contract NativeOrdersCancellation is INativeOrdersEvents, NativeOrdersI /// @param takerTokens The taker tokens. /// @param minValidSalts The new minimum valid salts. function batchCancelPairLimitOrders( - IERC20TokenV06[] memory makerTokens, - IERC20TokenV06[] memory takerTokens, + IERC20Token[] memory makerTokens, + IERC20Token[] memory takerTokens, uint256[] memory minValidSalts ) public { require( @@ -138,8 +138,8 @@ abstract contract NativeOrdersCancellation is INativeOrdersEvents, NativeOrdersI /// @param minValidSalts The new minimum valid salts. function batchCancelPairLimitOrdersWithSigner( address maker, - IERC20TokenV06[] memory makerTokens, - IERC20TokenV06[] memory takerTokens, + IERC20Token[] memory makerTokens, + IERC20Token[] memory takerTokens, uint256[] memory minValidSalts ) public { require( @@ -163,7 +163,7 @@ abstract contract NativeOrdersCancellation is INativeOrdersEvents, NativeOrdersI /// @param makerToken The maker token. /// @param takerToken The taker token. /// @param minValidSalt The new minimum valid salt. - function cancelPairRfqOrders(IERC20TokenV06 makerToken, IERC20TokenV06 takerToken, uint256 minValidSalt) public { + function cancelPairRfqOrders(IERC20Token makerToken, IERC20Token takerToken, uint256 minValidSalt) public { _cancelPairRfqOrders(msg.sender, makerToken, takerToken, minValidSalt); } @@ -177,8 +177,8 @@ abstract contract NativeOrdersCancellation is INativeOrdersEvents, NativeOrdersI /// @param minValidSalt The new minimum valid salt. function cancelPairRfqOrdersWithSigner( address maker, - IERC20TokenV06 makerToken, - IERC20TokenV06 takerToken, + IERC20Token makerToken, + IERC20Token takerToken, uint256 minValidSalt ) public { if (!isValidOrderSigner(maker, msg.sender)) { @@ -196,8 +196,8 @@ abstract contract NativeOrdersCancellation is INativeOrdersEvents, NativeOrdersI /// @param takerTokens The taker tokens. /// @param minValidSalts The new minimum valid salts. function batchCancelPairRfqOrders( - IERC20TokenV06[] memory makerTokens, - IERC20TokenV06[] memory takerTokens, + IERC20Token[] memory makerTokens, + IERC20Token[] memory takerTokens, uint256[] memory minValidSalts ) public { require( @@ -220,8 +220,8 @@ abstract contract NativeOrdersCancellation is INativeOrdersEvents, NativeOrdersI /// @param minValidSalts The new minimum valid salts. function batchCancelPairRfqOrdersWithSigner( address maker, - IERC20TokenV06[] memory makerTokens, - IERC20TokenV06[] memory takerTokens, + IERC20Token[] memory makerTokens, + IERC20Token[] memory takerTokens, uint256[] memory minValidSalts ) public { require( @@ -258,8 +258,8 @@ abstract contract NativeOrdersCancellation is INativeOrdersEvents, NativeOrdersI /// @param minValidSalt The new minimum valid salt. function _cancelPairRfqOrders( address maker, - IERC20TokenV06 makerToken, - IERC20TokenV06 takerToken, + IERC20Token makerToken, + IERC20Token takerToken, uint256 minValidSalt ) private { LibNativeOrdersStorage.Storage storage stor = LibNativeOrdersStorage.getStorage(); @@ -288,8 +288,8 @@ abstract contract NativeOrdersCancellation is INativeOrdersEvents, NativeOrdersI /// @param minValidSalt The new minimum valid salt. function _cancelPairLimitOrders( address maker, - IERC20TokenV06 makerToken, - IERC20TokenV06 takerToken, + IERC20Token makerToken, + IERC20Token takerToken, uint256 minValidSalt ) private { LibNativeOrdersStorage.Storage storage stor = LibNativeOrdersStorage.getStorage(); diff --git a/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersInfo.sol b/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersInfo.sol index 9207135e71..ed1f114ff2 100644 --- a/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersInfo.sol +++ b/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersInfo.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibMathV06.sol"; import "../../fixins/FixinEIP712.sol"; @@ -32,7 +32,7 @@ abstract contract NativeOrdersInfo is FixinEIP712, FixinTokenSpender { // @dev Params for `_getActualFillableTakerTokenAmount()`. struct GetActualFillableTakerTokenAmountParams { address maker; - IERC20TokenV06 makerToken; + IERC20Token makerToken; uint128 orderMakerAmount; uint128 orderTakerAmount; LibNativeOrder.OrderInfo orderInfo; diff --git a/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersProtocolFees.sol b/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersProtocolFees.sol index 5b8768922e..627e6711c7 100644 --- a/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersProtocolFees.sol +++ b/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersProtocolFees.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../../fixins/FixinProtocolFees.sol"; @@ -28,7 +28,7 @@ abstract contract NativeOrdersProtocolFees is FixinProtocolFees { using LibRichErrorsV06 for bytes; constructor( - IEtherTokenV06 weth, + IEtherToken weth, IStaking staking, FeeCollectorController feeCollectorController, uint32 protocolFeeMultiplier diff --git a/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersSettlement.sol b/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersSettlement.sol index 164281ed50..abfa3f4d43 100644 --- a/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersSettlement.sol +++ b/contracts/zero-ex/contracts/src/features/native_orders/NativeOrdersSettlement.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibMathV06.sol"; @@ -51,9 +51,9 @@ abstract contract NativeOrdersSettlement is // Recipient of the maker tokens. address recipient; // Maker token. - IERC20TokenV06 makerToken; + IERC20Token makerToken; // Taker token. - IERC20TokenV06 takerToken; + IERC20Token takerToken; // Maker token amount. uint128 makerAmount; // Taker token amount. @@ -105,7 +105,7 @@ abstract contract NativeOrdersSettlement is constructor( address zeroExAddress, - IEtherTokenV06 weth, + IEtherToken weth, IStaking staking, FeeCollectorController feeCollectorController, uint32 protocolFeeMultiplier @@ -352,8 +352,8 @@ abstract contract NativeOrdersSettlement is maker: params.order.maker, payer: params.taker, recipient: params.taker, - makerToken: IERC20TokenV06(params.order.makerToken), - takerToken: IERC20TokenV06(params.order.takerToken), + makerToken: IERC20Token(params.order.makerToken), + takerToken: IERC20Token(params.order.takerToken), makerAmount: params.order.makerAmount, takerAmount: params.order.takerAmount, takerTokenFillAmount: params.takerTokenFillAmount, @@ -441,8 +441,8 @@ abstract contract NativeOrdersSettlement is maker: params.order.maker, payer: params.useSelfBalance ? address(this) : params.taker, recipient: params.recipient, - makerToken: IERC20TokenV06(params.order.makerToken), - takerToken: IERC20TokenV06(params.order.takerToken), + makerToken: IERC20Token(params.order.makerToken), + takerToken: IERC20Token(params.order.takerToken), makerAmount: params.order.makerAmount, takerAmount: params.order.takerAmount, takerTokenFillAmount: params.takerTokenFillAmount, diff --git a/contracts/zero-ex/contracts/src/features/nft_orders/ERC1155OrdersFeature.sol b/contracts/zero-ex/contracts/src/features/nft_orders/ERC1155OrdersFeature.sol index 21bbb9eb47..262d7fa6b8 100644 --- a/contracts/zero-ex/contracts/src/features/nft_orders/ERC1155OrdersFeature.sol +++ b/contracts/zero-ex/contracts/src/features/nft_orders/ERC1155OrdersFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../../fixins/FixinERC1155Spender.sol"; import "../../migrations/LibMigrate.sol"; @@ -41,7 +41,7 @@ contract ERC1155OrdersFeature is IFeature, IERC1155OrdersFeature, FixinERC1155Sp /// @dev The magic return value indicating the success of a `onERC1155Received`. bytes4 private constant ERC1155_RECEIVED_MAGIC_BYTES = this.onERC1155Received.selector; - constructor(address zeroExAddress, IEtherTokenV06 weth) public NFTOrders(zeroExAddress, weth) {} + constructor(address zeroExAddress, IEtherToken weth) public NFTOrders(zeroExAddress, weth) {} /// @dev Initialize and register this feature. /// Should be delegatecalled by `Migrate.migrate()`. diff --git a/contracts/zero-ex/contracts/src/features/nft_orders/ERC721OrdersFeature.sol b/contracts/zero-ex/contracts/src/features/nft_orders/ERC721OrdersFeature.sol index 44f3382ada..c66e0b27e4 100644 --- a/contracts/zero-ex/contracts/src/features/nft_orders/ERC721OrdersFeature.sol +++ b/contracts/zero-ex/contracts/src/features/nft_orders/ERC721OrdersFeature.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../../fixins/FixinERC721Spender.sol"; import "../../migrations/LibMigrate.sol"; @@ -40,7 +40,7 @@ contract ERC721OrdersFeature is IFeature, IERC721OrdersFeature, FixinERC721Spend /// @dev The magic return value indicating the success of a `onERC721Received`. bytes4 private constant ERC721_RECEIVED_MAGIC_BYTES = this.onERC721Received.selector; - constructor(address zeroExAddress, IEtherTokenV06 weth) public NFTOrders(zeroExAddress, weth) {} + constructor(address zeroExAddress, IEtherToken weth) public NFTOrders(zeroExAddress, weth) {} /// @dev Initialize and register this feature. /// Should be delegatecalled by `Migrate.migrate()`. diff --git a/contracts/zero-ex/contracts/src/features/nft_orders/NFTOrders.sol b/contracts/zero-ex/contracts/src/features/nft_orders/NFTOrders.sol index 53371df5e1..cd56189764 100644 --- a/contracts/zero-ex/contracts/src/features/nft_orders/NFTOrders.sol +++ b/contracts/zero-ex/contracts/src/features/nft_orders/NFTOrders.sol @@ -15,8 +15,7 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "@0x/contracts-utils/contracts/src/v06/LibMathV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../../errors/LibNFTOrdersRichErrors.sol"; @@ -36,14 +35,14 @@ abstract contract NFTOrders is FixinCommon, FixinEIP712, FixinTokenSpender { /// @dev Native token pseudo-address. address internal constant NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; /// @dev The WETH token contract. - IEtherTokenV06 internal immutable WETH; + IEtherToken internal immutable WETH; /// @dev The magic return value indicating the success of a `receiveZeroExFeeCallback`. bytes4 private constant FEE_CALLBACK_MAGIC_BYTES = IFeeRecipient.receiveZeroExFeeCallback.selector; /// @dev The magic return value indicating the success of a `zeroExTakerCallback`. bytes4 private constant TAKER_CALLBACK_MAGIC_BYTES = ITakerCallback.zeroExTakerCallback.selector; - constructor(address zeroExAddress, IEtherTokenV06 weth) public FixinEIP712(zeroExAddress) { + constructor(address zeroExAddress, IEtherToken weth) public FixinEIP712(zeroExAddress) { WETH = weth; } diff --git a/contracts/zero-ex/contracts/src/fixins/FixinProtocolFees.sol b/contracts/zero-ex/contracts/src/fixins/FixinProtocolFees.sol index 4217f11ce1..fcd5c8d444 100644 --- a/contracts/zero-ex/contracts/src/fixins/FixinProtocolFees.sol +++ b/contracts/zero-ex/contracts/src/fixins/FixinProtocolFees.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "../external/FeeCollector.sol"; import "../external/FeeCollectorController.sol"; import "../external/LibFeeCollector.sol"; @@ -30,12 +30,12 @@ abstract contract FixinProtocolFees { /// @dev Hash of the fee collector init code. bytes32 private immutable FEE_COLLECTOR_INIT_CODE_HASH; /// @dev The WETH token contract. - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; /// @dev The staking contract. IStaking private immutable STAKING; constructor( - IEtherTokenV06 weth, + IEtherToken weth, IStaking staking, FeeCollectorController feeCollectorController, uint32 protocolFeeMultiplier diff --git a/contracts/zero-ex/contracts/src/fixins/FixinTokenSpender.sol b/contracts/zero-ex/contracts/src/fixins/FixinTokenSpender.sol index 2e884e2e76..1f501e14ba 100644 --- a/contracts/zero-ex/contracts/src/fixins/FixinTokenSpender.sol +++ b/contracts/zero-ex/contracts/src/fixins/FixinTokenSpender.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; /// @dev Helpers for moving tokens around. @@ -28,7 +28,7 @@ abstract contract FixinTokenSpender { /// @param owner The owner of the tokens. /// @param to The recipient of the tokens. /// @param amount The amount of `token` to transfer. - function _transferERC20TokensFrom(IERC20TokenV06 token, address owner, address to, uint256 amount) internal { + function _transferERC20TokensFrom(IERC20Token token, address owner, address to, uint256 amount) internal { require(address(token) != address(this), "FixinTokenSpender/CANNOT_INVOKE_SELF"); assembly { @@ -69,7 +69,7 @@ abstract contract FixinTokenSpender { /// @param token The token to spend. /// @param to The recipient of the tokens. /// @param amount The amount of `token` to transfer. - function _transferERC20Tokens(IERC20TokenV06 token, address to, uint256 amount) internal { + function _transferERC20Tokens(IERC20Token token, address to, uint256 amount) internal { require(address(token) != address(this), "FixinTokenSpender/CANNOT_INVOKE_SELF"); assembly { @@ -121,7 +121,7 @@ abstract contract FixinTokenSpender { /// @param token The token to spend. /// @param owner The owner of the tokens. /// @return amount The amount of tokens that can be pulled. - function _getSpendableERC20BalanceOf(IERC20TokenV06 token, address owner) internal view returns (uint256) { + function _getSpendableERC20BalanceOf(IERC20Token token, address owner) internal view returns (uint256) { return LibSafeMathV06.min256(token.allowance(owner, address(this)), token.balanceOf(owner)); } } diff --git a/contracts/zero-ex/contracts/src/liquidity-providers/CurveLiquidityProvider.sol b/contracts/zero-ex/contracts/src/liquidity-providers/CurveLiquidityProvider.sol index 5dd433538c..71b3d82d66 100644 --- a/contracts/zero-ex/contracts/src/liquidity-providers/CurveLiquidityProvider.sol +++ b/contracts/zero-ex/contracts/src/liquidity-providers/CurveLiquidityProvider.sol @@ -16,14 +16,14 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../transformers/LibERC20Transformer.sol"; import "../vendor/ILiquidityProvider.sol"; contract CurveLiquidityProvider is ILiquidityProvider { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; using LibRichErrorsV06 for bytes; @@ -48,8 +48,8 @@ contract CurveLiquidityProvider is ILiquidityProvider { /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract. /// @return boughtAmount The amount of `outputToken` bought. function sellTokenForToken( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -79,7 +79,7 @@ contract CurveLiquidityProvider is ILiquidityProvider { /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract. /// @return boughtAmount The amount of `outputToken` bought. function sellEthForToken( - IERC20TokenV06 outputToken, + IERC20Token outputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -105,7 +105,7 @@ contract CurveLiquidityProvider is ILiquidityProvider { /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract. /// @return boughtAmount The amount of ETH bought. function sellTokenForEth( - IERC20TokenV06 inputToken, + IERC20Token inputToken, address payable recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -126,8 +126,8 @@ contract CurveLiquidityProvider is ILiquidityProvider { /// @dev Quotes the amount of `outputToken` that would be obtained by /// selling `sellAmount` of `inputToken`. function getSellQuote( - IERC20TokenV06 /* inputToken */, - IERC20TokenV06 /* outputToken */, + IERC20Token /* inputToken */, + IERC20Token /* outputToken */, uint256 /* sellAmount */ ) external view override returns (uint256) { revert("CurveLiquidityProvider/NOT_IMPLEMENTED"); @@ -136,8 +136,8 @@ contract CurveLiquidityProvider is ILiquidityProvider { /// @dev Perform the swap against the curve pool. Handles any combination of /// tokens function _executeSwap( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 minBuyAmount, CurveData memory data, address recipient // Only used to log event. diff --git a/contracts/zero-ex/contracts/src/liquidity-providers/MooniswapLiquidityProvider.sol b/contracts/zero-ex/contracts/src/liquidity-providers/MooniswapLiquidityProvider.sol index 60dbf3d8ae..5e8348b735 100644 --- a/contracts/zero-ex/contracts/src/liquidity-providers/MooniswapLiquidityProvider.sol +++ b/contracts/zero-ex/contracts/src/liquidity-providers/MooniswapLiquidityProvider.sol @@ -16,22 +16,22 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../transformers/LibERC20Transformer.sol"; import "../vendor/ILiquidityProvider.sol"; import "../vendor/IMooniswapPool.sol"; contract MooniswapLiquidityProvider is ILiquidityProvider { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; using LibRichErrorsV06 for bytes; - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; - constructor(IEtherTokenV06 weth) public { + constructor(IEtherToken weth) public { WETH = weth; } @@ -49,8 +49,8 @@ contract MooniswapLiquidityProvider is ILiquidityProvider { /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract. /// @return boughtAmount The amount of `outputToken` bought. function sellTokenForToken( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -80,7 +80,7 @@ contract MooniswapLiquidityProvider is ILiquidityProvider { /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract. /// @return boughtAmount The amount of `outputToken` bought. function sellEthForToken( - IERC20TokenV06 outputToken, + IERC20Token outputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -104,7 +104,7 @@ contract MooniswapLiquidityProvider is ILiquidityProvider { /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract. /// @return boughtAmount The amount of ETH bought. function sellTokenForEth( - IERC20TokenV06 inputToken, + IERC20Token inputToken, address payable recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -123,8 +123,8 @@ contract MooniswapLiquidityProvider is ILiquidityProvider { /// @dev Quotes the amount of `outputToken` that would be obtained by /// selling `sellAmount` of `inputToken`. function getSellQuote( - IERC20TokenV06 /* inputToken */, - IERC20TokenV06 /* outputToken */, + IERC20Token /* inputToken */, + IERC20Token /* outputToken */, uint256 /* sellAmount */ ) external view override returns (uint256) { revert("MooniswapLiquidityProvider/NOT_IMPLEMENTED"); @@ -133,8 +133,8 @@ contract MooniswapLiquidityProvider is ILiquidityProvider { /// @dev Perform the swap against the curve pool. Handles any combination of /// tokens function _executeSwap( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 minBuyAmount, IMooniswapPool pool, address recipient // Only used to log event @@ -157,8 +157,8 @@ contract MooniswapLiquidityProvider is ILiquidityProvider { } boughtAmount = pool.swap{value: ethValue}( - _isTokenEthLike(inputToken) ? IERC20TokenV06(0) : inputToken, - _isTokenEthLike(outputToken) ? IERC20TokenV06(0) : outputToken, + _isTokenEthLike(inputToken) ? IERC20Token(0) : inputToken, + _isTokenEthLike(outputToken) ? IERC20Token(0) : outputToken, sellAmount, minBuyAmount, address(0) @@ -181,7 +181,7 @@ contract MooniswapLiquidityProvider is ILiquidityProvider { } /// @dev Check if a token is ETH or WETH. - function _isTokenEthLike(IERC20TokenV06 token) private view returns (bool isEthOrWeth) { + function _isTokenEthLike(IERC20Token token) private view returns (bool isEthOrWeth) { return LibERC20Transformer.isTokenETH(token) || token == WETH; } } diff --git a/contracts/zero-ex/contracts/src/transformers/AffiliateFeeTransformer.sol b/contracts/zero-ex/contracts/src/transformers/AffiliateFeeTransformer.sol index 5ab5d2260b..d310f8ad1b 100644 --- a/contracts/zero-ex/contracts/src/transformers/AffiliateFeeTransformer.sol +++ b/contracts/zero-ex/contracts/src/transformers/AffiliateFeeTransformer.sol @@ -17,8 +17,8 @@ pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; import "../errors/LibTransformERC20RichErrors.sol"; import "./Transformer.sol"; import "./LibERC20Transformer.sol"; @@ -27,12 +27,12 @@ import "./LibERC20Transformer.sol"; contract AffiliateFeeTransformer is Transformer { using LibRichErrorsV06 for bytes; using LibSafeMathV06 for uint256; - using LibERC20Transformer for IERC20TokenV06; + using LibERC20Transformer for IERC20Token; /// @dev Information for a single fee. struct TokenFee { // The token to transfer to `recipient`. - IERC20TokenV06 token; + IERC20Token token; // Amount of each `token` to transfer to `recipient`. // If `amount == uint256(-1)`, the entire balance of `token` will be // transferred. diff --git a/contracts/zero-ex/contracts/src/transformers/FillQuoteTransformer.sol b/contracts/zero-ex/contracts/src/transformers/FillQuoteTransformer.sol index f1ee7080f9..b5e238c2f4 100644 --- a/contracts/zero-ex/contracts/src/transformers/FillQuoteTransformer.sol +++ b/contracts/zero-ex/contracts/src/transformers/FillQuoteTransformer.sol @@ -16,8 +16,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibMathV06.sol"; import "../errors/LibTransformERC20RichErrors.sol"; @@ -31,8 +31,8 @@ import "../IZeroEx.sol"; /// @dev A transformer that fills an ERC20 market sell/buy quote. /// This transformer shortcuts bridge orders and fills them directly contract FillQuoteTransformer is Transformer { - using LibERC20TokenV06 for IERC20TokenV06; - using LibERC20Transformer for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; + using LibERC20Transformer for IERC20Token; using LibSafeMathV06 for uint256; using LibSafeMathV06 for uint128; using LibRichErrorsV06 for bytes; @@ -77,10 +77,10 @@ contract FillQuoteTransformer is Transformer { Side side; // The token being sold. // This should be an actual token, not the ETH pseudo-token. - IERC20TokenV06 sellToken; + IERC20Token sellToken; // The token being bought. // This should be an actual token, not the ETH pseudo-token. - IERC20TokenV06 buyToken; + IERC20Token buyToken; // External liquidity bridge orders. Sorted by fill sequence. IBridgeAdapter.BridgeOrder[] bridgeOrders; // Native limit orders. Sorted by fill sequence. diff --git a/contracts/zero-ex/contracts/src/transformers/IERC20Transformer.sol b/contracts/zero-ex/contracts/src/transformers/IERC20Transformer.sol index e642883ec1..005887d4cd 100644 --- a/contracts/zero-ex/contracts/src/transformers/IERC20Transformer.sol +++ b/contracts/zero-ex/contracts/src/transformers/IERC20Transformer.sol @@ -15,8 +15,6 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; - /// @dev A transformation callback used in `TransformERC20.transformERC20()`. interface IERC20Transformer { /// @dev Context information to pass into `transform()` by `TransformERC20.transformERC20()`. diff --git a/contracts/zero-ex/contracts/src/transformers/LibERC20Transformer.sol b/contracts/zero-ex/contracts/src/transformers/LibERC20Transformer.sol index d8bd17c891..b4b1a53940 100644 --- a/contracts/zero-ex/contracts/src/transformers/LibERC20Transformer.sol +++ b/contracts/zero-ex/contracts/src/transformers/LibERC20Transformer.sol @@ -15,16 +15,16 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; library LibERC20Transformer { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; /// @dev ETH pseudo-token address. address internal constant ETH_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; /// @dev ETH pseudo-token. - IERC20TokenV06 internal constant ETH_TOKEN = IERC20TokenV06(ETH_TOKEN_ADDRESS); + IERC20Token internal constant ETH_TOKEN = IERC20Token(ETH_TOKEN_ADDRESS); /// @dev Return value indicating success in `IERC20Transformer.transform()`. /// This is just `keccak256('TRANSFORMER_SUCCESS')`. bytes4 internal constant TRANSFORMER_SUCCESS = 0x13c9929e; @@ -35,7 +35,7 @@ library LibERC20Transformer { /// @param token An ERC20 or the ETH pseudo-token address (`ETH_TOKEN_ADDRESS`). /// @param to The recipient. /// @param amount The transfer amount. - function transformerTransfer(IERC20TokenV06 token, address payable to, uint256 amount) internal { + function transformerTransfer(IERC20Token token, address payable to, uint256 amount) internal { if (isTokenETH(token)) { to.transfer(amount); } else { @@ -48,7 +48,7 @@ library LibERC20Transformer { /// @param token An ERC20 or the ETH pseudo-token address (`ETH_TOKEN_ADDRESS`). /// @param to The recipient. /// @param amount The transfer amount. - function unsafeTransformerTransfer(IERC20TokenV06 token, address payable to, uint256 amount) internal { + function unsafeTransformerTransfer(IERC20Token token, address payable to, uint256 amount) internal { if (isTokenETH(token)) { (bool sent, ) = to.call{value: amount}(""); require(sent, "LibERC20Transformer/FAILED_TO_SEND_ETHER"); @@ -60,7 +60,7 @@ library LibERC20Transformer { /// @dev Check if a token is the ETH pseudo-token. /// @param token The token to check. /// @return isETH `true` if the token is the ETH pseudo-token. - function isTokenETH(IERC20TokenV06 token) internal pure returns (bool isETH) { + function isTokenETH(IERC20Token token) internal pure returns (bool isETH) { return address(token) == ETH_TOKEN_ADDRESS; } @@ -68,7 +68,7 @@ library LibERC20Transformer { /// @param token An ERC20 or the ETH pseudo-token address (`ETH_TOKEN_ADDRESS`). /// @param owner Holder of the tokens. /// @return tokenBalance The balance of `owner`. - function getTokenBalanceOf(IERC20TokenV06 token, address owner) internal view returns (uint256 tokenBalance) { + function getTokenBalanceOf(IERC20Token token, address owner) internal view returns (uint256 tokenBalance) { if (isTokenETH(token)) { return owner.balance; } diff --git a/contracts/zero-ex/contracts/src/transformers/PayTakerTransformer.sol b/contracts/zero-ex/contracts/src/transformers/PayTakerTransformer.sol index 8a4d774c07..f2d57b3ba2 100644 --- a/contracts/zero-ex/contracts/src/transformers/PayTakerTransformer.sol +++ b/contracts/zero-ex/contracts/src/transformers/PayTakerTransformer.sol @@ -17,8 +17,8 @@ pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; import "../errors/LibTransformERC20RichErrors.sol"; import "./Transformer.sol"; import "./LibERC20Transformer.sol"; @@ -27,12 +27,12 @@ import "./LibERC20Transformer.sol"; contract PayTakerTransformer is Transformer { using LibRichErrorsV06 for bytes; using LibSafeMathV06 for uint256; - using LibERC20Transformer for IERC20TokenV06; + using LibERC20Transformer for IERC20Token; /// @dev Transform data to ABI-encode and pass into `transform()`. struct TransformData { // The tokens to transfer to the taker. - IERC20TokenV06[] tokens; + IERC20Token[] tokens; // Amount of each token in `tokens` to transfer to the taker. // `uint(-1)` will transfer the entire balance. uint256[] amounts; diff --git a/contracts/zero-ex/contracts/src/transformers/PositiveSlippageFeeTransformer.sol b/contracts/zero-ex/contracts/src/transformers/PositiveSlippageFeeTransformer.sol index f1373a766a..a02fb7c5ea 100644 --- a/contracts/zero-ex/contracts/src/transformers/PositiveSlippageFeeTransformer.sol +++ b/contracts/zero-ex/contracts/src/transformers/PositiveSlippageFeeTransformer.sol @@ -17,8 +17,8 @@ pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; import "../errors/LibTransformERC20RichErrors.sol"; import "./Transformer.sol"; import "./LibERC20Transformer.sol"; @@ -27,12 +27,12 @@ import "./LibERC20Transformer.sol"; contract PositiveSlippageFeeTransformer is Transformer { using LibRichErrorsV06 for bytes; using LibSafeMathV06 for uint256; - using LibERC20Transformer for IERC20TokenV06; + using LibERC20Transformer for IERC20Token; /// @dev Information for a single fee. struct TokenFee { // The token to transfer to `recipient`. - IERC20TokenV06 token; + IERC20Token token; // Amount of each `token` to transfer to `recipient`. uint256 bestCaseAmount; // Recipient of `token`. diff --git a/contracts/zero-ex/contracts/src/transformers/WethTransformer.sol b/contracts/zero-ex/contracts/src/transformers/WethTransformer.sol index c7cedd4949..9cbba32435 100644 --- a/contracts/zero-ex/contracts/src/transformers/WethTransformer.sol +++ b/contracts/zero-ex/contracts/src/transformers/WethTransformer.sol @@ -17,7 +17,7 @@ pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "../errors/LibTransformERC20RichErrors.sol"; import "./Transformer.sol"; import "./LibERC20Transformer.sol"; @@ -26,25 +26,25 @@ import "./LibERC20Transformer.sol"; contract WethTransformer is Transformer { using LibRichErrorsV06 for bytes; using LibSafeMathV06 for uint256; - using LibERC20Transformer for IERC20TokenV06; + using LibERC20Transformer for IERC20Token; /// @dev Transform data to ABI-encode and pass into `transform()`. struct TransformData { // The token to wrap/unwrap. Must be either ETH or WETH. - IERC20TokenV06 token; + IERC20Token token; // Amount of `token` to wrap or unwrap. // `uint(-1)` will unwrap the entire balance. uint256 amount; } /// @dev The WETH contract address. - IEtherTokenV06 public immutable weth; + IEtherToken public immutable weth; /// @dev Maximum uint256 value. uint256 private constant MAX_UINT256 = uint256(-1); /// @dev Construct the transformer and store the WETH address in an immutable. /// @param weth_ The weth token. - constructor(IEtherTokenV06 weth_) public Transformer() { + constructor(IEtherToken weth_) public Transformer() { weth = weth_; } diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/AbstractBridgeAdapter.sol b/contracts/zero-ex/contracts/src/transformers/bridges/AbstractBridgeAdapter.sol index c78d91a37f..d1460ed36b 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/AbstractBridgeAdapter.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/AbstractBridgeAdapter.sol @@ -32,15 +32,15 @@ abstract contract AbstractBridgeAdapter is IBridgeAdapter { function isSupportedSource(bytes32 source) external override returns (bool isSupported) { BridgeOrder memory placeholderOrder; placeholderOrder.source = source; - IERC20TokenV06 placeholderToken = IERC20TokenV06(address(0)); + IERC20Token placeholderToken = IERC20Token(address(0)); (, isSupported) = _trade(placeholderOrder, placeholderToken, placeholderToken, 0, true); } function trade( BridgeOrder memory order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount ) public override returns (uint256 boughtAmount) { (boughtAmount, ) = _trade(order, sellToken, buyToken, sellAmount, false); @@ -48,8 +48,8 @@ abstract contract AbstractBridgeAdapter is IBridgeAdapter { function _trade( BridgeOrder memory order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bool dryRun ) internal virtual returns (uint256 boughtAmount, bool supportedSource); diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/ArbitrumBridgeAdapter.sol b/contracts/zero-ex/contracts/src/transformers/bridges/ArbitrumBridgeAdapter.sol index 70714bb565..8c91e3502c 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/ArbitrumBridgeAdapter.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/ArbitrumBridgeAdapter.sol @@ -45,12 +45,12 @@ contract ArbitrumBridgeAdapter is MixinWOOFi, MixinZeroExBridge { - constructor(IEtherTokenV06 weth) public MixinCurve(weth) MixinAaveV3(true) {} + constructor(IEtherToken weth) public MixinCurve(weth) MixinAaveV3(true) {} function _trade( BridgeOrder memory order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bool dryRun ) internal override returns (uint256 boughtAmount, bool supportedSource) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/AvalancheBridgeAdapter.sol b/contracts/zero-ex/contracts/src/transformers/bridges/AvalancheBridgeAdapter.sol index 5726fd4da1..cfe59f6811 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/AvalancheBridgeAdapter.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/AvalancheBridgeAdapter.sol @@ -43,12 +43,12 @@ contract AvalancheBridgeAdapter is MixinWOOFi, MixinZeroExBridge { - constructor(IEtherTokenV06 weth) public MixinCurve(weth) MixinAaveV3(false) {} + constructor(IEtherToken weth) public MixinCurve(weth) MixinAaveV3(false) {} function _trade( BridgeOrder memory order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bool dryRun ) internal override returns (uint256 boughtAmount, bool supportedSource) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/BSCBridgeAdapter.sol b/contracts/zero-ex/contracts/src/transformers/bridges/BSCBridgeAdapter.sol index 122e233e42..f59b7bf146 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/BSCBridgeAdapter.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/BSCBridgeAdapter.sol @@ -39,12 +39,12 @@ contract BSCBridgeAdapter is MixinWOOFi, MixinZeroExBridge { - constructor(IEtherTokenV06 weth) public MixinCurve(weth) MixinMooniswap(weth) {} + constructor(IEtherToken weth) public MixinCurve(weth) MixinMooniswap(weth) {} function _trade( BridgeOrder memory order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bool dryRun ) internal override returns (uint256 boughtAmount, bool supportedSource) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/BridgeProtocols.sol b/contracts/zero-ex/contracts/src/transformers/bridges/BridgeProtocols.sol index f2c4ce73fd..2baebcf54f 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/BridgeProtocols.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/BridgeProtocols.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; library BridgeProtocols { // A incrementally increasing, append-only list of protocol IDs. diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/CeloBridgeAdapter.sol b/contracts/zero-ex/contracts/src/transformers/bridges/CeloBridgeAdapter.sol index b94b958367..d1d128c2f0 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/CeloBridgeAdapter.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/CeloBridgeAdapter.sol @@ -26,8 +26,8 @@ contract CeloBridgeAdapter is AbstractBridgeAdapter(42220, "Celo"), MixinNerve, function _trade( BridgeOrder memory order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bool dryRun ) internal override returns (uint256 boughtAmount, bool supportedSource) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapter.sol b/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapter.sol index bb911510fd..af4e8dec32 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapter.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/EthereumBridgeAdapter.sol @@ -66,7 +66,7 @@ contract EthereumBridgeAdapter is MixinZeroExBridge { constructor( - IEtherTokenV06 weth + IEtherToken weth ) public MixinBancor(weth) @@ -79,8 +79,8 @@ contract EthereumBridgeAdapter is function _trade( BridgeOrder memory order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bool dryRun ) internal override returns (uint256 boughtAmount, bool supportedSource) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/FantomBridgeAdapter.sol b/contracts/zero-ex/contracts/src/transformers/bridges/FantomBridgeAdapter.sol index ec6165703c..5bd71764ee 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/FantomBridgeAdapter.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/FantomBridgeAdapter.sol @@ -35,12 +35,12 @@ contract FantomBridgeAdapter is MixinWOOFi, MixinZeroExBridge { - constructor(IEtherTokenV06 weth) public MixinCurve(weth) {} + constructor(IEtherToken weth) public MixinCurve(weth) {} function _trade( BridgeOrder memory order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bool dryRun ) internal override returns (uint256 boughtAmount, bool supportedSource) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/IBridgeAdapter.sol b/contracts/zero-ex/contracts/src/transformers/bridges/IBridgeAdapter.sol index ffd45149d6..1e0b1c2f68 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/IBridgeAdapter.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/IBridgeAdapter.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; interface IBridgeAdapter { struct BridgeOrder { @@ -37,8 +37,8 @@ interface IBridgeAdapter { /// @param outputTokenAmount Amount of output token bought. event BridgeFill( bytes32 source, - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 inputTokenAmount, uint256 outputTokenAmount ); @@ -47,8 +47,8 @@ interface IBridgeAdapter { function trade( BridgeOrder calldata order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount ) external returns (uint256 boughtAmount); } diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/OptimismBridgeAdapter.sol b/contracts/zero-ex/contracts/src/transformers/bridges/OptimismBridgeAdapter.sol index 502646d785..f072270ccd 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/OptimismBridgeAdapter.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/OptimismBridgeAdapter.sol @@ -41,13 +41,13 @@ contract OptimismBridgeAdapter is MixinWOOFi, MixinZeroExBridge { - constructor(IEtherTokenV06 weth) public MixinCurve(weth) MixinAaveV3(true) {} + constructor(IEtherToken weth) public MixinCurve(weth) MixinAaveV3(true) {} /* solhint-disable function-max-lines */ function _trade( BridgeOrder memory order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bool dryRun ) internal override returns (uint256 boughtAmount, bool supportedSource) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/PolygonBridgeAdapter.sol b/contracts/zero-ex/contracts/src/transformers/bridges/PolygonBridgeAdapter.sol index 9ccb827ac3..2dc1c1cc57 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/PolygonBridgeAdapter.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/PolygonBridgeAdapter.sol @@ -51,12 +51,12 @@ contract PolygonBridgeAdapter is MixinWOOFi, MixinZeroExBridge { - constructor(IEtherTokenV06 weth) public MixinCurve(weth) MixinAaveV3(false) {} + constructor(IEtherToken weth) public MixinCurve(weth) MixinAaveV3(false) {} function _trade( BridgeOrder memory order, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bool dryRun ) internal override returns (uint256 boughtAmount, bool supportedSource) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinAaveV2.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinAaveV2.sol index 35f4252fa5..7872dabf07 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinAaveV2.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinAaveV2.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; // Minimal Aave V2 LendingPool interface interface ILendingPool { @@ -48,11 +48,11 @@ interface ILendingPool { } contract MixinAaveV2 { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeAaveV2( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinAaveV3.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinAaveV3.sol index b3b9ba60ce..53aaff79ef 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinAaveV3.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinAaveV3.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; // Minimal Aave V3 Pool interface interface IPool { @@ -73,7 +73,7 @@ interface IL2Pool { } contract MixinAaveV3 { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; bool private immutable _isL2; @@ -82,8 +82,8 @@ contract MixinAaveV3 { } function _tradeAaveV3( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBalancer.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBalancer.sol index 60c63b5ff4..e71626b69e 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBalancer.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBalancer.sol @@ -14,8 +14,8 @@ pragma solidity ^0.6.5; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; interface IBalancerPool { /// @dev Sell `tokenAmountIn` of `tokenIn` and receive `tokenOut`. @@ -28,20 +28,20 @@ interface IBalancerPool { /// @return spotPriceAfter The new marginal spot price of the given /// token pair for this pool. function swapExactAmountIn( - IERC20TokenV06 tokenIn, + IERC20Token tokenIn, uint256 tokenAmountIn, - IERC20TokenV06 tokenOut, + IERC20Token tokenOut, uint256 minAmountOut, uint256 maxPrice ) external returns (uint256 tokenAmountOut, uint256 spotPriceAfter); } contract MixinBalancer { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeBalancer( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBalancerV2Batch.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBalancerV2Batch.sol index 4054e381cf..0a16da7a5a 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBalancerV2Batch.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBalancerV2Batch.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; interface IBalancerV2BatchSwapVault { enum SwapKind { @@ -42,7 +42,7 @@ interface IBalancerV2BatchSwapVault { function batchSwap( SwapKind kind, BatchSwapStep[] calldata swaps, - IERC20TokenV06[] calldata assets, + IERC20Token[] calldata assets, FundManagement calldata funds, int256[] calldata limits, uint256 deadline @@ -50,12 +50,12 @@ interface IBalancerV2BatchSwapVault { } contract MixinBalancerV2Batch { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; struct BalancerV2BatchBridgeData { IBalancerV2BatchSwapVault vault; IBalancerV2BatchSwapVault.BatchSwapStep[] swapSteps; - IERC20TokenV06[] assets; + IERC20Token[] assets; } function _tradeBalancerV2Batch( @@ -68,7 +68,7 @@ contract MixinBalancerV2Batch { IBalancerV2BatchSwapVault.BatchSwapStep[] memory swapSteps, address[] memory assets_ ) = abi.decode(bridgeData, (IBalancerV2BatchSwapVault, IBalancerV2BatchSwapVault.BatchSwapStep[], address[])); - IERC20TokenV06[] memory assets; + IERC20Token[] memory assets; assembly { assets := assets_ } diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBancor.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBancor.sol index 46a6b35402..59e07a2a46 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBancor.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBancor.sol @@ -15,14 +15,14 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "../IBridgeAdapter.sol"; interface IBancorNetwork { function convertByPath( - IERC20TokenV06[] calldata _path, + IERC20Token[] calldata _path, uint256 _amount, uint256 _minReturn, address _beneficiary, @@ -33,21 +33,21 @@ interface IBancorNetwork { contract MixinBancor { /// @dev Bancor ETH pseudo-address. - IERC20TokenV06 public constant BANCOR_ETH_ADDRESS = IERC20TokenV06(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); - IEtherTokenV06 private immutable WETH; + IERC20Token public constant BANCOR_ETH_ADDRESS = IERC20Token(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); + IEtherToken private immutable WETH; - constructor(IEtherTokenV06 weth) public { + constructor(IEtherToken weth) public { WETH = weth; } function _tradeBancor( - IERC20TokenV06 buyToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { // Decode the bridge data. IBancorNetwork bancorNetworkAddress; - IERC20TokenV06[] memory path; + IERC20Token[] memory path; { address[] memory _path; (bancorNetworkAddress, _path) = abi.decode(bridgeData, (IBancorNetwork, address[])); diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBancorV3.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBancorV3.sol index 91ed720d31..49554aa014 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBancorV3.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinBancorV3.sol @@ -15,9 +15,9 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; /* BancorV3 @@ -41,22 +41,22 @@ interface IBancorV3 { } contract MixinBancorV3 { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; - IERC20TokenV06 public constant BANCORV3_ETH_ADDRESS = IERC20TokenV06(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); - IEtherTokenV06 private immutable WETH; + IERC20Token public constant BANCORV3_ETH_ADDRESS = IERC20Token(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); + IEtherToken private immutable WETH; - constructor(IEtherTokenV06 weth) public { + constructor(IEtherToken weth) public { WETH = weth; } function _tradeBancorV3( - IERC20TokenV06 buyToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 amountOut) { IBancorV3 router; - IERC20TokenV06[] memory path; + IERC20Token[] memory path; address[] memory _path; uint256 payableAmount = 0; diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCompound.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCompound.sol index 24f99c1f6a..9634bbc142 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCompound.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCompound.sol @@ -15,9 +15,9 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; /// @dev Minimal CToken interface @@ -45,20 +45,20 @@ interface ICEther { } contract MixinCompound { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; - constructor(IEtherTokenV06 weth) public { + constructor(IEtherToken weth) public { WETH = weth; } uint256 private constant COMPOUND_SUCCESS_CODE = 0; function _tradeCompound( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCryptoCom.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCryptoCom.sol index 3d06a81c53..3b7d6cd8ca 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCryptoCom.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCryptoCom.sol @@ -15,20 +15,20 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "./MixinUniswapV2.sol"; contract MixinCryptoCom { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeCryptoCom( - IERC20TokenV06 buyToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { IUniswapV2Router02 router; - IERC20TokenV06[] memory path; + IERC20Token[] memory path; { address[] memory _path; (router, _path) = abi.decode(bridgeData, (IUniswapV2Router02, address[])); diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCurve.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCurve.sol index 1b016563f1..ac3f1a561d 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCurve.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCurve.sol @@ -16,20 +16,20 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; contract MixinCurve { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; using LibRichErrorsV06 for bytes; /// @dev Mainnet address of the WETH contract. - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; - constructor(IEtherTokenV06 weth) public { + constructor(IEtherToken weth) public { WETH = weth; } @@ -41,8 +41,8 @@ contract MixinCurve { } function _tradeCurve( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCurveV2.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCurveV2.sol index 9b3b7b7969..33b8e33c9e 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCurveV2.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinCurveV2.sol @@ -16,12 +16,12 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; contract MixinCurveV2 { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; using LibRichErrorsV06 for bytes; @@ -33,8 +33,8 @@ contract MixinCurveV2 { } function _tradeCurveV2( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinDodo.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinDodo.sol index 17986db954..a06bf1dc17 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinDodo.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinDodo.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../IBridgeAdapter.sol"; interface IDODO { @@ -30,10 +30,10 @@ interface IDODOHelper { } contract MixinDodo { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeDodo( - IERC20TokenV06 sellToken, + IERC20Token sellToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinDodoV2.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinDodoV2.sol index a20a9e3200..725054565f 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinDodoV2.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinDodoV2.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../IBridgeAdapter.sol"; interface IDODOV2 { @@ -26,10 +26,10 @@ interface IDODOV2 { } contract MixinDodoV2 { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeDodoV2( - IERC20TokenV06 sellToken, + IERC20Token sellToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinGMX.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinGMX.sol index 68eae45099..f8e14280a0 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinGMX.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinGMX.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../IBridgeAdapter.sol"; @@ -36,11 +36,11 @@ interface IGmxRouter { } contract MixinGMX { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; function _tradeGMX( - IERC20TokenV06 buyToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) public returns (uint256 boughtAmount) { @@ -49,7 +49,7 @@ contract MixinGMX { address vault; address[] memory _path; IGmxRouter router; - IERC20TokenV06[] memory path; + IERC20Token[] memory path; { //decode the bridge data diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinKyberDmm.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinKyberDmm.sol index eb9f32c727..786cabf6b6 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinKyberDmm.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinKyberDmm.sol @@ -20,8 +20,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../IBridgeAdapter.sol"; /* @@ -50,10 +50,10 @@ interface IKyberDmmRouter { } contract MixinKyberDmm { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeKyberDmm( - IERC20TokenV06 buyToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { @@ -69,7 +69,7 @@ contract MixinKyberDmm { "MixinKyberDmm/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN" ); // Grant the KyberDmm router an allowance to sell the first token. - IERC20TokenV06(path[0]).approveIfBelow(address(router), sellAmount); + IERC20Token(path[0]).approveIfBelow(address(router), sellAmount); uint256[] memory amounts = IKyberDmmRouter(router).swapExactTokensForTokens( // Sell all tokens we hold. diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinLido.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinLido.sol index 040abc23ca..03a8859fb1 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinLido.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinLido.sol @@ -15,9 +15,9 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; /// @dev Minimal interface for minting StETH interface IStETH { @@ -59,18 +59,18 @@ interface IWstETH { } contract MixinLido { - using LibERC20TokenV06 for IERC20TokenV06; - using LibERC20TokenV06 for IEtherTokenV06; + using LibERC20TokenV06 for IERC20Token; + using LibERC20TokenV06 for IEtherToken; - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; - constructor(IEtherTokenV06 weth) public { + constructor(IEtherToken weth) public { WETH = weth; } function _tradeLido( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { @@ -82,7 +82,7 @@ contract MixinLido { } function _tradeStETH( - IERC20TokenV06 buyToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) private returns (uint256 boughtAmount) { @@ -96,12 +96,12 @@ contract MixinLido { } function _tradeWstETH( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) private returns (uint256 boughtAmount) { - (IEtherTokenV06 stETH, IWstETH wstETH) = abi.decode(bridgeData, (IEtherTokenV06, IWstETH)); + (IEtherToken stETH, IWstETH wstETH) = abi.decode(bridgeData, (IEtherToken, IWstETH)); if (address(sellToken) == address(stETH) && address(buyToken) == address(wstETH)) { sellToken.approveIfBelow(address(wstETH), sellAmount); return wstETH.wrap(sellAmount); diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMStable.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMStable.sol index 2c9816415f..95059134b8 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMStable.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMStable.sol @@ -15,14 +15,14 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../IBridgeAdapter.sol"; interface IMStable { function swap( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, uint256 minBoughtAmount, address recipient @@ -30,11 +30,11 @@ interface IMStable { } contract MixinMStable { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeMStable( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMakerPSM.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMakerPSM.sol index efd982b69b..5e44d1dfa6 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMakerPSM.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMakerPSM.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; interface IPSM { @@ -48,7 +48,7 @@ interface IPSM { } contract MixinMakerPSM { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; struct MakerPsmBridgeData { @@ -67,8 +67,8 @@ contract MixinMakerPSM { // See https://github.com/makerdao/dss/blob/master/DEVELOPING.md function _tradeMakerPsm( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMooniswap.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMooniswap.sol index 9987886b31..306ea6fb42 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMooniswap.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinMooniswap.sol @@ -15,16 +15,16 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "../IBridgeAdapter.sol"; /// @dev Moooniswap pool interface. interface IMooniswapPool { function swap( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, uint256 minBoughtAmount, address referrer @@ -33,19 +33,19 @@ interface IMooniswapPool { /// @dev BridgeAdapter mixin for mooniswap. contract MixinMooniswap { - using LibERC20TokenV06 for IERC20TokenV06; - using LibERC20TokenV06 for IEtherTokenV06; + using LibERC20TokenV06 for IERC20Token; + using LibERC20TokenV06 for IEtherToken; /// @dev WETH token. - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; - constructor(IEtherTokenV06 weth) public { + constructor(IEtherToken weth) public { WETH = weth; } function _tradeMooniswap( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { @@ -62,8 +62,8 @@ contract MixinMooniswap { } boughtAmount = pool.swap{value: ethValue}( - sellToken == WETH ? IERC20TokenV06(0) : sellToken, - buyToken == WETH ? IERC20TokenV06(0) : buyToken, + sellToken == WETH ? IERC20Token(0) : sellToken, + buyToken == WETH ? IERC20Token(0) : buyToken, sellAmount, 1, address(0) diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinNerve.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinNerve.sol index 9798cd10b6..768c0970d1 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinNerve.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinNerve.sol @@ -16,12 +16,12 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; contract MixinNerve { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; using LibRichErrorsV06 for bytes; @@ -33,7 +33,7 @@ contract MixinNerve { } function _tradeNerve( - IERC20TokenV06 sellToken, + IERC20Token sellToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinPlatypus.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinPlatypus.sol index a11777578e..4cc2da5507 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinPlatypus.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinPlatypus.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; interface IPlatypusRouter { @@ -31,18 +31,18 @@ interface IPlatypusRouter { } contract MixinPlatypus { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; function _tradePlatypus( - IERC20TokenV06 buyToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) public returns (uint256 boughtAmount) { IPlatypusRouter router; address _router; address[] memory _pool; - IERC20TokenV06[] memory path; + IERC20Token[] memory path; address[] memory _path; { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinShell.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinShell.sol index fee7c10611..a65d6c9634 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinShell.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinShell.sol @@ -15,13 +15,13 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; interface IShell { function originSwap( - IERC20TokenV06 from, - IERC20TokenV06 to, + IERC20Token from, + IERC20Token to, uint256 fromAmount, uint256 minTargetAmount, uint256 deadline @@ -29,18 +29,18 @@ interface IShell { } contract MixinShell { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeShell( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { IShell pool = abi.decode(bridgeData, (IShell)); // Grant the Shell contract an allowance to sell the first token. - IERC20TokenV06(sellToken).approveIfBelow(address(pool), sellAmount); + IERC20Token(sellToken).approveIfBelow(address(pool), sellAmount); boughtAmount = pool.originSwap( sellToken, diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinSolidly.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinSolidly.sol index 03cdd33cd7..bc694f79ae 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinSolidly.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinSolidly.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; interface ISolidlyRouter { function swapExactTokensForTokensSimple( @@ -31,11 +31,11 @@ interface ISolidlyRouter { } contract MixinSolidly { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeSolidly( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswap.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswap.sol index 22994382d6..87d5af9850 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswap.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswap.sol @@ -15,15 +15,15 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "../IBridgeAdapter.sol"; interface IUniswapExchangeFactory { /// @dev Get the exchange for a token. /// @param token The token contract. - function getExchange(IERC20TokenV06 token) external view returns (IUniswapExchange exchange); + function getExchange(IERC20Token token) external view returns (IUniswapExchange exchange); } interface IUniswapExchange { @@ -65,7 +65,7 @@ interface IUniswapExchange { uint256 minEthBought, uint256 deadline, address recipient, - IERC20TokenV06 buyToken + IERC20Token buyToken ) external returns (uint256 tokensBought); /// @dev Buys at least `minTokensBought` tokens with the exchange token. @@ -80,24 +80,24 @@ interface IUniswapExchange { uint256 minTokensBought, uint256 minEthBought, uint256 deadline, - IERC20TokenV06 buyToken + IERC20Token buyToken ) external returns (uint256 tokensBought); } contract MixinUniswap { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; /// @dev Mainnet address of the WETH contract. - IEtherTokenV06 private immutable WETH; + IEtherToken private immutable WETH; - constructor(IEtherTokenV06 weth) public { + constructor(IEtherToken weth) public { WETH = weth; } //·solhint-disable-next-line·function-max-lines function _tradeUniswap( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { @@ -166,8 +166,8 @@ contract MixinUniswap { /// @return exchange The uniswap exchange. function _getUniswapExchangeForTokenPair( IUniswapExchangeFactory exchangeFactory, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken + IERC20Token sellToken, + IERC20Token buyToken ) private view returns (IUniswapExchange exchange) { // Whichever isn't WETH is the exchange token. exchange = sellToken == WETH ? exchangeFactory.getExchange(buyToken) : exchangeFactory.getExchange(sellToken); diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswapV2.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswapV2.sol index 8efab70c20..584dbe3f33 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswapV2.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswapV2.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../IBridgeAdapter.sol"; /* @@ -36,22 +36,22 @@ interface IUniswapV2Router02 { function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, - IERC20TokenV06[] calldata path, + IERC20Token[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); } contract MixinUniswapV2 { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeUniswapV2( - IERC20TokenV06 buyToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { IUniswapV2Router02 router; - IERC20TokenV06[] memory path; + IERC20Token[] memory path; { address[] memory _path; (router, _path) = abi.decode(bridgeData, (IUniswapV2Router02, address[])); diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswapV3.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswapV3.sol index 94e6854be8..1aedd28cc0 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswapV3.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinUniswapV3.sol @@ -15,8 +15,8 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../IBridgeAdapter.sol"; interface IUniswapV3Router { @@ -32,10 +32,10 @@ interface IUniswapV3Router { } contract MixinUniswapV3 { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; function _tradeUniswapV3( - IERC20TokenV06 sellToken, + IERC20Token sellToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinWOOFi.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinWOOFi.sol index 7b208cfeeb..d6f28c582e 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinWOOFi.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinWOOFi.sol @@ -15,9 +15,9 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "../IBridgeAdapter.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; @@ -42,16 +42,16 @@ interface IWooPP { } contract MixinWOOFi { - using LibERC20TokenV06 for IERC20TokenV06; - using LibERC20TokenV06 for IEtherTokenV06; + using LibERC20TokenV06 for IERC20Token; + using LibERC20TokenV06 for IEtherToken; using LibSafeMathV06 for uint256; // solhint-disable-next-line const-name-snakecase address constant rebateAddress = 0xBfdcBB4C05843163F491C24f9c0019c510786304; function _tradeWOOFi( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) public returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinZeroExBridge.sol b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinZeroExBridge.sol index 5de0d04968..ac5b1cb0f2 100644 --- a/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinZeroExBridge.sol +++ b/contracts/zero-ex/contracts/src/transformers/bridges/mixins/MixinZeroExBridge.sol @@ -14,18 +14,18 @@ pragma solidity ^0.6.5; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "../../../vendor/ILiquidityProvider.sol"; contract MixinZeroExBridge { - using LibERC20TokenV06 for IERC20TokenV06; + using LibERC20TokenV06 for IERC20Token; using LibSafeMathV06 for uint256; function _tradeZeroExBridge( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, bytes memory bridgeData ) internal returns (uint256 boughtAmount) { diff --git a/contracts/zero-ex/contracts/src/vendor/ILiquidityProvider.sol b/contracts/zero-ex/contracts/src/vendor/ILiquidityProvider.sol index 4996dbd83d..5d041128d9 100644 --- a/contracts/zero-ex/contracts/src/vendor/ILiquidityProvider.sol +++ b/contracts/zero-ex/contracts/src/vendor/ILiquidityProvider.sol @@ -14,7 +14,7 @@ pragma solidity ^0.6.5; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; interface ILiquidityProvider { /// @dev An optional event an LP can emit for each fill against a source. @@ -29,8 +29,8 @@ interface ILiquidityProvider { /// @param sender The caller of the LP. /// @param recipient The recipient of the output tokens. event LiquidityProviderFill( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 inputTokenAmount, uint256 outputTokenAmount, bytes32 sourceId, @@ -49,8 +49,8 @@ interface ILiquidityProvider { /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract. /// @return boughtAmount The amount of `outputToken` bought. function sellTokenForToken( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -65,7 +65,7 @@ interface ILiquidityProvider { /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract. /// @return boughtAmount The amount of `outputToken` bought. function sellEthForToken( - IERC20TokenV06 outputToken, + IERC20Token outputToken, address recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -79,7 +79,7 @@ interface ILiquidityProvider { /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract. /// @return boughtAmount The amount of ETH bought. function sellTokenForEth( - IERC20TokenV06 inputToken, + IERC20Token inputToken, address payable recipient, uint256 minBuyAmount, bytes calldata auxiliaryData @@ -94,8 +94,8 @@ interface ILiquidityProvider { /// @param sellAmount Amount of `inputToken` to sell. /// @return outputTokenAmount Amount of `outputToken` that would be obtained. function getSellQuote( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 sellAmount ) external view returns (uint256 outputTokenAmount); } diff --git a/contracts/zero-ex/contracts/src/vendor/IMooniswapPool.sol b/contracts/zero-ex/contracts/src/vendor/IMooniswapPool.sol index 4b6f5c5657..9e6b5adcfa 100644 --- a/contracts/zero-ex/contracts/src/vendor/IMooniswapPool.sol +++ b/contracts/zero-ex/contracts/src/vendor/IMooniswapPool.sol @@ -15,15 +15,15 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/v06/LibERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; /// @dev Moooniswap pool interface. interface IMooniswapPool { function swap( - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, uint256 minBoughtAmount, address referrer diff --git a/contracts/zero-ex/contracts/test/TestFixinProtocolFees.sol b/contracts/zero-ex/contracts/test/TestFixinProtocolFees.sol index 7a8ccb4f3d..076f29af71 100644 --- a/contracts/zero-ex/contracts/test/TestFixinProtocolFees.sol +++ b/contracts/zero-ex/contracts/test/TestFixinProtocolFees.sol @@ -19,7 +19,7 @@ import "../src/fixins/FixinProtocolFees.sol"; contract TestFixinProtocolFees is FixinProtocolFees { constructor( - IEtherTokenV06 weth, + IEtherToken weth, IStaking staking, FeeCollectorController feeCollectorController, uint32 protocolFeeMultiplier diff --git a/contracts/zero-ex/contracts/test/TestFixinTokenSpender.sol b/contracts/zero-ex/contracts/test/TestFixinTokenSpender.sol index a511e0d1a5..fd4337b5f1 100644 --- a/contracts/zero-ex/contracts/test/TestFixinTokenSpender.sol +++ b/contracts/zero-ex/contracts/test/TestFixinTokenSpender.sol @@ -15,19 +15,19 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../src/fixins/FixinTokenSpender.sol"; contract TestFixinTokenSpender is FixinTokenSpender { constructor() public {} - function transferERC20TokensFrom(IERC20TokenV06 token, address owner, address to, uint256 amount) external { + function transferERC20TokensFrom(IERC20Token token, address owner, address to, uint256 amount) external { _transferERC20TokensFrom(token, owner, to, amount); } event FallbackCalled(address token, address owner, address to, uint256 amount); - function getSpendableERC20BalanceOf(IERC20TokenV06 token, address owner) external view returns (uint256) { + function getSpendableERC20BalanceOf(IERC20Token token, address owner) external view returns (uint256) { return _getSpendableERC20BalanceOf(token, owner); } } diff --git a/contracts/zero-ex/contracts/test/TestMetaTransactionsNativeOrdersFeature.sol b/contracts/zero-ex/contracts/test/TestMetaTransactionsNativeOrdersFeature.sol index 20e8b3ace8..8645c339ac 100644 --- a/contracts/zero-ex/contracts/test/TestMetaTransactionsNativeOrdersFeature.sol +++ b/contracts/zero-ex/contracts/test/TestMetaTransactionsNativeOrdersFeature.sol @@ -24,7 +24,7 @@ contract TestMetaTransactionsNativeOrdersFeature is NativeOrdersFeature { public NativeOrdersFeature( address(0), - IEtherTokenV06(0), + IEtherToken(0), IStaking(0), FeeCollectorController(address(new TestFeeCollectorController())), 0 diff --git a/contracts/zero-ex/contracts/test/TestMetaTransactionsTransformERC20Feature.sol b/contracts/zero-ex/contracts/test/TestMetaTransactionsTransformERC20Feature.sol index d2e29d681f..6a8b7a4553 100644 --- a/contracts/zero-ex/contracts/test/TestMetaTransactionsTransformERC20Feature.sol +++ b/contracts/zero-ex/contracts/test/TestMetaTransactionsTransformERC20Feature.sol @@ -23,8 +23,8 @@ contract TestMetaTransactionsTransformERC20Feature is TransformERC20Feature { address sender, uint256 value, address taker, - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 inputTokenAmount, uint256 minOutputTokenAmount, Transformation[] transformations @@ -58,7 +58,7 @@ contract TestMetaTransactionsTransformERC20Feature is TransformERC20Feature { salt: 0, callData: "", value: 0, - feeToken: IERC20TokenV06(0), + feeToken: IERC20Token(0), feeAmount: 0 }), signature @@ -79,7 +79,7 @@ contract TestMetaTransactionsTransformERC20Feature is TransformERC20Feature { salt: 0, callData: "", value: 0, - feeToken: IERC20TokenV06(0), + feeToken: IERC20Token(0), feeAmount: 0 }); IMetaTransactionsFeature(address(this)).batchExecuteMetaTransactions(mtxs, signatures); diff --git a/contracts/zero-ex/contracts/test/TestMintTokenERC20Transformer.sol b/contracts/zero-ex/contracts/test/TestMintTokenERC20Transformer.sol index b27978c1fb..0b4bf75425 100644 --- a/contracts/zero-ex/contracts/test/TestMintTokenERC20Transformer.sol +++ b/contracts/zero-ex/contracts/test/TestMintTokenERC20Transformer.sol @@ -15,14 +15,14 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../src/transformers/IERC20Transformer.sol"; import "../src/transformers/LibERC20Transformer.sol"; import "./tokens/TestMintableERC20Token.sol"; contract TestMintTokenERC20Transformer is IERC20Transformer { struct TransformData { - IERC20TokenV06 inputToken; + IERC20Token inputToken; TestMintableERC20Token outputToken; uint256 burnAmount; uint256 mintAmount; @@ -59,7 +59,7 @@ contract TestMintTokenERC20Transformer is IERC20Transformer { data.inputToken.transfer(address(0), data.burnAmount); } // Mint output tokens. - if (!LibERC20Transformer.isTokenETH(IERC20TokenV06(address(data.outputToken)))) { + if (!LibERC20Transformer.isTokenETH(IERC20Token(address(data.outputToken)))) { if (data.feeAmount > data.mintAmount) { data.outputToken.burn(context.recipient, data.feeAmount - data.mintAmount); } else { diff --git a/contracts/zero-ex/contracts/test/TestNFTOrderPresigner.sol b/contracts/zero-ex/contracts/test/TestNFTOrderPresigner.sol index 1ea39dad1d..bc03f4b7c0 100644 --- a/contracts/zero-ex/contracts/test/TestNFTOrderPresigner.sol +++ b/contracts/zero-ex/contracts/test/TestNFTOrderPresigner.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../src/IZeroEx.sol"; import "../src/vendor/IERC1155Token.sol"; import "../src/vendor/IERC721Token.sol"; @@ -46,7 +46,7 @@ contract TestNFTOrderPresigner { token.setApprovalForAll(address(zeroEx), true); } - function approveERC20(IERC20TokenV06 token) external { + function approveERC20(IERC20Token token) external { token.approve(address(zeroEx), uint256(-1)); } diff --git a/contracts/zero-ex/contracts/test/TestNativeOrdersFeature.sol b/contracts/zero-ex/contracts/test/TestNativeOrdersFeature.sol index 821d758d3a..2fd66cdf7e 100644 --- a/contracts/zero-ex/contracts/test/TestNativeOrdersFeature.sol +++ b/contracts/zero-ex/contracts/test/TestNativeOrdersFeature.sol @@ -21,7 +21,7 @@ import "./TestFeeCollectorController.sol"; contract TestNativeOrdersFeature is NativeOrdersFeature { constructor( address zeroExAddress, - IEtherTokenV06 weth, + IEtherToken weth, IStaking staking, FeeCollectorController _feeCollectorController, // Unused but necessary for artifact compatibility. uint32 protocolFeeMultiplier diff --git a/contracts/zero-ex/contracts/test/TestOrderSignerRegistryWithContractWallet.sol b/contracts/zero-ex/contracts/test/TestOrderSignerRegistryWithContractWallet.sol index b00fddaa14..7d2b0a45db 100644 --- a/contracts/zero-ex/contracts/test/TestOrderSignerRegistryWithContractWallet.sol +++ b/contracts/zero-ex/contracts/test/TestOrderSignerRegistryWithContractWallet.sol @@ -16,7 +16,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/OwnableV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../src/IZeroEx.sol"; contract TestOrderSignerRegistryWithContractWallet is OwnableV06 { @@ -30,7 +30,7 @@ contract TestOrderSignerRegistryWithContractWallet is OwnableV06 { zeroex.registerAllowedOrderSigner(signer, allowed); } - function approveERC20(IERC20TokenV06 token, address spender, uint256 value) external onlyOwner { + function approveERC20(IERC20Token token, address spender, uint256 value) external onlyOwner { token.approve(spender, value); } } diff --git a/contracts/zero-ex/contracts/test/TestStaking.sol b/contracts/zero-ex/contracts/test/TestStaking.sol index e7242c6680..dc2ff96bb6 100644 --- a/contracts/zero-ex/contracts/test/TestStaking.sol +++ b/contracts/zero-ex/contracts/test/TestStaking.sol @@ -15,15 +15,15 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; contract TestStaking { mapping(address => bytes32) public poolForMaker; mapping(bytes32 => uint256) public balanceForPool; - IEtherTokenV06 immutable weth; + IEtherToken immutable weth; - constructor(IEtherTokenV06 _weth) public { + constructor(IEtherToken _weth) public { weth = _weth; } diff --git a/contracts/zero-ex/contracts/test/TestTransformerHost.sol b/contracts/zero-ex/contracts/test/TestTransformerHost.sol index e1c93ed2e5..ed5f6b580c 100644 --- a/contracts/zero-ex/contracts/test/TestTransformerHost.sol +++ b/contracts/zero-ex/contracts/test/TestTransformerHost.sol @@ -16,12 +16,12 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../src/transformers/IERC20Transformer.sol"; import "../src/transformers/LibERC20Transformer.sol"; contract TestTransformerHost { - using LibERC20Transformer for IERC20TokenV06; + using LibERC20Transformer for IERC20Token; using LibRichErrorsV06 for bytes; function rawExecuteTransform( diff --git a/contracts/zero-ex/contracts/test/TestUniswapV3Feature.sol b/contracts/zero-ex/contracts/test/TestUniswapV3Feature.sol index a32d26eb8b..21400c5b64 100644 --- a/contracts/zero-ex/contracts/test/TestUniswapV3Feature.sol +++ b/contracts/zero-ex/contracts/test/TestUniswapV3Feature.sol @@ -18,7 +18,7 @@ import "../src/features/UniswapV3Feature.sol"; contract TestUniswapV3Feature is UniswapV3Feature { constructor( - IEtherTokenV06 weth, + IEtherToken weth, address uniFactory, bytes32 poolInitCodeHash ) public UniswapV3Feature(weth, uniFactory, poolInitCodeHash) {} diff --git a/contracts/zero-ex/contracts/test/integration/TestCurve.sol b/contracts/zero-ex/contracts/test/integration/TestCurve.sol index a3fe2a141d..cf6e6135d0 100644 --- a/contracts/zero-ex/contracts/test/integration/TestCurve.sol +++ b/contracts/zero-ex/contracts/test/integration/TestCurve.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../tokens/TestMintableERC20Token.sol"; contract TestCurve { @@ -37,10 +37,10 @@ contract TestCurve { int128 public constant ETH_COIN_IDX = 2; uint256 public buyAmount; - IERC20TokenV06 public sellToken; + IERC20Token public sellToken; TestMintableERC20Token public buyToken; - constructor(IERC20TokenV06 sellToken_, TestMintableERC20Token buyToken_, uint256 buyAmount_) public payable { + constructor(IERC20Token sellToken_, TestMintableERC20Token buyToken_, uint256 buyAmount_) public payable { sellToken = sellToken_; buyToken = buyToken_; buyAmount = buyAmount_; diff --git a/contracts/zero-ex/contracts/test/integration/TestLiquidityProvider.sol b/contracts/zero-ex/contracts/test/integration/TestLiquidityProvider.sol index 1d459c0e3a..7bf91f0f95 100644 --- a/contracts/zero-ex/contracts/test/integration/TestLiquidityProvider.sol +++ b/contracts/zero-ex/contracts/test/integration/TestLiquidityProvider.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; contract TestLiquidityProvider { event SellTokenForToken( @@ -52,10 +52,10 @@ contract TestLiquidityProvider { outputToken, recipient, minBuyAmount, - IERC20TokenV06(inputToken).balanceOf(address(this)) + IERC20Token(inputToken).balanceOf(address(this)) ); - uint256 outputTokenBalance = IERC20TokenV06(outputToken).balanceOf(address(this)); - IERC20TokenV06(outputToken).transfer(recipient, outputTokenBalance); + uint256 outputTokenBalance = IERC20Token(outputToken).balanceOf(address(this)); + IERC20Token(outputToken).transfer(recipient, outputTokenBalance); } /// @dev Trades ETH for token. ETH must be sent to the contract prior to @@ -71,8 +71,8 @@ contract TestLiquidityProvider { bytes calldata // auxiliaryData ) external returns (uint256) { emit SellEthForToken(outputToken, recipient, minBuyAmount, address(this).balance); - uint256 outputTokenBalance = IERC20TokenV06(outputToken).balanceOf(address(this)); - IERC20TokenV06(outputToken).transfer(recipient, outputTokenBalance); + uint256 outputTokenBalance = IERC20Token(outputToken).balanceOf(address(this)); + IERC20Token(outputToken).transfer(recipient, outputTokenBalance); } /// @dev Trades token for ETH. The token must be sent to the contract prior @@ -87,7 +87,7 @@ contract TestLiquidityProvider { uint256 minBuyAmount, bytes calldata // auxiliaryData ) external returns (uint256) { - emit SellTokenForEth(inputToken, recipient, minBuyAmount, IERC20TokenV06(inputToken).balanceOf(address(this))); + emit SellTokenForEth(inputToken, recipient, minBuyAmount, IERC20Token(inputToken).balanceOf(address(this))); recipient.transfer(address(this).balance); } } diff --git a/contracts/zero-ex/contracts/test/integration/TestMooniswap.sol b/contracts/zero-ex/contracts/test/integration/TestMooniswap.sol index 2f11297bbc..d5a6bd14d4 100644 --- a/contracts/zero-ex/contracts/test/integration/TestMooniswap.sol +++ b/contracts/zero-ex/contracts/test/integration/TestMooniswap.sol @@ -15,14 +15,14 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../tokens/TestMintableERC20Token.sol"; contract TestMooniswap { event MooniswapCalled( uint256 value, - IERC20TokenV06 sellToken, - IERC20TokenV06 buyToken, + IERC20Token sellToken, + IERC20Token buyToken, uint256 sellAmount, uint256 minBuyAmount, address referral @@ -35,24 +35,17 @@ contract TestMooniswap { } function swap( - IERC20TokenV06 sellToken, + IERC20Token sellToken, TestMintableERC20Token buyToken, uint256 sellAmount, uint256 minBuyAmount, address referral ) external payable returns (uint256 boughtAmount) { - emit MooniswapCalled( - msg.value, - sellToken, - IERC20TokenV06(address(buyToken)), - sellAmount, - minBuyAmount, - referral - ); + emit MooniswapCalled(msg.value, sellToken, IERC20Token(address(buyToken)), sellAmount, minBuyAmount, referral); boughtAmount = nextBuyAmount; nextBuyAmount = 0; require(boughtAmount >= minBuyAmount, "UNDERBOUGHT"); - if (sellToken != IERC20TokenV06(0)) { + if (sellToken != IERC20Token(0)) { sellToken.transferFrom(msg.sender, address(this), sellAmount); } else { require(sellAmount == msg.value, "NOT_ENOUGH_ETH"); diff --git a/contracts/zero-ex/contracts/test/integration/TestUniswapV2Factory.sol b/contracts/zero-ex/contracts/test/integration/TestUniswapV2Factory.sol index 27d7c78094..8448add593 100644 --- a/contracts/zero-ex/contracts/test/integration/TestUniswapV2Factory.sol +++ b/contracts/zero-ex/contracts/test/integration/TestUniswapV2Factory.sol @@ -14,27 +14,27 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "./TestUniswapV2Pool.sol"; contract TestUniswapV2Factory { struct CreationParameters { - IERC20TokenV06 token0; - IERC20TokenV06 token1; + IERC20Token token0; + IERC20Token token1; } event PoolCreated(TestUniswapV2Pool pool); bytes32 public immutable POOL_INIT_CODE_HASH; - mapping(IERC20TokenV06 => mapping(IERC20TokenV06 => TestUniswapV2Pool)) public getPool; + mapping(IERC20Token => mapping(IERC20Token => TestUniswapV2Pool)) public getPool; CreationParameters public creationParameters; constructor() public { POOL_INIT_CODE_HASH = keccak256(type(TestUniswapV2Pool).creationCode); } - function createPool(IERC20TokenV06 tokenA, IERC20TokenV06 tokenB) external returns (TestUniswapV2Pool pool) { - (IERC20TokenV06 token0, IERC20TokenV06 token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); + function createPool(IERC20Token tokenA, IERC20Token tokenB) external returns (TestUniswapV2Pool pool) { + (IERC20Token token0, IERC20Token token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(getPool[token0][token1] == TestUniswapV2Pool(0), "TestUniswapV2Factory/POOL_ALREADY_EXISTS"); creationParameters = CreationParameters({token0: token0, token1: token1}); pool = new TestUniswapV2Pool{salt: keccak256(abi.encodePacked(token0, token1))}(); diff --git a/contracts/zero-ex/contracts/test/integration/TestUniswapV2Pool.sol b/contracts/zero-ex/contracts/test/integration/TestUniswapV2Pool.sol index cb0761d9f6..324c9f9ee3 100644 --- a/contracts/zero-ex/contracts/test/integration/TestUniswapV2Pool.sol +++ b/contracts/zero-ex/contracts/test/integration/TestUniswapV2Pool.sol @@ -14,21 +14,21 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../../src/vendor/IUniswapV2Pair.sol"; interface IUniswapV2PoolDeployer { struct CreationParameters { - IERC20TokenV06 token0; - IERC20TokenV06 token1; + IERC20Token token0; + IERC20Token token1; } function creationParameters() external view returns (CreationParameters memory); } contract TestUniswapV2Pool is IUniswapV2Pair { - IERC20TokenV06 public immutable token0; - IERC20TokenV06 public immutable token1; + IERC20Token public immutable token0; + IERC20Token public immutable token1; uint112 reserve0; uint112 reserve1; diff --git a/contracts/zero-ex/contracts/test/integration/TestUniswapV3Factory.sol b/contracts/zero-ex/contracts/test/integration/TestUniswapV3Factory.sol index 89d604f46d..fb1a83e5fb 100644 --- a/contracts/zero-ex/contracts/test/integration/TestUniswapV3Factory.sol +++ b/contracts/zero-ex/contracts/test/integration/TestUniswapV3Factory.sol @@ -14,32 +14,28 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "./TestUniswapV3Pool.sol"; contract TestUniswapV3Factory { struct CreationParameters { - IERC20TokenV06 token0; - IERC20TokenV06 token1; + IERC20Token token0; + IERC20Token token1; uint24 fee; } event PoolCreated(TestUniswapV3Pool pool); bytes32 public immutable POOL_INIT_CODE_HASH; - mapping(IERC20TokenV06 => mapping(IERC20TokenV06 => mapping(uint24 => TestUniswapV3Pool))) public getPool; + mapping(IERC20Token => mapping(IERC20Token => mapping(uint24 => TestUniswapV3Pool))) public getPool; CreationParameters public creationParameters; constructor() public { POOL_INIT_CODE_HASH = keccak256(type(TestUniswapV3Pool).creationCode); } - function createPool( - IERC20TokenV06 tokenA, - IERC20TokenV06 tokenB, - uint24 fee - ) external returns (TestUniswapV3Pool pool) { - (IERC20TokenV06 token0, IERC20TokenV06 token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); + function createPool(IERC20Token tokenA, IERC20Token tokenB, uint24 fee) external returns (TestUniswapV3Pool pool) { + (IERC20Token token0, IERC20Token token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(getPool[token0][token1][fee] == TestUniswapV3Pool(0), "TestUniswapV3Factory/POOL_ALREADY_EXISTS"); creationParameters = CreationParameters({token0: token0, token1: token1, fee: fee}); pool = new TestUniswapV3Pool{salt: keccak256(abi.encode(token0, token1, fee))}(); diff --git a/contracts/zero-ex/contracts/test/integration/TestUniswapV3Pool.sol b/contracts/zero-ex/contracts/test/integration/TestUniswapV3Pool.sol index 411c2a7a28..6797966567 100644 --- a/contracts/zero-ex/contracts/test/integration/TestUniswapV3Pool.sol +++ b/contracts/zero-ex/contracts/test/integration/TestUniswapV3Pool.sol @@ -14,13 +14,13 @@ pragma solidity ^0.6; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "../../src/vendor/IUniswapV3Pool.sol"; interface IUniswapV3PoolDeployer { struct CreationParameters { - IERC20TokenV06 token0; - IERC20TokenV06 token1; + IERC20Token token0; + IERC20Token token1; uint24 fee; } @@ -32,8 +32,8 @@ interface IUniswapV3SwapCallback { } contract TestUniswapV3Pool is IUniswapV3Pool { - IERC20TokenV06 public immutable token0; - IERC20TokenV06 public immutable token1; + IERC20Token public immutable token0; + IERC20Token public immutable token1; uint24 public immutable fee; constructor() public { diff --git a/contracts/zero-ex/tests/ForkUtils.t.sol b/contracts/zero-ex/tests/ForkUtils.t.sol index c3f55f5ac7..30b77e5416 100644 --- a/contracts/zero-ex/tests/ForkUtils.t.sol +++ b/contracts/zero-ex/tests/ForkUtils.t.sol @@ -19,7 +19,7 @@ pragma experimental ABIEncoderV2; import "utils/ForkUtils.sol"; import "utils/TestUtils.sol"; import "src/IZeroEx.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "src/features/TransformERC20Feature.sol"; import "src/external/TransformerDeployer.sol"; import "src/transformers/WethTransformer.sol"; diff --git a/contracts/zero-ex/tests/WrapEth.t.sol b/contracts/zero-ex/tests/WrapEth.t.sol index 1c44abdeba..8914473936 100644 --- a/contracts/zero-ex/tests/WrapEth.t.sol +++ b/contracts/zero-ex/tests/WrapEth.t.sol @@ -20,7 +20,7 @@ import "utils/TestUtils.sol"; import "utils/DeployZeroEx.sol"; import "forge-std/Test.sol"; import "src/IZeroEx.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "src/features/TransformERC20Feature.sol"; import "src/external/TransformerDeployer.sol"; import "src/transformers/WethTransformer.sol"; @@ -61,9 +61,9 @@ contract WrapEth is Test, ForkUtils, TestUtils { uint256 balanceWETHBefore = zeroExDeployed.weth.balanceOf(address(this)); zeroExDeployed.zeroEx.transformERC20{value: 1e18}( // input token - IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS), + IERC20Token(LibERC20Transformer.ETH_TOKEN_ADDRESS), // output token - IERC20TokenV06(address(zeroExDeployed.weth)), + IERC20Token(address(zeroExDeployed.weth)), // input token amount 1e18, // min output token amount diff --git a/contracts/zero-ex/tests/forked/RfqtV2Test.t.sol b/contracts/zero-ex/tests/forked/RfqtV2Test.t.sol index cb585ea44d..819393d427 100644 --- a/contracts/zero-ex/tests/forked/RfqtV2Test.t.sol +++ b/contracts/zero-ex/tests/forked/RfqtV2Test.t.sol @@ -19,7 +19,7 @@ pragma experimental ABIEncoderV2; import "../utils/ForkUtils.sol"; import "../utils/TestUtils.sol"; import "src/IZeroEx.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "src/features/TransformERC20Feature.sol"; import "src/external/TransformerDeployer.sol"; import "src/transformers/WethTransformer.sol"; @@ -83,7 +83,7 @@ contract RfqtV2Test is Test, ForkUtils, TestUtils { // Set up the FillQuoteTransformer data FillQuoteTransformer.TransformData memory fqtData; fqtData.side = FillQuoteTransformer.Side.Sell; - fqtData.sellToken = IERC20TokenV06(address(tokens.WrappedNativeToken)); + fqtData.sellToken = IERC20Token(address(tokens.WrappedNativeToken)); fqtData.buyToken = tokens.USDC; // the FQT has a sequence, e.g first RFQ then Limit then Bridge // since solidity doesn't support arrays of different types, this is one simple solution @@ -106,7 +106,7 @@ contract RfqtV2Test is Test, ForkUtils, TestUtils { (order.maker, privateKey) = getSigner(); deal(address(order.makerToken), order.maker, 1e20); vm.prank(order.maker); - IERC20TokenV06(tokens.USDC).approve(address(addresses.exchangeProxy), 1e20); + IERC20Token(tokens.USDC).approve(address(addresses.exchangeProxy), 1e20); vm.prank(order.maker); order.taker = address(0); @@ -133,7 +133,7 @@ contract RfqtV2Test is Test, ForkUtils, TestUtils { log_string(" Successful fill, makerTokens bought"); IZERO_EX.transformERC20{value: 1e18}( // input token - IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS), + IERC20Token(LibERC20Transformer.ETH_TOKEN_ADDRESS), // output token tokens.USDC, // input token amount diff --git a/contracts/zero-ex/tests/forked/SwapEthForERC20Test.t.sol b/contracts/zero-ex/tests/forked/SwapEthForERC20Test.t.sol index 751cd722b0..41218fc959 100644 --- a/contracts/zero-ex/tests/forked/SwapEthForERC20Test.t.sol +++ b/contracts/zero-ex/tests/forked/SwapEthForERC20Test.t.sol @@ -19,7 +19,7 @@ pragma experimental ABIEncoderV2; import "../utils/ForkUtils.sol"; import "../utils/TestUtils.sol"; import "src/IZeroEx.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "src/features/TransformERC20Feature.sol"; import "src/external/TransformerDeployer.sol"; import "src/transformers/WethTransformer.sol"; @@ -94,8 +94,8 @@ contract SwapEthForERC20Test is Test, ForkUtils, TestUtils { // Set up the FillQuoteTransformer data FillQuoteTransformer.TransformData memory fqtData; fqtData.side = FillQuoteTransformer.Side.Sell; - fqtData.sellToken = IERC20TokenV06(address(tokens.WrappedNativeToken)); - fqtData.buyToken = IERC20TokenV06(address(tokens.USDT)); + fqtData.sellToken = IERC20Token(address(tokens.WrappedNativeToken)); + fqtData.buyToken = IERC20Token(address(tokens.USDT)); // the FQT has a sequence, e.g first RFQ then Limit then Bridge // since solidity doesn't support arrays of different types, this is one simple solution // We use a Bridge order type here as we will fill on UniswapV2 @@ -142,13 +142,13 @@ contract SwapEthForERC20Test is Test, ForkUtils, TestUtils { vm.deal(address(this), 1e18); uint256 balanceETHBefore = address(this).balance; - uint256 balanceERC20Before = IERC20TokenV06(tokens.USDT).balanceOf(address(this)); + uint256 balanceERC20Before = IERC20Token(tokens.USDT).balanceOf(address(this)); IZeroEx(payable(addresses.exchangeProxy)).transformERC20{value: 1e18}( // input token - IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS), + IERC20Token(LibERC20Transformer.ETH_TOKEN_ADDRESS), // output token - IERC20TokenV06(address(tokens.USDT)), + IERC20Token(address(tokens.USDT)), // input token amount 1e18, // min output token amount @@ -162,9 +162,9 @@ contract SwapEthForERC20Test is Test, ForkUtils, TestUtils { log_named_uint(" NativeAsset balance after", balanceETHBefore - address(this).balance); log_named_uint( " ERC-20 balance after", - IERC20TokenV06(tokens.USDT).balanceOf(address(this)) - balanceERC20Before + IERC20Token(tokens.USDT).balanceOf(address(this)) - balanceERC20Before ); - assert(IERC20TokenV06(tokens.USDT).balanceOf(address(this)) > 0); + assert(IERC20Token(tokens.USDT).balanceOf(address(this)) > 0); } else { emit log_string("Liquidity Source not available on this chain"); } diff --git a/contracts/zero-ex/tests/forked/WrapEthTest.t.sol b/contracts/zero-ex/tests/forked/WrapEthTest.t.sol index 8923392364..0ad736c93c 100644 --- a/contracts/zero-ex/tests/forked/WrapEthTest.t.sol +++ b/contracts/zero-ex/tests/forked/WrapEthTest.t.sol @@ -20,7 +20,7 @@ import "../utils/TestUtils.sol"; import "../utils/DeployZeroEx.sol"; import "forge-std/Test.sol"; import "src/IZeroEx.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; import "src/features/TransformERC20Feature.sol"; import "src/external/TransformerDeployer.sol"; import "src/transformers/WethTransformer.sol"; @@ -61,9 +61,9 @@ contract WrapEthTest is Test, ForkUtils, TestUtils { uint256 balanceWETHBefore = zeroExDeployed.weth.balanceOf(address(this)); zeroExDeployed.zeroEx.transformERC20{value: 1e18}( // input token - IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS), + IERC20Token(LibERC20Transformer.ETH_TOKEN_ADDRESS), // output token - IERC20TokenV06(address(zeroExDeployed.weth)), + IERC20Token(address(zeroExDeployed.weth)), // input token amount 1e18, // min output token amount diff --git a/contracts/zero-ex/tests/transformers/AffiliateFeeTransformerTest.t.sol b/contracts/zero-ex/tests/transformers/AffiliateFeeTransformerTest.t.sol index 3c895cfc79..19078503af 100644 --- a/contracts/zero-ex/tests/transformers/AffiliateFeeTransformerTest.t.sol +++ b/contracts/zero-ex/tests/transformers/AffiliateFeeTransformerTest.t.sol @@ -15,8 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/WETH9V06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/MintableERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/v06/WETH9V06.sol"; import "utils/BaseTest.sol"; import "../../contracts/src/transformers/AffiliateFeeTransformer.sol"; @@ -26,7 +25,7 @@ contract AffiliateFeeTransformerTest is BaseTest { address public owner = account1; address public feeRecipient = account2; WETH9V06 weth = new WETH9V06(); - IERC20TokenV06 token1 = IERC20TokenV06(address(weth)); + IERC20Token token1 = IERC20Token(address(weth)); AffiliateFeeTransformer target = new AffiliateFeeTransformer(); @@ -42,7 +41,7 @@ contract AffiliateFeeTransformerTest is BaseTest { AffiliateFeeTransformer.TokenFee[] memory fees = new AffiliateFeeTransformer.TokenFee[](1); fees[0] = AffiliateFeeTransformer.TokenFee({ - token: IERC20TokenV06(token1), + token: IERC20Token(token1), amount: affiliateFeeAmount, recipient: payable(feeRecipient) }); @@ -64,7 +63,7 @@ contract AffiliateFeeTransformerTest is BaseTest { AffiliateFeeTransformer.TokenFee[] memory fees = new AffiliateFeeTransformer.TokenFee[](1); fees[0] = AffiliateFeeTransformer.TokenFee({ - token: IERC20TokenV06(token1), + token: IERC20Token(token1), amount: uint256(-1), recipient: payable(feeRecipient) }); @@ -86,13 +85,13 @@ contract AffiliateFeeTransformerTest is BaseTest { AffiliateFeeTransformer.TokenFee[] memory fees = new AffiliateFeeTransformer.TokenFee[](2); fees[0] = AffiliateFeeTransformer.TokenFee({ - token: IERC20TokenV06(token1), + token: IERC20Token(token1), amount: uint256(1), recipient: payable(feeRecipient) }); fees[1] = AffiliateFeeTransformer.TokenFee({ - token: IERC20TokenV06(token1), + token: IERC20Token(token1), amount: uint256(1), recipient: payable(feeRecipient) }); @@ -115,7 +114,7 @@ contract AffiliateFeeTransformerTest is BaseTest { AffiliateFeeTransformer.TokenFee[] memory fees = new AffiliateFeeTransformer.TokenFee[](1); fees[0] = AffiliateFeeTransformer.TokenFee({ - token: IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS), + token: IERC20Token(LibERC20Transformer.ETH_TOKEN_ADDRESS), amount: uint256(1), recipient: payable(feeRecipient) }); @@ -140,13 +139,13 @@ contract AffiliateFeeTransformerTest is BaseTest { AffiliateFeeTransformer.TokenFee[] memory fees = new AffiliateFeeTransformer.TokenFee[](2); fees[0] = AffiliateFeeTransformer.TokenFee({ - token: IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS), + token: IERC20Token(LibERC20Transformer.ETH_TOKEN_ADDRESS), amount: uint256(1), recipient: payable(feeRecipient) }); fees[1] = AffiliateFeeTransformer.TokenFee({ - token: IERC20TokenV06(token1), + token: IERC20Token(token1), amount: uint256(1), recipient: payable(feeRecipient) }); @@ -169,7 +168,7 @@ contract AffiliateFeeTransformerTest is BaseTest { AffiliateFeeTransformer.TokenFee[] memory fees = new AffiliateFeeTransformer.TokenFee[](1); fees[0] = AffiliateFeeTransformer.TokenFee({ - token: IERC20TokenV06(token1), + token: IERC20Token(token1), amount: 0, recipient: payable(feeRecipient) }); diff --git a/contracts/zero-ex/tests/transformers/PositiveSlippageFeeTransformerTest.t.sol b/contracts/zero-ex/tests/transformers/PositiveSlippageFeeTransformerTest.t.sol index e8f4ac3630..3189fea02d 100644 --- a/contracts/zero-ex/tests/transformers/PositiveSlippageFeeTransformerTest.t.sol +++ b/contracts/zero-ex/tests/transformers/PositiveSlippageFeeTransformerTest.t.sol @@ -15,7 +15,7 @@ pragma solidity ^0.6.5; pragma experimental ABIEncoderV2; -import "@0x/contracts-erc20/contracts/src/v06/WETH9V06.sol"; +import "@0x/contracts-erc20/src/v06/WETH9V06.sol"; import "utils/BaseTest.sol"; import "../../contracts/src/transformers/PositiveSlippageFeeTransformer.sol"; @@ -25,7 +25,7 @@ contract PositiveSlippageFeeTransformerTest is BaseTest { address public owner = account1; address public feeRecipient = account2; WETH9V06 weth = new WETH9V06(); - IERC20TokenV06 token1 = IERC20TokenV06(address(weth)); + IERC20Token token1 = IERC20Token(address(weth)); PositiveSlippageFeeTransformer target = new PositiveSlippageFeeTransformer(); @@ -45,7 +45,7 @@ contract PositiveSlippageFeeTransformerTest is BaseTest { recipient: payable(address(this)), data: abi.encode( PositiveSlippageFeeTransformer.TokenFee({ - token: IERC20TokenV06(token1), + token: IERC20Token(token1), bestCaseAmount: bestCaseAmount, recipient: payable(feeRecipient) }) @@ -66,7 +66,7 @@ contract PositiveSlippageFeeTransformerTest is BaseTest { recipient: payable(address(this)), data: abi.encode( PositiveSlippageFeeTransformer.TokenFee({ - token: IERC20TokenV06(token1), + token: IERC20Token(token1), bestCaseAmount: bestCaseAmount, recipient: payable(feeRecipient) }) @@ -87,7 +87,7 @@ contract PositiveSlippageFeeTransformerTest is BaseTest { recipient: payable(address(this)), data: abi.encode( PositiveSlippageFeeTransformer.TokenFee({ - token: IERC20TokenV06(token1), + token: IERC20Token(token1), bestCaseAmount: bestCaseAmount, recipient: payable(feeRecipient) }) diff --git a/contracts/zero-ex/tests/utils/DeployZeroEx.sol b/contracts/zero-ex/tests/utils/DeployZeroEx.sol index a7e04b33cb..bb176fd580 100644 --- a/contracts/zero-ex/tests/utils/DeployZeroEx.sol +++ b/contracts/zero-ex/tests/utils/DeployZeroEx.sol @@ -42,8 +42,8 @@ import "src/transformers/PositiveSlippageFeeTransformer.sol"; import "src/transformers/bridges/IBridgeAdapter.sol"; import "src/transformers/bridges/EthereumBridgeAdapter.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/WETH9V06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; +import "@0x/contracts-erc20/src/v06/WETH9V06.sol"; contract DeployZeroEx is Test { ZeroEx public ZERO_EX = ZeroEx(0xDef1C0ded9bec7F1a1670819833240f027b25EfF); @@ -84,7 +84,7 @@ contract DeployZeroEx is Test { IStaking staking; // address(0) Features features; Transformers transformers; - IEtherTokenV06 weth; + IEtherToken weth; } ZeroExDeployed ZERO_EX_DEPLOYED; @@ -136,7 +136,7 @@ contract DeployZeroEx is Test { return ZERO_EX_DEPLOYED; } - ZERO_EX_DEPLOYED.weth = IEtherTokenV06(address(new WETH9V06())); + ZERO_EX_DEPLOYED.weth = IEtherToken(address(new WETH9V06())); InitialMigration initialMigration = new InitialMigration(address(this)); // Append the required ZeroEx constructor arguments (address bootstrapper) bytes memory zeroExDeploycode = abi.encodePacked(type(ZeroEx).creationCode, abi.encode(initialMigration)); @@ -158,7 +158,7 @@ contract DeployZeroEx is Test { ZERO_EX_DEPLOYED.staking = IStaking(address(0)); ZERO_EX_DEPLOYED.transformerDeployer = new TransformerDeployer(transformerSigners); ZERO_EX_DEPLOYED.feeCollectorController = new FeeCollectorController( - IEtherTokenV06(ZERO_EX_DEPLOYED.weth), + IEtherToken(ZERO_EX_DEPLOYED.weth), IStaking(ZERO_EX_DEPLOYED.staking) ); diff --git a/contracts/zero-ex/tests/utils/ForkUtils.sol b/contracts/zero-ex/tests/utils/ForkUtils.sol index 70ee39eb4d..c232d63747 100644 --- a/contracts/zero-ex/tests/utils/ForkUtils.sol +++ b/contracts/zero-ex/tests/utils/ForkUtils.sol @@ -20,8 +20,8 @@ import "src/features/TransformERC20Feature.sol"; import "src/external/TransformerDeployer.sol"; import "src/transformers/WethTransformer.sol"; import "src/transformers/FillQuoteTransformer.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol"; -import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; +import "@0x/contracts-erc20/src/IEtherToken.sol"; +import "@0x/contracts-erc20/src/IERC20Token.sol"; import "src/transformers/bridges/BridgeProtocols.sol"; import "src/transformers/bridges/EthereumBridgeAdapter.sol"; import "src/transformers/bridges/PolygonBridgeAdapter.sol"; @@ -82,10 +82,10 @@ struct Addresses { } struct TokenAddresses { - IERC20TokenV06 DAI; - IERC20TokenV06 USDC; - IERC20TokenV06 USDT; - IEtherTokenV06 WrappedNativeToken; + IERC20Token DAI; + IERC20Token USDC; + IERC20Token USDT; + IEtherToken WrappedNativeToken; } struct LiquiditySources { @@ -146,13 +146,13 @@ interface IUniswapV3QuoterV2 { } interface IUniswapV3Factory { - function getPool(IERC20TokenV06 a, IERC20TokenV06 b, uint24 fee) external view returns (IUniswapV3Pool pool); + function getPool(IERC20Token a, IERC20Token b, uint24 fee) external view returns (IUniswapV3Pool pool); } interface IUniswapV3Pool { - function token0() external view returns (IERC20TokenV06); + function token0() external view returns (IERC20Token); - function token1() external view returns (IERC20TokenV06); + function token1() external view returns (IERC20Token); function fee() external view returns (uint24); } @@ -253,7 +253,7 @@ contract ForkUtils is Test { } //creates the appropriate bridge adapter based on what chain the tests are currently executing on. - function createBridgeAdapter(IEtherTokenV06 weth) public returns (IBridgeAdapter bridgeAdapter) { + function createBridgeAdapter(IEtherToken weth) public returns (IBridgeAdapter bridgeAdapter) { uint chainId; assembly { @@ -317,13 +317,13 @@ contract ForkUtils is Test { //deploy a new FillQuoteTransformer //executes in the context of the transformerDeployer function createNewFQT( - IEtherTokenV06 wrappedNativeToken, + IEtherToken wrappedNativeToken, address payable exchangeProxy, address transformerDeployer ) public { vm.startPrank(transformerDeployer); // deploy a new instance of the bridge adapter from the transformerDeployer - bridgeAdapter = createBridgeAdapter(IEtherTokenV06(wrappedNativeToken)); + bridgeAdapter = createBridgeAdapter(IEtherToken(wrappedNativeToken)); // deploy a new instance of the fill quote transformer from the transformerDeployer fillQuoteTransformer = new FillQuoteTransformer(IBridgeAdapter(bridgeAdapter), IZeroEx(exchangeProxy)); vm.label(address(fillQuoteTransformer), "zeroEx/FillQuoteTransformer"); @@ -412,7 +412,7 @@ contract ForkUtils is Test { /// @return makerTokenAmounts Maker amounts bought at each taker token amount. function sampleSellsFromUniswapV3( IUniswapV3QuoterV2 quoter, - IERC20TokenV06[] memory path, + IERC20Token[] memory path, uint256[] memory takerTokenAmounts ) public @@ -471,13 +471,13 @@ contract ForkUtils is Test { /// @return takerTokenAmounts Taker amounts sold at each maker token amount. function sampleBuysFromUniswapV3( IUniswapV3QuoterV2 quoter, - IERC20TokenV06[] memory path, + IERC20Token[] memory path, uint256[] memory makerTokenAmounts ) public returns (bytes[] memory uniswapPaths, uint256[] memory uniswapGasUsed, uint256[] memory takerTokenAmounts) { - IERC20TokenV06[] memory reversedPath = _reverseTokenPath(path); + IERC20Token[] memory reversedPath = _reverseTokenPath(path); IUniswapV3Pool[][] memory poolPaths = _getPoolPaths( quoter, reversedPath, @@ -526,7 +526,7 @@ contract ForkUtils is Test { function _getPoolPaths( IUniswapV3QuoterV2 quoter, - IERC20TokenV06[] memory path, + IERC20Token[] memory path, uint256 inputAmount ) private returns (IUniswapV3Pool[][] memory poolPaths) { if (path.length == 2) { @@ -540,7 +540,7 @@ contract ForkUtils is Test { function _getPoolPathSingleHop( IUniswapV3QuoterV2 quoter, - IERC20TokenV06[] memory path, + IERC20Token[] memory path, uint256 inputAmount ) public returns (IUniswapV3Pool[][] memory poolPaths) { poolPaths = new IUniswapV3Pool[][](2); @@ -563,7 +563,7 @@ contract ForkUtils is Test { function _getPoolPathTwoHop( IUniswapV3QuoterV2 quoter, - IERC20TokenV06[] memory path, + IERC20Token[] memory path, uint256 inputAmount ) private returns (IUniswapV3Pool[][] memory poolPaths) { IUniswapV3Factory factory = quoter.factory(); @@ -600,11 +600,11 @@ contract ForkUtils is Test { function _getTopTwoPools( IUniswapV3QuoterV2 quoter, IUniswapV3Factory factory, - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 inputAmount ) private returns (IUniswapV3Pool[2] memory topPools, uint256[2] memory outputAmounts) { - IERC20TokenV06[] memory path = new IERC20TokenV06[](2); + IERC20Token[] memory path = new IERC20Token[](2); path[0] = inputToken; path[1] = outputToken; @@ -638,10 +638,8 @@ contract ForkUtils is Test { } } - function _reverseTokenPath( - IERC20TokenV06[] memory tokenPath - ) private pure returns (IERC20TokenV06[] memory reversed) { - reversed = new IERC20TokenV06[](tokenPath.length); + function _reverseTokenPath(IERC20Token[] memory tokenPath) private pure returns (IERC20Token[] memory reversed) { + reversed = new IERC20Token[](tokenPath.length); for (uint256 i = 0; i < tokenPath.length; ++i) { reversed[i] = tokenPath[tokenPath.length - i - 1]; } @@ -687,7 +685,7 @@ contract ForkUtils is Test { } function _toUniswapPath( - IERC20TokenV06[] memory tokenPath, + IERC20Token[] memory tokenPath, IUniswapV3Pool[] memory poolPath ) private view returns (bytes memory uniswapPath) { require( @@ -709,7 +707,7 @@ contract ForkUtils is Test { o := add(o, 3) } } - IERC20TokenV06 token = tokenPath[i]; + IERC20Token token = tokenPath[i]; assembly { mstore(o, shl(96, token)) o := add(o, 20) diff --git a/docs/advanced/erc20_transformations.rst b/docs/advanced/erc20_transformations.rst index a0ebaa7acc..d75b7153d0 100644 --- a/docs/advanced/erc20_transformations.rst +++ b/docs/advanced/erc20_transformations.rst @@ -25,8 +25,8 @@ Anyone can run transformations using the ``transformERC20`` Exchange function. /// in sequence. /// @return outputTokenAmount The amount of `outputToken` received by the sender. function transformERC20( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 inputTokenAmount, uint256 minOutputTokenAmount, Transformation[] memory transformations @@ -76,10 +76,10 @@ Below are just a few of the Supported DEX's on Ethereum: This transformation is implemented by the `FillQuoteTransformer <../architecture/transformers.html>`_. Abi-Encode the following struct to get the ``data``: -.. warning:: +.. warning:: An upgrade is pending to this transformation. This currently uses Exchange V3 Orders, but will soon be updated to use `V4 Orders <../basics/orders.html>`_. - 11/26/2020 -.. code-block:: solidity +.. code-block:: solidity /// @dev Transform data to ABI-encode and pass into `transform()`. struct TransformData { @@ -87,10 +87,10 @@ This transformation is implemented by the `FillQuoteTransformer <../architecture Side side; // The token being sold. // This should be an actual token, not the ETH pseudo-token. - IERC20TokenV06 sellToken; + IERC20Token sellToken; // The token being bought. // This should be an actual token, not the ETH pseudo-token. - IERC20TokenV06 buyToken; + IERC20Token buyToken; // The orders to fill. IExchange.Order[] orders; // Signatures for each respective order in `orders`. @@ -128,7 +128,7 @@ This transformation is implemented by the `WethTransformer <../architecture/tran /// @dev Transform data to ABI-encode and pass into `transform()`. struct TransformData { // The token to wrap/unwrap. Must be either ETH or WETH. - IERC20TokenV06 token; + IERC20Token token; // Amount of `token` to wrap or unwrap. // `uint(-1)` will unwrap the entire balance. uint256 amount; @@ -146,7 +146,7 @@ This transformation is implemented by the `AffiliateFeeTransformer <../architect /// @dev Information for a single fee. struct TokenFee { // The token to transfer to `recipient`. - IERC20TokenV06 token; + IERC20Token token; // Amount of each `token` to transfer to `recipient`. // If `amount == uint256(-1)`, the entire balance of `token` will be // transferred. @@ -167,7 +167,7 @@ This transformation is implemented by the `PayTakerTransformer <../architecture/ /// @dev Transform data to ABI-encode and pass into `transform()`. struct TransformData { // The tokens to transfer to the taker. - IERC20TokenV06[] tokens; + IERC20Token[] tokens; // Amount of each token in `tokens` to transfer to the taker. // `uint(-1)` will transfer the entire balance. uint256[] amounts; @@ -179,4 +179,4 @@ No events are emitted by 0x during this transformation, although token contracts Adding Custom Transformations ----------------------------- -Transformations are trustless, but at this time they are permissioned so only 0x Labs can deploy new Transformers. If you are interested in deploying your own transformation logic, please reach out to us on `Discord `_. Learn more about why this is permissioned in the `Transformer Deployer <../architecture/transformer_deployer.html>`_ section. \ No newline at end of file +Transformations are trustless, but at this time they are permissioned so only 0x Labs can deploy new Transformers. If you are interested in deploying your own transformation logic, please reach out to us on `Discord `_. Learn more about why this is permissioned in the `Transformer Deployer <../architecture/transformer_deployer.html>`_ section. diff --git a/docs/advanced/mtx.rst b/docs/advanced/mtx.rst index 9844ecc671..43bbb23fc9 100644 --- a/docs/advanced/mtx.rst +++ b/docs/advanced/mtx.rst @@ -38,7 +38,7 @@ To construct a Meta-Transaction, abi-encode the following struct and sign it. // Amount of ETH to attach to the call. uint256 value; // ERC20 fee `signer` pays `sender`. - IERC20TokenV06 feeToken; + IERC20Token feeToken; // ERC20 fee amount. uint256 feeAmount; } diff --git a/docs/advanced/uniswap.rst b/docs/advanced/uniswap.rst index aa11d536e2..007cf411e3 100644 --- a/docs/advanced/uniswap.rst +++ b/docs/advanced/uniswap.rst @@ -13,7 +13,7 @@ The 0x Protocol is equipped with a highly optimized `UniswapV2 Router `_ for information on events/reverts/allowances. .. note:: - This function does not use allowances set on 0x. The ``msg.sender`` must have allowances set on Uniswap (or SushiSwap). \ No newline at end of file + This function does not use allowances set on 0x. The ``msg.sender`` must have allowances set on Uniswap (or SushiSwap). diff --git a/docs/basics/events.rst b/docs/basics/events.rst index 26ede11dd2..c2e93dcc3c 100644 --- a/docs/basics/events.rst +++ b/docs/basics/events.rst @@ -98,8 +98,8 @@ ERC20BridgeTransfer /// @param from The bridge address, indicating the underlying source of the fill. /// @param to The `to` address, currrently `address(this)` event ERC20BridgeTransfer( - IERC20TokenV06 inputToken, - IERC20TokenV06 outputToken, + IERC20Token inputToken, + IERC20Token outputToken, uint256 inputTokenAmount, uint256 outputTokenAmount, address from, @@ -409,7 +409,7 @@ ERC721OrderFilled address maker, address taker, uint256 nonce, - IERC20TokenV06 erc20Token, + IERC20Token erc20Token, uint256 erc20TokenAmount, IERC721Token erc721Token, uint256 erc721TokenId, @@ -443,7 +443,7 @@ ERC721OrderPreSigned address taker, uint256 expiry, uint256 nonce, - IERC20TokenV06 erc20Token, + IERC20Token erc20Token, uint256 erc20TokenAmount, LibNFTOrder.Fee[] fees, IERC721Token erc721Token, @@ -473,7 +473,7 @@ ERC1155OrderFilled address maker, address taker, uint256 nonce, - IERC20TokenV06 erc20Token, + IERC20Token erc20Token, uint256 erc20FillAmount, IERC1155Token erc1155Token, uint256 erc1155TokenId, @@ -507,7 +507,7 @@ ERC1155OrderPreSigned address taker, uint256 expiry, uint256 nonce, - IERC20TokenV06 erc20Token, + IERC20Token erc20Token, uint256 erc20TokenAmount, LibNFTOrder.Fee[] fees, IERC1155Token erc1155Token, diff --git a/docs/basics/functions.rst b/docs/basics/functions.rst index faf2b48451..5c6b6ef6ed 100644 --- a/docs/basics/functions.rst +++ b/docs/basics/functions.rst @@ -236,8 +236,8 @@ Same functionality as ``cancelPairLimitOrders`` but ``msg.sender`` is a register /// @param minValidSalt The new minimum valid salt. function cancelPairLimitOrdersWithSigner( address maker, - IERC20TokenV06 makerToken, - IERC20TokenV06 takerToken, + IERC20Token makerToken, + IERC20Token takerToken, uint256 minValidSalt ) external; @@ -277,8 +277,8 @@ Same functionality as ``batchCancelPairLimitOrders`` but ``msg.sender`` is a reg /// @param minValidSalts The new minimum valid salts. function batchCancelPairLimitOrdersWithSigner( address maker, - IERC20TokenV06[] memory makerTokens, - IERC20TokenV06[] memory takerTokens, + IERC20Token[] memory makerTokens, + IERC20Token[] memory takerTokens, uint256[] memory minValidSalts ) external; @@ -521,8 +521,8 @@ Same functionality as ``cancelPairRfqOrders`` but ``msg.sender`` is a registered /// @param minValidSalt The new minimum valid salt. function cancelPairRfqOrdersWithSigner( address maker, - IERC20TokenV06 makerToken, - IERC20TokenV06 takerToken, + IERC20Token makerToken, + IERC20Token takerToken, uint256 minValidSalt ) external; @@ -562,8 +562,8 @@ Same functionality as ``batchCancelPairRfqOrders`` but ``msg.sender`` is a regis /// @param minValidSalts The new minimum valid salts. function batchCancelPairRfqOrdersWithSigner( address maker, - IERC20TokenV06[] memory makerTokens, - IERC20TokenV06[] memory takerTokens, + IERC20Token[] memory makerTokens, + IERC20Token[] memory takerTokens, uint256[] memory minValidSalts ) external; @@ -818,7 +818,7 @@ This function buys an ERC721 token given a sell order. .. code-block:: solidity - + /// @dev Buys an ERC721 asset by filling the given order. /// @param sellOrder The ERC721 sell order. /// @param signature The order signature. @@ -843,7 +843,7 @@ cancelERC721Order This function cancels an ERC721 order using the order `nonce` field. .. code-block:: solidity - + /// @dev Cancel a single ERC721 order by its nonce. The caller /// should be the maker of the order. Silently succeeds if /// an order with the same nonce has already been filled or @@ -874,7 +874,7 @@ batchBuyERC721s This function buys a number of ERC721's. If you wish the transaction to revert unless ALL NFT's are purchased, set `revertIfIncomplete` to true. .. code-block:: solidity - + /// @dev Buys multiple ERC721 assets by filling the /// given orders. /// @param sellOrders The ERC721 sell orders. @@ -898,7 +898,7 @@ matchERC721Orders This function matches a buy order and a sell order together. The matcher receives any spread in price. .. code-block:: solidity - + /// @dev Matches a pair of complementary orders that have /// a non-negative spread. Each order is filled at /// their respective price, and the matcher receives @@ -926,7 +926,7 @@ batchMatchERC721Orders This function matches a buy orders and a sell orders together. The matcher receives any spread in price. .. code-block:: solidity - + /// @dev Matches pairs of complementary orders that have /// non-negative spreads. Each order is filled at /// their respective price, and the matcher receives @@ -948,8 +948,8 @@ This function matches a buy orders and a sell orders together. The matcher recei ) _external_ returns (uint256[] _memory_ profits, bool[] _memory_ successes); - - + + preSignERC721Order ---------------------------- @@ -962,7 +962,7 @@ This function pre-signs an order. Useful for contracts that wish to buy or sell /// valid for that order and signer. /// @param order An ERC721 order. function preSignERC721Order(LibNFTOrder.ERC721Order _calldata_ order) - _external_; + _external_; validateERC721OrderSignature ---------------------------- @@ -981,7 +981,7 @@ A read function to validate an ERC721 order signature. ) _external_ _view_; - + validateERC721OrderProperties --------------------------------- @@ -1013,7 +1013,7 @@ getERC721OrderStatus A read function to return the order status. E.g whether it is filled, cancelled or expired. .. code-block:: solidity - + /// @dev Get the current status of an ERC721 order. /// @param order The ERC721 order. /// @return status The status of the order. @@ -1021,7 +1021,7 @@ A read function to return the order status. E.g whether it is filled, cancelled _external_ _view_ returns (LibNFTOrder.OrderStatus status); - + getERC721OrderHash ---------------------------- @@ -1037,7 +1037,7 @@ A read function to return the uniquie order hash. _external_ _view_ returns (bytes32 orderHash); - + getERC721OrderStatusBitVector --------------------------------- @@ -1060,7 +1060,7 @@ getERC721OrderStatusBitVector sellERC1155 ---------------------------- -Sells an ERC115 token given a buy order. +Sells an ERC115 token given a buy order. .. code-block:: solidity @@ -1089,12 +1089,12 @@ Sells an ERC115 token given a buy order. bytes _calldata_ callbackData ) _external_; - + buyERC1155 ---------------------------- -Buys an ERC115 token given a sell order. +Buys an ERC115 token given a sell order. .. code-block:: solidity @@ -1117,12 +1117,12 @@ Buys an ERC115 token given a sell order. ) _external_ _payable_; - + cancelERC1155Order ---------------------------- -Cancels an ERC115 order given the order struct. +Cancels an ERC115 order given the order struct. .. code-block:: solidity @@ -1136,7 +1136,7 @@ Cancels an ERC115 order given the order struct. batchCancelERC1155Orders ---------------------------- -Cancels a number of ERC115 orders. +Cancels a number of ERC115 orders. .. code-block:: solidity @@ -1146,7 +1146,7 @@ Cancels a number of ERC115 orders. /// @param orders The orders to cancel. function batchCancelERC1155Orders(LibNFTOrder.ERC1155Order[] _calldata_ orders) _external_; - + batchBuyERC1155s ---------------------------- @@ -1173,7 +1173,7 @@ Buys multiple ERC1155 assets given the sell orders. _external_ _payable_ returns (bool[] _memory_ successes); - + preSignERC1155Order ---------------------------- @@ -1259,4 +1259,4 @@ A read function to calculate the unique order hash. function getERC1155OrderHash(LibNFTOrder.ERC1155Order calldata order) external view - returns (bytes32 orderHash); \ No newline at end of file + returns (bytes32 orderHash); diff --git a/package.json b/package.json index 03b95a0d52..6d43c22480 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "test:all": "wsrun --fast-exit --serial --exclude-missing -p $PKG -c test", "test:contracts": "wsrun --serial -p $(echo ${npm_package_config_contractsPackages} ${npm_package_config_ignoreTestsForPackages} | tr ' ' '\n' | sort | uniq -u | tr '\n' ' ') --fast-exit --exclude-missing -c test", "test:contracts:all": "wsrun --serial -p ${npm_package_config_contractsPackages} --fast-exit --exclude-missing -c test", - "test:links": "yarn check-md --ignore **/contracts/zero-ex/contracts/deps/forge-std/README.md,**/node_modules", + "test:links": "yarn check-md --ignore **/forge-std/README.md,**/lib/openzeppelin-contracts,**/node_modules", "generate_doc": "node ./node_modules/@0x/monorepo-scripts/lib/doc_generate.js --config ./doc-gen-config.json", "upload_md_docs": "aws s3 rm --recursive s3://docs-markdown; wsrun --exclude-missing -c s3:sync_md_docs", "diff_md_docs:ci": "wsrun --exclude-missing -c diff_docs", diff --git a/tsconfig.json b/tsconfig.json index 7f10a174d0..dca2b5a38c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,12 +21,10 @@ // any top-level TypeScript code. "include": [], "references": [ - { "path": "./contracts/erc20" }, { "path": "./contracts/test-utils" }, { "path": "./contracts/utils" }, { "path": "./packages/contract-addresses" }, { "path": "./packages/contract-artifacts" }, - { "path": "./packages/contract-wrappers" }, - { "path": "./packages/migrations" } + { "path": "./packages/contract-wrappers" } ] } diff --git a/yarn.lock b/yarn.lock index cef4671c6b..55aa646505 100644 --- a/yarn.lock +++ b/yarn.lock @@ -807,6 +807,14 @@ "@0x/web3-wrapper" "^7.5.3" lodash "^4.17.11" +"@0x/contracts-erc20@3.3.57", "@0x/contracts-erc20@^3.3.16", "@0x/contracts-erc20@^3.3.57": + version "3.3.57" + resolved "https://registry.yarnpkg.com/@0x/contracts-erc20/-/contracts-erc20-3.3.57.tgz#4f41a29858f2acb8dd243b49686ea6c3b4005b56" + integrity sha512-HFdfgTiqMJN7tPVn26udMLPdtR6iCa0UACJzhmXCcNLPAne+sRuKMfNN3i28+3GsmFdSsi3tuYrU9E5vaI+Ljw== + dependencies: + "@0x/base-contract" "^7.0.0" + ethers "~4.0.4" + "@0x/contracts-erc721@^3.1.37": version "3.1.37" resolved "https://registry.yarnpkg.com/@0x/contracts-erc721/-/contracts-erc721-3.1.37.tgz#d7d356737e3d2752cf49be385237fbf7d0c5745c" @@ -4220,9 +4228,9 @@ before-after-hook@^2.0.0: integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ== bignumber.js@7.2.1, bignumber.js@^9.0.1, bignumber.js@^9.0.2, bignumber.js@~9.0.0, bignumber.js@~9.0.2: - version "9.1.0" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.0.tgz#8d340146107fe3a6cb8d40699643c302e8773b62" - integrity sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A== + version "9.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6" + integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig== binary-extensions@^2.0.0: version "2.2.0"