Skip to content
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: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ coverage.json

.idea

.env
.env*
.yarn
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
370 changes: 370 additions & 0 deletions Makefile

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions config/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const constants = require('./constants.json');

module.exports = {
ACCESS_TOKEN_SALT: constants.accessTokenSalt || {},
ACCESS_TOKEN_OWNER: constants.accessTokenOwner || {},
CREATE3_DEPLOYERS: constants.create3Deployers || {},
SETTLEMENT_SALT: constants.settlementSalt || {},
SETTLEMENT_OWNER_ADDRESS: constants.settlementOwnerAddress || {},
ACCESS_TOKEN_ADDRESS: constants.accessTokenAddress || {},
WETH: constants.weth || {},
ROUTER_V6_ADDRESS: constants.routerV6Address || {},
ST1INCH_ADDR: constants.st1inchAddr || {},
DAO_ADDRESS: constants.daoAddress || {},
POWER_POD_ADDRESS: constants.powerPodAddress || {},
WHITELIST_REGISTRY_ADDRESS: constants.whitelistRegistryAddress || {},
MINT_TO: constants.mintTo || {},
MINT_TOKEN_ID: constants.mintTokenId || {},
CONTRACT_ADDRESS: constants.contractAddress || {},
NEW_OWNER: constants.newOwner || {},
};
25 changes: 25 additions & 0 deletions config/constants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"accessTokenSalt": {
"31337": "0xfd0450e10366502b67f46a6037db5b90d1cad2d4a744b961f7986bf35f4d35d7"
},
"accessTokenOwner": {
"31337": "0x56E44874F624EbDE6efCc783eFD685f0FBDC6dcF"
},
"create3Deployers": {
"31337": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"1": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"56": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"137": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"42161": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"10": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"43114": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"100": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"250": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"1313161554": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"8217": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"8453": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"59144": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"146": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"130": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65"
}
}
37 changes: 37 additions & 0 deletions deploy/deploy-crosschain-whitelist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const hre = require('hardhat');
const { deployAndGetContract } = require('@1inch/solidity-utils');
const constants = require('../config/constants');
const { getChainId } = hre;

module.exports = async ({ getNamedAccounts, deployments }) => {
const networkName = hre.network.name;
console.log(`running ${networkName} deploy script`);
const chainId = await getChainId();
console.log('network id ', chainId);

if (
networkName in hre.config.networks &&
chainId !== hre.config.networks[networkName].chainId?.toString()
) {
console.log(`network chain id: ${hre.config.networks[networkName].chainId}, your chain id ${chainId}`);
console.log('skipping wrong chain id deployment');
return;
}

const { deployer } = await getNamedAccounts();

const whitelist = await deployAndGetContract({
contractName: 'CrosschainWhitelistRegistry',
constructorArgs: [constants.WHITELIST_REGISTRY_ADDRESS[chainId]],
deployments,
deployer,
deploymentName: 'CrosschainWhitelistRegistry',
skipVerify: process.env.OPS_SKIP_VERIFY === 'true',
});

const tx = await whitelist.transferOwnership(constants.DAO_ADDRESS[chainId]);
await tx.wait();
console.log(`Ownership has been successfully transferred to ${constants.DAO_ADDRESS[chainId]}`);
};

module.exports.skip = async () => true;
54 changes: 38 additions & 16 deletions deploy/deploy-kyc-nft.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,61 @@
const { getChainId, network } = require('hardhat');
const hre = require('hardhat');
const { ethers } = hre;
const { deployAndGetContractWithCreate3, deployAndGetContract } = require('@1inch/solidity-utils');
const constants = require('../config/constants');

const constructorArgs = [
'Resolver Access Token', // name
'RES', // symbol
'1', // version
'0x56E44874F624EbDE6efCc783eFD685f0FBDC6dcF', // owner
];
const create3Deployer = '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65';
const salt = '0xfd0450e10366502b67f46a6037db5b90d1cad2d4a744b961f7986bf35f4d35d7';
const AT_NAME = 'Resolver Access Token';
const AT_SYMBOL = 'RES';
const AT_VERSION = '1';

