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
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 15 additions & 7 deletions src/providers/on-chain-quote-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,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,
Expand Down Expand Up @@ -384,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.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 +1092,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
44 changes: 26 additions & 18 deletions src/routers/alpha-router/alpha-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,12 @@ export class AlphaRouter
minTimeout: 100,
maxTimeout: 1000,
},
{
multicallChunk: 110,
gasLimitPerCall: 1_200_000,
quoteMinSuccessRate: 0.1,
(_) => {
return {
multicallChunk: 110,
gasLimitPerCall: 1_200_000,
quoteMinSuccessRate: 0.1,
}
},
{
gasLimitOverride: 3_000_000,
Expand Down Expand Up @@ -561,10 +563,12 @@ export class AlphaRouter
minTimeout: 100,
maxTimeout: 1000,
},
{
multicallChunk: 80,
gasLimitPerCall: 1_200_000,
quoteMinSuccessRate: 0.1,
(_) => {
return {
multicallChunk: 80,
gasLimitPerCall: 1_200_000,
quoteMinSuccessRate: 0.1,
}
},
{
gasLimitOverride: 3_000_000,
Expand Down Expand Up @@ -596,10 +600,12 @@ export class AlphaRouter
minTimeout: 100,
maxTimeout: 1000,
},
{
multicallChunk: 10,
gasLimitPerCall: 12_000_000,
quoteMinSuccessRate: 0.1,
(_) => {
return {
multicallChunk: 10,
gasLimitPerCall: 12_000_000,
quoteMinSuccessRate: 0.1,
}
},
{
gasLimitOverride: 30_000_000,
Expand All @@ -622,10 +628,12 @@ export class AlphaRouter
minTimeout: 100,
maxTimeout: 1000,
},
{
multicallChunk: 10,
gasLimitPerCall: 5_000_000,
quoteMinSuccessRate: 0.1,
(_) => {
return {
multicallChunk: 10,
gasLimitPerCall: 5_000_000,
quoteMinSuccessRate: 0.1,
}
},
{
gasLimitOverride: 5_000_000,
Expand All @@ -646,7 +654,7 @@ export class AlphaRouter
provider,
this.multicall2Provider,
RETRY_OPTIONS[chainId],
BATCH_PARAMS[chainId],
(_) => BATCH_PARAMS[chainId]!,
GAS_ERROR_FAILURE_OVERRIDES[chainId],
SUCCESS_RATE_FAILURE_OVERRIDES[chainId],
BLOCK_NUMBER_CONFIGS[chainId]
Expand All @@ -658,7 +666,7 @@ export class AlphaRouter
provider,
this.multicall2Provider,
DEFAULT_RETRY_OPTIONS,
DEFAULT_BATCH_PARAMS,
(_) => DEFAULT_BATCH_PARAMS,
DEFAULT_GAS_ERROR_FAILURE_OVERRIDES,
DEFAULT_SUCCESS_RATE_FAILURE_OVERRIDES,
DEFAULT_BLOCK_NUMBER_CONFIGS,
Expand Down
Loading