Skip to content

feat: cherry pick UniversalSwapAndBridge deployments #937

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 12 additions & 7 deletions deploy/033_deploy_uniswap_universal_swap_and_bridge.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import { getDeployedAddress } from "../src/DeploymentUtils";
import { L2_ADDRESS_MAP } from "./consts";
import { L1_ADDRESS_MAP, L2_ADDRESS_MAP } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts();
Expand All @@ -12,13 +11,19 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
contract: "UniversalSwapAndBridge",
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
skipIfAlreadyDeployed: false,
deterministicDeployment: "0x123456789abc", // Salt for the create2 call.
args: [
getDeployedAddress("SpokePool", chainId),
L2_ADDRESS_MAP[chainId].uniswapV3SwapRouter,
// Function selector for `exactInputSingle` method in Uniswap V3 SwapRouter
// https://etherscan.io/address/0xE592427A0AEce92De3Edee1F18E0157C05861564#writeProxyContract#F2
["0x414bf389"],
chainId === 1 ? L1_ADDRESS_MAP[chainId].uniswapV3SwapRouter02 : L2_ADDRESS_MAP[chainId].uniswapV3SwapRouter02,
// Allows function selectors in Uniswap V3 SwapRouter02:
// - exactInputSingle
// - exactInput
// - exactOutputSingle
// - exactOutput
// - multicall
// See https://etherscan.io/address/0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45#writeProxyContract
["0xb858183f", "0x04e45aaf", "0x09b81346", "0x5023b4df", "0x1f0464d1", "0x5ae401dc", "0xac9650d8"],
],
});
};
Expand Down
48 changes: 48 additions & 0 deletions deploy/064_deploy_uniswap_universal_swap_and_bridge_zk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import * as zk from "zksync-web3";
import { Deployer as zkDeployer } from "@matterlabs/hardhat-zksync-deploy";
import { DeployFunction, DeploymentSubmission } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { getDeployedAddress } from "../src/DeploymentUtils";
import { L1_ADDRESS_MAP, L2_ADDRESS_MAP } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const contractName = "UniversalSwapAndBridge";
const { deployments } = hre;

const chainId = parseInt(await hre.getChainId());
const mnemonic = hre.network.config.accounts.mnemonic;
const wallet = zk.Wallet.fromMnemonic(mnemonic);
const deployer = new zkDeployer(hre, wallet);

const artifact = await deployer.loadArtifact(contractName);
const constructorArgs = [
getDeployedAddress("SpokePool", chainId),
chainId === 1 ? L1_ADDRESS_MAP[chainId].uniswapV3SwapRouter02 : L2_ADDRESS_MAP[chainId].uniswapV3SwapRouter02,
// Allows function selectors in Uniswap V3 SwapRouter02:
// - exactInputSingle
// - exactInput
// - exactOutputSingle
// - exactOutput
// - multicall
// See https://etherscan.io/address/0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45#writeProxyContract
["0xb858183f", "0x04e45aaf", "0x09b81346", "0x5023b4df", "0x1f0464d1", "0x5ae401dc", "0xac9650d8"],
];

const _deployment = await deployer.deploy(artifact, constructorArgs);
const newAddress = _deployment.address;
console.log(`New ${contractName} implementation deployed @ ${newAddress}`);

// Save the deployment manually because OZ's hardhat-upgrades packages bypasses hardhat-deploy.
// See also: https://stackoverflow.com/questions/74870472
const extendedArtifact = await deployments.getExtendedArtifact(contractName);
const deployment: DeploymentSubmission = {
address: newAddress,
...extendedArtifact,
};
await deployments.save(contractName, deployment);

await hre.run("verify:verify", { address: newAddress, constructorArguments: constructorArgs });
};

module.exports = func;
func.tags = ["UniswapV3_UniversalSwapAndBridgeZk", "UniversalSwapAndBridgeZk", "uniswapV3"];
29 changes: 29 additions & 0 deletions deploy/065_deploy_wgho_universal_swap_and_bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { getDeployedAddress } from "../src/DeploymentUtils";
import { TOKEN_SYMBOLS_MAP } from "@across-protocol/constants";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts();
const chainId = parseInt(await hre.getChainId());

