-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Deploy system contracts to Amoy
- Loading branch information
1 parent
9d0791e
commit b430334
Showing
11 changed files
with
136 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { network } from "hardhat"; | ||
|
||
import { isProtocolNetworkName } from "../../../lib/address.tools"; | ||
import { deterministicDeployERC20Custody } from "./deterministic-deploy-erc20-custody"; | ||
import { deterministicDeployZetaConnector } from "./deterministic-deploy-zeta-connector"; | ||
import { deterministicDeployZetaToken } from "./deterministic-deploy-zeta-token"; | ||
|
||
const networkName = network.name; | ||
|
||
async function main() { | ||
if (!isProtocolNetworkName(networkName)) throw new Error("Invalid network name"); | ||
|
||
await deterministicDeployZetaToken(); | ||
await deterministicDeployZetaConnector(); | ||
await deterministicDeployERC20Custody(); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Contract } from "ethers"; | ||
import { ethers, network } from "hardhat"; | ||
import { getAddress, isProtocolNetworkName } from "lib"; | ||
|
||
import { ERC20_CUSTODY_ZETA_FEE, ERC20_CUSTODY_ZETA_MAX_FEE } from "../../../lib/contracts.constants"; | ||
import { deployERC20Custody as deployERC20CustodyHelper } from "../../../lib/contracts.helpers"; | ||
|
||
export async function deployERC20Custody(zetaTokenAddress: string) { | ||
if (!isProtocolNetworkName(network.name)) { | ||
throw new Error(`network.name: ${network.name} isn't supported.`); | ||
} | ||
const accounts = await ethers.getSigners(); | ||
const [signer] = accounts; | ||
const initialBalance = await signer.getBalance(); | ||
|
||
const tssAddress = getAddress("tss", network.name); | ||
const tssUpdaterAddress = getAddress("tssUpdater", network.name); | ||
|
||
const zetaFee = ERC20_CUSTODY_ZETA_FEE; | ||
const zetaMaxFee = ERC20_CUSTODY_ZETA_MAX_FEE; | ||
|
||
let contract: Contract; | ||
console.log(`Deploying ERC20Custody to ${network.name}`); | ||
|
||
const constructorArgs = [tssAddress, tssUpdaterAddress, zetaFee.toString(), zetaMaxFee.toString(), zetaTokenAddress]; | ||
contract = await deployERC20CustodyHelper({ | ||
args: constructorArgs, | ||
}); | ||
|
||
const finalBalance = await signer.getBalance(); | ||
console.log("Deployed ERC20Custody. Address:", contract.address); | ||
console.log("Constructor Args", constructorArgs); | ||
console.log("ETH spent:", initialBalance.sub(finalBalance).toString()); | ||
|
||
return contract.address; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
import { Contract } from "ethers"; | ||
import { network } from "hardhat"; | ||
import { getAddress, isProtocolNetworkName } from "lib/address.tools"; | ||
import { ethers, network } from "hardhat"; | ||
import { getAddress, isProtocolNetworkName } from "lib"; | ||
|
||
import { deployZetaConnectorEth, deployZetaConnectorNonEth, isEthNetworkName } from "../../../lib/contracts.helpers"; | ||
|
||
export async function deployZetaConnector() { | ||
export async function deployZetaConnector(zetaTokenAddress: string) { | ||
if (!isProtocolNetworkName(network.name)) { | ||
throw new Error(`network.name: ${network.name} isn't supported.`); | ||
} | ||
const accounts = await ethers.getSigners(); | ||
const [signer] = accounts; | ||
const initialBalance = await signer.getBalance(); | ||
|
||
const zetaTokenAddress = getAddress("zetaToken", network.name); | ||
const tssAddress = getAddress("tss", network.name); | ||
const tssUpdaterAddress = getAddress("tssUpdater", network.name); | ||
|
||
const constructorArgs = [zetaTokenAddress, tssAddress, tssUpdaterAddress, tssUpdaterAddress]; | ||
let contract: Contract; | ||
console.log(`Deploying ZetaConnector to ${network.name}`); | ||
|
||
if (isEthNetworkName(network.name)) { | ||
contract = await deployZetaConnectorEth({ | ||
args: [zetaTokenAddress, tssAddress, tssUpdaterAddress, tssUpdaterAddress], | ||
args: constructorArgs, | ||
}); | ||
} else { | ||
contract = await deployZetaConnectorNonEth({ | ||
args: [zetaTokenAddress, tssAddress, tssUpdaterAddress, tssUpdaterAddress], | ||
args: constructorArgs, | ||
}); | ||
} | ||
|
||
const finalBalance = await signer.getBalance(); | ||
console.log("Deployed ZetaConnector. Address:", contract.address); | ||
console.log("Constructor Args", constructorArgs); | ||
console.log("ETH spent:", initialBalance.sub(finalBalance).toString()); | ||
return contract.address; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters