From c59e5c2179496c45a8dda137e3fd0268fe013030 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Tue, 11 Jul 2023 16:45:53 -0700 Subject: [PATCH 1/4] dont use router in uniswaplp --- src/connectors/uniswap/uniswap.lp.helper.ts | 85 +++++++++++---------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/src/connectors/uniswap/uniswap.lp.helper.ts b/src/connectors/uniswap/uniswap.lp.helper.ts index a5728384a4..5ce58f146d 100644 --- a/src/connectors/uniswap/uniswap.lp.helper.ts +++ b/src/connectors/uniswap/uniswap.lp.helper.ts @@ -7,7 +7,7 @@ import { UniswapConfig } from './uniswap.config'; import { Contract, ContractInterface } from '@ethersproject/contracts'; import { Token, - Fraction, + // Fraction, CurrencyAmount, Percent, Price, @@ -15,8 +15,8 @@ import { import * as uniV3 from '@uniswap/v3-sdk'; import { AlphaRouter, - SwapToRatioResponse, - SwapToRatioStatus, + // SwapToRatioResponse, + // SwapToRatioStatus, } from '@uniswap/smart-order-router'; import { providers, Wallet, Signer, utils } from 'ethers'; import { percentRegexp } from '../../services/config-manager-v2'; @@ -384,44 +384,47 @@ export class UniswapLPHelper { useFullPrecision: true, }); - const autorouterRoute: SwapToRatioResponse = - await this.alphaRouter.routeToRatio( - CurrencyAmount.fromRawAmount( - token0, - utils.parseUnits(amount0, token0.decimals).toString() - ), - CurrencyAmount.fromRawAmount( - token1, - utils.parseUnits(amount1, token1.decimals).toString() - ), - position, - { - ratioErrorTolerance: new Fraction(1, 100), - maxIterations: 6, - }, - { - swapOptions: swapOptions, - addLiquidityOptions: addLiquidityOptions, - } - ); - - let methodParameters: uniV3.MethodParameters; - let swapReq = false; - if (autorouterRoute.status === SwapToRatioStatus.SUCCESS) { - swapReq = true; - methodParameters = autorouterRoute.result - .methodParameters as uniV3.MethodParameters; - } else if (autorouterRoute.status === SwapToRatioStatus.NO_SWAP_NEEDED) { - methodParameters = uniV3.NonfungiblePositionManager.addCallParameters( - position, - { ...swapOptions, ...addLiquidityOptions } - ); - } else { - throw new Error( - `Unable to add liquidity - ${SwapToRatioStatus[autorouterRoute.status]}` - ); - } - return { ...methodParameters, swapRequired: swapReq }; + // const autorouterRoute: SwapToRatioResponse = + // await this.alphaRouter.routeToRatio( + // CurrencyAmount.fromRawAmount( + // token0, + // utils.parseUnits(amount0, token0.decimals).toString() + // ), + // CurrencyAmount.fromRawAmount( + // token1, + // utils.parseUnits(amount1, token1.decimals).toString() + // ), + // position, + // { + // ratioErrorTolerance: new Fraction(1, 100), + // maxIterations: 6, + // }, + // { + // swapOptions: swapOptions, + // addLiquidityOptions: addLiquidityOptions, + // } + // ); + // let methodParameters: uniV3.MethodParameters; + // let swapReq = false; + // if (autorouterRoute.status === SwapToRatioStatus.SUCCESS) { + // swapReq = true; + // methodParameters = autorouterRoute.result + // .methodParameters as uniV3.MethodParameters; + // } else if (autorouterRoute.status === SwapToRatioStatus.NO_SWAP_NEEDED) { + // methodParameters = uniV3.NonfungiblePositionManager.addCallParameters( + // position, + // { ...swapOptions, ...addLiquidityOptions } + // ); + // } else { + // throw new Error( + // `Unable to add liquidity - ${SwapToRatioStatus[autorouterRoute.status]}` + // ); + // } + const methodParameters = uniV3.NonfungiblePositionManager.addCallParameters( + position, + { ...swapOptions, ...addLiquidityOptions } + ); + return { ...methodParameters, swapRequired: false }; } async reducePositionHelper( From f0486b5b2c14633c0fba81750a5d4548962ece8a Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Thu, 13 Jul 2023 15:59:21 -0700 Subject: [PATCH 2/4] remove commented code --- src/connectors/uniswap/uniswap.lp.helper.ts | 50 +-------------------- 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/src/connectors/uniswap/uniswap.lp.helper.ts b/src/connectors/uniswap/uniswap.lp.helper.ts index 5ce58f146d..bd50ac5d4c 100644 --- a/src/connectors/uniswap/uniswap.lp.helper.ts +++ b/src/connectors/uniswap/uniswap.lp.helper.ts @@ -5,19 +5,9 @@ import { } from '../../services/error-handler'; import { UniswapConfig } from './uniswap.config'; import { Contract, ContractInterface } from '@ethersproject/contracts'; -import { - Token, - // Fraction, - CurrencyAmount, - Percent, - Price, -} from '@uniswap/sdk-core'; +import { Token, CurrencyAmount, Percent, Price } from '@uniswap/sdk-core'; import * as uniV3 from '@uniswap/v3-sdk'; -import { - AlphaRouter, - // SwapToRatioResponse, - // SwapToRatioStatus, -} from '@uniswap/smart-order-router'; +import { AlphaRouter } from '@uniswap/smart-order-router'; import { providers, Wallet, Signer, utils } from 'ethers'; import { percentRegexp } from '../../services/config-manager-v2'; import { Ethereum } from '../../chains/ethereum/ethereum'; @@ -384,42 +374,6 @@ export class UniswapLPHelper { useFullPrecision: true, }); - // const autorouterRoute: SwapToRatioResponse = - // await this.alphaRouter.routeToRatio( - // CurrencyAmount.fromRawAmount( - // token0, - // utils.parseUnits(amount0, token0.decimals).toString() - // ), - // CurrencyAmount.fromRawAmount( - // token1, - // utils.parseUnits(amount1, token1.decimals).toString() - // ), - // position, - // { - // ratioErrorTolerance: new Fraction(1, 100), - // maxIterations: 6, - // }, - // { - // swapOptions: swapOptions, - // addLiquidityOptions: addLiquidityOptions, - // } - // ); - // let methodParameters: uniV3.MethodParameters; - // let swapReq = false; - // if (autorouterRoute.status === SwapToRatioStatus.SUCCESS) { - // swapReq = true; - // methodParameters = autorouterRoute.result - // .methodParameters as uniV3.MethodParameters; - // } else if (autorouterRoute.status === SwapToRatioStatus.NO_SWAP_NEEDED) { - // methodParameters = uniV3.NonfungiblePositionManager.addCallParameters( - // position, - // { ...swapOptions, ...addLiquidityOptions } - // ); - // } else { - // throw new Error( - // `Unable to add liquidity - ${SwapToRatioStatus[autorouterRoute.status]}` - // ); - // } const methodParameters = uniV3.NonfungiblePositionManager.addCallParameters( position, { ...swapOptions, ...addLiquidityOptions } From 8d63bb2c4b9aa247bd99b6d34f2f4f8e8886c0f0 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Thu, 13 Jul 2023 16:10:07 -0700 Subject: [PATCH 3/4] replace workflow lists path --- .github/workflows/workflow.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index f79ceedc1f..b1229ef70d 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -73,10 +73,11 @@ jobs: - name: Build project run: yarn build - - name: Replace testnet nodeURL for local hardhat node + - name: Replace testnet nodeURL and lists path run: | mkdir conf db - cp -r src/templates/* conf + cp -rf src/templates/* conf + sed -i 's|/home/gateway/conf/lists/|/conf/lists/|g' ./conf/*.yml sed -i 's/https:\/\/rpc.ankr.com\/eth_goerli/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml sed -i 's/https:\/\/arbitrum-rinkeby.infura.io\/v3/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml sed -i 's/https:\/\/rpc.ankr.com\/optimism/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml From 23edc3f9d47ab1c65f20b994295f3a41eb922509 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Thu, 13 Jul 2023 16:16:30 -0700 Subject: [PATCH 4/4] fix folder link --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index b1229ef70d..9f1c6a4f25 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -77,7 +77,7 @@ jobs: run: | mkdir conf db cp -rf src/templates/* conf - sed -i 's|/home/gateway/conf/lists/|/conf/lists/|g' ./conf/*.yml + sed -i 's|/home/gateway/conf/lists/|conf/lists/|g' ./conf/*.yml sed -i 's/https:\/\/rpc.ankr.com\/eth_goerli/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml sed -i 's/https:\/\/arbitrum-rinkeby.infura.io\/v3/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml sed -i 's/https:\/\/rpc.ankr.com\/optimism/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml