Skip to content

Commit

Permalink
Merge pull request #335 from 1inch/deploy/safe-order-builder
Browse files Browse the repository at this point in the history
[SC-1284] Deploy SafeOrderBuilder
  • Loading branch information
ZumZoom authored Nov 10, 2024
2 parents 7b0d37a + a35f09a commit cbcbae6
Show file tree
Hide file tree
Showing 24 changed files with 3,725 additions and 49 deletions.
75 changes: 38 additions & 37 deletions deploy/deploy-SafeOrderBuilder.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const hre = require('hardhat');
const { ethers } = hre;
const { getChainId } = hre;
const { ethers, getChainId, getNamedAccounts } = hre;
const { deployAndGetContractWithCreate3, deployAndGetContract } = require('@1inch/solidity-utils');
const { getNetwork } = require('@1inch/solidity-utils/hardhat-setup');

const ROUTER_V6_ADDR = '0x111111125421ca6dc452d289314280a0f8842a65';
const ROUTER_V6_ADDR_ZKSYNC = '0x6fd4383cb451173d5f9304f041c7bcbf27d561ff';

const ORDER_REGISTRATOR_SALT = ethers.keccak256(ethers.toUtf8Bytes('OrderRegistrator'));
const SAFE_ORDER_BUILDER_SALT = ethers.keccak256(ethers.toUtf8Bytes('SafeOrderBuilder'));

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

