Skip to content

Commit

Permalink
Fix gas factory pool resolver to include FeeAmount.lowest, routeToStr…
Browse files Browse the repository at this point in the history
…ing (#200)
  • Loading branch information
zhongeric authored Feb 28, 2023
1 parent adf5b62 commit 86fe325
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
9 changes: 3 additions & 6 deletions cli/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,11 @@ export abstract class BaseCommand extends Command {
// chainId != ChainId.ARBITRUM_ONE && chainId != ChainId.ARBITRUM_RINKEBY;

const v3PoolProvider = new CachingV3PoolProvider(
ChainId.MAINNET,
new V3PoolProvider(ChainId.MAINNET, multicall2Provider),
chainId,
new V3PoolProvider(chainId, multicall2Provider),
new NodeJSCache(new NodeCache({ stdTTL: 360, useClones: false }))
);
const v2PoolProvider = new V2PoolProvider(
ChainId.MAINNET,
multicall2Provider
);
const v2PoolProvider = new V2PoolProvider(chainId, multicall2Provider);

const tenderlySimulator = new TenderlySimulator(
chainId,
Expand Down
16 changes: 13 additions & 3 deletions src/util/gas-factory-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function getV2NativePool(
reserve0: pool?.reserve0.toExact(),
reserve1: pool?.reserve1.toExact(),
},
`Could not find a valid WETH pool with ${token.symbol} for computing gas costs.`
`Could not find a valid WETH V2 pool with ${token.symbol} for computing gas costs.`
);

return null;
Expand All @@ -56,15 +56,25 @@ export async function getHighestLiquidityV3NativePool(
): Promise<Pool | null> {
const nativeCurrency = WRAPPED_NATIVE_CURRENCY[token.chainId as ChainId]!;

const nativePools = _([FeeAmount.HIGH, FeeAmount.MEDIUM, FeeAmount.LOW])
const nativePools = _([
FeeAmount.HIGH,
FeeAmount.MEDIUM,
FeeAmount.LOW,
FeeAmount.LOWEST,
])
.map<[Token, Token, FeeAmount]>((feeAmount) => {
return [nativeCurrency, token, feeAmount];
})
.value();

const poolAccessor = await poolProvider.getPools(nativePools);

const pools = _([FeeAmount.HIGH, FeeAmount.MEDIUM, FeeAmount.LOW])
const pools = _([
FeeAmount.HIGH,
FeeAmount.MEDIUM,
FeeAmount.LOW,
FeeAmount.LOWEST,
])
.map((feeAmount) => {
return poolAccessor.getPool(nativeCurrency, token, feeAmount);
})
Expand Down
5 changes: 4 additions & 1 deletion src/util/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import _ from 'lodash';

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

import { CurrencyAmount } from '.';

Expand All @@ -29,7 +30,9 @@ export const routeToString = (
? ` -- ${pool.fee / 10000}% [${Pool.getAddress(
pool.token0,
pool.token1,
pool.fee
pool.fee,
undefined,
V3_CORE_FACTORY_ADDRESSES[pool.chainId]
)}]`
: ` -- [${Pair.getAddress(
(pool as Pair).token0,
Expand Down

0 comments on commit 86fe325

Please sign in to comment.