module.exports = async ({ getNamedAccounts, deployments }) => {
console.log('running deploy script: kyc-nft');
console.log('network id ', await getChainId());
module.exports = async ({ getNamedAccounts, deployments, config }) => {
const networkName = hre.network.name;
console.log(`running ${networkName} deploy script: kyc-nft`);
const chainId = await hre.getChainId();
console.log('network id ', chainId);

if (network.name.indexOf('zksync') !== -1) {
if (chainId !== hre.config.networks[networkName].chainId?.toString()) {
console.log(`network chain id: ${hre.config.networks[networkName].chainId}, your chain id ${chainId}`);
console.log('skipping wrong chain id deployment');
return;
}

const constructorArgs = [
AT_NAME,
AT_SYMBOL,
AT_VERSION,
constants.ACCESS_TOKEN_OWNER[chainId],
];

const deploymentName = config.deployOpts.kycTokenSuffix ? `KycNFT_${config.deployOpts.kycTokenSuffix}` : 'KycNFT';

if (networkName.indexOf('zksync') !== -1) {
// Deploy on zkSync-like networks without create3
const { deployer } = await getNamedAccounts();
await deployAndGetContract({
contractName: 'KycNFT',
deploymentName,
constructorArgs,
deployments,
deployer,
skipVerify: process.env.OPS_SKIP_VERIFY === 'true',
});
} else {
let salt = constants.ACCESS_TOKEN_SALT[chainId];
salt = salt?.startsWith('0x') ? salt : ethers.keccak256(ethers.toUtf8Bytes(salt));

console.log(`Using salt: ${salt}`);

// Deploy with create3
await deployAndGetContractWithCreate3({
contractName: 'KycNFT',
deploymentName,
constructorArgs,
create3Deployer,
create3Deployer: constants.CREATE3_DEPLOYERS[chainId],
salt,
deployments,
skipVerify: network.name === 'klaytn',
skipVerify: networkName === 'klaytn' || process.env.OPS_SKIP_VERIFY === 'true',
});
}
};

module.exports.skip = async () => true;
module.exports.skip = async () => false;
32 changes: 32 additions & 0 deletions deploy/deploy-power-pod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const hre = require('hardhat');
const { deployAndGetContract } = require('@1inch/solidity-utils');
const constants = require('../config/constants');
const { getChainId } = hre;

module.exports = async ({ getNamedAccounts, deployments }) => {
const networkName = hre.network.name;
console.log(`running ${networkName} deploy script`);
const chainId = await getChainId();
console.log('network id ', chainId);

if (
networkName in hre.config.networks &&
chainId !== hre.config.networks[networkName].chainId?.toString()
) {
console.log(`network chain id: ${hre.config.networks[networkName].chainId}, your chain id ${chainId}`);
console.log('skipping wrong chain id deployment');
return;
}

const { deployer } = await getNamedAccounts();

await deployAndGetContract({
contractName: 'PowerPod',
constructorArgs: ['Delegated st1INCH', 'dst1INCH', constants.ST1INCH_ADDR[chainId]],
deployments,
deployer,
skipVerify: process.env.OPS_SKIP_VERIFY === 'true',
});
};

module.exports.skip = async () => true;
22 changes: 9 additions & 13 deletions deploy/deploy_zksync.js → deploy/deploy-resolver-metadata.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
const hre = require('hardhat');
const { getChainId } = hre;
const { deployAndGetContract } = require('@1inch/solidity-utils');
const constants = require('../config/constants');
const { getChainId } = hre;

const WETH = '0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91';
const ROUTER_V6_ADDR = '0x6fd4383cB451173D5f9304F041C7BCBf27d561fF';

module.exports = async ({ deployments, getNamedAccounts }) => {
module.exports = async ({ getNamedAccounts, deployments }) => {
const networkName = hre.network.name;
console.log(`running ${networkName} deploy script`);
const chainId = await getChainId();
console.log('network id ', chainId);

if (
networkName in hre.config.networks[networkName] &&
chainId !== hre.config.networks[networkName].chainId.toString()
networkName in hre.config.networks &&
chainId !== hre.config.networks[networkName].chainId?.toString()
) {
console.log(`network chain id: ${hre.config.networks[networkName].chainId}, your chain id ${chainId}`);
console.log('skipping wrong chain id deployment');
Expand All @@ -21,15 +20,12 @@ module.exports = async ({ deployments, getNamedAccounts }) => {

const { deployer } = await getNamedAccounts();

const accessToken = (await deployments.get('KycNFT')).address;
const constructorArgs = [ROUTER_V6_ADDR, accessToken, WETH, deployer];
const contractName = 'SimpleSettlement';

await deployAndGetContract({
contractName,
constructorArgs,
contractName: 'ResolverMetadata',
constructorArgs: [constants.POWER_POD_ADDRESS[chainId]],
deployments,
deployer,
skipVerify: process.env.OPS_SKIP_VERIFY === 'true',
});
};

Expand Down
66 changes: 66 additions & 0 deletions deploy/deploy-settlement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const hre = require('hardhat');
const { deployAndGetContractWithCreate3, deployAndGetContract } = require('@1inch/solidity-utils');
const constants = require('../config/constants');
const { getChainId, ethers } = hre;

module.exports = async ({ getNamedAccounts, deployments, config }) => {
const networkName = hre.network.name;
console.log(`running ${networkName} deploy script`);
const chainId = await getChainId();
console.log('network id ', chainId);

if (
networkName in hre.config.networks &&
chainId !== hre.config.networks[networkName].chainId?.toString()
) {
console.log(`network chain id: ${hre.config.networks[networkName].chainId}, your chain id ${chainId}`);
console.log('skipping wrong chain id deployment');
return;
}

let DEPLOYMENT_METHOD = config.deployOpts?.deploymentMethod || 'create3';
if (networkName.indexOf('zksync') !== -1) { // create3 is not supported for zksync
DEPLOYMENT_METHOD = 'create';
}

const constructorArgs = [
constants.ROUTER_V6_ADDRESS[chainId],
constants.ACCESS_TOKEN_ADDRESS[chainId],
constants.WETH[chainId],
constants.SETTLEMENT_OWNER_ADDRESS[chainId],
];

const deploymentName = 'SimpleSettlement';
const contractName = 'SimpleSettlement';

if (DEPLOYMENT_METHOD === 'create3') {
let salt = constants.SETTLEMENT_SALT[chainId];
salt = salt?.startsWith('0x') ? salt : ethers.keccak256(ethers.toUtf8Bytes(salt));

console.log(`Using salt: ${salt}`);

// Deploy with create3
await deployAndGetContractWithCreate3({
contractName,
deploymentName,
constructorArgs,
create3Deployer: constants.CREATE3_DEPLOYERS[chainId],
salt,
deployments,
skipVerify: process.env.OPS_SKIP_VERIFY === 'true',
});
} else {
// Deploy on zkSync-like networks without create3
const { deployer } = await getNamedAccounts();
await deployAndGetContract({
contractName,
deploymentName,
constructorArgs,
deployments,
deployer,
skipVerify: process.env.OPS_SKIP_VERIFY === 'true',
});
}
};

module.exports.skip = async () => true;
36 changes: 36 additions & 0 deletions deploy/deploy-whitelist-registry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const hre = require('hardhat');
const { deployAndGetContract } = require('@1inch/solidity-utils');
const constants = require('../config/constants');
const { getChainId } = hre;

module.exports = async ({ getNamedAccounts, deployments }) => {
const networkName = hre.network.name;
console.log(`running ${networkName} deploy script`);
const chainId = await getChainId();
console.log('network id ', chainId);

if (
networkName in hre.config.networks &&
chainId !== hre.config.networks[networkName].chainId?.toString()
) {
console.log(`network chain id: ${hre.config.networks[networkName].chainId}, your chain id ${chainId}`);
console.log('skipping wrong chain id deployment');
return;
}

const { deployer } = await getNamedAccounts();

const whitelist = await deployAndGetContract({
contractName: 'WhitelistRegistry',
constructorArgs: [constants.POWER_POD_ADDRESS[chainId], '1000'], // 1000 = 10% threshold
deployments,
deployer,
skipVerify: process.env.OPS_SKIP_VERIFY === 'true',
});

const tx = await whitelist.transferOwnership(constants.DAO_ADDRESS[chainId]);
await tx.wait();
console.log(`Ownership has been successfully transferred to ${constants.DAO_ADDRESS[chainId]}`);
};

module.exports.skip = async () => true;
31 changes: 0 additions & 31 deletions deploy/deploy_crosschain_whitelist.js

This file was deleted.

Loading
Loading