Skip to content

Commit

Permalink
Merge pull request #2 from VenusProtocol/feat/xvs-bridge-deployments
Browse files Browse the repository at this point in the history
[VEN-2010]: Add XVS token bridge deployments
  • Loading branch information
GitGuru7 authored Nov 28, 2023
2 parents 08854aa + 9172b7d commit b4b95cf
Show file tree
Hide file tree
Showing 14 changed files with 2,087 additions and 239 deletions.
26 changes: 14 additions & 12 deletions deploy/001-xvs-bridge-local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from "../helpers/deploymentConfig";
import { toAddress } from "../helpers/utils";
import { getArgTypesFromSignature } from "../helpers/utils";
import { XVSBridgeAdmin, XVSProxyOFTSrc } from "../typechain";

interface GovernanceCommand {
contract: string;
Expand Down Expand Up @@ -70,11 +69,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const preconfiguredAddresses = await getPreConfiguredAddresses(hre.network.name);
const accessControlManager = await ethers.getContract("AccessControlManager");
const normalTimelock = await ethers.getContract("NormalTimelock");
const resilientOracle = await ethers.getContract("ResilientOracle");

const XVSProxyOFTSrc = await deploy("XVSProxyOFTSrc", {
from: deployer,
contract: "XVSProxyOFTSrc",
args: [preconfiguredAddresses.XVS, 8, preconfiguredAddresses.LzEndpoint, preconfiguredAddresses.ResilientOracle],
args: [preconfiguredAddresses.XVS, 8, preconfiguredAddresses.LzEndpoint, resilientOracle.address],
autoMine: true,
log: true,
});
Expand All @@ -84,20 +86,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
args: [XVSProxyOFTSrc.address],
contract: "XVSBridgeAdmin",
proxy: {
owner: preconfiguredAddresses.NormalTimelock,
owner: normalTimelock.address,
proxyContract: "OpenZeppelinTransparentProxy",
execute: {
methodName: "initialize",
args: [preconfiguredAddresses.AccessControlManager],
args: [accessControlManager.address],
},
upgradeIndex: 0,
},
log: true,
autoMine: true,
});

const bridge = await ethers.getContractAt<XVSProxyOFTSrc>("XVSProxyOFTSrc", XVSProxyOFTSrc.address, deployer);
const bridgeAdmin = await ethers.getContractAt<XVSBridgeAdmin>("XVSBridgeAdmin", XVSBridgeAdmin.address, deployer);
const bridge = await ethers.getContract("XVSProxyOFTSrc");
const bridgeAdmin = await ethers.getContract("XVSBridgeAdmin");

const removeArray = new Array(xvsBridgeMethods.length).fill(false);
let tx = await bridgeAdmin.upsertSignature(xvsBridgeMethods, removeArray);
Expand All @@ -106,24 +108,24 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
tx = await bridge.transferOwnership(XVSBridgeAdmin.address);
await tx.wait();

tx = await bridgeAdmin.transferOwnership(preconfiguredAddresses.NormalTimelock);
tx = await bridgeAdmin.transferOwnership(normalTimelock.address);
await tx.wait();
console.log(
`Bridge Admin owner ${deployer} sucessfully changed to ${preconfiguredAddresses.NormalTimelock}. Please accept the ownership.`,
`Bridge Admin owner ${deployer} sucessfully changed to ${normalTimelock.address}. Please accept the ownership.`,
);

const commands = [
...(await configureAccessControls(
xvsBridgeMethods,
preconfiguredAddresses.AccessControlManager,
preconfiguredAddresses.NormalTimelock,
accessControlManager.address,
normalTimelock.address,
XVSBridgeAdmin.address,
hre,
)),
...(await configureAccessControls(
bridgeAdminMethods,
preconfiguredAddresses.AccessControlManager,
preconfiguredAddresses.NormalTimelock,
accessControlManager.address,
normalTimelock.address,
XVSBridgeAdmin.address,
hre,
)),
Expand Down
39 changes: 26 additions & 13 deletions deploy/002-xvs-bridge-remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
xvsTokenPermissions,
} from "../helpers/deploymentConfig";
import { toAddress } from "../helpers/utils";
import { XVSBridgeAdmin, XVSProxyOFTDest } from "../typechain";
import { XVSProxyOFTDest } from "../typechain";

