Skip to content

Commit

Permalink
Merge pull request #287 from balancer-labs/develop
Browse files Browse the repository at this point in the history
4.0.1-beta.4
  • Loading branch information
John Grant authored Aug 30, 2022
2 parents e15d6d4 + f2b3681 commit ad024bb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@balancer-labs/sor",
"version": "4.0.1-beta.3",
"version": "4.0.1-beta.4",
"license": "GPL-3.0-only",
"main": "dist/index.js",
"module": "dist/index.esm.js",
Expand Down
4 changes: 4 additions & 0 deletions src/routeProposal/filtering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { ZERO } from '../utils/bignumber';
import { parseNewPool } from '../pools';
import { Zero } from '@ethersproject/constants';

const BOOSTED_PATHS_MAX_LENGTH = 7;

export const filterPoolsByType = (
pools: SubgraphPoolBase[],
poolTypeFilter: PoolFilter
Expand Down Expand Up @@ -163,6 +165,7 @@ export function producePaths(
// These paths can be organized as a directed tree having tokenIn as a root.
// We build this tree by adding at each step all the possible continuations for
// each branch. When a branch reaches tokenOut, we write down the corresponding path.
// We only allow paths up to length BOOSTED_PATHS_MAX_LENGTH = 7

export function getBoostedGraph(
tokenIn: string,
Expand Down Expand Up @@ -360,6 +363,7 @@ export function getBoostedPaths(
if (newTreeEdges.length == 0) {
iterate = false;
} else treeEdges.push(newTreeEdges);
if (n == BOOSTED_PATHS_MAX_LENGTH) iterate = false;
}
return pathsInfoToPaths(pathsInfo, poolsAllDict);
}
Expand Down
17 changes: 3 additions & 14 deletions test/boostedPaths.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ describe('multiple boosted pools, path creation test', () => {
maxPools,
sorConfigTest
);
console.log('paths ids');
console.log(paths[0].id);
console.log(paths[1].id);
assert.equal(
boostedPaths[0].id,
'LBPweightedTusdOhmBBaUSD-TUSDbbaUSD-BAL'
Expand Down Expand Up @@ -291,9 +288,6 @@ describe('multiple boosted pools, path creation test', () => {
'weightedBalWeth',
],
];
for (const path of paths) {
console.log(path.id);
}
for (let i = 0; i < 2; i++) {
assert.isTrue(
// eslint-disable-next-line prettier/prettier
Expand Down Expand Up @@ -366,9 +360,6 @@ describe('multiple boosted pools, path creation test', () => {
maxPools,
sorConfigTest
);
for (const path of paths) {
console.log(path.id);
}
assert.equal(
paths[0].id,
'LBPweightedTusdOhmweightedTusdWethLBPweightedWethQre'
Expand Down Expand Up @@ -496,15 +487,13 @@ describe('generic boosted pools with wstETH, path creation test', () => {
'FuseLinearFeibbfUSD-PoolbbaUSD-bbfDAIbbaUSD-bbfUSDweightedWstETH-BBfusdwETH-wstETHweightedBalWeth',
'FuseLinearFeibbfUSD-PoolbbaUSD-bbfDAIweightedWstETH-BBausdwETH-wstETHweightedBalWeth',
'FuseLinearFeibbfUSD-PoolbbaUSD-bbfDAIbbaUSD-BAL',
'FuseLinearFeibbfUSD-PoolFuseLinearDaiAaveLinearDaibbaUSD-PoolweightedWstETH-BBausdwETH-wstETHweightedBalWeth',
'FuseLinearFeibbfUSD-PoolFuseLinearDaiAaveLinearDaibbaUSD-PoolbbaUSD-bbfUSDweightedWstETH-BBfusdwETH-wstETHweightedBalWeth',
'FuseLinearFeibbfUSD-PoolFuseLinearDaiAaveLinearDaibbaUSD-PoolbbaUSD-BAL',
];
for (let i = 0; i < 10; i++) {
for (let i = 0; i < 8; i++) {
assert.equal(paths[i].id, pathsIds[i], 'unexpected path');
}
assert.equal(boostedPaths.length, 10);
assert.equal(paths.length, 10);
assert.equal(boostedPaths.length, 8);
assert.equal(paths.length, 8);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/candidatePaths.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('Tests pools filtering and path processing', () => {
poolsDict,
4
);
assert.equal(paths.length, 50, 'Should have 50 paths');
assert.equal(paths.length, 34, 'Should have 34 paths');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/testScripts/swapExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function setUp(networkId: Network, provider: JsonRpcProvider): SOR {
}

export async function swap(): Promise<void> {
const networkId = Network.POLYGON;
const networkId = Network.MAINNET;
const provider = new JsonRpcProvider(PROVIDER_URLS[networkId]);
// gasPrice is used by SOR as a factor to determine how many pools to swap against.
// i.e. higher cost means more costly to trade against lots of different pools.
Expand Down

0 comments on commit ad024bb

Please sign in to comment.