module.exports = async ({ deployments }) => {
const networkName = hre.network.name;
console.log(`running ${networkName} deploy script`);
Expand All @@ -23,41 +23,42 @@ module.exports = async ({ deployments }) => {
return;
}

const create3Deployer = await ethers.getContractAt('ICreate3Deployer', (await deployments.get('Create3Deployer')).address);

const OrderRegistratorFactory = await ethers.getContractFactory('OrderRegistrator');

const deployData = (await OrderRegistratorFactory.getDeployTransaction(ROUTER_V6_ADDR)).data;

const txn = create3Deployer.deploy(ORDER_REGISTRATOR_SALT, deployData, { gasLimit: 5000000 });
await (await txn).wait();

const orderRegistratorAddr = await create3Deployer.addressOf(ORDER_REGISTRATOR_SALT);

console.log('OrderRegistrator deployed to:', orderRegistratorAddr);

const SafeOrderBuilderFactory = await ethers.getContractFactory('SafeOrderBuilder');

const deployData2 = (await SafeOrderBuilderFactory.getDeployTransaction(ROUTER_V6_ADDR, orderRegistratorAddr)).data;
const { deployer } = await getNamedAccounts();

const txn2 = create3Deployer.deploy(SAFE_ORDER_BUILDER_SALT, deployData2, { gasLimit: 5000000 });
await (await txn2).wait();

const safeOrderBuilderAddr = await create3Deployer.addressOf(SAFE_ORDER_BUILDER_SALT);

console.log('SafeOrderBuilder deployed to:', safeOrderBuilderAddr);

await sleep(5000); // wait for etherscan to index contract

if (chainId !== '31337') {
await hre.run('verify:verify', {
address: orderRegistratorAddr,
constructorArguments: [ROUTER_V6_ADDR],
if (getNetwork().indexOf('zksync') !== -1) {
// ZkSync deploy without create3
const orderRegistrator = await deployAndGetContract({
contractName: 'OrderRegistrator',
constructorArgs: [ROUTER_V6_ADDR_ZKSYNC],
deploymentName: 'OrderRegistrator',
deployments,
deployer,
});

await hre.run('verify:verify', {
address: safeOrderBuilderAddr,
constructorArguments: [ROUTER_V6_ADDR, orderRegistratorAddr],
await deployAndGetContract({
contractName: 'SafeOrderBuilder',
constructorArgs: [ROUTER_V6_ADDR_ZKSYNC, await orderRegistrator.getAddress()],
deploymentName: 'SafeOrderBuilder',
deployments,
deployer,
});
} else {
const create3Deployer = await ethers.getContractAt('ICreate3Deployer', (await deployments.get('Create3Deployer')).address);

const orderRegistrator = await deployAndGetContractWithCreate3({
contractName: 'OrderRegistrator',
constructorArgs: [ROUTER_V6_ADDR],
deploymentName: 'OrderRegistrator',
create3Deployer,
salt: ORDER_REGISTRATOR_SALT,
deployments,
});
await deployAndGetContractWithCreate3({
contractName: 'SafeOrderBuilder',
constructorArgs: [ROUTER_V6_ADDR, await orderRegistrator.getAddress()],
deploymentName: 'SafeOrderBuilder',
create3Deployer,
salt: SAFE_ORDER_BUILDER_SALT,
deployments,
});
}
};
Expand Down
174 changes: 174 additions & 0 deletions deployments/arbitrum/OrderRegistrator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
{
"address": "0x2339f78e2Ec15C47Cf042F2460C532C0D7ff1CCE",
"abi": [
{
"inputs": [
{
"internalType": "contract IOrderMixin",
"name": "limitOrderProtocol",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "BadSignature",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"components": [
{
"internalType": "uint256",
"name": "salt",
"type": "uint256"
},
{
"internalType": "Address",
"name": "maker",
"type": "uint256"
},
{
"internalType": "Address",
"name": "receiver",
"type": "uint256"
},
{
"internalType": "Address",
"name": "makerAsset",
"type": "uint256"
},
{
"internalType": "Address",
"name": "takerAsset",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "makingAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "takingAmount",
"type": "uint256"
},
{
"internalType": "MakerTraits",
"name": "makerTraits",
"type": "uint256"
}
],
"indexed": false,
"internalType": "struct IOrderMixin.Order",
"name": "order",
"type": "tuple"
},
{
"indexed": false,
"internalType": "bytes",
"name": "extension",
"type": "bytes"
},
{
"indexed": false,
"internalType": "bytes",
"name": "signature",
"type": "bytes"
}
],
"name": "OrderRegistered",
"type": "event"
},
{
"inputs": [
{
"components": [
{
"internalType": "uint256",
"name": "salt",
"type": "uint256"
},
{
"internalType": "Address",
"name": "maker",
"type": "uint256"
},
{
"internalType": "Address",
"name": "receiver",
"type": "uint256"
},
{
"internalType": "Address",
"name": "makerAsset",
"type": "uint256"
},
{
"internalType": "Address",
"name": "takerAsset",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "makingAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "takingAmount",
"type": "uint256"
},
{
"internalType": "MakerTraits",
"name": "makerTraits",
"type": "uint256"
}
],
"internalType": "struct IOrderMixin.Order",
"name": "order",
"type": "tuple"
},
{
"internalType": "bytes",
"name": "extension",
"type": "bytes"
},
{
"internalType": "bytes",
"name": "signature",
"type": "bytes"
}
],
"name": "registerOrder",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"transactionHash": "0xd39a201fd0428da93d5753063e9762832758f37a4a517d26b53f85838588daa3",
"receipt": {
"to": "0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65",
"from": "0x56E44874F624EbDE6efCc783eFD685f0FBDC6dcF",
"contractAddress": null,
"transactionIndex": 3,
"gasUsed": "2029430",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0xf72a5724c1ff7f177b6eed91a207a36bc7be9fc79655c1ab7d682add2af90d98",
"transactionHash": "0xd39a201fd0428da93d5753063e9762832758f37a4a517d26b53f85838588daa3",
"logs": [],
"blockNumber": 261690271,
"cumulativeGasUsed": "2363099",
"status": 1
},
"args": [
"0x111111125421ca6dc452d289314280a0f8842a65"
],
"numDeployments": 1,
"bytecode": "0x60a03461006a57601f6106e738819003918201601f19168301916001600160401b0383118484101761006e5780849260209460405283398101031261006a57516001600160a01b038116810361006a57608052604051610664908161008382396080518161013a0152f35b5f80fd5b634e487b7160e01b5f52604160045260245ffdfe6080604052600480361015610012575f80fd5b5f3560e01c63dfcb3e3414610025575f80fd5b3461027157610140367ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0181811261027157610100809112610271576101049267ffffffffffffffff843581811161027157610084903690840161028f565b9091610124359081116102715761009e903690850161028f565b9390966100ab8385610369565b9015610288575073ffffffffffffffffffffffffffffffffffffffff602060405180937f802b2ef10000000000000000000000000000000000000000000000000000000082526101368683016004358152602435602082015260443560408201526064356060820152608435608082015260a43560a082015260c43560c082015260e060e435910152565b81847f0000000000000000000000000000000000000000000000000000000000000000165afa90811561027d5786918a915f9161023e575b61017c9450602435166104a5565b156102165750916102027f1e8610b3a2275f01a103e27257e911d890537b0c70578537ea077ec0a27b5bc9969261021194876040519889986101f78a6004358152602435602082015260443560408201526064356060820152608435608082015260a43560a082015260c43560c082015260e060e435910152565b89015287019161032b565b9184830361012086015261032b565b0390a1005b6040517f5cd5d233000000000000000000000000000000000000000000000000000000008152fd5b925050506020823d602011610275575b8161025b602093836102bd565b810103126102715788869161017c93519061016e565b5f80fd5b3d915061024e565b6040513d5f823e3d90fd5b90505f525ffd5b9181601f840112156102715782359167ffffffffffffffff8311610271576020838186019501011161027157565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176102fe57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b9060e4357f020000000000000000000000000000000000000000000000000000000000000016156104785780156104505767ffffffffffffffff81116102fe57604051906103df60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601836102bd565b8082526020820192368282011161027157815f9260209286378301015273ffffffffffffffffffffffffffffffffffffffff9182915190201690600435160361042a575b6001905f90565b5f907fdc11ee6b0000000000000000000000000000000000000000000000000000000090565b50505f907fb2d25e490000000000000000000000000000000000000000000000000000000090565b905015610423575f907f74896a7b0000000000000000000000000000000000000000000000000000000090565b90919273ffffffffffffffffffffffffffffffffffffffff9182811692831561062457604093848414918215610619575b8261054c575b505061054257602092825f9384978351937f1626ba7e0000000000000000000000000000000000000000000000000000000098898652600486015260248501528160448501526064840137606401915afa610535575090565b5f51143d60201416919050565b5050505050600190565b9091505f85518580604114610601576040146105bc57505f805b610575575b5016145f806104dc565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a16060820151101561056b5760209150608081895f935282805260015afa505f515f61056b565b807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60208b01358060ff1c601b01602084015260208c8b850137166060820152610566565b50868901355f1a602082015280878a81830137610566565b6041851492506104d6565b5050505050505f9056fea264697066735822122053480125ebf0a0c8c85a365d146577b5c860059ec723d24fd2ed9500b61730e164736f6c63430008170033",
"deployedBytecode": "0x6080604052600480361015610012575f80fd5b5f3560e01c63dfcb3e3414610025575f80fd5b3461027157610140367ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0181811261027157610100809112610271576101049267ffffffffffffffff843581811161027157610084903690840161028f565b9091610124359081116102715761009e903690850161028f565b9390966100ab8385610369565b9015610288575073ffffffffffffffffffffffffffffffffffffffff602060405180937f802b2ef10000000000000000000000000000000000000000000000000000000082526101368683016004358152602435602082015260443560408201526064356060820152608435608082015260a43560a082015260c43560c082015260e060e435910152565b81847f0000000000000000000000000000000000000000000000000000000000000000165afa90811561027d5786918a915f9161023e575b61017c9450602435166104a5565b156102165750916102027f1e8610b3a2275f01a103e27257e911d890537b0c70578537ea077ec0a27b5bc9969261021194876040519889986101f78a6004358152602435602082015260443560408201526064356060820152608435608082015260a43560a082015260c43560c082015260e060e435910152565b89015287019161032b565b9184830361012086015261032b565b0390a1005b6040517f5cd5d233000000000000000000000000000000000000000000000000000000008152fd5b925050506020823d602011610275575b8161025b602093836102bd565b810103126102715788869161017c93519061016e565b5f80fd5b3d915061024e565b6040513d5f823e3d90fd5b90505f525ffd5b9181601f840112156102715782359167ffffffffffffffff8311610271576020838186019501011161027157565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176102fe57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b9060e4357f020000000000000000000000000000000000000000000000000000000000000016156104785780156104505767ffffffffffffffff81116102fe57604051906103df60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601836102bd565b8082526020820192368282011161027157815f9260209286378301015273ffffffffffffffffffffffffffffffffffffffff9182915190201690600435160361042a575b6001905f90565b5f907fdc11ee6b0000000000000000000000000000000000000000000000000000000090565b50505f907fb2d25e490000000000000000000000000000000000000000000000000000000090565b905015610423575f907f74896a7b0000000000000000000000000000000000000000000000000000000090565b90919273ffffffffffffffffffffffffffffffffffffffff9182811692831561062457604093848414918215610619575b8261054c575b505061054257602092825f9384978351937f1626ba7e0000000000000000000000000000000000000000000000000000000098898652600486015260248501528160448501526064840137606401915afa610535575090565b5f51143d60201416919050565b5050505050600190565b9091505f85518580604114610601576040146105bc57505f805b610575575b5016145f806104dc565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a16060820151101561056b5760209150608081895f935282805260015afa505f515f61056b565b807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60208b01358060ff1c601b01602084015260208c8b850137166060820152610566565b50868901355f1a602082015280878a81830137610566565b6041851492506104d6565b5050505050505f9056fea264697066735822122053480125ebf0a0c8c85a365d146577b5c860059ec723d24fd2ed9500b61730e164736f6c63430008170033"
}
Loading

0 comments on commit cbcbae6

Please sign in to comment.