Skip to content

Commit

Permalink
Merge pull request #156 from 1inch/feat/unified-deploy
Browse files Browse the repository at this point in the history
Feat/unified deploy
  • Loading branch information
ZumZoom authored Apr 12, 2024
2 parents 0270f92 + 4b48a4c commit 3854d8f
Show file tree
Hide file tree
Showing 18 changed files with 2,241 additions and 416 deletions.
4 changes: 2 additions & 2 deletions contracts/FeeBankCharger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ contract FeeBankCharger is IFeeBankCharger {
_;
}

constructor(IERC20 feeToken) {
FEE_BANK = new FeeBank(this, feeToken, msg.sender);
constructor(IERC20 feeToken, address owner) {
FEE_BANK = new FeeBank(this, feeToken, owner);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/SimpleSettlement.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract SimpleSettlement is WhitelistExtension, ResolverFeeExtension, Integrato
*/
constructor(address limitOrderProtocol, IERC20 feeToken, address weth, address owner)
BaseExtension(limitOrderProtocol)
ResolverFeeExtension(feeToken)
ResolverFeeExtension(feeToken, owner)
IntegratorFeeExtension(weth)
Ownable(owner)
{}
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/ResolverFeeExtension.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract contract ResolverFeeExtension is BaseExtension, FeeBankCharger {

uint256 private constant _ORDER_FEE_BASE_POINTS = 1e15;

constructor(IERC20 feeToken) FeeBankCharger(feeToken) {}
constructor(IERC20 feeToken, address owner) FeeBankCharger(feeToken, owner) {}

/**
* @dev Calculates the resolver fee.
Expand Down
8 changes: 8 additions & 0 deletions contracts/interfaces/ICreate3Deployer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.23;

interface ICreate3Deployer {
function deploy(bytes32 salt, bytes calldata code) external returns (address);
function addressOf(bytes32 salt) external view returns (address);
}
66 changes: 46 additions & 20 deletions deploy/deploy_settlement_only.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
const hre = require('hardhat');
const { getChainId } = hre;
const { deployAndGetContract } = require('@1inch/solidity-utils');
const { getChainId, ethers } = hre;

const INCH = {
const FEE_TOKEN = {
1: '0x111111111117dC0aa78b770fA6A738034120C302', // Mainnet
56: '0x111111111117dC0aa78b770fA6A738034120C302', // BSC
137: '0x9c2C5fd7b07E95EE044DDeba0E97a665F142394f', // Matic
42161: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8', // Arbitrum (USDC)
10: '0x7F5c764cBc14f9669B88837ca1490cCa17c31607', // Optimistic (USDC)
43114: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', // Avalanche (USDC)
100: '0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83', // xDAI (USDC)
250: '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75', // FTM (USDC)
1313161554: '0xB12BFcA5A55806AaF64E99521918A4bf0fC40802', // Aurora (USDC)
8217: '0x754288077d0ff82af7a5317c7cb8c444d421d103', // Klaytn (USDC)
8453: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // Base (USDC)
42161: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1', // Arbitrum (DAI)
10: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1', // Optimistic (DAI)
43114: '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70', // Avalanche (DAI)
100: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', // xDAI (wXDAI)
250: '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E', // FTM (DAI)
1313161554: '0xe3520349F477A5F6EB06107066048508498A291b', // Aurora (DAI)
8217: '0x5c74070FDeA071359b86082bd9f9b3dEaafbe32b', // Klaytn (KDAI)
8453: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb', // Base (DAI)
31337: '0x111111111117dC0aa78b770fA6A738034120C302', // Hardhat
};

const WETH = {
1: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // Mainnet
56: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', // BSC
137: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', // Matic
42161: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1', // Arbitrum
10: '0x4200000000000000000000000000000000000006', // Optimistic
43114: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7', // Avalanche
100: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', // xDAI
250: '0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83', // FTM
1313161554: '0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB', // Aurora
8217: '0xe4f05A66Ec68B54A58B17c22107b02e0232cC817', // Klaytn
8453: '0x4200000000000000000000000000000000000006', // Base
31337: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // Hardhat
};

const ROUTER_V6_ADDR = '0x111111125421ca6dc452d289314280a0f8842a65';

const SETTLEMENT_SALT = ethers.keccak256(ethers.toUtf8Bytes('1inch Settlement V2'));

module.exports = async ({ getNamedAccounts, deployments }) => {
const chainId = await getChainId();

Expand All @@ -27,23 +43,33 @@ module.exports = async ({ getNamedAccounts, deployments }) => {

const { deployer } = await getNamedAccounts();

const settlement = await deployAndGetContract({
contractName: 'Settlement',
constructorArgs: [ROUTER_V6_ADDR, INCH[chainId]],
deployments,
deployer,
skipIfAlreadyDeployed: false,
});
const create3Deployer = await ethers.getContractAt('ICreate3Deployer', (await deployments.get('Create3Deployer')).address);

const CONTRACT_NAME = chainId === '1' ? 'Settlement' : 'SimpleSettlement';

const SettlementFactory = await ethers.getContractFactory(CONTRACT_NAME);

const deployData = (await SettlementFactory.getDeployTransaction(ROUTER_V6_ADDR, FEE_TOKEN[chainId], WETH[chainId], deployer)).data;

console.log('Settlement deployed to:', await settlement.getAddress());
const txn = create3Deployer.deploy(SETTLEMENT_SALT, deployData, { gasLimit: 6000000 });
await (await txn).wait();

const settlement = await ethers.getContractAt('Settlement', await create3Deployer.addressOf(SETTLEMENT_SALT));

const feeBankAddress = await settlement.FEE_BANK();

console.log(CONTRACT_NAME, 'deployed to:', await settlement.getAddress());
console.log('FeeBank deployed to:', feeBankAddress);

if (chainId !== '31337') {
await hre.run('verify:verify', {
address: feeBankAddress,
constructorArguments: [await settlement.getAddress(), INCH[chainId], deployer],
constructorArguments: [await settlement.getAddress(), FEE_TOKEN[chainId], deployer],
});

await hre.run('verify:verify', {
address: await settlement.getAddress(),
constructorArguments: [ROUTER_V6_ADDR, FEE_TOKEN[chainId], WETH[chainId], deployer],
});
}
};
Expand Down
191 changes: 191 additions & 0 deletions deployments/arbitrum/Create3Deployer.json

Large diffs are not rendered by default.

191 changes: 191 additions & 0 deletions deployments/aurora/Create3Deployer.json

Large diffs are not rendered by default.

191 changes: 191 additions & 0 deletions deployments/avax/Create3Deployer.json

Large diffs are not rendered by default.

191 changes: 191 additions & 0 deletions deployments/base/Create3Deployer.json

Large diffs are not rendered by default.

191 changes: 191 additions & 0 deletions deployments/bsc/Create3Deployer.json

Large diffs are not rendered by default.

191 changes: 191 additions & 0 deletions deployments/fantom/Create3Deployer.json

Large diffs are not rendered by default.

191 changes: 191 additions & 0 deletions deployments/klaytn/Create3Deployer.json

Large diffs are not rendered by default.

191 changes: 191 additions & 0 deletions deployments/mainnet/Create3Deployer.json

Large diffs are not rendered by default.

Loading

0 comments on commit 3854d8f

Please sign in to comment.