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

Base #1

Merged
merged 8 commits into from
Aug 15, 2023
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/xTokens"]
path = lib/xTokens
url = https://github.com/defi-wonderland/xTokens
1,010 changes: 0 additions & 1,010 deletions cache_hardhat/solidity-files-cache.json

This file was deleted.

1,264 changes: 0 additions & 1,264 deletions cache_hardhat/validations.json

This file was deleted.

81 changes: 81 additions & 0 deletions deploy/001_deploy_xerc20.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, ethers, getChainId } = hre;
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();
console.log("deployer: ", deployer.address);
const chainId = await getChainId();
console.log("chainId: ", chainId);

const network = await deployer.provider.getNetwork();
console.log("network: ", network.chainId);

const xerc20Res = await deploy("XERC20", {
contract: "src/XERC20.sol:XERC20",
from: deployer.address,
proxy: {
proxyContract: "OpenZeppelinTransparentProxy",
execute: {
init: {
methodName: "initialize",
args: [
[8453n, 84531n].includes(network.chainId)
? "BasedZoomerCoin"
: "ZoomerCoin",
"ZOOMER",
deployer.address,
],
},
},
},
log: true,
});
console.log("xerc20Res.address: ", xerc20Res.address);
console.log("xerc20Res.transactionHash: ", xerc20Res.transactionHash);
const xerc20 = await ethers.getContractAt(
"src/XERC20.sol:XERC20",
xerc20Res.address
);
console.log("xerc20.name: ", await xerc20.name());
console.log("xerc20.symbol: ", await xerc20.symbol());
console.log("xerc20.decimals: ", await xerc20.decimals());
console.log("xerc20.totalSupply: ", await xerc20.totalSupply());

if (["1", "5"].includes(chainId)) {
const xerc20LockboxRes = await deploy("XERC20Lockbox", {
contract: "src/XERC20Lockbox.sol:XERC20Lockbox",
from: deployer.address,
proxy: {
proxyContract: "OpenZeppelinTransparentProxy",
execute: {
init: {
methodName: "initialize",
args: [
xerc20Res.address,
chainId === "1"
? "0x0D505C03d30e65f6e9b4Ef88855a47a89e4b7676"
: "0x7ea6eA49B0b0Ae9c5db7907d139D9Cd3439862a1",
false,
],
},
},
},
log: true,
});
console.log("xerc20LockboxRes: ", xerc20LockboxRes.address);
console.log(
"xerc20LockboxRes.transactionHash: ",
xerc20LockboxRes.transactionHash
);

const lockbox = await xerc20.lockbox();
console.log("lockbox: ", lockbox);
if (lockbox !== xerc20LockboxRes.address) {
await xerc20.setLockbox(xerc20LockboxRes.address);
}
}
};
export default func;
func.tags = ["XERC20"];
102 changes: 102 additions & 0 deletions deploy/002_deploy_bridgeContracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { MaxUint256, ZeroAddress } from "ethers";

const l1CrossDomainMessengerAddresses: Record<string, string> = {
"1": "0x866E82a600A1414e583f7F13623F1aC5d58b0Afa",
"5": "0x8e5693140eA606bcEB98761d9beB1BC87383706D",
};

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, ethers } = hre;
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();
console.log("deployer: ", deployer.address);

const network = await deployer.provider.getNetwork();
console.log("network: ", network.chainId);

console.log("Deploying OP Bridge Contracts...");
const xerc20 = await deployments.get("XERC20");
if (!xerc20) {
throw new Error("XERC20 not deployed");
}

let bridgeAddress: string | undefined;
if ([1n, 5n].includes(network.chainId)) {
console.log("Deploying L1 side...");
const opBridgeRes = await deploy("OpL1XERC20Bridge", {
from: deployer.address,
proxy: {
proxyContract: "OpenZeppelinTransparentProxy",
execute: {
init: {
methodName: "initialize",
args: [
deployer.address,
xerc20.address,
l1CrossDomainMessengerAddresses[network.chainId.toString()],
],
},
},
},
log: true,
});
console.log("opBridge L1 deployed to:", opBridgeRes.address);
const opBridge = await ethers.getContractAt(
"OpL1XERC20Bridge",
opBridgeRes.address
);
console.log("opBridge L1 zoomer: ", await opBridge.zoomer());
bridgeAddress = opBridgeRes.address;
}

if ([8453n, 84531n].includes(network.chainId)) {
console.log("Deploying L2 side...");
const opBridgeRes = await deploy("OpL2XERC20Bridge", {
from: deployer.address,
proxy: {
proxyContract: "OpenZeppelinTransparentProxy",

execute: {
init: {
methodName: "initialize",
args: [deployer.address, xerc20.address],
},
},
},
log: true,
});
console.log("opBridge L2 deployed to:", opBridgeRes.address);
const opBridge = await ethers.getContractAt(
"OpL2XERC20Bridge",
opBridgeRes.address
);
console.log("opBridge L2 zoomer: ", await opBridge.zoomer());
bridgeAddress = opBridgeRes.address;
}

if (bridgeAddress) {
console.log("Setting limits...");
const _xerc20 = await ethers.getContractAt(
"src/XERC20.sol:XERC20",
xerc20.address
);
const mintLimit = await _xerc20.mintingMaxLimitOf(bridgeAddress);
console.log("mintLimit: ", mintLimit);
const burnLimit = await _xerc20.burningMaxLimitOf(bridgeAddress);
console.log("burnLimit: ", burnLimit);
if (mintLimit != MaxUint256 || burnLimit != MaxUint256) {
const res = await _xerc20.setLimits(
bridgeAddress,
MaxUint256,
MaxUint256
);
console.log("setLimits tx: ", res.hash);
await res.wait();
console.log("setLimits done");
}
}
};
export default func;
func.tags = ["BridgeContracts"];
1 change: 1 addition & 0 deletions deployments/base/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8453
259 changes: 259 additions & 0 deletions deployments/base/DefaultProxyAdmin.json

Large diffs are not rendered by default.

Loading