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

[Multi ZNS] Replacing the meowToken with zToken #117

Open
wants to merge 14 commits into
base: rc/zns-meowchain
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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
6 changes: 3 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ SILENT_LOGGER="false" | "true"
# Boolean value for if we deploy the mock
# true = we deploy the mock
# false = we use a hard coded address and pull data from chain
MOCK_MEOW_TOKEN=
# Address of the MEOW Token deployed to the network PRIOR to running Campaign or any other EXISTING token
# This is only used if MOCK_MEOW_TOKEN is set to false (`test` and `prod` environments)
MOCK_Z_TOKEN=
# Address of the Z Token deployed to the network PRIOR to running Campaign or any other EXISTING token
# This is only used if MOCK_Z_TOKEN is set to false (`test` and `prod` environments)
STAKING_TOKEN_ADDRESS=

# Environment variables to create an entirely custom config when `env_level` above is not dev
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ docker*.tgz

# We don't ever use the generated manifests
.openzeppelin
/.vscode
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Create `.env` file in the root directory and add the following variables:
ENV_LEVEL: "dev" # local dev environment
MONGO_DB_URI: "mongodb://localhost:27018" # local instance of MongoDB in the Docker
MONGO_DB_NAME: "zns-campaign" # name of the database
MOCK_MEOW_TOKEN: "true" # use mock MeowToken contract for local testing
MOCK_Z_TOKEN: "true" # use mock ZToken contract for local testing
SILENT_LOGGER: "true" # disable logging for tests
```

Expand Down
16 changes: 0 additions & 16 deletions contracts/token/mocks/MeowTokenMock.sol

This file was deleted.

29 changes: 29 additions & 0 deletions contracts/token/mocks/ZTokenMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import { ZToken } from "@zero-tech/z-token/contracts/ZToken.sol";


contract ZTokenMock is ZToken {
MichaelKorchagin marked this conversation as resolved.
Show resolved Hide resolved
constructor(
string memory _name,
string memory _symbol,
address _defaultAdmin,
uint48 _initialAdminDelay,
address _minter,
address _mintBeneficiary,
uint256 _initialSupplyBase,
uint16[] memory _inflationRates,
uint16 _finalInflationRate
) ZToken(
_name,
_symbol,
_defaultAdmin,
_initialAdminDelay,
_minter,
_mintBeneficiary,
_initialSupplyBase,
_inflationRates,
_finalInflationRate
) {}
}
46 changes: 23 additions & 23 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,29 @@ const config : HardhatUserConfig = {
enabled: false,
},
networks: {
mainnet: {
url: `${process.env.MAINNET_RPC_URL}`,
gasPrice: 80000000000,
},
sepolia: {
url: `${process.env.SEPOLIA_RPC_URL}`,
timeout: 10000000,
// accounts: [ // Comment out for CI, uncomment this when using Sepolia
// `${process.env.TESTNET_PRIVATE_KEY_A}`,
// `${process.env.TESTNET_PRIVATE_KEY_B}`,
// `${process.env.TESTNET_PRIVATE_KEY_C}`,
// `${process.env.TESTNET_PRIVATE_KEY_D}`,
// `${process.env.TESTNET_PRIVATE_KEY_E}`,
// `${process.env.TESTNET_PRIVATE_KEY_F}`,
// ],
// // Must have to avoid instead failing as `invalid length for result data` error
// throwOnCallFailures: false, // not sure if this even works
},
devnet: {
// Add current URL that you spawned if not using automated spawning
url: `${process.env.DEVNET_RPC_URL}`,
chainId: 1,
},
// mainnet: {
MichaelKorchagin marked this conversation as resolved.
Show resolved Hide resolved
// url: `${process.env.MAINNET_RPC_URL}`,
// gasPrice: 80000000000,
// },
// sepolia: {
// url: `${process.env.SEPOLIA_RPC_URL}`,
// timeout: 10000000,
// // accounts: [ // Comment out for CI, uncomment this when using Sepolia
// // `${process.env.TESTNET_PRIVATE_KEY_A}`,
// // `${process.env.TESTNET_PRIVATE_KEY_B}`,
// // `${process.env.TESTNET_PRIVATE_KEY_C}`,
// // `${process.env.TESTNET_PRIVATE_KEY_D}`,
// // `${process.env.TESTNET_PRIVATE_KEY_E}`,
// // `${process.env.TESTNET_PRIVATE_KEY_F}`,
// // ],
// // // Must have to avoid instead failing as `invalid length for result data` error
// // throwOnCallFailures: false, // not sure if this even works
// },
// devnet: {
// // Add current URL that you spawned if not using automated spawning
// url: `${process.env.DEVNET_RPC_URL}`,
// chainId: 1,
// },
// meowtestnet: {
// url: `${process.env.MEOWTESTNET_RPC_URL}`,
// accounts: [
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"lint": "yarn lint-sol & yarn lint-ts --no-error-on-unmatched-pattern",
"clean": "hardhat clean",
"build": "yarn run clean && yarn run compile && tsc",
"reinstall": "yarn cache clean && rm -rf node_modules && yarn",
MichaelKorchagin marked this conversation as resolved.
Show resolved Hide resolved
"postbuild": "yarn save-tag",
"typechain": "hardhat typechain",
"pretest": "yarn mongo:start",
Expand Down Expand Up @@ -62,7 +63,7 @@
"@types/mocha": "^9.1.0",
"@types/node": "^18.15.11",
"@zero-tech/eslint-config-cpt": "0.2.7",
"@zero-tech/ztoken": "2.1.0",
"@zero-tech/z-token": "1.0.0",
"chai": "^4.3.10",
"eslint": "^8.37.0",
"ethers": "^6.9.0",
Expand All @@ -83,4 +84,4 @@
"mongodb": "^6.1.0",
"winston": "^3.11.0"
}
}
}
27 changes: 21 additions & 6 deletions src/deploy/campaign/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ import {
INVALID_CURVE_ERR,
MONGO_URI_ERR,
INVALID_ENV_ERR, NO_ZERO_VAULT_ERR,
INITIAL_ADMIN_DELAY_DEFAULT,
INITIAL_SUPPLY_DEFAULT,
INFLATION_RATES_DEFAULT,
FINAL_INFLATION_RATE_DEFAULT,
} from "../../../test/helpers";
import { ethers } from "ethers";
import { ICurvePriceConfig } from "../missions/types";
import { MeowMainnet } from "../missions/contracts/meow-token/mainnet-data";
import { ICurvePriceConfig, IZTokenConfig } from "../missions/types";
import { MeowMainnet } from "../missions/contracts/z-token/mainnet-data";


const getCustomAddresses = (
Expand Down Expand Up @@ -88,6 +92,16 @@ export const getConfig = async ({
zeroVaultAddressConf = process.env.ZERO_VAULT_ADDRESS;
}

let zConfig : IZTokenConfig | undefined;
if (process.env.MOCK_Z_TOKEN === "true") {
MichaelKorchagin marked this conversation as resolved.
Show resolved Hide resolved
zConfig = {
initialAdminDelay: INITIAL_ADMIN_DELAY_DEFAULT,
initialSupplyBase: INITIAL_SUPPLY_DEFAULT,
inflationRates: INFLATION_RATES_DEFAULT,
finalInflationRate: FINAL_INFLATION_RATE_DEFAULT,
};
}

// Domain Token Values
const royaltyReceiver = process.env.ENV_LEVEL !== "dev" ? process.env.ROYALTY_RECEIVER! : zeroVaultAddressConf;
const royaltyFraction =
Expand All @@ -113,8 +127,9 @@ export const getConfig = async ({
defaultRoyaltyFraction: royaltyFraction,
},
rootPriceConfig: priceConfig,
zTokenConfig: zConfig,
zeroVaultAddress: zeroVaultAddressConf as string,
mockMeowToken: process.env.MOCK_MEOW_TOKEN === "true",
mockZToken: process.env.MOCK_Z_TOKEN === "true",
MichaelKorchagin marked this conversation as resolved.
Show resolved Hide resolved
stakingTokenAddress: process.env.STAKING_TOKEN_ADDRESS!,
postDeploy: {
tenderlyProjectSlug: process.env.TENDERLY_PROJECT_SLUG!,
Expand Down Expand Up @@ -146,8 +161,8 @@ export const validateEnv = (
if (envLevel === "dev") return priceConfig;

if (envLevel === "test" || envLevel === "dev") {
if (process.env.MOCK_MEOW_TOKEN === "false" && !process.env.STAKING_TOKEN_ADDRESS) {
throw new Error("Must provide a staking token address if not mocking MEOW token in `dev` environment");
if (process.env.MOCK_Z_TOKEN === "false" && !process.env.STAKING_TOKEN_ADDRESS) {
MichaelKorchagin marked this conversation as resolved.
Show resolved Hide resolved
throw new Error("Must provide a staking token address if not mocking Z token in `dev` environment");
}
}

Expand All @@ -172,7 +187,7 @@ export const validateEnv = (

// Mainnet
if (envLevel === "prod") {
requires(process.env.MOCK_MEOW_TOKEN === "false", NO_MOCK_PROD_ERR);
requires(process.env.MOCK_Z_TOKEN === "false", NO_MOCK_PROD_ERR);
requires(process.env.STAKING_TOKEN_ADDRESS === MeowMainnet.address, STAKING_TOKEN_ERR);
MichaelKorchagin marked this conversation as resolved.
Show resolved Hide resolved
requires(!process.env.MONGO_DB_URI.includes("localhost"), MONGO_URI_ERR);
}
Expand Down
16 changes: 9 additions & 7 deletions src/deploy/campaign/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { HardhatEthersSigner, SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
import { DefenderRelaySigner } from "@openzeppelin/defender-sdk-relay-signer-client/lib/ethers";
import { ICurvePriceConfig } from "../missions/types";
import { ICurvePriceConfig, IZTokenConfig } from "../missions/types";
import { IContractState, IDeployCampaignConfig } from "@zero-tech/zdc";
import {
MeowTokenMock,
ZNSAccessController,
ZNSAddressResolver,
ZNSCurvePricer,
Expand All @@ -13,8 +12,10 @@ import {
ZNSRootRegistrar,
ZNSSubRegistrar,
ZNSTreasury,
ZToken,
ZTokenMock,
} from "../../../typechain";
import { MeowToken } from "@zero-tech/ztoken/typechain-js";
import { bigint } from "hardhat/internal/core/params/argumentTypes";
MichaelKorchagin marked this conversation as resolved.
Show resolved Hide resolved

export type IZNSSigner = HardhatEthersSigner | DefenderRelaySigner | SignerWithAddress;

Expand All @@ -30,8 +31,9 @@ export interface IZNSCampaignConfig <Signer> extends IDeployCampaignConfig<Signe
defaultRoyaltyFraction : bigint;
};
rootPriceConfig : ICurvePriceConfig;
zTokenConfig ?: IZTokenConfig;
zeroVaultAddress : string;
mockMeowToken : boolean;
mockZToken : boolean;
stakingTokenAddress : string;
postDeploy : {
tenderlyProjectSlug : string;
Expand All @@ -44,8 +46,8 @@ export type ZNSContract =
ZNSAccessController |
ZNSRegistry |
ZNSDomainToken |
MeowTokenMock |
MeowToken |
ZTokenMock |
ZToken |
ZNSAddressResolver |
ZNSCurvePricer |
ZNSTreasury |
Expand All @@ -57,7 +59,7 @@ export interface IZNSContracts extends IContractState<ZNSContract> {
accessController : ZNSAccessController;
registry : ZNSRegistry;
domainToken : ZNSDomainToken;
meowToken : MeowTokenMock;
zToken : ZTokenMock;
addressResolver : ZNSAddressResolver;
curvePricer : ZNSCurvePricer;
treasury : ZNSTreasury;
Expand Down
2 changes: 1 addition & 1 deletion src/deploy/missions/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export * from "./domain-token";
export * from "./treasury";
export * from "./curve-pricer";
export * from "./access-controller";
export * from "./meow-token/meow-token";
export * from "./z-token/z-token";
export * from "./fixed-pricer";
export * from "./sub-registrar";
8 changes: 4 additions & 4 deletions src/deploy/missions/contracts/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export const znsNames = {
contract: "ZNSDomainToken",
instance: "domainToken",
},
meowToken: {
contract: "MeowToken",
contractMock: "MeowTokenMock",
instance: "meowToken",
zToken: {
contract: "ZToken",
contractMock: "ZTokenMock",
instance: "zToken",
},
addressResolver: {
contract: "ZNSAddressResolver",
Expand Down
4 changes: 2 additions & 2 deletions src/deploy/missions/contracts/treasury.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ IZNSContracts
const {
accessController,
registry,
meowToken,
zToken,
config: {
zeroVaultAddress,
},
Expand All @@ -36,7 +36,7 @@ IZNSContracts
return [
await accessController.getAddress(),
await registry.getAddress(),
await meowToken.getAddress(),
await zToken.getAddress(),
zeroVaultAddress,
];
}
Expand Down
Loading