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
onchain quoter batch param differed by optimistic cached routes
  • Loading branch information
jsy1218 committed May 10, 2024
commit dff7d1643fa60b5090fcce74db715a545437dc0f
29 changes: 17 additions & 12 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,18 +12,20 @@ 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 @@ -289,11 +291,14 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider {
minTimeout: 25,
maxTimeout: 250,
},
protected batchParams: BatchParams = {
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 @@ -384,8 +389,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider {
/// Validate that there are no incorrect routes / function combinations
this.validateRoutes(routes, functionName, useMixedRouteQuoter);

let multicallChunk = this.batchParams.multicallChunk;
let gasLimitOverride = this.batchParams.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 Expand Up @@ -1084,7 +1089,7 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider {

const successRate = (1.0 * numSuccessResults) / numResults;

const { quoteMinSuccessRate } = this.batchParams;
const { quoteMinSuccessRate } = this.batchParams(optimisticCachedRoutes);
if (successRate < quoteMinSuccessRate) {
if (haveRetriedForSuccessRate) {
log.info(
Expand Down