await hre.deployments.deploy("Wgho_UniversalSwapAndBridge", {
contract: "UniversalSwapAndBridge",
from: deployer,
log: true,
skipIfAlreadyDeployed: false,
deterministicDeployment: "0x123456789abc", // Salt for the create2 call.
args: [
getDeployedAddress("SpokePool", chainId),
TOKEN_SYMBOLS_MAP.WGHO.addresses[chainId],
// Allows function selectors in WGHO:
// - transferFrom
// - withdrawTo
// - depositFor
// See https://etherscan.io/address/0x1ff1dC3cB9eeDbC6Eb2d99C03b30A05cA625fB5a#writeProxyContract
["0x205c2878", "0x23b872dd", "0x2f4f21e2"],
],
});
};
module.exports = func;
func.tags = ["Wgho_UniversalSwapAndBridge", "UniversalSwapAndBridge", "wgho"];
46 changes: 46 additions & 0 deletions deploy/066_deploy_wgho_universal_swap_and_bridge_zk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import * as zk from "zksync-web3";
import { Deployer as zkDeployer } from "@matterlabs/hardhat-zksync-deploy";
import { DeployFunction, DeploymentSubmission } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { getDeployedAddress } from "../src/DeploymentUtils";
import { L1_ADDRESS_MAP, L2_ADDRESS_MAP } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const contractName = "UniversalSwapAndBridge";
const { deployments } = hre;

const chainId = parseInt(await hre.getChainId());
const mnemonic = hre.network.config.accounts.mnemonic;
const wallet = zk.Wallet.fromMnemonic(mnemonic);
const deployer = new zkDeployer(hre, wallet);

const artifact = await deployer.loadArtifact(contractName);
const constructorArgs = [
getDeployedAddress("SpokePool", chainId),
chainId === 1 ? L1_ADDRESS_MAP[chainId].uniswapV3SwapRouter02 : L2_ADDRESS_MAP[chainId].uniswapV3SwapRouter02,
// Allows function selectors in WGHO:
// - transferFrom
// - withdrawTo
// - depositFor
// See https://etherscan.io/address/0x1ff1dC3cB9eeDbC6Eb2d99C03b30A05cA625fB5a#writeProxyContract
["0x205c2878", "0x23b872dd", "0x2f4f21e2"],
];

const _deployment = await deployer.deploy(artifact, constructorArgs);
const newAddress = _deployment.address;
console.log(`New ${contractName} implementation deployed @ ${newAddress}`);

// Save the deployment manually because OZ's hardhat-upgrades packages bypasses hardhat-deploy.
// See also: https://stackoverflow.com/questions/74870472
const extendedArtifact = await deployments.getExtendedArtifact(contractName);
const deployment: DeploymentSubmission = {
address: newAddress,
...extendedArtifact,
};
await deployments.save(contractName, deployment);

await hre.run("verify:verify", { address: newAddress, constructorArguments: constructorArgs });
};

module.exports = func;
func.tags = ["Wgho_UniversalSwapAndBridgeZk", "UniversalSwapAndBridgeZk", "wgho"];
30 changes: 30 additions & 0 deletions deploy/067_deploy_multicall_universal_swap_and_bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import { getDeployedAddress } from "../src/DeploymentUtils";
import { CHAIN_IDs } from "@across-protocol/constants";
import { L1_ADDRESS_MAP } from "./consts";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts();
const chainId = parseInt(await hre.getChainId());

await hre.deployments.deploy("Multicall3_UniversalSwapAndBridge", {
contract: "UniversalSwapAndBridge",
from: deployer,
log: true,
skipIfAlreadyDeployed: false,
deterministicDeployment: "0x123456789abc", // Salt for the create2 call.
args: [
getDeployedAddress("SpokePool", chainId),
chainId === CHAIN_IDs.MAINNET ? L1_ADDRESS_MAP[chainId].multicall3 : L1_ADDRESS_MAP[chainId].multicall3,
// Allows function selectors in Multicall3:
// - aggregate
// - aggregate3
// https://etherscan.io/address/0xcA11bde05977b3631167028862bE2a173976CA11#writeContract
["0x252dba42", "0x82ad56cb"],
],
});
};
module.exports = func;
func.tags = ["Multicall3_UniversalSwapAndBridge", "UniversalSwapAndBridge", "multicall3"];
19 changes: 19 additions & 0 deletions deploy/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export const L1_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
l1AlephZeroERC20GatewayRouter: "0xeBb17f398ed30d02F2e8733e7c1e5cf566e17812",
donationBox: "0x0d57392895Db5aF3280e9223323e20F3951E81B1",
zkBridgeHub: "0x303a465B659cBB0ab36eE643eA362c509EEb5213",
uniswapV3SwapRouter02: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
multicall3: "0xcA11bde05977b3631167028862bE2a173976CA11",
},
[CHAIN_IDs.SEPOLIA]: {
finder: "0xeF684C38F94F48775959ECf2012D7E864ffb9dd4",
Expand Down Expand Up @@ -173,13 +175,15 @@ export const L2_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
cctpTokenMessenger: "0x19330d10D9Cc8751218eaf51E8885D058642E08A",
cctpMessageTransmitter: "0xC30362313FBBA5cf9163F0bb16a0e01f01A896ca",
uniswapV3SwapRouter: "0xE592427A0AEce92De3Edee1F18E0157C05861564",
uniswapV3SwapRouter02: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
"1inchV6Router": "0x111111125421cA6dc452d289314280a0f8842A65",
},
[CHAIN_IDs.POLYGON]: {
fxChild: "0x8397259c983751DAf40400790063935a11afa28a",
cctpTokenMessenger: "0x9daF8c91AEFAE50b9c0E69629D3F6Ca40cA3B3FE",
cctpMessageTransmitter: "0xF3be9355363857F3e001be68856A2f96b4C39Ba9",
uniswapV3SwapRouter: "0xE592427A0AEce92De3Edee1F18E0157C05861564",
uniswapV3SwapRouter02: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
"1inchV6Router": "0x111111125421cA6dc452d289314280a0f8842A65",
},
[CHAIN_IDs.POLYGON_AMOY]: {
Expand All @@ -189,12 +193,14 @@ export const L2_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
},
[CHAIN_IDs.ZK_SYNC]: {
zkErc20Bridge: "0x11f943b2c77b743AB90f4A0Ae7d5A4e7FCA3E102",
uniswapV3SwapRouter02: "0x99c56385daBCE3E81d8499d0b8d0257aBC07E8A3",
"1inchV6Router": "0x6fd4383cB451173D5f9304F041C7BCBf27d561fF",
},
[CHAIN_IDs.OPTIMISM]: {
cctpTokenMessenger: "0x2B4069517957735bE00ceE0fadAE88a26365528f",
cctpMessageTransmitter: "0x4d41f22c5a0e5c74090899e5a8fb597a8842b3e8",
uniswapV3SwapRouter: "0xE592427A0AEce92De3Edee1F18E0157C05861564",
uniswapV3SwapRouter02: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
"1inchV6Router": "0x111111125421cA6dc452d289314280a0f8842A65",
},
[CHAIN_IDs.OPTIMISM_SEPOLIA]: {
Expand All @@ -206,6 +212,7 @@ export const L2_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
cctpTokenMessenger: "0x1682Ae6375C4E4A97e4B583BC394c861A46D8962",
cctpMessageTransmitter: "0xAD09780d193884d503182aD4588450C416D6F9D4",
uniswapV3SwapRouter: "0x2626664c2603336E57B271c5C0b26F421741e481",
uniswapV3SwapRouter02: "0x2626664c2603336E57B271c5C0b26F421741e481",
"1inchV6Router": "0x111111125421cA6dc452d289314280a0f8842A65",
},
[CHAIN_IDs.BASE_SEPOLIA]: {
Expand All @@ -216,6 +223,9 @@ export const L2_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
232: {
zkErc20Bridge: "0xfBEC23c5BB0E076F2ef4d0AaD7fe331aE5A01143",
},
[CHAIN_IDs.LENS]: {
uniswapV3SwapRouter02: "0x6ddD32cd941041D8b61df213B9f515A7D288Dc13",
},
[CHAIN_IDs.LENS_SEPOLIA]: {
zkErc20Bridge: "0x427373Be173120D7A042b44D0804E37F25E7330b",
},
Expand Down Expand Up @@ -247,6 +257,15 @@ export const L2_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
cctpTokenMessenger: "0x8ed94B8dAd2Dc5453862ea5e316A8e71AAed9782",
cctpMessageTransmitter: "0xbc498c326533d675cf571B90A2Ced265ACb7d086",
},
[CHAIN_IDs.WORLD_CHAIN]: {
uniswapV3SwapRouter02: "0x091AD9e2e6e5eD44c1c66dB50e49A601F9f36cF6",
},
[CHAIN_IDs.ZORA]: {
uniswapV3SwapRouter02: "0x7De04c96BE5159c3b5CeffC82aa176dc81281557",
},
[CHAIN_IDs.BLAST]: {
uniswapV3SwapRouter02: "0x549FEB8c9bd4c12Ad2AB27022dA12492aC452B66",
},
};

export const POLYGON_CHAIN_IDS: { [l1ChainId: number]: number } = {
Expand Down
Loading
Loading