diff --git a/packages/asset-swapper/CHANGELOG.json b/packages/asset-swapper/CHANGELOG.json index de866ec49d..a81c159b06 100644 --- a/packages/asset-swapper/CHANGELOG.json +++ b/packages/asset-swapper/CHANGELOG.json @@ -14,6 +14,10 @@ { "note": "Add LUSD Curve pool", "pr": 218 + }, + { + "note": "Fix exchangeProxyGasOverhead for fallback path", + "pr": 215 } ] }, diff --git a/packages/asset-swapper/src/utils/market_operation_utils/index.ts b/packages/asset-swapper/src/utils/market_operation_utils/index.ts index 8642ce0c62..709e2a77fa 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/index.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/index.ts @@ -560,7 +560,12 @@ export class MarketOperationUtils { // We create a fallback path that is exclusive of Native liquidity // This is the optimal on-chain path for the entire input amount const nonNativeFills = fills.filter(p => p.length > 0 && p[0].source !== ERC20BridgeSource.Native); - const nonNativeOptimalPath = await findOptimalPathAsync(side, nonNativeFills, inputAmount, opts.runLimit); + const nonNativeOptimalPath = await findOptimalPathAsync(side, nonNativeFills, inputAmount, opts.runLimit, { + ...penaltyOpts, + exchangeProxyOverhead: (sourceFlags: number) => + // tslint:disable-next-line: no-bitwise + penaltyOpts.exchangeProxyOverhead(sourceFlags | optimalPath.sourceFlags), + }); // Calculate the slippage of on-chain sources compared to the most optimal path if ( nonNativeOptimalPath !== undefined &&