Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/ adding uniswap updates PR to gateway staging #349

Merged
merged 7 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@
"@types/minimist": "^1.2.2",
"@types/morgan": "^1.9.3",
"@types/uuid": "^8.3.4",
"@uniswap/sdk": "3.0.2",
"@uniswap/sdk-core": "^3.0.0",
"@uniswap/smart-order-router": "^2.5.26",
"@uniswap/v3-core": "^1.0.0",
"@uniswap/sdk": "3.0.3",
"@uniswap/sdk-core": "^5.3.1",
"@uniswap/smart-order-router": "^3.39.0",
"@uniswap/v3-core": "^1.0.1",
"@uniswap/v3-periphery": "^1.1.1",
"@uniswap/v3-sdk": "^3.7.0",
"@uniswap/v3-sdk": "^3.13.1",
"abi-decoder": "^2.4.0",
"ajv": "^8.6.3",
"algosdk": "^2.2.0",
Expand Down
18 changes: 4 additions & 14 deletions src/connectors/uniswap/uniswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,10 @@ export class Uniswap implements Uniswapish {
this._ttl = UniswapConfig.config.ttl;
this._maximumHops = UniswapConfig.config.maximumHops;

this._alphaRouter = null;
const excluded_chainIds = [
11155111, // sepolia
8453, // base
56, // binance-smart-chain
42220, // celo
43114, // avalanche
];
if (this.chainId in excluded_chainIds) {
this._alphaRouter = new AlphaRouter({
chainId: this.chainId,
provider: this.chain.provider,
});
}
this._alphaRouter = new AlphaRouter({
chainId: this.chainId,
provider: this.chain.provider,
});
this._routerAbi = routerAbi.abi;
this._gasLimitEstimate = UniswapConfig.config.gasLimitEstimate;
this._router = config.uniswapV3SmartOrderRouterAddress(chain, network);
Expand Down
8 changes: 5 additions & 3 deletions test/connectors/uniswap/uniswap.lp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const USDC = new Token(

const TX = {
type: 2,
chainId: 42,
chainId: 5,
nonce: 115,
maxPriorityFeePerGas: { toString: () => '106000000000' },
maxFeePerGas: { toString: () => '106000000000' },
Expand Down Expand Up @@ -117,8 +117,10 @@ const patchPoolState = () => {
};

const patchAlphaRouter = () => {
patch(uniswapLP.alphaRouter, 'routeToRatio', () => {
return { status: 3 };
patch(uniswapLP, '_alphaRouter', {
routeToRatio() {
return { status: 3 };
}
});
};

Expand Down
88 changes: 45 additions & 43 deletions test/connectors/uniswap/uniswap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,49 +68,51 @@ afterAll(async () => {
});

const patchTrade = (_key: string, error?: Error) => {
patch(uniswap.alphaRouter, 'route', () => {
if (error) return false;
const WETH_DAI = new Pair(
CurrencyAmount.fromRawAmount(WETH, '2000000000000000000'),
CurrencyAmount.fromRawAmount(DAI, '1000000000000000000')
);
const DAI_TO_WETH = new Route([WETH_DAI], DAI, WETH);
return {
quote: CurrencyAmount.fromRawAmount(DAI, '1000000000000000000'),
quoteGasAdjusted: CurrencyAmount.fromRawAmount(
DAI,
'1000000000000000000'
),
estimatedGasUsed: utils.parseEther('100'),
estimatedGasUsedQuoteToken: CurrencyAmount.fromRawAmount(
DAI,
'1000000000000000000'
),
estimatedGasUsedUSD: CurrencyAmount.fromRawAmount(
DAI,
'1000000000000000000'
),
gasPriceWei: utils.parseEther('100'),
trade: new Trade({
v2Routes: [
{
routev2: DAI_TO_WETH,
inputAmount: CurrencyAmount.fromRawAmount(
DAI,
'1000000000000000000'
),
outputAmount: CurrencyAmount.fromRawAmount(
WETH,
'2000000000000000000'
),
},
],
v3Routes: [],
tradeType: TradeType.EXACT_INPUT,
}),
route: [],
blockNumber: BigNumber.from(5000),
};
patch(uniswap, '_alphaRouter', {
route() {
if (error) return false;
const WETH_DAI = new Pair(
CurrencyAmount.fromRawAmount(WETH, '2000000000000000000'),
CurrencyAmount.fromRawAmount(DAI, '1000000000000000000')
);
const DAI_TO_WETH = new Route([WETH_DAI], DAI, WETH);
return {
quote: CurrencyAmount.fromRawAmount(DAI, '1000000000000000000'),
quoteGasAdjusted: CurrencyAmount.fromRawAmount(
DAI,
'1000000000000000000'
),
estimatedGasUsed: utils.parseEther('100'),
estimatedGasUsedQuoteToken: CurrencyAmount.fromRawAmount(
DAI,
'1000000000000000000'
),
estimatedGasUsedUSD: CurrencyAmount.fromRawAmount(
DAI,
'1000000000000000000'
),
gasPriceWei: utils.parseEther('100'),
trade: new Trade({
v2Routes: [
{
routev2: DAI_TO_WETH,
inputAmount: CurrencyAmount.fromRawAmount(
DAI,
'1000000000000000000'
),
outputAmount: CurrencyAmount.fromRawAmount(
WETH,
'2000000000000000000'
),
},
],
v3Routes: [],
tradeType: TradeType.EXACT_INPUT,
}),
route: [],
blockNumber: BigNumber.from(5000),
};
}
});
};

Expand Down
Loading
Loading