Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
[asset-swapper] Bump sampler gas limit and allow for override (#2471)
Browse files Browse the repository at this point in the history
* [asset-swapper] Bump sampler gas limit and allow for override

* Fix imports

* Set to 36e6
  • Loading branch information
dekz authored Feb 6, 2020
1 parent 8b46b53 commit 0b80e51
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
},
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 2 additions & 3 deletions src/swap_quoter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -145,7 +144,7 @@ export class SwapQuoter {
* @return An instance of SwapQuoter
*/
constructor(supportedProvider: SupportedProvider, orderbook: Orderbook, options: Partial<SwapQuoterOpts> = {}) {
const { chainId, expiryBufferMs, permittedOrderFeeTypes } = _.merge(
const { chainId, expiryBufferMs, permittedOrderFeeTypes, samplerGasLimit } = _.merge(
{},
constants.DEFAULT_SWAP_QUOTER_OPTS,
options,
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/utils/market_operation_utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ export const constants = {
DEFAULT_GET_MARKET_ORDERS_OPTS,
ERC20_PROXY_ID: '0xf47261b0',
WALLET_SIGNATURE: '0x04',
SAMPLER_CONTRACT_GAS_LIMIT: 16e6,
};

0 comments on commit 0b80e51

Please sign in to comment.