From 0b80e517a3b8a9a37017ae02f5d4de1721a5b966 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Thu, 6 Feb 2020 12:31:28 +1000 Subject: [PATCH] [asset-swapper] Bump sampler gas limit and allow for override (#2471) * [asset-swapper] Bump sampler gas limit and allow for override * Fix imports * Set to 36e6 --- CHANGELOG.json | 7 ++++++- src/constants.ts | 1 + src/swap_quoter.ts | 5 ++--- src/types.ts | 3 +++ src/utils/market_operation_utils/constants.ts | 1 - 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.json b/CHANGELOG.json index b0281d6ac0..141a4707fb 100644 --- a/CHANGELOG.json +++ b/CHANGELOG.json @@ -3,7 +3,12 @@ "version": "4.1.1", "changes": [ { - "note": "Prune orders before creating a dummy order for the Sampler" + "note": "Prune orders before creating a dummy order for the Sampler", + "pr": 2470 + }, + { + "note": "Bump sampler gas limit to 60e6", + "pr": 2471 } ] }, diff --git a/src/constants.ts b/src/constants.ts index 2d30c5300a..6ab389a25c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -42,6 +42,7 @@ const DEFAULT_SWAP_QUOTER_OPTS: SwapQuoterOpts = { orderRefreshIntervalMs: 10000, // 10 seconds }, ...DEFAULT_ORDER_PRUNER_OPTS, + samplerGasLimit: 36e6, }; const DEFAULT_FORWARDER_EXTENSION_CONTRACT_OPTS: ForwarderExtensionContractOpts = { diff --git a/src/swap_quoter.ts b/src/swap_quoter.ts index 64316c4b9d..602e0213e6 100644 --- a/src/swap_quoter.ts +++ b/src/swap_quoter.ts @@ -22,7 +22,6 @@ import { import { assert } from './utils/assert'; import { calculateLiquidity } from './utils/calculate_liquidity'; import { MarketOperationUtils } from './utils/market_operation_utils'; -import { constants as marketOperationConstants } from './utils/market_operation_utils/constants'; import { dummyOrderUtils } from './utils/market_operation_utils/dummy_order_utils'; import { orderPrunerUtils } from './utils/order_prune_utils'; import { OrderStateUtils } from './utils/order_state_utils'; @@ -145,7 +144,7 @@ export class SwapQuoter { * @return An instance of SwapQuoter */ constructor(supportedProvider: SupportedProvider, orderbook: Orderbook, options: Partial = {}) { - const { chainId, expiryBufferMs, permittedOrderFeeTypes } = _.merge( + const { chainId, expiryBufferMs, permittedOrderFeeTypes, samplerGasLimit } = _.merge( {}, constants.DEFAULT_SWAP_QUOTER_OPTS, options, @@ -166,7 +165,7 @@ export class SwapQuoter { const samplerContract = new IERC20BridgeSamplerContract( this._contractAddresses.erc20BridgeSampler, this.provider, - { gas: marketOperationConstants.SAMPLER_CONTRACT_GAS_LIMIT }, + { gas: samplerGasLimit }, ); this._marketOperationUtils = new MarketOperationUtils(samplerContract, this._contractAddresses, { chainId, diff --git a/src/types.ts b/src/types.ts index a31953522a..c355dbd061 100644 --- a/src/types.ts +++ b/src/types.ts @@ -203,12 +203,15 @@ export interface CalculateSwapQuoteOpts extends GetMarketOrdersOpts {} * chainId: The ethereum chain id. Defaults to 1 (mainnet). * orderRefreshIntervalMs: The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s). * expiryBufferMs: The number of seconds to add when calculating whether an order is expired or not. Defaults to 300s (5m). + * contractAddresses: Optionally override the contract addresses used for the chain + * samplerGasLimit: The gas limit used when querying the sampler contract. Defaults to 36e6 */ export interface SwapQuoterOpts extends OrderPrunerOpts { chainId: number; orderRefreshIntervalMs: number; expiryBufferMs: number; contractAddresses?: ContractAddresses; + samplerGasLimit?: number; } /** diff --git a/src/utils/market_operation_utils/constants.ts b/src/utils/market_operation_utils/constants.ts index 965079f144..620f7e90b8 100644 --- a/src/utils/market_operation_utils/constants.ts +++ b/src/utils/market_operation_utils/constants.ts @@ -42,5 +42,4 @@ export const constants = { DEFAULT_GET_MARKET_ORDERS_OPTS, ERC20_PROXY_ID: '0xf47261b0', WALLET_SIGNATURE: '0x04', - SAMPLER_CONTRACT_GAS_LIMIT: 16e6, };