Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: onchain quoter batch param differed by optimistic cached routes #570

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix prettier onchain quoter
  • Loading branch information
jsy1218 committed May 10, 2024
commit 44b1d69aa100de1667ac2b0c79771e0e9fd9b5da
35 changes: 19 additions & 16 deletions src/providers/on-chain-quote-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BaseProvider } from '@ethersproject/providers';
import {
encodeMixedRouteToPath,
MixedRouteSDK,
Protocol
Protocol,
} from '@uniswap/router-sdk';
import { ChainId } from '@uniswap/sdk-core';
import { encodeRouteToPath } from '@uniswap/v3-sdk';
Expand All @@ -12,20 +12,18 @@ import _ from 'lodash';
import stats from 'stats-lite';

import { MixedRoute, V2Route, V3Route } from '../routers/router';
import {
IMixedRouteQuoterV1__factory
} from '../types/other/factories/IMixedRouteQuoterV1__factory';
import { IMixedRouteQuoterV1__factory } from '../types/other/factories/IMixedRouteQuoterV1__factory';
import { IQuoterV2__factory } from '../types/v3/factories/IQuoterV2__factory';
import { ID_TO_NETWORK_NAME, metric, MetricLoggerUnit } from '../util';
import {
MIXED_ROUTE_QUOTER_V1_ADDRESSES,
NEW_QUOTER_V2_ADDRESSES
NEW_QUOTER_V2_ADDRESSES,
} from '../util/addresses';
import { CurrencyAmount } from '../util/amounts';
import { log } from '../util/log';
import {
DEFAULT_BLOCK_NUMBER_CONFIGS,
DEFAULT_SUCCESS_RATE_FAILURE_OVERRIDES
DEFAULT_SUCCESS_RATE_FAILURE_OVERRIDES,
} from '../util/onchainQuoteProviderConfigs';
import { routeToString } from '../util/routes';

Expand Down Expand Up @@ -291,14 +289,15 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider {
minTimeout: 25,
maxTimeout: 250,
},
protected batchParams: (optimisticCachedRoutes: boolean) => BatchParams =
(_) => {
return {
multicallChunk: 150,
gasLimitPerCall: 1_000_000,
quoteMinSuccessRate: 0.2,
};
},
protected batchParams: (optimisticCachedRoutes: boolean) => BatchParams = (
_
) => {
return {
multicallChunk: 150,
gasLimitPerCall: 1_000_000,
quoteMinSuccessRate: 0.2,
};
},
protected gasErrorFailureOverride: FailureOverrides = {
gasLimitOverride: 1_500_000,
multicallChunk: 100,
Expand Down Expand Up @@ -389,8 +388,12 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider {
/// Validate that there are no incorrect routes / function combinations
this.validateRoutes(routes, functionName, useMixedRouteQuoter);

let multicallChunk = this.batchParams(optimisticCachedRoutes).multicallChunk;
let gasLimitOverride = this.batchParams(optimisticCachedRoutes).gasLimitPerCall;
let multicallChunk = this.batchParams(
optimisticCachedRoutes
).multicallChunk;
let gasLimitOverride = this.batchParams(
optimisticCachedRoutes
).gasLimitPerCall;
const { baseBlockOffset, rollback } = this.blockNumberConfig;

// Apply the base block offset if provided
Expand Down
Loading