Skip to content

Commit

Permalink
(clean-up) factory address added
Browse files Browse the repository at this point in the history
  • Loading branch information
isreallee82 committed Jun 3, 2024
1 parent 9382e84 commit e90dfec
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@uniswap/sdk": "3.0.2",
"@uniswap/sdk-core": "^3.0.0",
"@uniswap/smart-order-router": "^3.28.7",
"@uniswap/v3-core": "^1.0.0",
"@uniswap/v3-core": "^1.0.1",
"@uniswap/v3-periphery": "^1.1.1",
"@uniswap/v3-sdk": "^3.7.0",
"abi-decoder": "^2.4.0",
Expand Down
9 changes: 6 additions & 3 deletions src/connectors/uniswap/uniswap.lp.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { getAddress } from 'ethers/lib/utils';
export class UniswapLPHelper {
protected ethereum: Ethereum;
protected chainId;
private _factory: string;
private _router: string;
private _nftManager: string;
private _ttl: number;
Expand All @@ -43,6 +44,7 @@ export class UniswapLPHelper {
chainId: this.chainId,
provider: this.ethereum.provider,
});
this._factory = UniswapConfig.config.uniswapV3FactoryAddress(network);
this._router =
UniswapConfig.config.uniswapV3SmartOrderRouterAddress(network);
this._nftManager = UniswapConfig.config.uniswapV3NftManagerAddress(network);
Expand Down Expand Up @@ -221,7 +223,7 @@ export class UniswapLPHelper {
const prices = [];
const fee = uniV3.FeeAmount[tier as keyof typeof uniV3.FeeAmount];
const poolContract = new Contract(
uniV3.Pool.getAddress(token0, token1, fee),
uniV3.Pool.getAddress(token0, token1, fee, undefined, this._factory),
this.poolAbi,
this.ethereum.provider
);
Expand Down Expand Up @@ -311,7 +313,7 @@ export class UniswapLPHelper {
const lowerPriceInFraction = math.fraction(lowerPrice) as math.Fraction;
const upperPriceInFraction = math.fraction(upperPrice) as math.Fraction;
const poolData = await this.getPoolState(
uniV3.Pool.getAddress(token0, token1, fee),
uniV3.Pool.getAddress(token0, token1, fee, undefined, this._factory),
fee
);
const pool = new uniV3.Pool(
Expand Down Expand Up @@ -392,13 +394,14 @@ export class UniswapLPHelper {
const positionData = await this.getRawPosition(wallet, tokenId);
const token0 = this.getTokenByAddress(positionData.token0);
const token1 = this.getTokenByAddress(positionData.token1);
const factoryAddress = this._factory
const fee = positionData.fee;
if (!token0 || !token1) {
throw new Error(
`One of the tokens in this position isn't recognized. $token0: ${token0}, $token1: ${token1}`
);
}
const poolAddress = uniV3.Pool.getAddress(token0, token1, fee);
const poolAddress = uniV3.Pool.getAddress(token0, token1, fee, undefined, factoryAddress);
const poolData = await this.getPoolState(poolAddress, fee);
const position = new uniV3.Position({
pool: new uniV3.Pool(
Expand Down
14 changes: 7 additions & 7 deletions test-helpers/curl/requests/eth_uniswap_add_liquidity.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"address": "$ETH_ADDRESS",
"token0": "COIN1",
"token1": "COIN3",
"address": "0x0a0CdC90CC16A0f3E67c296c8C0f7207cbdC0F4E",
"token0": "WAVAX",
"token1": "USDT",
"amount0": "1",
"amount1": "1",
"fee": "LOW",
"lowerPrice": "1",
"upperPrice": "5",
"chain": "ethereum",
"network": "goerli",
"lowerPrice": "0.028842772",
"upperPrice": "0.028851772",
"chain": "avalanche",
"network": "avalanche",
"connector": "uniswapLP"
}
8 changes: 4 additions & 4 deletions test-helpers/curl/requests/eth_uniswap_pool_price.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"token0": "COIN1",
"token1": "COIN3",
"token0": "WAVAX",
"token1": "USDT",
"fee": "LOW",
"period": 120,
"interval": 60,
"chain": "ethereum",
"network": "goerli",
"chain": "avalanche",
"network": "avalanche",
"connector": "uniswapLP"
}
8 changes: 4 additions & 4 deletions test-helpers/curl/requests/price_uniswap.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"connector": "uniswap",
"chain": "ethereum",
"network": "goerli",
"quote": "WETH",
"base": "DAI",
"chain": "avalanche",
"network": "avalanche",
"quote": "WAVAX",
"base": "USDT",
"amount": "1",
"side": "BUY"
}

0 comments on commit e90dfec

Please sign in to comment.