Skip to content

Commit

Permalink
Revert "chore: bump sor to 4.17.9 - base mixed quoter v1 address (#817)…
Browse files Browse the repository at this point in the history
…" (#818)

- **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)

- **What is the current behavior?** (You can also link to an open issue here)

- **What is the new behavior (if this is a feature change)?**

- **Other information**:
  • Loading branch information
jsy1218 authored Jan 31, 2025
1 parent 9a1e48e commit e53239a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 420 deletions.
58 changes: 29 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uniswap/smart-order-router",
"version": "4.17.9",
"version": "4.17.6",
"description": "Uniswap Smart Order Router",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
Expand Down Expand Up @@ -37,15 +37,15 @@
"@types/brotli": "^1.3.4",
"@uniswap/default-token-list": "^11.13.0",
"@uniswap/permit2-sdk": "^1.3.0",
"@uniswap/router-sdk": "^1.21.4",
"@uniswap/router-sdk": "^1.21.0",
"@uniswap/sdk-core": "^7.5.0",
"@uniswap/swap-router-contracts": "^1.3.1",
"@uniswap/token-lists": "^1.0.0-beta.31",
"@uniswap/universal-router": "^1.6.0",
"@uniswap/universal-router-sdk": "^4.15.1",
"@uniswap/universal-router-sdk": "^4.14.0",
"@uniswap/v2-sdk": "^4.13.0",
"@uniswap/v3-sdk": "^3.24.0",
"@uniswap/v4-sdk": "^1.18.1",
"@uniswap/v4-sdk": "^1.18.0",
"async-retry": "^1.3.1",
"await-timeout": "^1.1.1",
"axios": "^0.21.1",
Expand Down
16 changes: 3 additions & 13 deletions src/routers/alpha-router/entities/route-with-valid-quote.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { BigNumber } from '@ethersproject/bignumber';
import { Protocol } from '@uniswap/router-sdk';
import { Currency, Token, TradeType } from '@uniswap/sdk-core';
import { Pair } from '@uniswap/v2-sdk';
import { Pool as V3Pool } from '@uniswap/v3-sdk';
import { Pool as V4Pool } from '@uniswap/v4-sdk';
import _ from 'lodash';

import { Pair } from '@uniswap/v2-sdk';
import { IV4PoolProvider } from '../../../providers';
import { IV2PoolProvider } from '../../../providers/v2/pool-provider';
import { IV3PoolProvider } from '../../../providers/v3/pool-provider';
import { CurrencyAmount } from '../../../util/amounts';
import { FAKE_TICK_SPACING } from '../../../util/pools';
import { routeToString } from '../../../util/routes';
import {
MixedRoute,
Expand Down Expand Up @@ -431,23 +430,14 @@ export class MixedRouteWithValidQuote implements IMixedRouteWithValidQuote {
v3PoolProvider,
v2PoolProvider,
}: MixedRouteWithValidQuoteParams) {
const poolsWithoutFakePool = route.pools.filter(
(p) => !(p instanceof V4Pool && p.tickSpacing === FAKE_TICK_SPACING)
);
const routeWithoutEthWethFakePool = new MixedRoute(
poolsWithoutFakePool,
route.input,
route.output
);

this.amount = amount;
this.rawQuote = rawQuote;
this.sqrtPriceX96AfterList = sqrtPriceX96AfterList;
this.initializedTicksCrossedList = initializedTicksCrossedList;
this.quoterGasEstimate = quoterGasEstimate;
this.quote = CurrencyAmount.fromRawAmount(quoteToken, rawQuote.toString());
this.percent = percent;
this.route = routeWithoutEthWethFakePool;
this.route = route;
this.gasModel = mixedRouteGasModel;
this.quoteToken = quoteToken;
this.tradeType = tradeType;
Expand All @@ -469,7 +459,7 @@ export class MixedRouteWithValidQuote implements IMixedRouteWithValidQuote {
this.quoteAdjustedForGas = quoteGasAdjusted;
}

this.poolIdentifiers = _.map(routeWithoutEthWethFakePool.pools, (p) => {
this.poolIdentifiers = _.map(route.pools, (p) => {
if (p instanceof V4Pool) {
return v4PoolProvider.getPoolId(
p.token0,
Expand Down
35 changes: 4 additions & 31 deletions src/routers/alpha-router/functions/compute-all-routes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { TPool } from '@uniswap/router-sdk/dist/utils/TPool';
import { ChainId, Currency, Token } from '@uniswap/sdk-core';
import { Currency, Token } from '@uniswap/sdk-core';
import { Pair } from '@uniswap/v2-sdk';
import { Pool as V3Pool } from '@uniswap/v3-sdk';
import { Pool as V4Pool } from '@uniswap/v4-sdk';

import { getAddressLowerCase, nativeOnChain } from '../../../util';
import { getAddressLowerCase } from '../../../util';
import { log } from '../../../util/log';
import { FAKE_TICK_SPACING, V4_ETH_WETH_FAKE_POOL } from '../../../util/pools';
import { poolToString, routeToString } from '../../../util/routes';
import {
MixedRoute,
Expand Down Expand Up @@ -76,17 +75,6 @@ export function computeAllMixedRoutes(
parts: TPool[],
maxHops: number
): MixedRoute[] {
// only add fake v4 pool, if we see there's a native v4 pool in the candidate pool
const containsV4NativePools =
parts.filter(
(pool) =>
pool instanceof V4Pool &&
pool.involvesToken(nativeOnChain(ChainId.MAINNET))
).length > 0;
// NOTE: we added a fake v4 pool, in order for mixed route to connect the v3 weth pool with v4 eth pool
const amendedPools = containsV4NativePools
? parts.concat(V4_ETH_WETH_FAKE_POOL[currencyIn.chainId as ChainId])
: parts;
const routesRaw = computeAllRoutes<TPool, MixedRoute, Currency>(
currencyIn,
currencyOut,
Expand All @@ -97,7 +85,7 @@ export function computeAllMixedRoutes(
currency.isNative
? (pool as V4Pool).involvesToken(currency)
: pool.involvesToken(currency),
amendedPools,
parts,
maxHops
);
/// filter out pure v4 and v3 and v2 routes
Expand Down Expand Up @@ -137,22 +125,7 @@ export function computeAllRoutes<
tokensVisited: Set<string>,
_previousTokenOut?: TCurrency
) => {
const currentRouteContainsFakeV4Pool =
currentRoute.filter(
(pool) =>
pool instanceof V4Pool && pool.tickSpacing === FAKE_TICK_SPACING
).length > 0;
const amendedMaxHops = currentRouteContainsFakeV4Pool
? maxHops + 1
: maxHops;

// amendedMaxHops is the maxHops + 1 if the current route contains a fake v4 pool
// b/c we want to allow the route to go through the fake v4 pool
// also gas wise, if a route goes through the fake v4 pool, mixed quoter will add the wrap/unwrap gas cost:
// https://github.com/Uniswap/mixed-quoter/pull/41/files#diff-a4d1289f264d1da22aac20cc55a9d01c8ba9cccd76ce1af8f952ec9034e7e1aaR189
// and SOR will use the gas cost from the mixed quoter:
// https://github.com/Uniswap/smart-order-router/blob/17da523f1af050e6430afb866d96681346c8fb8b/src/routers/alpha-router/gas-models/mixedRoute/mixed-route-heuristic-gas-model.ts#L222
if (currentRoute.length > amendedMaxHops) {
if (currentRoute.length > maxHops) {
return;
}

Expand Down
2 changes: 0 additions & 2 deletions src/util/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,12 @@ export const MIXED_ROUTE_QUOTER_V1_ADDRESSES: AddressMap = {
CHAIN_TO_ADDRESSES_MAP[ChainId.MAINNET].mixedRouteQuoterV1Address,
[ChainId.GOERLI]:
CHAIN_TO_ADDRESSES_MAP[ChainId.GOERLI].mixedRouteQuoterV1Address,
[ChainId.BASE]: '0xc7A3b85D43fF66AD98A895dE0EaE4b9e24C932D7',
};

export const MIXED_ROUTE_QUOTER_V2_ADDRESSES: AddressMap = {
[ChainId.SEPOLIA]:
CHAIN_TO_ADDRESSES_MAP[ChainId.SEPOLIA].mixedRouteQuoterV2Address,
[ChainId.MAINNET]: '0xE63C5F5005909E96b5aA9CE10744CCE70eC16CC3',
[ChainId.BASE]: '0xc7A3b85D43fF66AD98A895dE0EaE4b9e24C932D7',
};

export const UNISWAP_MULTICALL_ADDRESSES: AddressMap = {
Expand Down
1 change: 0 additions & 1 deletion src/util/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const MIXED_SUPPORTED = [
ChainId.MAINNET,
ChainId.SEPOLIA,
ChainId.GOERLI,
ChainId.BASE,
];

export const HAS_L1_FEE = [
Expand Down
Loading

0 comments on commit e53239a

Please sign in to comment.