interface GovernanceCommand {
contract: string;
Expand Down Expand Up @@ -87,11 +87,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const preconfiguredAddresses = await getPreConfiguredAddresses(hre.network.name);

const proxyOwnerAddress = await toAddress(preconfiguredAddresses.NormalTimelock, hre);
const accessControlManager = await ethers.getContract("AccessControlManager");

const XVS = await deploy("XVS", {
from: deployer,
contract: "XVS",
args: [accessControlManager.address],
autoMine: true,
log: true,
});

const XVSProxyOFTDest = await deploy("XVSProxyOFTDest", {
from: deployer,
contract: "XVSProxyOFTDest",
args: [preconfiguredAddresses.XVS, 8, preconfiguredAddresses.LzEndpoint, preconfiguredAddresses.ResilientOracle],
args: [XVS.address, 8, preconfiguredAddresses.LzEndpoint, preconfiguredAddresses.ResilientOracle],
autoMine: true,
log: true,
});
Expand All @@ -105,23 +114,27 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
proxyContract: "OpenZeppelinTransparentProxy",
execute: {
methodName: "initialize",
args: [preconfiguredAddresses.AccessControlManager],
args: [accessControlManager.address],
},
upgradeIndex: 0,
},
log: true,
autoMine: true,
});

const bridge = await ethers.getContractAt<XVSProxyOFTDest>("XVSProxyOFTDest", XVSProxyOFTDest.address, deployer);
const bridgeAdmin = await ethers.getContractAt<XVSBridgeAdmin>("XVSBridgeAdmin", XVSBridgeAdmin.address, deployer);
const bridge = await ethers.getContract<XVSProxyOFTDest>("XVSProxyOFTDest");
const bridgeAdmin = await ethers.getContract("XVSBridgeAdmin");
const xvs = await ethers.getContract("XVS");

await executeBridgeCommands(bridge, hre, deployer);

const removeArray = new Array(xvsBridgeMethods.length).fill(false);
let tx = await bridgeAdmin.upsertSignature(xvsBridgeMethods, removeArray);
await tx.wait();

tx = await xvs.transferOwnership(preconfiguredAddresses.NormalTimelock);
await tx.wait();

tx = await bridge.transferOwnership(XVSBridgeAdmin.address);
await tx.wait();

Expand All @@ -134,31 +147,31 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const commands = [
...(await configureAccessControls(
xvsBridgeMethods,
preconfiguredAddresses.AccessControlManager,
accessControlManager.address,
preconfiguredAddresses.NormalTimelock,
XVSBridgeAdmin.address,
hre,
)),

...(await configureAccessControls(
xvsTokenPermissions,
preconfiguredAddresses.AccessControlManager,
accessControlManager.address,
XVSProxyOFTDest.address,
preconfiguredAddresses.XVS,
XVS.address,
hre,
)),

...(await configureAccessControls(
["setMintCap(address,uint256"],
preconfiguredAddresses.AccessControlManager,
["setMintCap(address,uint256)"],
accessControlManager.address,
preconfiguredAddresses.NormalTimelock,
preconfiguredAddresses.XVS,
XVS.address,
hre,
)),

...(await configureAccessControls(
bridgeAdminMethods,
preconfiguredAddresses.AccessControlManager,
accessControlManager.address,
preconfiguredAddresses.NormalTimelock,
XVSBridgeAdmin.address,
hre,
Expand All @@ -178,7 +191,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
value: 0,
},

...(await configureXVSTokenMintCapCommands(preconfiguredAddresses.XVS, XVSProxyOFTDest.address)),
...(await configureXVSTokenMintCapCommands(XVS.address, XVSProxyOFTDest.address)),
];
console.log("Please propose a Multisig tx with the following commands:");
console.log(
Expand Down
Loading

0 comments on commit b4b95cf

Please sign in to comment.