-
Notifications
You must be signed in to change notification settings - Fork 23
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
V6 replace uni v2 router and add polygon #300
V6 replace uni v2 router and add polygon #300
Conversation
Changes to gas cost
🧾 Summary (20% most significant diffs)
Full diff report 👇
|
test/utils/UniswapV2Library.sol
Outdated
require(path.length >= 2, "UniswapV2Library: INVALID_PATH"); | ||
amounts = new uint256[](path.length); | ||
amounts[0] = amountIn; | ||
for (uint256 i; i < path.length - 1; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the suffix increment with the prefix one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3652669
} | ||
|
||
// performs chained getAmountOut calculations on any number of pairs | ||
function getAmountsOut(uint256 amountIn, address[] memory path) internal view returns (uint256[] memory amounts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use calldata to store the path is better here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We create path in memory in tests so can't use calldata here. Also, these utils are for test only so we won't spend too much effort on optimizing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave some comments for the better practices, overall LGTM.
contracts/AMMStrategy.sol
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This strategy is for testing purposes, there is no need to keep it.
contracts/UniswapStrategy.sol
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This strategy is for testing purposes, there is no need to keep it.
"ARBITRUM_L1_GATEWAY_ROUTER_ADDR": "0x0000000000000000000000000000000000000000", | ||
"ARBITRUM_L1_BRIDGE_ADDR": "0x0000000000000000000000000000000000000000", | ||
"OPTIMISM_L1_STANDARD_BRIDGE_ADDR": "0x0000000000000000000000000000000000000000" | ||
"UNISWAP_UNIVERSAL_ROUTER_ADDRESS": "0x4648a43B2C14Da09FdF82B161150d3F634f40491" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"UNISWAP_UNIVERSAL_ROUTER_ADDRESS": "0x4648a43B2C14Da09FdF82B161150d3F634f40491" | |
"UNISWAP_UNIVERSAL_ROUTER_ADDRESS": "0x4C60051384bd2d3C01bfc845Cf5F4b44bcbE9de5" | |
"UNISWAP_UNIVERSAL_ROUTER_ADDRESS_V1_2": "0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4" |
Addresses should be these according to latest code: https://github.com/Uniswap/universal-router/blob/main/deploy-addresses/arbitrum.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 22e1a59
"CRV_ADDRESS": "0x172370d5Cd63279eFa6d502DAB29171933a610AF", | ||
"TUSD_ADDRESS": "0x2e1AD108fF1D8C782fcBbB89AAd783aC49586756", | ||
"DAI_ADDRESS": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063", | ||
"LON_ADDRESS": "0x6f7C932e7684666C9fd1d44527765433e01fF61d", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"LON_ADDRESS": "0x6f7C932e7684666C9fd1d44527765433e01fF61d", | |
"MKR_ADDRESS": "0x6f7C932e7684666C9fd1d44527765433e01fF61d", | |
"LON_ADDRESS": "0x000000000000000000000000000000000000000", |
This address belongs to MAKER on Polygon: https://polygonscan.com/address/0x6f7C932e7684666C9fd1d44527765433e01fF61d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but we don't have LON on polygon.
test/utils/config/polygon.json
Outdated
"UNISWAP_V3_QUOTER_ADDRESS": "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6", | ||
"UNISWAP_PERMIT2_ADDRESS": "0x000000000022d473030f116ddee9f6b43ac78ba3", | ||
"UNISWAP_SWAP_ROUTER_02_ADDRESS": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", | ||
"UNISWAP_UNIVERSAL_ROUTER_ADDRESS": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"UNISWAP_UNIVERSAL_ROUTER_ADDRESS": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" | |
"UNISWAP_UNIVERSAL_ROUTER_ADDRESS": "0x4C60051384bd2d3C01bfc845Cf5F4b44bcbE9de5" |
Universal router is 0x4C60051384bd2d3C01bfc845Cf5F4b44bcbE9de5
according to latest code: https://github.com/Uniswap/universal-router/blob/main/deploy-addresses/polygon.json
However 0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD
is still a workable address at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 22e1a59
Thank you @108356037 for carefully checking the addresses. I found that Uniswap no longer use same address across multiple networks so can't assume it's all the same anymore. |
SwapRouter02