ERC20BridgeSampler: Gas limits (#2405)
* `@0x/contracts-erc20-bridge-sampler`: Add gas limits to external quote calls. `@0x/contract-addresses`: Point `erc20BridgeSampler` to new version. * `@0x/contracts-utils`: Add kovan addresses to `DeploymentConstants`. `@0x/contract-addresses`: Add kovan `ERC20BridgeSampler` address. * `@0x/contracts-erc20-bridge-sampler`: Fix changelog. * `@0x/contracts-erc20-bridge-contracts`: Fix invalid CHANGELOG json (I hope).
This commit is contained in:
		@@ -1,10 +1,19 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "version": "1.0.3",
 | 
			
		||||
        "changes": [
 | 
			
		||||
            {
 | 
			
		||||
                "note": "Add gas limits to external quote calls.",
 | 
			
		||||
                "pr": 2405
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "version": "1.0.2",
 | 
			
		||||
        "changes": [
 | 
			
		||||
            {
 | 
			
		||||
                "note": "Do not query empty/unsigned orders. Swallow revets on DEX quotes.",
 | 
			
		||||
                "pr": 2365
 | 
			
		||||
                "pr": 2395
 | 
			
		||||
            }
 | 
			
		||||
        ],
 | 
			
		||||
        "timestamp": 1576540892
 | 
			
		||||
 
 | 
			
		||||
@@ -37,6 +37,9 @@ contract ERC20BridgeSampler is
 | 
			
		||||
    DeploymentConstants
 | 
			
		||||
{
 | 
			
		||||
    bytes4 constant internal ERC20_PROXY_ID = 0xf47261b0; // bytes4(keccak256("ERC20Token(address)"));
 | 
			
		||||
    uint256 constant internal KYBER_SAMPLE_CALL_GAS = 600e3;
 | 
			
		||||
    uint256 constant internal UNISWAP_SAMPLE_CALL_GAS = 150e3;
 | 
			
		||||
    uint256 constant internal ETH2DAI_SAMPLE_CALL_GAS = 250e3;
 | 
			
		||||
 | 
			
		||||
    /// @dev Query native orders and sample sell quotes on multiple DEXes at once.
 | 
			
		||||
    /// @param orders Native orders to query.
 | 
			
		||||
@@ -268,7 +271,8 @@ contract ERC20BridgeSampler is
 | 
			
		||||
        makerTokenAmounts = new uint256[](numSamples);
 | 
			
		||||
        for (uint256 i = 0; i < numSamples; i++) {
 | 
			
		||||
            (bool didSucceed, bytes memory resultData) =
 | 
			
		||||
                _getKyberNetworkProxyAddress().staticcall(abi.encodeWithSelector(
 | 
			
		||||
                _getKyberNetworkProxyAddress().staticcall.gas(KYBER_SAMPLE_CALL_GAS)(
 | 
			
		||||
                    abi.encodeWithSelector(
 | 
			
		||||
                        IKyberNetwork(0).getExpectedRate.selector,
 | 
			
		||||
                        _takerToken,
 | 
			
		||||
                        _makerToken,
 | 
			
		||||
@@ -307,7 +311,8 @@ contract ERC20BridgeSampler is
 | 
			
		||||
        makerTokenAmounts = new uint256[](numSamples);
 | 
			
		||||
        for (uint256 i = 0; i < numSamples; i++) {
 | 
			
		||||
            (bool didSucceed, bytes memory resultData) =
 | 
			
		||||
                _getEth2DaiAddress().staticcall(abi.encodeWithSelector(
 | 
			
		||||
                _getEth2DaiAddress().staticcall.gas(ETH2DAI_SAMPLE_CALL_GAS)(
 | 
			
		||||
                    abi.encodeWithSelector(
 | 
			
		||||
                        IEth2Dai(0).getBuyAmount.selector,
 | 
			
		||||
                        makerToken,
 | 
			
		||||
                        takerToken,
 | 
			
		||||
@@ -341,7 +346,8 @@ contract ERC20BridgeSampler is
 | 
			
		||||
        takerTokenAmounts = new uint256[](numSamples);
 | 
			
		||||
        for (uint256 i = 0; i < numSamples; i++) {
 | 
			
		||||
            (bool didSucceed, bytes memory resultData) =
 | 
			
		||||
                _getEth2DaiAddress().staticcall(abi.encodeWithSelector(
 | 
			
		||||
                _getEth2DaiAddress().staticcall.gas(ETH2DAI_SAMPLE_CALL_GAS)(
 | 
			
		||||
                    abi.encodeWithSelector(
 | 
			
		||||
                        IEth2Dai(0).getPayAmount.selector,
 | 
			
		||||
                        takerToken,
 | 
			
		||||
                        makerToken,
 | 
			
		||||
@@ -493,7 +499,8 @@ contract ERC20BridgeSampler is
 | 
			
		||||
            return 0;
 | 
			
		||||
        }
 | 
			
		||||
        (bool didSucceed, bytes memory resultData) =
 | 
			
		||||
            uniswapExchangeAddress.staticcall(abi.encodeWithSelector(
 | 
			
		||||
            uniswapExchangeAddress.staticcall.gas(UNISWAP_SAMPLE_CALL_GAS)(
 | 
			
		||||
                abi.encodeWithSelector(
 | 
			
		||||
                    functionSelector,
 | 
			
		||||
                    inputAmount
 | 
			
		||||
                ));
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,9 @@ import { ContractArtifact } from 'ethereum-types';
 | 
			
		||||
 | 
			
		||||
import * as ERC20BridgeSampler from '../generated-artifacts/ERC20BridgeSampler.json';
 | 
			
		||||
import * as IERC20BridgeSampler from '../generated-artifacts/IERC20BridgeSampler.json';
 | 
			
		||||
import * as IKyberNetwork from '../generated-artifacts/IKyberNetwork.json';
 | 
			
		||||
export const artifacts = {
 | 
			
		||||
    ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
 | 
			
		||||
    IERC20BridgeSampler: IERC20BridgeSampler as ContractArtifact,
 | 
			
		||||
    IKyberNetwork: IKyberNetwork as ContractArtifact,
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -5,3 +5,4 @@
 | 
			
		||||
 */
 | 
			
		||||
export * from '../generated-wrappers/erc20_bridge_sampler';
 | 
			
		||||
export * from '../generated-wrappers/i_erc20_bridge_sampler';
 | 
			
		||||
export * from '../generated-wrappers/i_kyber_network';
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
    "files": [
 | 
			
		||||
        "generated-artifacts/ERC20BridgeSampler.json",
 | 
			
		||||
        "generated-artifacts/IERC20BridgeSampler.json",
 | 
			
		||||
        "generated-artifacts/IKyberNetwork.json",
 | 
			
		||||
        "test/generated-artifacts/ERC20BridgeSampler.json",
 | 
			
		||||
        "test/generated-artifacts/IDevUtils.json",
 | 
			
		||||
        "test/generated-artifacts/IERC20BridgeSampler.json",
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,8 @@ import "./LibRichErrors.sol";
 | 
			
		||||
contract DeploymentConstants {
 | 
			
		||||
    /// @dev Mainnet address of the WETH contract.
 | 
			
		||||
    address constant private WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
 | 
			
		||||
    // /// @dev Kovan address of the WETH contract.
 | 
			
		||||
    // address constant private WETH_ADDRESS = 0xd0A1E359811322d97991E03f863a0C30C2cF029C;
 | 
			
		||||
    /// @dev Mainnet address of the KyberNeworkProxy contract.
 | 
			
		||||
    address constant private KYBER_NETWORK_PROXY_ADDRESS = 0x818E6FECD516Ecc3849DAf6845e3EC868087B755;
 | 
			
		||||
    /// @dev Mainnet address of the `UniswapExchangeFactory` contract.
 | 
			
		||||
@@ -34,12 +36,16 @@ contract DeploymentConstants {
 | 
			
		||||
    address constant private ETH2DAI_ADDRESS = 0x39755357759cE0d7f32dC8dC45414CCa409AE24e;
 | 
			
		||||
    /// @dev Mainnet address of the `ERC20BridgeProxy` contract
 | 
			
		||||
    address constant private ERC20_BRIDGE_PROXY_ADDRESS = 0x8ED95d1746bf1E4dAb58d8ED4724f1Ef95B20Db0;
 | 
			
		||||
    // /// @dev Kovan address of the `ERC20BridgeProxy` contract
 | 
			
		||||
    // address constant private ERC20_BRIDGE_PROXY_ADDRESS = 0xFb2DD2A1366dE37f7241C83d47DA58fd503E2C64;
 | 
			
		||||
    ///@dev Mainnet address of the `Dai` (multi-collateral) contract
 | 
			
		||||
    address constant private DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
 | 
			
		||||
    /// @dev Mainnet address of the `Chai` contract
 | 
			
		||||
    address constant private CHAI_ADDRESS = 0x06AF07097C9Eeb7fD685c692751D5C66dB49c215;
 | 
			
		||||
    /// @dev Address of the 0x DevUtils contract.
 | 
			
		||||
    /// @dev Mainnet address of the 0x DevUtils contract.
 | 
			
		||||
    address constant private DEV_UTILS_ADDRESS = 0xcCc2431a7335F21d9268bA62F0B32B0f2EFC463f;
 | 
			
		||||
    // /// @dev Kovan address of the 0x DevUtils contract.
 | 
			
		||||
    // address constant private DEV_UTILS_ADDRESS = 0x56A8Da16fd8a65768c97913402212EAB60531BaE;
 | 
			
		||||
    /// @dev Kyber ETH pseudo-address.
 | 
			
		||||
    address constant internal KYBER_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
 | 
			
		||||
    /// @dev Mainnet address of the dYdX contract.
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,10 @@
 | 
			
		||||
            {
 | 
			
		||||
                "note": "Added new `DevUtils` addresses",
 | 
			
		||||
                "pr": 2402
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "note": "Update ERC20BridgeSampler address on Kovan and mainnet.",
 | 
			
		||||
                "pr": 2405
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@
 | 
			
		||||
        "erc20BridgeProxy": "0x8ed95d1746bf1e4dab58d8ed4724f1ef95b20db0",
 | 
			
		||||
        "uniswapBridge": "0xa6baaed2053058a3c8f11e0c7a9716304454b09e",
 | 
			
		||||
        "eth2DaiBridge": "0x0ac2d6f5f5afc669d3ca38f830dad2b4f238ad3f",
 | 
			
		||||
        "erc20BridgeSampler": "0x0937aca3f6e8bed40b560c3abf255ed40e6c7c9e",
 | 
			
		||||
        "erc20BridgeSampler": "0x1b402fdb5ee87f989c11e3963557e89cc313b6c0",
 | 
			
		||||
        "kyberBridge": "0xe64660275c40c16c491c2dabf50afaded20f858f"
 | 
			
		||||
    },
 | 
			
		||||
    "3": {
 | 
			
		||||
@@ -104,7 +104,7 @@
 | 
			
		||||
        "erc20BridgeProxy": "0xfb2dd2a1366de37f7241c83d47da58fd503e2c64",
 | 
			
		||||
        "uniswapBridge": "0x0000000000000000000000000000000000000000",
 | 
			
		||||
        "eth2DaiBridge": "0x0000000000000000000000000000000000000000",
 | 
			
		||||
        "erc20BridgeSampler": "0x0000000000000000000000000000000000000000",
 | 
			
		||||
        "erc20BridgeSampler": "0x551f0e213dcb71f676558d8b0ab559d1cdd103f2",
 | 
			
		||||
        "kyberBridge": "0x0000000000000000000000000000000000000000"
 | 
			
		||||
    },
 | 
			
		||||
    "1337": {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user