Skip to content

Commit

Permalink
feat: Update protocol contracts repo to deploy bsc-mainnet (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello authored Oct 3, 2023
1 parent 6ac2599 commit 3bcfaa3
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 88 deletions.
18 changes: 16 additions & 2 deletions data/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
"zetaTokenConsumerUniV2": "",
"zetaTokenConsumerUniV3": ""
},
"bsc_mainnet": {
"connector": "",
"erc20Custody": "",
"immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d",
"tss": "",
"tssUpdater": "",
"zetaToken": ""
},
"bsc_testnet": {
"connector": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1",
"erc20Custody": "0x0000a7db254145767262c6a81a7ee1650684258e",
Expand All @@ -28,7 +36,7 @@
"zetaTokenConsumerUniV2": "",
"zetaTokenConsumerUniV3": ""
},
"ethereum_mainnet": {
"eth_mainnet": {
"connector": "",
"erc20Custody": "",
"immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d",
Expand Down Expand Up @@ -73,13 +81,19 @@
"uniswapV3Router": "",
"weth9": ""
},
"bsc_mainnet": {
"uniswapV2Router02": "",
"uniswapV3Factory": "",
"uniswapV3Router": "",
"weth9": ""
},
"bsc_testnet": {
"uniswapV2Router02": "0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3",
"uniswapV3Factory": "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865",
"uniswapV3Router": "0x9a489505a00cE272eAa5e07Dba6491314CaE3796",
"weth9": ""
},
"ethereum_mainnet": {
"eth_mainnet": {
"uniswapV2Router02": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
"uniswapV3Factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984",
"uniswapV3Router": "0xE592427A0AEce92De3Edee1F18E0157C05861564",
Expand Down
14 changes: 11 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ import type { HardhatUserConfig } from "hardhat/types";

dotenv.config();

const PRIVATE_KEYS = process.env.PRIVATE_KEY !== undefined ? [`0x${process.env.PRIVATE_KEY}`] : [];

const config: HardhatUserConfig = {
//@ts-ignore
etherscan: {
apiKey: {
// BSC
bscTestnet: process.env.BSCSCAN_API_KEY || "",
// ETH
goerli: process.env.ETHERSCAN_API_KEY || "",
mainnet: process.env.ETHERSCAN_API_KEY || "",
},
},
networks: {
...getHardhatConfigNetworks(PRIVATE_KEYS),
...getHardhatConfigNetworks(),
hardhat: {
chainId: 1337,
forking: {
Expand Down
3 changes: 2 additions & 1 deletion lib/address.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ const MissingZetaNetworkError = new Error(

export const ProtocolNetworkNetworkNameMap: Record<ZetaProtocolNetwork, NetworkName> = {
baobab_testnet: "klaytn-baobab",
bsc_mainnet: "bsc-mainnet",
bsc_testnet: "bsc-testnet",
ethereum_mainnet: "eth-mainnet",
eth_mainnet: "eth-mainnet",
goerli_testnet: "goerli",
mumbai_testnet: "polygon-mumbai",
zeta_testnet: "athens",
Expand Down
4 changes: 2 additions & 2 deletions lib/address.tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export declare type NonZetaAddress = "uniswapV2Router02" | "uniswapV3Factory" |

export const nonZetaAddress: NonZetaAddress[] = ["uniswapV2Router02", "uniswapV3Router", "uniswapV3Factory", "weth9"];

export declare type ZetaProtocolMainNetwork = "ethereum_mainnet";
export const zetaProtocolMainNetworks: ZetaProtocolMainNetwork[] = ["ethereum_mainnet"];
export declare type ZetaProtocolMainNetwork = "bsc_mainnet" | "eth_mainnet";
export const zetaProtocolMainNetworks: ZetaProtocolMainNetwork[] = ["eth_mainnet", "bsc_mainnet"];

export declare type ZetaProtocolNetwork = ZetaProtocolMainNetwork | ZetaProtocolTestNetwork;
export const zetaProtocolNetworks: ZetaProtocolNetwork[] = [...zetaProtocolTestNetworks, ...zetaProtocolMainNetworks];
Expand Down
5 changes: 4 additions & 1 deletion lib/contracts.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import { BaseContract, ContractFactory } from "ethers";
import { ethers } from "hardhat";

export const isEthNetworkName = (networkName: string) =>
networkName === "eth-localnet" || networkName === "goerli_testnet" || networkName === "ethereum_mainnet";
networkName === "eth-localnet" ||
networkName === "goerli_testnet" ||
networkName === "eth_mainnet" ||
networkName === "bsc_mainnet";

export const deployZetaConnectorBase = async ({ args }: { args: Parameters<ZetaConnectorBaseFactory["deploy"]> }) => {
const Factory = (await ethers.getContractFactory("ZetaConnectorBase")) as ZetaConnectorBaseFactory;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"@uniswap/v2-core": "^1.0.1",
"@uniswap/v2-periphery": "^1.1.0-beta.0",
"@uniswap/v3-periphery": "^1.4.3",
"@zetachain/addresses": "^0.0.9",
"@zetachain/networks": "^2.4.2",
"@zetachain/addresses": "^0.0.13",
"@zetachain/networks": "^2.4.3",
"chai": "^4.3.6",
"cpx": "^1.5.0",
"del-cli": "^5.0.0",
Expand Down Expand Up @@ -80,4 +80,4 @@
},
"types": "./dist/lib/index.d.ts",
"version": "0.0.8"
}
}
73 changes: 6 additions & 67 deletions test/ZetaTokenConsumer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import {
IERC20,
IERC20__factory,
INonfungiblePositionManager,
INonfungiblePositionManager__factory,
IPoolInitializer__factory,
UniswapV2Router02__factory,
ZetaTokenConsumer,
ZetaTokenConsumerUniV2,
Expand Down Expand Up @@ -57,64 +54,6 @@ describe("ZetaTokenConsumer tests", () => {
await tx.wait();
};

/**
* @todo (andy): WIP, not in use yet
*/
const createPoolV3 = async (signer: SignerWithAddress, tokenAddress: string) => {
const DAI = getExternalAddress("dai", {
customNetworkName: "ethereum_mainnet",
customZetaNetwork: "mainnet",
});

const UNI_NFT_MANAGER_V3 = getExternalAddress("uniswapV3NftManager", {
customNetworkName: "ethereum_mainnet",
customZetaNetwork: "mainnet",
});

const USDC = getExternalAddress("usdc", {
customNetworkName: "ethereum_mainnet",
customZetaNetwork: "mainnet",
});

await swapToken(signer, DAI, parseUnits("10000", 18));

const token = IERC20__factory.connect(USDC, signer);
const tx1 = await token.approve(UNI_NFT_MANAGER_V3, MaxUint256);
await tx1.wait();

const token2 = IERC20__factory.connect(DAI, signer);
const tx2 = await token2.approve(UNI_NFT_MANAGER_V3, MaxUint256);
await tx2.wait();

const uniswapRouter = INonfungiblePositionManager__factory.connect(UNI_NFT_MANAGER_V3, signer);

const uniswapNFTManager = IPoolInitializer__factory.connect(UNI_NFT_MANAGER_V3, signer);
const tx3 = await uniswapNFTManager.createAndInitializePoolIfNecessary(
USDC,
DAI,
3000,
"80000000000000000000000000000"
);
await tx3.wait();

const params: INonfungiblePositionManager.MintParamsStruct = {
amount0Desired: parseEther("10"),
amount0Min: 0,
amount1Desired: parseEther("10"),
amount1Min: 0,
deadline: (await getNow()) + 360,
fee: 3000,
recipient: signer.address,
tickLower: 193,
tickUpper: 194,
token0: USDC,
token1: DAI,
};

const tx4 = await uniswapRouter.mint(params);
await tx4.wait();
};

beforeEach(async () => {
accounts = await ethers.getSigners();
[tssUpdater, tssSigner, randomSigner] = accounts;
Expand All @@ -124,22 +63,22 @@ describe("ZetaTokenConsumer tests", () => {
});

const DAI = getExternalAddress("dai", {
customNetworkName: "ethereum_mainnet",
customNetworkName: "eth_mainnet",
customZetaNetwork: "mainnet",
});

USDCAddr = getExternalAddress("usdc", {
customNetworkName: "ethereum_mainnet",
customNetworkName: "eth_mainnet",
customZetaNetwork: "mainnet",
});

uniswapV2RouterAddr = getNonZetaAddress("uniswapV2Router02", "ethereum_mainnet");
uniswapV2RouterAddr = getNonZetaAddress("uniswapV2Router02", "eth_mainnet");

const UNI_FACTORY_V3 = getNonZetaAddress("uniswapV3Factory", "ethereum_mainnet");
const UNI_FACTORY_V3 = getNonZetaAddress("uniswapV3Factory", "eth_mainnet");

const UNI_ROUTER_V3 = getNonZetaAddress("uniswapV3Router", "ethereum_mainnet");
const UNI_ROUTER_V3 = getNonZetaAddress("uniswapV3Router", "eth_mainnet");

const WETH9 = getNonZetaAddress("weth9", "ethereum_mainnet");
const WETH9 = getNonZetaAddress("weth9", "eth_mainnet");

// For testing purposes we use an existing uni v3 pool
await swapToken(tssUpdater, DAI, parseEther("10000"));
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2076,15 +2076,15 @@
"@uniswap/v3-core" "1.0.0"
base64-sol "1.0.1"

"@zetachain/addresses@^0.0.9":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@zetachain/addresses/-/addresses-0.0.9.tgz#d8ad93242590c0a6d028be8f515ad9f84fd588c2"
integrity sha512-MA/kD8a2NY5xJMFjwPj1oph6P3O7l0g23QB3QTgcBs4DdmwubvTVH6S6/e8CWzLFojTP5qBiqIWBsU0iHP/HFg==

"@zetachain/networks@^2.4.2":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@zetachain/networks/-/networks-2.4.2.tgz#611986d2a7cfd45505c2f61cdbc403aeeff14812"
integrity sha512-Md2SbP9YPIbzkbzWa9853/L8tB1DwdPXmN7uPg2KrbxQk5AEqzSh/RuMq8hXaH14CunbiSqXmEuTq0mOtMsfZw==
"@zetachain/addresses@^0.0.13":
version "0.0.13"
resolved "https://registry.yarnpkg.com/@zetachain/addresses/-/addresses-0.0.13.tgz#cbe56d3916e62d36e1d82e15a79404e84ed49176"
integrity sha512-hqCsEH+a3IqYR0cx9tlV0Rwk22i0MUpll81aLynxUkjoKQx5BaO3+5Mp/o62W8ZqYJICVbHPqb28DhmfoNQffg==

"@zetachain/networks@^2.4.3":
version "2.4.3"
resolved "https://registry.yarnpkg.com/@zetachain/networks/-/networks-2.4.3.tgz#870b2cda4b91f913be990246831378f60688d452"
integrity sha512-ZoqN8M6+59OkujZCl3FcSEgSftIN1tw5bpuFwI/2+f0SlKH+8ztAk7aF1QHmzrPqolIJKt29ogsfvIjiynXNkg==
dependencies:
dotenv "^16.1.4"

Expand Down

0 comments on commit 3bcfaa3

Please sign in to comment.