Skip to content

Commit

Permalink
Merge pull request #3 from violetprotocol/fix/pool-get-address
Browse files Browse the repository at this point in the history
[FIX] Pool getAddress
  • Loading branch information
ra-phael authored Jan 23, 2023
2 parents f60f9f3 + d71251f commit 4597967
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@violetprotocol/mauve-smart-order-router",
"version": "0.0.1",
"version": "4.0.0",
"description": "Mauve Smart Order Router",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
Expand Down
9 changes: 8 additions & 1 deletion src/providers/v3/static-subgraph-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FeeAmount, Pool } from '@uniswap/v3-sdk';
import JSBI from 'jsbi';
import _ from 'lodash';

import { V3_CORE_FACTORY_ADDRESSES } from '../../util';
import { unparseFeeAmount } from '../../util/amounts';
import { ChainId, WRAPPED_NATIVE_CURRENCY } from '../../util/chains';
import { log } from '../../util/log';
Expand Down Expand Up @@ -229,7 +230,13 @@ export class StaticV3SubgraphProvider implements IV3SubgraphProvider {
.map((pool) => {
const { token0, token1, fee, liquidity } = pool;

const poolAddress = Pool.getAddress(pool.token0, pool.token1, pool.fee);
const poolAddress = Pool.getAddress(
pool.token0,
pool.token1,
pool.fee,
undefined,
pool.chainId ? V3_CORE_FACTORY_ADDRESSES[pool.chainId] : undefined
);

if (poolAddressSet.has(poolAddress)) {
return undefined;
Expand Down
3 changes: 2 additions & 1 deletion src/routers/alpha-router/alpha-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ export class AlphaRouter
...routingConfig,
/// @dev We do not want to query for mixedRoutes for routeToRatio as they are not supported
/// [Protocol.V3, Protocol.V2] will make sure we only query for V3 and V2
protocols: [Protocol.V3, Protocol.V2],
// EDIT: Removed V2 as well for Mauve
protocols: [Protocol.V3],
}
);
if (!swap) {
Expand Down
3 changes: 3 additions & 0 deletions src/routers/alpha-router/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Protocol } from '@uniswap/router-sdk';

import { ChainId } from '../../util/chains';

import { AlphaRouterConfig } from './alpha-router';
Expand Down Expand Up @@ -65,6 +67,7 @@ export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = (
};
default:
return {
protocols: [Protocol.V3],
v2PoolSelection: {
topN: 3,
topNDirectSwaps: 1,
Expand Down
6 changes: 4 additions & 2 deletions src/util/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Pair } from '@uniswap/v2-sdk';
import { Pool } from '@uniswap/v3-sdk';
import _ from 'lodash';

import { CurrencyAmount } from '.';
import { CurrencyAmount, V3_CORE_FACTORY_ADDRESSES } from '.';
import { RouteWithValidQuote } from '../routers/alpha-router';
import { MixedRoute, V2Route, V3Route } from '../routers/router';

Expand All @@ -28,7 +28,9 @@ export const routeToString = (
? ` -- ${pool.fee / 10000}% [${Pool.getAddress(
pool.token0,
pool.token1,
pool.fee
pool.fee,
undefined,
pool.chainId ? V3_CORE_FACTORY_ADDRESSES[pool.chainId] : undefined
)}]`
: ` -- [${Pair.getAddress(
(pool as Pair).token0,
Expand Down
9 changes: 6 additions & 3 deletions test/unit/routers/alpha-router/alpha-router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ describe('alpha router', () => {
});

describe('exact in', () => {
test('succeeds to route across all protocols when no protocols specified', async () => {
// Skipping this test as we are not interested to route across all protocols, only V3.
test.skip('succeeds to route across all protocols when no protocols specified', async () => {
// Mock the quote providers so that for each protocol, one route and one
// amount less than 100% of the input gives a huge quote.
// Ensures a split route.
Expand Down Expand Up @@ -1176,7 +1177,8 @@ describe('alpha router', () => {
expect(swap!.blockNumber.toString()).toEqual(mockBlockBN.toString());
});

test('finds a route with no protocols specified and forceMixedRoutes is true', async () => {
// Skipping this test as we are not allowing mixed routes
test.skip('finds a route with no protocols specified and forceMixedRoutes is true', async () => {
const swap = await alphaRouter.route(
CurrencyAmount.fromRawAmount(USDC, 10000),
WRAPPED_NATIVE_CURRENCY[1],
Expand Down Expand Up @@ -1653,7 +1655,8 @@ describe('alpha router', () => {
});

describe('exact out', () => {
test('succeeds to route across all protocols', async () => {
// Skipping this test as we are not interested to route across all protocols, only V3.
test.skip('succeeds to route across all protocols', async () => {
// Mock the quote providers so that for each protocol, one route and one
// amount less than 100% of the input gives a huge quote.
// Ensures a split route.
Expand Down

0 comments on commit 4597967

Please sign in to comment.