From 9a3065aea6a77151e96cfdf0961be12e9c6b91da Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Wed, 17 Apr 2024 08:55:41 -0700 Subject: [PATCH 01/30] fix: multicall return gas used in case of failure (#534) * return gas used from multicall in case of a failed quote * fix compiling error * add target contract address to the failed multicall debug log * also return gas limit --- src/providers/multicall-provider.ts | 1 + src/providers/multicall-uniswap-provider.ts | 3 ++- src/providers/on-chain-quote-provider.ts | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/providers/multicall-provider.ts b/src/providers/multicall-provider.ts index d10ff566e..af9c8ebd3 100644 --- a/src/providers/multicall-provider.ts +++ b/src/providers/multicall-provider.ts @@ -47,6 +47,7 @@ export type SuccessResult = { export type FailResult = { success: false; returnData: string; + gasUsed?: BigNumber; }; export type Result = SuccessResult | FailResult; diff --git a/src/providers/multicall-uniswap-provider.ts b/src/providers/multicall-uniswap-provider.ts index 2f047ca80..18e5c710c 100644 --- a/src/providers/multicall-uniswap-provider.ts +++ b/src/providers/multicall-uniswap-provider.ts @@ -191,11 +191,12 @@ export class UniswapMulticallProvider extends IMulticallProvider( quoteResults: Result<[BigNumber, BigNumber[], number[], BigNumber]>[], routes: TRoute[], - amounts: CurrencyAmount[] + amounts: CurrencyAmount[], + gasLimit: BigNumber ): RouteWithQuotes[] { const routesQuotes: RouteWithQuotes[] = []; @@ -905,7 +911,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { amount, quote: null, sqrtPriceX96AfterList: null, - gasEstimate: null, + gasEstimate: quoteResult.gasUsed ?? null, + gasLimit: gasLimit, initializedTicksCrossedList: null, }; } @@ -916,6 +923,7 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { sqrtPriceX96AfterList: quoteResult.result[1], initializedTicksCrossedList: quoteResult.result[2], gasEstimate: quoteResult.result[3], + gasLimit: gasLimit, }; } ); From 452c55a697352d56d514880063fb02427c7f2f9c Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:23:28 -0700 Subject: [PATCH 02/30] chore: bump to v3.28.1 (#535) - **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) Release https://github.com/Uniswap/smart-order-router/pull/534 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index dc46cc544..dfc96fd35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.0", + "version": "3.28.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.0", + "version": "3.28.1", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index be974f7eb..2f87f304a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.0", + "version": "3.28.1", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From 68b279a78b6e8715b0c958352530563434556521 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Wed, 17 Apr 2024 13:51:38 -0700 Subject: [PATCH 03/30] add polygon view-only quoter deploy address (#536) --- src/routers/alpha-router/alpha-router.ts | 1 + src/util/addresses.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/routers/alpha-router/alpha-router.ts b/src/routers/alpha-router/alpha-router.ts index f8ea19132..86e64439b 100644 --- a/src/routers/alpha-router/alpha-router.ts +++ b/src/routers/alpha-router/alpha-router.ts @@ -640,6 +640,7 @@ export class AlphaRouter case ChainId.POLYGON_MUMBAI: case ChainId.SEPOLIA: case ChainId.MAINNET: + case ChainId.POLYGON: this.onChainQuoteProvider = new OnChainQuoteProvider( chainId, provider, diff --git a/src/util/addresses.ts b/src/util/addresses.ts index d0b8d5b74..f66166e8c 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -64,7 +64,8 @@ export const NEW_QUOTER_V2_ADDRESSES: AddressMap = { ...constructSameAddressMap('0x61fFE014bA17989E743c5F6cB21bF9697530B21e'), [ChainId.POLYGON_MUMBAI]: '0x60e06b92bC94a665036C26feC5FF2A92E2d04c5f', [ChainId.SEPOLIA]: '0x6650ab818c0a7efa72fc1404a878fef1fec8e058', - [ChainId.MAINNET]: '0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3' + [ChainId.MAINNET]: '0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3', + [ChainId.POLYGON]: '0x5e55c9e631fae526cd4b0526c4818d6e0a9ef0e3', }; export const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap = { From ec8a7502f89a8ff836d82ffe61b3daa5ecf553cf Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Wed, 17 Apr 2024 15:42:08 -0700 Subject: [PATCH 04/30] 3.28.2 (#537) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index dfc96fd35..476aa66b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.1", + "version": "3.28.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.1", + "version": "3.28.2", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index 2f87f304a..d425066ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.1", + "version": "3.28.2", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From 0df00393e3eff26930863975d4401d04dcbe6e10 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:03:26 -0700 Subject: [PATCH 05/30] use single default view-only quoter deploy address (#538) --- src/util/addresses.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/util/addresses.ts b/src/util/addresses.ts index f66166e8c..db53ecefc 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -61,11 +61,8 @@ export const QUOTER_V2_ADDRESSES: AddressMap = { }; export const NEW_QUOTER_V2_ADDRESSES: AddressMap = { - ...constructSameAddressMap('0x61fFE014bA17989E743c5F6cB21bF9697530B21e'), + ...constructSameAddressMap('0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3'), [ChainId.POLYGON_MUMBAI]: '0x60e06b92bC94a665036C26feC5FF2A92E2d04c5f', - [ChainId.SEPOLIA]: '0x6650ab818c0a7efa72fc1404a878fef1fec8e058', - [ChainId.MAINNET]: '0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3', - [ChainId.POLYGON]: '0x5e55c9e631fae526cd4b0526c4818d6e0a9ef0e3', }; export const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap = { From 387d222e460fbfe8438a2aeac21443fee3dff229 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:09:29 -0700 Subject: [PATCH 06/30] add new view quoter address on base (#539) --- src/util/addresses.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/addresses.ts b/src/util/addresses.ts index db53ecefc..609f6f414 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -63,6 +63,7 @@ export const QUOTER_V2_ADDRESSES: AddressMap = { export const NEW_QUOTER_V2_ADDRESSES: AddressMap = { ...constructSameAddressMap('0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3'), [ChainId.POLYGON_MUMBAI]: '0x60e06b92bC94a665036C26feC5FF2A92E2d04c5f', + [ChainId.BASE]: '0xf0c802dcb0cf1c4f7b953756b49d940eed190221', }; export const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap = { From 528318cb8648d141c9b8bf564ccf486663624fa0 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Fri, 19 Apr 2024 07:06:17 -0700 Subject: [PATCH 07/30] chore: bump to v3.28.3 (#541) - **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) Release https://github.com/Uniswap/smart-order-router/pull/538 https://github.com/Uniswap/smart-order-router/pull/539 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 476aa66b3..6e6f93675 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.2", + "version": "3.28.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.2", + "version": "3.28.3", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index d425066ab..b377f08f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.2", + "version": "3.28.3", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From d4339945c3e4ec458fdf47c8eab8fc0300e85885 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Fri, 19 Apr 2024 07:11:41 -0700 Subject: [PATCH 08/30] fix: update view-only quoter address in base (#542) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) Big fix - **What is the current behavior?** (You can also link to an open issue here) Since shadow quoting in Base today (https://github.com/Uniswap/routing-api/pull/598), the accuracy has been low: ![Screenshot 2024-04-18 at 9 52 46 PM](https://github.com/Uniswap/smart-order-router/assets/91580504/d2c18e04-1ae2-4ec7-adf3-0ebab0f0988b) I used tenderly [simulation](https://www.tdly.co/shared/simulation/cf37f5ed-5eaf-49f6-b966-fc33c10e0748) to debug, then I noticed the computed pool address from the view-only quoter is non-existent on Base. I was using the wrong v3 core factory when deploying to Base. I already fixed that and re-deployed https://github.com/Uniswap/view-quoter-v3/pull/12, but we also need to update the quoter deploy address in SOR, so that routing-api quote accuracy can go up on Base. - **What is the new behavior (if this is a feature change)?** Update [quoter](https://basescan.org/address/0x222cA98F00eD15B1faE10B61c277703a194cf5d2#code) address - **Other information**: --- src/util/addresses.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/addresses.ts b/src/util/addresses.ts index 609f6f414..7784bb67d 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -63,7 +63,7 @@ export const QUOTER_V2_ADDRESSES: AddressMap = { export const NEW_QUOTER_V2_ADDRESSES: AddressMap = { ...constructSameAddressMap('0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3'), [ChainId.POLYGON_MUMBAI]: '0x60e06b92bC94a665036C26feC5FF2A92E2d04c5f', - [ChainId.BASE]: '0xf0c802dcb0cf1c4f7b953756b49d940eed190221', + [ChainId.BASE]: '0x222cA98F00eD15B1faE10B61c277703a194cf5d2', }; export const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap = { From f76837fcb5514e693c0fd5fe1b6c2dc5eeff9822 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Fri, 19 Apr 2024 08:34:28 -0700 Subject: [PATCH 09/30] 3.28.4 (#544) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6e6f93675..3442b6d2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.3", + "version": "3.28.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.3", + "version": "3.28.4", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index b377f08f8..752c62534 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.3", + "version": "3.28.4", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From dc238d2c9dc76e8bf8488a8033009bfc92dfd1e2 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:50:44 -0700 Subject: [PATCH 10/30] add new view quoter address on blast (#545) --- src/util/addresses.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/addresses.ts b/src/util/addresses.ts index 7784bb67d..3c22b24f6 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -64,6 +64,7 @@ export const NEW_QUOTER_V2_ADDRESSES: AddressMap = { ...constructSameAddressMap('0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3'), [ChainId.POLYGON_MUMBAI]: '0x60e06b92bC94a665036C26feC5FF2A92E2d04c5f', [ChainId.BASE]: '0x222cA98F00eD15B1faE10B61c277703a194cf5d2', + [ChainId.BLAST]: '0x9D0F15f2cf58655fDDcD1EE6129C547fDaeD01b1', }; export const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap = { From 525533453fd888ecb4271a44efbe5f953b7c7b20 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Sun, 21 Apr 2024 14:18:35 -0700 Subject: [PATCH 11/30] 3.28.5 (#546) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3442b6d2d..d603d1226 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.4", + "version": "3.28.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.4", + "version": "3.28.5", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index 752c62534..54422fb08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.4", + "version": "3.28.5", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From f73799d8025bddfea725df93f9dad6ecbe895d62 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Mon, 22 Apr 2024 08:47:35 -0700 Subject: [PATCH 12/30] fix: improve quote provider logging & update sepolia quoter address (#547) * improve quote provider logging * fix minor string placeholder * revert unintended lodash import * revert unintended lodash import * add override quoter address definedness check to be consistent --- src/providers/on-chain-quote-provider.ts | 83 +++++++++++++++++++----- src/util/addresses.ts | 8 ++- 2 files changed, 73 insertions(+), 18 deletions(-) diff --git a/src/providers/on-chain-quote-provider.ts b/src/providers/on-chain-quote-provider.ts index 382e76759..233f46430 100644 --- a/src/providers/on-chain-quote-provider.ts +++ b/src/providers/on-chain-quote-provider.ts @@ -303,13 +303,26 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { // In alpha-router default case, we will also define the constants with same values as below. protected successRateFailureOverrides: FailureOverrides = DEFAULT_SUCCESS_RATE_FAILURE_OVERRIDES, protected blockNumberConfig: BlockNumberConfig = DEFAULT_BLOCK_NUMBER_CONFIGS, - protected quoterAddressOverride?: string, - protected metricsPrefix: string = '' // default metric prefix to be empty string + protected quoterAddressOverride?: (useMixedRouteQuoter: boolean) => string | undefined, + protected metricsPrefix: ( + chainId: ChainId, + useMixedRouteQuoter: boolean + ) => string = (chainId, useMixedRouteQuoter) => + useMixedRouteQuoter + ? `ChainId_${chainId}_MixedQuoter` + : `ChainId_${chainId}_V3Quoter` ) {} private getQuoterAddress(useMixedRouteQuoter: boolean): string { if (this.quoterAddressOverride) { - return this.quoterAddressOverride; + const quoterAddress = this.quoterAddressOverride(useMixedRouteQuoter); + + if (!quoterAddress) { + throw new Error( + `No address for the quoter contract on chain id: ${this.chainId}` + ); + } + return quoterAddress; } const quoterAddress = useMixedRouteQuoter ? MIXED_ROUTE_QUOTER_V1_ADDRESSES[this.chainId] @@ -424,12 +437,15 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { ); metric.putMetric( - `${this.metricsPrefix}QuoteBatchSize`, + `${this.metricsPrefix(this.chainId, useMixedRouteQuoter)}QuoteBatchSize`, inputs.length, MetricLoggerUnit.Count ); metric.putMetric( - `${this.metricsPrefix}QuoteBatchSize_${ID_TO_NETWORK_NAME(this.chainId)}`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteBatchSize_${ID_TO_NETWORK_NAME(this.chainId)}`, inputs.length, MetricLoggerUnit.Count ); @@ -602,7 +618,10 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { if (error instanceof BlockConflictError) { if (!haveRetriedForBlockConflictError) { metric.putMetric( - `${this.metricsPrefix}QuoteBlockConflictErrorRetry`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteBlockConflictErrorRetry`, 1, MetricLoggerUnit.Count ); @@ -613,7 +632,10 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { } else if (error instanceof ProviderBlockHeaderError) { if (!haveRetriedForBlockHeader) { metric.putMetric( - `${this.metricsPrefix}QuoteBlockHeaderNotFoundRetry`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteBlockHeaderNotFoundRetry`, 1, MetricLoggerUnit.Count ); @@ -653,7 +675,10 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { } else if (error instanceof ProviderTimeoutError) { if (!haveRetriedForTimeout) { metric.putMetric( - `${this.metricsPrefix}QuoteTimeoutRetry`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteTimeoutRetry`, 1, MetricLoggerUnit.Count ); @@ -662,7 +687,10 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { } else if (error instanceof ProviderGasError) { if (!haveRetriedForOutOfGas) { metric.putMetric( - `${this.metricsPrefix}QuoteOutOfGasExceptionRetry`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteOutOfGasExceptionRetry`, 1, MetricLoggerUnit.Count ); @@ -674,7 +702,10 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { } else if (error instanceof SuccessRateError) { if (!haveRetriedForSuccessRate) { metric.putMetric( - `${this.metricsPrefix}QuoteSuccessRateRetry`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteSuccessRateRetry`, 1, MetricLoggerUnit.Count ); @@ -690,7 +721,10 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { } else { if (!haveRetriedForUnknownReason) { metric.putMetric( - `${this.metricsPrefix}QuoteUnknownReasonRetry`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteUnknownReasonRetry`, 1, MetricLoggerUnit.Count ); @@ -781,37 +815,52 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { const endTime = Date.now(); metric.putMetric( - `${this.metricsPrefix}QuoteLatency`, + `${this.metricsPrefix(this.chainId, useMixedRouteQuoter)}QuoteLatency`, endTime - startTime, MetricLoggerUnit.Milliseconds ); metric.putMetric( - `${this.metricsPrefix}QuoteApproxGasUsedPerSuccessfulCall`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteApproxGasUsedPerSuccessfulCall`, approxGasUsedPerSuccessCall, MetricLoggerUnit.Count ); metric.putMetric( - `${this.metricsPrefix}QuoteNumRetryLoops`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteNumRetryLoops`, finalAttemptNumber - 1, MetricLoggerUnit.Count ); metric.putMetric( - `${this.metricsPrefix}QuoteTotalCallsToProvider`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteTotalCallsToProvider`, totalCallsMade, MetricLoggerUnit.Count ); metric.putMetric( - `${this.metricsPrefix}QuoteExpectedCallsToProvider`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteExpectedCallsToProvider`, expectedCallsMade, MetricLoggerUnit.Count ); metric.putMetric( - `${this.metricsPrefix}QuoteNumRetriedCalls`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter + )}QuoteNumRetriedCalls`, totalCallsMade - expectedCallsMade, MetricLoggerUnit.Count ); diff --git a/src/util/addresses.ts b/src/util/addresses.ts index 3c22b24f6..d2dbe17cb 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -1,4 +1,9 @@ -import { CHAIN_TO_ADDRESSES_MAP, ChainId, SWAP_ROUTER_02_ADDRESSES as SWAP_ROUTER_02_ADDRESSES_HELPER, Token } from '@uniswap/sdk-core'; +import { + ChainId, + CHAIN_TO_ADDRESSES_MAP, + SWAP_ROUTER_02_ADDRESSES as SWAP_ROUTER_02_ADDRESSES_HELPER, + Token, +} from '@uniswap/sdk-core'; import { FACTORY_ADDRESS } from '@uniswap/v3-sdk'; import { NETWORKS_WITH_SAME_UNISWAP_ADDRESSES } from './chains'; @@ -62,6 +67,7 @@ export const QUOTER_V2_ADDRESSES: AddressMap = { export const NEW_QUOTER_V2_ADDRESSES: AddressMap = { ...constructSameAddressMap('0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3'), + [ChainId.SEPOLIA]: '0xf0c802dcb0cf1c4f7b953756b49d940eed190221', [ChainId.POLYGON_MUMBAI]: '0x60e06b92bC94a665036C26feC5FF2A92E2d04c5f', [ChainId.BASE]: '0x222cA98F00eD15B1faE10B61c277703a194cf5d2', [ChainId.BLAST]: '0x9D0F15f2cf58655fDDcD1EE6129C547fDaeD01b1', From 8f6963b4322262444dd94bb60b26fcb9dabe8fb9 Mon Sep 17 00:00:00 2001 From: Miguel Cervera Date: Mon, 22 Apr 2024 10:40:41 -0700 Subject: [PATCH 13/30] chore: token out with fot fix (#540) * chore: token out with fot fix * missing var * fix tests, tests pending to add * add test for fot flag * reset to main * tokenOutHasFot * test FOT and Fee * undefined aware * fix * review feedback --- src/providers/portion-provider.ts | 8 +- src/routers/alpha-router/alpha-router.ts | 31 ++- .../alpha-router.integration.test.ts | 10 + test/unit/providers/portion-provider.test.ts | 180 +++++++++++++----- 4 files changed, 171 insertions(+), 58 deletions(-) diff --git a/src/providers/portion-provider.ts b/src/providers/portion-provider.ts index 766f4ad1e..a8214f43f 100644 --- a/src/providers/portion-provider.ts +++ b/src/providers/portion-provider.ts @@ -22,6 +22,7 @@ export interface IPortionProvider { getPortionAmount( tokenOutAmount: CurrencyAmount, tradeType: TradeType, + tokenOutHasFot?: boolean, swapConfig?: SwapOptions ): CurrencyAmount | undefined; @@ -116,9 +117,10 @@ export class PortionProvider implements IPortionProvider { getPortionAmount( tokenOutAmount: CurrencyAmount, tradeType: TradeType, + tokenOutHasFot?: boolean, swapConfig?: SwapOptions ): CurrencyAmount | undefined { - if (swapConfig?.type !== SwapType.UNIVERSAL_ROUTER) { + if (tokenOutHasFot || swapConfig?.type !== SwapType.UNIVERSAL_ROUTER) { return undefined; } @@ -202,9 +204,13 @@ export class PortionProvider implements IPortionProvider { } return routeWithQuotes.map((routeWithQuote) => { + const tokenOut = + routeWithQuote.tokenPath[routeWithQuote.tokenPath.length - 1]; + const tokenOutHasFot = tokenOut && tokenOut.buyFeeBps?.gt(0); const portionAmount = this.getPortionAmount( routeWithQuote.quote, tradeType, + tokenOutHasFot, swapConfig ); diff --git a/src/routers/alpha-router/alpha-router.ts b/src/routers/alpha-router/alpha-router.ts index 86e64439b..4aca46243 100644 --- a/src/routers/alpha-router/alpha-router.ts +++ b/src/routers/alpha-router/alpha-router.ts @@ -1039,10 +1039,30 @@ export class AlphaRouter partialRoutingConfig: Partial = {} ): Promise { const originalAmount = amount; + + const { currencyIn, currencyOut } = + this.determineCurrencyInOutFromTradeType( + tradeType, + amount, + quoteCurrency + ); + + const tokenIn = currencyIn.wrapped; + const tokenOut = currencyOut.wrapped; + + const tokenOutProperties = + await this.tokenPropertiesProvider.getTokensProperties( + [tokenOut], + partialRoutingConfig + ); + const buyFeeBps = tokenOutProperties[tokenOut.address.toLowerCase()]?.tokenFeeResult?.buyFeeBps; + const tokenOutHasFot = buyFeeBps && buyFeeBps.gt(0); + if (tradeType === TradeType.EXACT_OUTPUT) { const portionAmount = this.portionProvider.getPortionAmount( amount, tradeType, + tokenOutHasFot, swapConfig ); if (portionAmount && portionAmount.greaterThan(ZERO)) { @@ -1056,16 +1076,6 @@ export class AlphaRouter } } - const { currencyIn, currencyOut } = - this.determineCurrencyInOutFromTradeType( - tradeType, - amount, - quoteCurrency - ); - - const tokenIn = currencyIn.wrapped; - const tokenOut = currencyOut.wrapped; - metric.setProperty('chainId', this.chainId); metric.setProperty('pair', `${tokenIn.symbol}/${tokenOut.symbol}`); metric.setProperty('tokenIn', tokenIn.address); @@ -1455,6 +1465,7 @@ export class AlphaRouter const portionAmount = this.portionProvider.getPortionAmount( tokenOutAmount, tradeType, + tokenOutHasFot, swapConfig ); const portionQuoteAmount = this.portionProvider.getPortionQuoteAmount( diff --git a/test/integ/routers/alpha-router/alpha-router.integration.test.ts b/test/integ/routers/alpha-router/alpha-router.integration.test.ts index 857e103d5..19cad6619 100644 --- a/test/integ/routers/alpha-router/alpha-router.integration.test.ts +++ b/test/integ/routers/alpha-router/alpha-router.integration.test.ts @@ -2815,6 +2815,10 @@ describe('alpha router integration', () => { slippageTolerance: LARGE_SLIPPAGE, deadlineOrPreviousBlockhash: parseDeadline(360), simulate: { fromAddress: WHALES(tokenIn!) }, + fee: { + fee: new Percent(FLAT_PORTION.bips, 10_000), + recipient: FLAT_PORTION.recipient + } }, { ...ROUTING_CONFIG, @@ -2830,6 +2834,12 @@ describe('alpha router integration', () => { expect(swap!.methodParameters).toBeDefined(); expect(swap!.methodParameters!.to).toBeDefined(); + if (enableFeeOnTransferFeeFetching && tokenOut?.address === BULLET_WITHOUT_TAX.address) { + expect(swap?.portionAmount?.quotient).toBeUndefined(); + } else { + expect(swap?.portionAmount?.quotient?.toString()).not.toEqual("0"); + } + return { enableFeeOnTransferFeeFetching, ...swap! } }) ) diff --git a/test/unit/providers/portion-provider.test.ts b/test/unit/providers/portion-provider.test.ts index 7b80f0ffe..b7e42c6fb 100644 --- a/test/unit/providers/portion-provider.test.ts +++ b/test/unit/providers/portion-provider.test.ts @@ -1,13 +1,13 @@ import { BigNumber } from '@ethersproject/bignumber'; +import { Currency, CurrencyAmount, Fraction, Percent, Token, TradeType, } from '@uniswap/sdk-core'; import { - Currency, - CurrencyAmount, - Fraction, - Percent, - Token, - TradeType, -} from '@uniswap/sdk-core'; -import { parseAmount, RouteWithValidQuote, SwapOptions, SwapType, V2RouteWithValidQuote, V3RouteWithValidQuote } from '../../../src'; + parseAmount, + RouteWithValidQuote, + SwapOptions, + SwapType, + V2RouteWithValidQuote, + V3RouteWithValidQuote +} from '../../../src'; import { PortionProvider } from '../../../src/providers/portion-provider'; import { FLAT_PORTION, GREENLIST_TOKEN_PAIRS } from '../../test-util/mock-data'; import { @@ -20,7 +20,7 @@ describe('portion provider', () => { const expectedRequestAmount = '1.01'; const expectedQuote = '1605.56'; const expectedGas = '2.35'; - const expectedPortion = FLAT_PORTION + const expectedPortion = FLAT_PORTION; const portionProvider = new PortionProvider(); describe('getPortion test', () => { @@ -34,13 +34,19 @@ describe('portion provider', () => { const tokenAddress1 = token1.wrapped.address; const tokenAddress2 = token2.wrapped.address; - it(`token address ${tokenAddress1} to token address ${tokenAddress2} within the list, should have portion`, async () => { - await exactInGetPortionAndAssert(token2); - }); + it( + `token address ${tokenAddress1} to token address ${tokenAddress2} within the list, should have portion`, + async () => { + await exactInGetPortionAndAssert(token2); + } + ); - it(`token symbol ${tokenSymbol1} to token symbol ${tokenSymbol2} within the list, should have portion`, async () => { - await exactInGetPortionAndAssert(token2); - }); + it( + `token symbol ${tokenSymbol1} to token symbol ${tokenSymbol2} within the list, should have portion`, + async () => { + await exactInGetPortionAndAssert(token2); + } + ); }); async function exactInGetPortionAndAssert( @@ -57,13 +63,18 @@ describe('portion provider', () => { fee: new Percent(expectedPortion.bips, 10_000), recipient: expectedPortion.recipient, } - } + }; const portionAmount = portionProvider.getPortionAmount( quoteAmount, TradeType.EXACT_INPUT, + undefined, swapConfig ); - const portionAdjustedQuote = portionProvider.getQuoteGasAndPortionAdjusted(TradeType.EXACT_INPUT, quoteGasAdjustedAmount, portionAmount); + const portionAdjustedQuote = portionProvider.getQuoteGasAndPortionAdjusted( + TradeType.EXACT_INPUT, + quoteGasAdjustedAmount, + portionAmount + ); // 1605.56 * 10^8 * 5 / 10000 = 80278000 const expectedPortionAmount = quoteAmount.multiply(new Fraction(expectedPortion.bips, 10_000)); @@ -89,15 +100,21 @@ describe('portion provider', () => { const tokenAddress1 = token1.wrapped.address; const tokenAddress2 = token2.wrapped.address; - it(`token address ${tokenAddress1} to token address ${tokenAddress2} within the list, should have portion`, async () => { - const amount = parseAmount(expectedRequestAmount, token2); - await exactOutGetPortionAndAssert(amount, token1); - }); + it( + `token address ${tokenAddress1} to token address ${tokenAddress2} within the list, should have portion`, + async () => { + const amount = parseAmount(expectedRequestAmount, token2); + await exactOutGetPortionAndAssert(amount, token1); + } + ); - it(`token symbol ${tokenSymbol1} to token symbol ${tokenSymbol2} within the list, should have portion`, async () => { - const amount = parseAmount(expectedRequestAmount, token2); - await exactOutGetPortionAndAssert(amount, token1); - }); + it( + `token symbol ${tokenSymbol1} to token symbol ${tokenSymbol2} within the list, should have portion`, + async () => { + const amount = parseAmount(expectedRequestAmount, token2); + await exactOutGetPortionAndAssert(amount, token1); + } + ); }); async function exactOutGetPortionAndAssert( @@ -116,8 +133,8 @@ describe('portion provider', () => { amount: expectedPortionAmount.quotient.toString(), recipient: expectedPortion.recipient, } - } - const portionAmount = portionProvider.getPortionAmount(amount, TradeType.EXACT_OUTPUT, swapConfig); + }; + const portionAmount = portionProvider.getPortionAmount(amount, TradeType.EXACT_OUTPUT, false, swapConfig); expect(portionAmount).toBeDefined(); // 1.01 * 10^8 * 12 / 10000 = 121200 @@ -132,24 +149,73 @@ describe('portion provider', () => { ); expect(actualPortionQuoteAmount).toBeDefined(); - const expectedPortionQuoteAmount = portionAmount!.divide(portionAmount!.add(amount)).multiply(quoteAmount) + const expectedPortionQuoteAmount = portionAmount!.divide(portionAmount!.add(amount)).multiply(quoteAmount); expect(actualPortionQuoteAmount!.quotient.toString()).toBe(expectedPortionQuoteAmount.quotient.toString()); - const actualCorrectedQuoteAmount = portionProvider.getQuote(TradeType.EXACT_OUTPUT, quoteAmount, actualPortionQuoteAmount); + const actualCorrectedQuoteAmount = portionProvider.getQuote( + TradeType.EXACT_OUTPUT, + quoteAmount, + actualPortionQuoteAmount + ); const expectedCorrectedQuoteAmount = quoteAmount.subtract(actualPortionQuoteAmount!); expect(actualCorrectedQuoteAmount?.quotient.toString()).toBe(expectedCorrectedQuoteAmount.quotient.toString()); - const actualCorrectedQuoteGasAdjustedAmount = portionProvider.getQuoteGasAdjusted(TradeType.EXACT_OUTPUT, quoteGasAdjustedAmount, actualPortionQuoteAmount); + const actualCorrectedQuoteGasAdjustedAmount = portionProvider.getQuoteGasAdjusted( + TradeType.EXACT_OUTPUT, + quoteGasAdjustedAmount, + actualPortionQuoteAmount + ); const expectedCorrectedQuoteGasAdjustedAmount = quoteGasAdjustedAmount.subtract(actualPortionQuoteAmount!); - expect(actualCorrectedQuoteGasAdjustedAmount?.quotient.toString()).toBe(expectedCorrectedQuoteGasAdjustedAmount.quotient.toString()) + expect(actualCorrectedQuoteGasAdjustedAmount?.quotient.toString()) + .toBe(expectedCorrectedQuoteGasAdjustedAmount.quotient.toString()); - const actualCorrectedQuoteGasAndPortionAdjustedAmount = portionProvider.getQuoteGasAndPortionAdjusted(TradeType.EXACT_OUTPUT, actualCorrectedQuoteGasAdjustedAmount, portionAmount); + const actualCorrectedQuoteGasAndPortionAdjustedAmount = portionProvider.getQuoteGasAndPortionAdjusted( + TradeType.EXACT_OUTPUT, + actualCorrectedQuoteGasAdjustedAmount, + portionAmount + ); // 1605.56 * 10^18 + 121200 / (1.01 * 10^8 + 121200) * 1605.56 * 10^18 = 1.6074867e+21 // (exact in quote gas adjusted amount) * (ETH decimal scale) + (portion amount) / (exact out requested amount + portion amount) * (exact in quote amount) * (ETH decimal scale) // = (quote gas and portion adjusted amount) - expect(actualCorrectedQuoteGasAndPortionAdjustedAmount?.quotient.toString()).toBe(actualCorrectedQuoteGasAdjustedAmount.quotient.toString()); + expect(actualCorrectedQuoteGasAndPortionAdjustedAmount?.quotient.toString()) + .toBe(actualCorrectedQuoteGasAdjustedAmount.quotient.toString()); } }); + + describe('TokenOutHasFot flag is true', () => { + + GREENLIST_TOKEN_PAIRS.forEach((pair) => { + const token1: Currency | Token = pair[0].isNative ? (pair[0] as Currency) : pair[0].wrapped; + const token2: Currency | Token = pair[1].isNative ? (pair[1] as Currency) : pair[1].wrapped; + const tokenAddress1 = token1.wrapped.address; + const tokenAddress2 = token2.wrapped.address; + + it( + `token address ${tokenAddress1} to token address ${tokenAddress2} within the list, but tokenOut has FOT, should not have portion`, + async () => { + const quoteAmount = parseAmount(expectedQuote, token2); + + const swapConfig: SwapOptions = { + type: SwapType.UNIVERSAL_ROUTER, + slippageTolerance: new Percent(5), + recipient: '0x123', + fee: { + fee: new Percent(expectedPortion.bips, 10_000), + recipient: expectedPortion.recipient, + } + }; + const portionAmount = portionProvider.getPortionAmount( + quoteAmount, + TradeType.EXACT_INPUT, + true, + swapConfig + ); + + expect(portionAmount).toBeUndefined(); + } + ); + }); + }); }); describe('getRouteWithQuotePortionAdjusted test', () => { @@ -170,7 +236,7 @@ describe('portion provider', () => { v2RouteWithQuote, v3RouteWithQuote, mixedRouteWithQuote - ] + ]; const swapParams: SwapOptions = { type: SwapType.UNIVERSAL_ROUTER, deadlineOrPreviousBlockhash: undefined, @@ -180,24 +246,40 @@ describe('portion provider', () => { fee: new Percent(FLAT_PORTION.bips, 10_000), recipient: FLAT_PORTION.recipient } - } + }; const oneHundredPercent = new Percent(1); - const routesWithQuotePortionAdjusted = portionProvider.getRouteWithQuotePortionAdjusted(TradeType.EXACT_INPUT, routesWithValidQuotes, swapParams); + const routesWithQuotePortionAdjusted = portionProvider.getRouteWithQuotePortionAdjusted( + TradeType.EXACT_INPUT, + routesWithValidQuotes, + swapParams + ); routesWithQuotePortionAdjusted.forEach((routeWithQuotePortionAdjusted) => { if (routeWithQuotePortionAdjusted instanceof V2RouteWithValidQuote) { - expect(routeWithQuotePortionAdjusted.quote.quotient.toString()).toEqual(oneHundredPercent.subtract(new Percent(FLAT_PORTION.bips, 10_000)).multiply(20).quotient.toString()) + expect(routeWithQuotePortionAdjusted.quote.quotient.toString()) + .toEqual(oneHundredPercent.subtract(new Percent(FLAT_PORTION.bips, 10_000)) + .multiply(20) + .quotient + .toString()); } if (routeWithQuotePortionAdjusted instanceof V3RouteWithValidQuote) { - expect(routeWithQuotePortionAdjusted.quote.toExact()).toEqual(oneHundredPercent.subtract(new Percent(FLAT_PORTION.bips, 10_000)).multiply(50).quotient.toString()) + expect(routeWithQuotePortionAdjusted.quote.toExact()) + .toEqual(oneHundredPercent.subtract(new Percent(FLAT_PORTION.bips, 10_000)) + .multiply(50) + .quotient + .toString()); } if (routeWithQuotePortionAdjusted instanceof V3RouteWithValidQuote) { - expect(routeWithQuotePortionAdjusted.quote.toExact()).toEqual(oneHundredPercent.subtract(new Percent(FLAT_PORTION.bips, 10_000)).multiply(60).quotient.toString()) + expect(routeWithQuotePortionAdjusted.quote.toExact()) + .toEqual(oneHundredPercent.subtract(new Percent(FLAT_PORTION.bips, 10_000)) + .multiply(60) + .quotient + .toString()); } - }) + }); }); it('exact out test', () => { @@ -217,7 +299,7 @@ describe('portion provider', () => { v2RouteWithQuote, v3RouteWithQuote, mixedRouteWithQuote - ] + ]; const swapParams: SwapOptions = { type: SwapType.UNIVERSAL_ROUTER, deadlineOrPreviousBlockhash: undefined, @@ -227,23 +309,27 @@ describe('portion provider', () => { fee: new Percent(FLAT_PORTION.bips, 10_000), recipient: FLAT_PORTION.recipient } - } + }; - const routesWithQuotePortionAdjusted = portionProvider.getRouteWithQuotePortionAdjusted(TradeType.EXACT_OUTPUT, routesWithValidQuotes, swapParams); + const routesWithQuotePortionAdjusted = portionProvider.getRouteWithQuotePortionAdjusted( + TradeType.EXACT_OUTPUT, + routesWithValidQuotes, + swapParams + ); routesWithQuotePortionAdjusted.forEach((routeWithQuotePortionAdjusted) => { if (routeWithQuotePortionAdjusted instanceof V2RouteWithValidQuote) { - expect(routeWithQuotePortionAdjusted.quote.quotient.toString()).toEqual('20') + expect(routeWithQuotePortionAdjusted.quote.quotient.toString()).toEqual('20'); } if (routeWithQuotePortionAdjusted instanceof V3RouteWithValidQuote) { - expect(routeWithQuotePortionAdjusted.quote.quotient.toString()).toEqual('50') + expect(routeWithQuotePortionAdjusted.quote.quotient.toString()).toEqual('50'); } if (routeWithQuotePortionAdjusted instanceof V3RouteWithValidQuote) { - expect(routeWithQuotePortionAdjusted.quote.quotient.toString()).toEqual('30') + expect(routeWithQuotePortionAdjusted.quote.quotient.toString()).toEqual('30'); } - }) + }); }); }); }); From f29b58cd37dc0c888537f4f34c3f07657b1364a7 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Mon, 22 Apr 2024 11:02:18 -0700 Subject: [PATCH 14/30] fix: missing chains for outside of same map config (#549) - **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) Bug fix - **What is the current behavior?** (You can also link to an open issue here) I was reviewing onchain quote provider config, and realized the same config map only contains Polygon. I populated for all networks to be safe for future references. Also I realized the [NETWORKS_WITH_SAME_UNISWAP_ADDRESSES](https://github.com/Uniswap/smart-order-router/blob/f73799d8025bddfea725df93f9dad6ecbe895d62/src/util/chains.ts#L53) doesn't contain all the production networks, so I need to manually populate them to be extra safe. - **What is the new behavior (if this is a feature change)?** Add the missing chains for the same config mapping. - **Other information**: --- src/util/addresses.ts | 6 ++++++ src/util/onchainQuoteProviderConfigs.ts | 25 +++++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/util/addresses.ts b/src/util/addresses.ts index d2dbe17cb..c0f20744f 100644 --- a/src/util/addresses.ts +++ b/src/util/addresses.ts @@ -67,7 +67,13 @@ export const QUOTER_V2_ADDRESSES: AddressMap = { export const NEW_QUOTER_V2_ADDRESSES: AddressMap = { ...constructSameAddressMap('0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3'), + [ChainId.CELO]: '0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3', + [ChainId.CELO_ALFAJORES]: '0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3', + [ChainId.OPTIMISM_SEPOLIA]: '0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3', [ChainId.SEPOLIA]: '0xf0c802dcb0cf1c4f7b953756b49d940eed190221', + [ChainId.ARBITRUM_SEPOLIA]: '0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3', + [ChainId.BNB]: '0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3', + [ChainId.AVALANCHE]: '0xf0c802dcb0cf1c4f7b953756b49d940eed190221', [ChainId.POLYGON_MUMBAI]: '0x60e06b92bC94a665036C26feC5FF2A92E2d04c5f', [ChainId.BASE]: '0x222cA98F00eD15B1faE10B61c277703a194cf5d2', [ChainId.BLAST]: '0x9D0F15f2cf58655fDDcD1EE6129C547fDaeD01b1', diff --git a/src/util/onchainQuoteProviderConfigs.ts b/src/util/onchainQuoteProviderConfigs.ts index 927712a69..a40987e78 100644 --- a/src/util/onchainQuoteProviderConfigs.ts +++ b/src/util/onchainQuoteProviderConfigs.ts @@ -4,10 +4,12 @@ import { BatchParams, BlockNumberConfig, FailureOverrides, - QuoteRetryOptions + QuoteRetryOptions, } from '../providers'; -export const NETWORKS_WITH_SAME_RETRY_OPTIONS = [ChainId.POLYGON]; +export const NETWORKS_WITH_SAME_RETRY_OPTIONS = Object.values( + ChainId +) as ChainId[]; export function constructSameRetryOptionsMap( retryOptions: T, @@ -31,7 +33,9 @@ export const RETRY_OPTIONS = { ...constructSameRetryOptionsMap(DEFAULT_RETRY_OPTIONS), }; -export const NETWORKS_WITH_SAME_BATCH_PARAMS = [ChainId.POLYGON]; +export const NETWORKS_WITH_SAME_BATCH_PARAMS = Object.values( + ChainId +) as ChainId[]; export function constructSameBatchParamsMap( batchParams: T, @@ -55,7 +59,9 @@ export const BATCH_PARAMS = { ...constructSameBatchParamsMap(DEFAULT_BATCH_PARAMS), }; -export const NETWORKS_WITH_SAME_GAS_ERROR_FAILURE_OVERRIDES = [ChainId.POLYGON]; +export const NETWORKS_WITH_SAME_GAS_ERROR_FAILURE_OVERRIDES = Object.values( + ChainId +) as ChainId[]; export function constructSameGasErrorFailureOverridesMap< T extends FailureOverrides @@ -104,8 +110,7 @@ export function constructSameSuccessRateFailureOverridesMap< }, {}); } -export const DEFAULT_SUCCESS_RATE_FAILURE_OVERRIDES: FailureOverrides = -{ +export const DEFAULT_SUCCESS_RATE_FAILURE_OVERRIDES: FailureOverrides = { gasLimitOverride: 1_300_000, multicallChunk: 110, }; @@ -116,7 +121,9 @@ export const SUCCESS_RATE_FAILURE_OVERRIDES = { ), }; -export const NETWORKS_WITH_SAME_BLOCK_NUMBER_CONFIGS = [ChainId.POLYGON]; +export const NETWORKS_WITH_SAME_BLOCK_NUMBER_CONFIGS = Object.values( + ChainId +) as ChainId[]; export function constructSameBlockNumberConfigsMap( blockNumberConfigs: T, @@ -138,7 +145,5 @@ export const DEFAULT_BLOCK_NUMBER_CONFIGS: BlockNumberConfig = { }; export const BLOCK_NUMBER_CONFIGS = { - ...constructSameBlockNumberConfigsMap( - DEFAULT_BLOCK_NUMBER_CONFIGS - ), + ...constructSameBlockNumberConfigsMap(DEFAULT_BLOCK_NUMBER_CONFIGS), }; From 1a7103950fb79681737c2fdb23a2c24ed46f9946 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Mon, 22 Apr 2024 11:06:12 -0700 Subject: [PATCH 15/30] chore: bump to v3.28.6 (#548) - **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) Release https://github.com/Uniswap/smart-order-router/pull/547 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d603d1226..759432e60 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.5", + "version": "3.28.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.5", + "version": "3.28.6", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index 54422fb08..772ca84ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.5", + "version": "3.28.6", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From 21744dd88cb802bf4f6f6b647f455cca2503f29e Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Tue, 23 Apr 2024 09:31:07 -0700 Subject: [PATCH 16/30] chore: bump to v3.28.7 (#550) - **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) Release https://github.com/Uniswap/smart-order-router/pull/549 & https://github.com/Uniswap/smart-order-router/pull/540 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 759432e60..1b6b0def3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.6", + "version": "3.28.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.6", + "version": "3.28.7", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index 772ca84ad..123d387f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.6", + "version": "3.28.7", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From bebfaf1e8c89f04b61527af8e46d760ae4d0942f Mon Sep 17 00:00:00 2001 From: Miguel Cervera Date: Fri, 26 Apr 2024 14:12:23 -0700 Subject: [PATCH 17/30] chore: add metrics to subgraph provider (#552) * chore: add metrics to subgraph provider * better metrics for subgraph provider * improve metrics and add v3 * base deviation is 39 now * optimism variation 61 --- src/providers/v2/subgraph-provider.ts | 34 +++++++++++++++++++ src/providers/v3/subgraph-provider.ts | 26 +++++++++++++- .../alpha-router.integration.test.ts | 4 +-- 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/src/providers/v2/subgraph-provider.ts b/src/providers/v2/subgraph-provider.ts index 6a171d377..47251de7d 100644 --- a/src/providers/v2/subgraph-provider.ts +++ b/src/providers/v2/subgraph-provider.ts @@ -5,6 +5,7 @@ import { gql, GraphQLClient } from 'graphql-request'; import _ from 'lodash'; import { log } from '../../util/log'; +import { metric } from '../../util/metric'; import { ProviderConfig } from '../provider'; export interface V2SubgraphPool { @@ -80,6 +81,7 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { _tokenOut?: Token, providerConfig?: ProviderConfig ): Promise { + const beforeAll = Date.now(); let blockNumber = providerConfig?.blockNumber ? await providerConfig.blockNumber : undefined; @@ -111,6 +113,7 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { }.` ); + let outerRetries = 0; await retry( async () => { const timeout = new Timeout(); @@ -120,25 +123,42 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { let pairs: RawV2SubgraphPool[] = []; let pairsPage: RawV2SubgraphPool[] = []; + // metrics variables + let totalPages = 0; + let retries = 0; + do { + totalPages += 1; + await retry( async () => { + const before = Date.now(); const poolsResult = await this.client.request<{ pairs: RawV2SubgraphPool[]; }>(query2, { pageSize: this.pageSize, id: lastId, }); + metric.putMetric( + `V2SubgraphProvider.chain_${this.chainId}.getPools.paginate.latency`, + Date.now() - before + ); pairsPage = poolsResult.pairs; pairs = pairs.concat(pairsPage); lastId = pairs[pairs.length - 1]!.id; + + metric.putMetric( + `V2SubgraphProvider.chain_${this.chainId}.getPools.paginate.pageSize`, + pairsPage.length + ); }, { retries: this.retries, onRetry: (err, retry) => { pools = []; + retries += 1; log.info( { err }, `Failed request for page of pools from subgraph. Retry attempt: ${retry}` @@ -148,6 +168,10 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { ); } while (pairsPage.length > 0); + metric.putMetric(`V2SubgraphProvider.chain_${this.chainId}.getPools.paginate`, totalPages); + metric.putMetric(`V2SubgraphProvider.chain_${this.chainId}.getPools.pairs.length`, pairs.length); + metric.putMetric(`V2SubgraphProvider.chain_${this.chainId}.getPools.paginate.retries`, retries); + return pairs; }; @@ -171,16 +195,19 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { { retries: this.retries, onRetry: (err, retry) => { + outerRetries += 1; if ( this.rollback && blockNumber && _.includes(err.message, 'indexed up to') ) { + metric.putMetric(`V2SubgraphProvider.chain_${this.chainId}.getPools.indexError`, 1); blockNumber = blockNumber - 10; log.info( `Detected subgraph indexing error. Rolled back block number to: ${blockNumber}` ); } + metric.putMetric(`V2SubgraphProvider.chain_${this.chainId}.getPools.timeout`, 1); pools = []; log.info( { err }, @@ -190,6 +217,8 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { } ); + metric.putMetric(`V2SubgraphProvider.chain_${this.chainId}.getPools.retries`, outerRetries); + // Filter pools that have tracked reserve ETH less than threshold. // trackedReserveETH filters pools that do not involve a pool from this allowlist: // https://github.com/Uniswap/v2-subgraph/blob/7c82235cad7aee4cfce8ea82f0030af3d224833e/src/mappings/pricing.ts#L43 @@ -198,6 +227,7 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { // TODO: Remove. Temporary fix to ensure tokens without trackedReserveETH are in the list. const FEI = '0x956f47f50a910163d8bf957cf5846d573e7f87ca'; + const beforeFilter = Date.now(); const poolsSanitized: V2SubgraphPool[] = pools .filter((pool) => { return ( @@ -222,6 +252,10 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { }; }); + metric.putMetric(`V2SubgraphProvider.chain_${this.chainId}.getPools.filter.latency`, Date.now() - beforeFilter); + metric.putMetric(`V2SubgraphProvider.chain_${this.chainId}.getPools`, 1); + metric.putMetric(`V2SubgraphProvider.chain_${this.chainId}.getPools.latency`, Date.now() - beforeAll); + log.info( `Got ${pools.length} V2 pools from the subgraph. ${poolsSanitized.length} after filtering` ); diff --git a/src/providers/v3/subgraph-provider.ts b/src/providers/v3/subgraph-provider.ts index e5e08d7bf..63645f28c 100644 --- a/src/providers/v3/subgraph-provider.ts +++ b/src/providers/v3/subgraph-provider.ts @@ -4,7 +4,7 @@ import Timeout from 'await-timeout'; import { gql, GraphQLClient } from 'graphql-request'; import _ from 'lodash'; -import { log } from '../../util'; +import { log, metric } from '../../util'; import { ProviderConfig } from '../provider'; import { V2SubgraphPool } from '../v2/subgraph-provider'; @@ -107,6 +107,7 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { _tokenOut?: Token, providerConfig?: ProviderConfig ): Promise { + const beforeAll = Date.now(); let blockNumber = providerConfig?.blockNumber ? await providerConfig.blockNumber : undefined; @@ -145,6 +146,8 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { }.` ); + let retries = 0; + await retry( async () => { const timeout = new Timeout(); @@ -154,7 +157,12 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { let pools: RawV3SubgraphPool[] = []; let poolsPage: RawV3SubgraphPool[] = []; + // metrics variables + let totalPages = 0; + do { + totalPages += 1; + const poolsResult = await this.client.request<{ pools: RawV3SubgraphPool[]; }>(query, { @@ -167,8 +175,13 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { pools = pools.concat(poolsPage); lastId = pools[pools.length - 1]!.id; + metric.putMetric(`V3SubgraphProvider.chain_${this.chainId}.getPools.paginate.pageSize`, poolsPage.length); + } while (poolsPage.length > 0); + metric.putMetric(`V3SubgraphProvider.chain_${this.chainId}.getPools.paginate`, totalPages); + metric.putMetric(`V3SubgraphProvider.chain_${this.chainId}.getPools.pools.length`, pools.length); + return pools; }; @@ -192,16 +205,19 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { { retries: this.retries, onRetry: (err, retry) => { + retries += 1; if ( this.rollback && blockNumber && _.includes(err.message, 'indexed up to') ) { + metric.putMetric(`V3SubgraphProvider.chain_${this.chainId}.getPools.indexError`, 1); blockNumber = blockNumber - 10; log.info( `Detected subgraph indexing error. Rolled back block number to: ${blockNumber}` ); } + metric.putMetric(`V3SubgraphProvider.chain_${this.chainId}.getPools.timeout`, 1); pools = []; log.info( { err }, @@ -211,6 +227,9 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { } ); + metric.putMetric(`V3SubgraphProvider.chain_${this.chainId}.getPools.retries`, retries); + + const beforeFilter = Date.now(); const poolsSanitized = pools .filter( (pool) => @@ -234,6 +253,11 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { }; }); + metric.putMetric(`V3SubgraphProvider.chain_${this.chainId}.getPools.filter.latency`, Date.now() - beforeFilter); + + metric.putMetric(`V3SubgraphProvider.chain_${this.chainId}.getPools`, 1); + metric.putMetric(`V3SubgraphProvider.chain_${this.chainId}.getPools.latency`, Date.now() - beforeAll); + log.info( `Got ${pools.length} V3 pools from the subgraph. ${poolsSanitized.length} after filtering` ); diff --git a/test/integ/routers/alpha-router/alpha-router.integration.test.ts b/test/integ/routers/alpha-router/alpha-router.integration.test.ts index 19cad6619..842edffa3 100644 --- a/test/integ/routers/alpha-router/alpha-router.integration.test.ts +++ b/test/integ/routers/alpha-router/alpha-router.integration.test.ts @@ -120,7 +120,7 @@ const GAS_ESTIMATE_DEVIATION_PERCENT: { [chainId in ChainId]: number } = { [ChainId.MAINNET]: 40, [ChainId.GOERLI]: 62, [ChainId.SEPOLIA]: 50, - [ChainId.OPTIMISM]: 35, + [ChainId.OPTIMISM]: 61, [ChainId.OPTIMISM_GOERLI]: 30, [ChainId.OPTIMISM_SEPOLIA]: 30, [ChainId.ARBITRUM_ONE]: 53, @@ -134,7 +134,7 @@ const GAS_ESTIMATE_DEVIATION_PERCENT: { [chainId in ChainId]: number } = { [ChainId.MOONBEAM]: 30, [ChainId.BNB]: 44, [ChainId.AVALANCHE]: 36, - [ChainId.BASE]: 34, + [ChainId.BASE]: 39, [ChainId.BASE_GOERLI]: 30, [ChainId.ZORA]: 30, [ChainId.ZORA_SEPOLIA]: 30, From 0bbd19ca412a0459de5ef7510e7b4e1f411f673f Mon Sep 17 00:00:00 2001 From: Miguel Cervera Date: Mon, 6 May 2024 10:26:05 -0700 Subject: [PATCH 18/30] Allow SubgraphProviders to receive a URL override (#558) --- src/providers/v2/subgraph-provider.ts | 5 +++-- src/providers/v3/subgraph-provider.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/providers/v2/subgraph-provider.ts b/src/providers/v2/subgraph-provider.ts index 47251de7d..ef1d2cd76 100644 --- a/src/providers/v2/subgraph-provider.ts +++ b/src/providers/v2/subgraph-provider.ts @@ -67,9 +67,10 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { private retries = 2, private timeout = 360000, private rollback = true, - private pageSize = PAGE_SIZE + private pageSize = PAGE_SIZE, + private subgraphUrlOverride?: string ) { - const subgraphUrl = SUBGRAPH_URL_BY_CHAIN[this.chainId]; + const subgraphUrl = this.subgraphUrlOverride ?? SUBGRAPH_URL_BY_CHAIN[this.chainId]; if (!subgraphUrl) { throw new Error(`No subgraph url for chain id: ${this.chainId}`); } diff --git a/src/providers/v3/subgraph-provider.ts b/src/providers/v3/subgraph-provider.ts index 63645f28c..77cbf82c4 100644 --- a/src/providers/v3/subgraph-provider.ts +++ b/src/providers/v3/subgraph-provider.ts @@ -93,9 +93,10 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { private chainId: ChainId, private retries = 2, private timeout = 30000, - private rollback = true + private rollback = true, + private subgraphUrlOverride?: string ) { - const subgraphUrl = SUBGRAPH_URL_BY_CHAIN[this.chainId]; + const subgraphUrl = this.subgraphUrlOverride ?? SUBGRAPH_URL_BY_CHAIN[this.chainId]; if (!subgraphUrl) { throw new Error(`No subgraph url for chain id: ${this.chainId}`); } From 0c3978b082170cdb8befc693644b5f704aac8691 Mon Sep 17 00:00:00 2001 From: Miguel Cervera Date: Mon, 6 May 2024 14:01:38 -0700 Subject: [PATCH 19/30] 3.28.9 (#559) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1b6b0def3..4cdc4487f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.7", + "version": "3.28.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.7", + "version": "3.28.9", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index 123d387f2..090728fe6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.7", + "version": "3.28.9", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From dd68b4003376f629c22948cf4d0908071cbab591 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Thu, 9 May 2024 07:08:18 -0700 Subject: [PATCH 20/30] fix: mixed quoter fallback to new view-only quoter (#561) - **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) Bug fix - **What is the current behavior?** (You can also link to an open issue here) When in mixed quote path, we fallback to the revert quoter - **What is the new behavior (if this is a feature change)?** When in mixed quote path, we should fallback to the view-only quoter now. - **Other information**: I expect the overall quote endpoint latency to improve along with the gas param tuning. --- src/providers/on-chain-quote-provider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/providers/on-chain-quote-provider.ts b/src/providers/on-chain-quote-provider.ts index 233f46430..a57de3be9 100644 --- a/src/providers/on-chain-quote-provider.ts +++ b/src/providers/on-chain-quote-provider.ts @@ -17,7 +17,7 @@ import { IQuoterV2__factory } from '../types/v3/factories/IQuoterV2__factory'; import { ID_TO_NETWORK_NAME, metric, MetricLoggerUnit } from '../util'; import { MIXED_ROUTE_QUOTER_V1_ADDRESSES, - QUOTER_V2_ADDRESSES, + NEW_QUOTER_V2_ADDRESSES, } from '../util/addresses'; import { CurrencyAmount } from '../util/amounts'; import { log } from '../util/log'; @@ -326,7 +326,7 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { } const quoterAddress = useMixedRouteQuoter ? MIXED_ROUTE_QUOTER_V1_ADDRESSES[this.chainId] - : QUOTER_V2_ADDRESSES[this.chainId]; + : NEW_QUOTER_V2_ADDRESSES[this.chainId]; if (!quoterAddress) { throw new Error( From ad23481fa205a767d0332ce88ad43124117b316b Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Thu, 9 May 2024 08:38:07 -0700 Subject: [PATCH 21/30] chore: log quote sucecss rate metric (#563) * fix: multicall return gas used in case of failure (#534) * return gas used from multicall in case of a failed quote * fix compiling error * add target contract address to the failed multicall debug log * also return gas limit * fix: multicall return gas used in case of failure (#534) * return gas used from multicall in case of a failed quote * fix compiling error * add target contract address to the failed multicall debug log * also return gas limit * log quote success rate metric --- src/providers/on-chain-quote-provider.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/providers/on-chain-quote-provider.ts b/src/providers/on-chain-quote-provider.ts index a57de3be9..0d359500a 100644 --- a/src/providers/on-chain-quote-provider.ts +++ b/src/providers/on-chain-quote-provider.ts @@ -515,7 +515,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { const successRateError = this.validateSuccessRate( results.results, - haveRetriedForSuccessRate + haveRetriedForSuccessRate, + useMixedRouteQuoter ); if (successRateError) { @@ -1046,7 +1047,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { protected validateSuccessRate( allResults: Result<[BigNumber, BigNumber[], number[], BigNumber]>[], - haveRetriedForSuccessRate: boolean + haveRetriedForSuccessRate: boolean, + useMixedRouteQuoter: boolean ): void | SuccessRateError { const numResults = allResults.length; const numSuccessResults = allResults.filter( @@ -1061,9 +1063,12 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { log.info( `Quote success rate still below threshold despite retry. Continuing. ${quoteMinSuccessRate}: ${successRate}` ); + metric.putMetric(`${this.metricsPrefix(this.chainId, useMixedRouteQuoter)}QuoteRetriedSuccessRateLow`, successRate, MetricLoggerUnit.Percent); + return; } + metric.putMetric(`${this.metricsPrefix(this.chainId, useMixedRouteQuoter)}QuoteSuccessRateLow`, successRate, MetricLoggerUnit.Percent); return new SuccessRateError( `Quote success rate below threshold of ${quoteMinSuccessRate}: ${successRate}` ); From 6ab530cb225d4ea6ccc0b9a15613a5102f3849cc Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Thu, 9 May 2024 08:58:26 -0700 Subject: [PATCH 22/30] 3.28.10 (#562) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4cdc4487f..3dc27906e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.9", + "version": "3.28.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.9", + "version": "3.28.10", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index 090728fe6..5dea1b128 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.9", + "version": "3.28.10", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From 9df621cee559d0621110b6a66453715ee5729c6e Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Thu, 9 May 2024 09:02:11 -0700 Subject: [PATCH 23/30] chore: bump to v3.28.11 (#565) * fix: multicall return gas used in case of failure (#534) * return gas used from multicall in case of a failed quote * fix compiling error * add target contract address to the failed multicall debug log * also return gas limit * 3.28.11 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3dc27906e..548a9d9d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.10", + "version": "3.28.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.10", + "version": "3.28.11", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index 5dea1b128..0848e76d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.10", + "version": "3.28.11", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From 9862bd92b3ff25e245f5658894ae7908ad97afa9 Mon Sep 17 00:00:00 2001 From: Miguel Cervera Date: Thu, 9 May 2024 12:08:00 -0700 Subject: [PATCH 24/30] chore(subgraph): Remove not necessary fields (#566) --- src/providers/v2/subgraph-provider.ts | 1 - src/providers/v3/subgraph-provider.ts | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/providers/v2/subgraph-provider.ts b/src/providers/v2/subgraph-provider.ts index ef1d2cd76..883899ffa 100644 --- a/src/providers/v2/subgraph-provider.ts +++ b/src/providers/v2/subgraph-provider.ts @@ -239,7 +239,6 @@ export class V2SubgraphProvider implements IV2SubgraphProvider { }) .map((pool) => { return { - ...pool, id: pool.id.toLowerCase(), token0: { id: pool.token0.id.toLowerCase(), diff --git a/src/providers/v3/subgraph-provider.ts b/src/providers/v3/subgraph-provider.ts index 77cbf82c4..f22e6b391 100644 --- a/src/providers/v3/subgraph-provider.ts +++ b/src/providers/v3/subgraph-provider.ts @@ -238,17 +238,18 @@ export class V3SubgraphProvider implements IV3SubgraphProvider { parseFloat(pool.totalValueLockedETH) > 0.01 ) .map((pool) => { - const { totalValueLockedETH, totalValueLockedUSD, ...rest } = pool; + const { totalValueLockedETH, totalValueLockedUSD } = pool; return { - ...rest, id: pool.id.toLowerCase(), + feeTier: pool.feeTier, token0: { id: pool.token0.id.toLowerCase(), }, token1: { id: pool.token1.id.toLowerCase(), }, + liquidity: pool.liquidity, tvlETH: parseFloat(totalValueLockedETH), tvlUSD: parseFloat(totalValueLockedUSD), }; From 5af930df1cd2a448ea03b11756705cae20c9105c Mon Sep 17 00:00:00 2001 From: Miguel Cervera Date: Thu, 9 May 2024 12:31:53 -0700 Subject: [PATCH 25/30] 3.28.12 (#567) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 548a9d9d1..2668e3f5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.11", + "version": "3.28.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.11", + "version": "3.28.12", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index 0848e76d8..54a2fdcf9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.11", + "version": "3.28.12", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From 1e8678057ae5d7a84e3b789b7e7a337174b66515 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Thu, 9 May 2024 16:24:54 -0700 Subject: [PATCH 26/30] chore: log optimistic quote metrics prefix in onchain quoting (#568) * fix: multicall return gas used in case of failure (#534) * return gas used from multicall in case of a failed quote * fix compiling error * add target contract address to the failed multicall debug log * also return gas limit * log optimistic quote metrics prefix in onchain quoting * fix prettier * add underscore metrics prefix * use provider config --- src/providers/on-chain-quote-provider.ts | 89 ++++++++++++++----- src/providers/provider.ts | 5 ++ .../alpha-router/quoters/mixed-quoter.ts | 4 +- src/routers/alpha-router/quoters/v3-quoter.ts | 4 +- 4 files changed, 73 insertions(+), 29 deletions(-) diff --git a/src/providers/on-chain-quote-provider.ts b/src/providers/on-chain-quote-provider.ts index 0d359500a..2feac8b13 100644 --- a/src/providers/on-chain-quote-provider.ts +++ b/src/providers/on-chain-quote-provider.ts @@ -303,14 +303,17 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { // In alpha-router default case, we will also define the constants with same values as below. protected successRateFailureOverrides: FailureOverrides = DEFAULT_SUCCESS_RATE_FAILURE_OVERRIDES, protected blockNumberConfig: BlockNumberConfig = DEFAULT_BLOCK_NUMBER_CONFIGS, - protected quoterAddressOverride?: (useMixedRouteQuoter: boolean) => string | undefined, + protected quoterAddressOverride?: ( + useMixedRouteQuoter: boolean + ) => string | undefined, protected metricsPrefix: ( chainId: ChainId, - useMixedRouteQuoter: boolean - ) => string = (chainId, useMixedRouteQuoter) => + useMixedRouteQuoter: boolean, + optimisticCachedRoutes: boolean + ) => string = (chainId, useMixedRouteQuoter, optimisticCachedRoutes) => useMixedRouteQuoter - ? `ChainId_${chainId}_MixedQuoter` - : `ChainId_${chainId}_V3Quoter` + ? `ChainId_${chainId}_MixedQuoter_OptimisticCachedRoutes${optimisticCachedRoutes}_` + : `ChainId_${chainId}_V3Quoter_OptimisticCachedRoutes${optimisticCachedRoutes}_` ) {} private getQuoterAddress(useMixedRouteQuoter: boolean): string { @@ -375,6 +378,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { const useMixedRouteQuoter = routes.some((route) => route.protocol === Protocol.V2) || routes.some((route) => route.protocol === Protocol.MIXED); + const optimisticCachedRoutes = + _providerConfig?.optimisticCachedRoutes ?? false; /// Validate that there are no incorrect routes / function combinations this.validateRoutes(routes, functionName, useMixedRouteQuoter); @@ -437,14 +442,19 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { ); metric.putMetric( - `${this.metricsPrefix(this.chainId, useMixedRouteQuoter)}QuoteBatchSize`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter, + optimisticCachedRoutes + )}QuoteBatchSize`, inputs.length, MetricLoggerUnit.Count ); metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteBatchSize_${ID_TO_NETWORK_NAME(this.chainId)}`, inputs.length, MetricLoggerUnit.Count @@ -516,7 +526,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { const successRateError = this.validateSuccessRate( results.results, haveRetriedForSuccessRate, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes ); if (successRateError) { @@ -621,7 +632,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteBlockConflictErrorRetry`, 1, MetricLoggerUnit.Count @@ -635,7 +647,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteBlockHeaderNotFoundRetry`, 1, MetricLoggerUnit.Count @@ -678,7 +691,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteTimeoutRetry`, 1, MetricLoggerUnit.Count @@ -690,7 +704,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteOutOfGasExceptionRetry`, 1, MetricLoggerUnit.Count @@ -705,7 +720,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteSuccessRateRetry`, 1, MetricLoggerUnit.Count @@ -724,7 +740,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteUnknownReasonRetry`, 1, MetricLoggerUnit.Count @@ -816,7 +833,11 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { const endTime = Date.now(); metric.putMetric( - `${this.metricsPrefix(this.chainId, useMixedRouteQuoter)}QuoteLatency`, + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter, + optimisticCachedRoutes + )}QuoteLatency`, endTime - startTime, MetricLoggerUnit.Milliseconds ); @@ -824,7 +845,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteApproxGasUsedPerSuccessfulCall`, approxGasUsedPerSuccessCall, MetricLoggerUnit.Count @@ -833,7 +855,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteNumRetryLoops`, finalAttemptNumber - 1, MetricLoggerUnit.Count @@ -842,7 +865,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteTotalCallsToProvider`, totalCallsMade, MetricLoggerUnit.Count @@ -851,7 +875,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteExpectedCallsToProvider`, expectedCallsMade, MetricLoggerUnit.Count @@ -860,7 +885,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { metric.putMetric( `${this.metricsPrefix( this.chainId, - useMixedRouteQuoter + useMixedRouteQuoter, + optimisticCachedRoutes )}QuoteNumRetriedCalls`, totalCallsMade - expectedCallsMade, MetricLoggerUnit.Count @@ -1048,7 +1074,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { protected validateSuccessRate( allResults: Result<[BigNumber, BigNumber[], number[], BigNumber]>[], haveRetriedForSuccessRate: boolean, - useMixedRouteQuoter: boolean + useMixedRouteQuoter: boolean, + optimisticCachedRoutes: boolean ): void | SuccessRateError { const numResults = allResults.length; const numSuccessResults = allResults.filter( @@ -1063,12 +1090,28 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider { log.info( `Quote success rate still below threshold despite retry. Continuing. ${quoteMinSuccessRate}: ${successRate}` ); - metric.putMetric(`${this.metricsPrefix(this.chainId, useMixedRouteQuoter)}QuoteRetriedSuccessRateLow`, successRate, MetricLoggerUnit.Percent); + metric.putMetric( + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter, + optimisticCachedRoutes + )}QuoteRetriedSuccessRateLow`, + successRate, + MetricLoggerUnit.Percent + ); return; } - metric.putMetric(`${this.metricsPrefix(this.chainId, useMixedRouteQuoter)}QuoteSuccessRateLow`, successRate, MetricLoggerUnit.Percent); + metric.putMetric( + `${this.metricsPrefix( + this.chainId, + useMixedRouteQuoter, + optimisticCachedRoutes + )}QuoteSuccessRateLow`, + successRate, + MetricLoggerUnit.Percent + ); return new SuccessRateError( `Quote success rate below threshold of ${quoteMinSuccessRate}: ${successRate}` ); diff --git a/src/providers/provider.ts b/src/providers/provider.ts index 1b5ed44ba..7c5638e7f 100644 --- a/src/providers/provider.ts +++ b/src/providers/provider.ts @@ -16,6 +16,11 @@ export type ProviderConfig = { * we need this as a pass-through flag to enable/disable this feature. */ saveTenderlySimulationIfFailed?: boolean; + /** + * Flag to indicate whether to use the CachedRoutes in optimistic mode. + * Optimistic mode means that we will allow blocksToLive greater than 1. + */ + optimisticCachedRoutes?: boolean; }; export type LocalCacheEntry = { diff --git a/src/routers/alpha-router/quoters/mixed-quoter.ts b/src/routers/alpha-router/quoters/mixed-quoter.ts index 335fa7365..c8a1ec4fd 100644 --- a/src/routers/alpha-router/quoters/mixed-quoter.ts +++ b/src/routers/alpha-router/quoters/mixed-quoter.ts @@ -189,9 +189,7 @@ export class MixedQuoter extends BaseQuoter< `Getting quotes for mixed for ${routes.length} routes with ${amounts.length} amounts per route.` ); - const { routesWithQuotes } = await quoteFn(amounts, routes, { - blockNumber: routingConfig.blockNumber, - }); + const { routesWithQuotes } = await quoteFn(amounts, routes, routingConfig); metric.putMetric( 'MixedQuotesLoad', diff --git a/src/routers/alpha-router/quoters/v3-quoter.ts b/src/routers/alpha-router/quoters/v3-quoter.ts index e8a96cb73..464d18c88 100644 --- a/src/routers/alpha-router/quoters/v3-quoter.ts +++ b/src/routers/alpha-router/quoters/v3-quoter.ts @@ -162,9 +162,7 @@ export class V3Quoter extends BaseQuoter { `Getting quotes for V3 for ${routes.length} routes with ${amounts.length} amounts per route.` ); - const { routesWithQuotes } = await quoteFn(amounts, routes, { - blockNumber: routingConfig.blockNumber, - }); + const { routesWithQuotes } = await quoteFn(amounts, routes, routingConfig); metric.putMetric( 'V3QuotesLoad', From 4c4e3e9182d605b6653172e2e4d2a5bf56285df3 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Fri, 10 May 2024 08:40:59 -0700 Subject: [PATCH 27/30] 3.28.13 (#569) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2668e3f5d..6706f2956 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.12", + "version": "3.28.13", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@uniswap/smart-order-router", - "version": "3.28.12", + "version": "3.28.13", "license": "GPL", "dependencies": { "@eth-optimism/sdk": "^3.2.2", diff --git a/package.json b/package.json index 54a2fdcf9..4d6064f97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uniswap/smart-order-router", - "version": "3.28.12", + "version": "3.28.13", "description": "Uniswap Smart Order Router", "main": "build/main/index.js", "typings": "build/main/index.d.ts", From ca9977fb002d9fdcd5cc8330e946ea6e79772d23 Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Wed, 17 Apr 2024 08:55:41 -0700 Subject: [PATCH 28/30] fix: multicall return gas used in case of failure (#534) * return gas used from multicall in case of a failed quote * fix compiling error * add target contract address to the failed multicall debug log * also return gas limit From dff7d1643fa60b5090fcce74db715a545437dc0f Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Fri, 10 May 2024 08:36:51 -0700 Subject: [PATCH 29/30] onchain quoter batch param differed by optimistic cached routes --- src/providers/on-chain-quote-provider.ts | 29 ++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/providers/on-chain-quote-provider.ts b/src/providers/on-chain-quote-provider.ts index 2feac8b13..4311749d1 100644 --- a/src/providers/on-chain-quote-provider.ts +++ b/src/providers/on-chain-quote-provider.ts @@ -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'; @@ -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'; @@ -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, @@ -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 @@ -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( From 44b1d69aa100de1667ac2b0c79771e0e9fd9b5da Mon Sep 17 00:00:00 2001 From: jsy1218 <91580504+jsy1218@users.noreply.github.com> Date: Fri, 10 May 2024 08:37:42 -0700 Subject: [PATCH 30/30] fix prettier onchain quoter --- src/providers/on-chain-quote-provider.ts | 35 +++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/providers/on-chain-quote-provider.ts b/src/providers/on-chain-quote-provider.ts index 4311749d1..313f882c8 100644 --- a/src/providers/on-chain-quote-provider.ts +++ b/src/providers/on-chain-quote-provider.ts @@ -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'; @@ -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'; @@ -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, @@ -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