Skip to content

Commit

Permalink
chore(deploy): base-sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbeckers committed Aug 18, 2024
1 parent 7ac979e commit 055efcd
Show file tree
Hide file tree
Showing 6 changed files with 507 additions and 189 deletions.
2 changes: 1 addition & 1 deletion contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ yarn hardhat deploy --network goerli
To transfer ownership of the proxy contract for upgrades, run the following:

```sh
yarn hardhat transfer-owner-minter --network goerli --proxy PROXY_CONTRACT_ADDRESS --owner NEW_OWNER_ADDRESS
yarn hardhat transfer-owner-minter --network base-sepolia --proxy PROXY_CONTRACT_ADDRESS --owner NEW_OWNER_ADDRESS
```

This is typically done to transfer control to a multi-sig (i.e. Gnosis Safe).
Expand Down
11 changes: 8 additions & 3 deletions contracts/hardhat.config.cts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ const chainIds = {

function getChainConfig(chain: keyof typeof chainIds) {
const jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + INFURA_API_KEY;
let config = {
let config: { [key: string]: string | number | { [key: string]: string | number } } = {
accounts: {
count: 10,
mnemonic: MNEMONIC,
mnemonic: MNEMONIC!,
path: "m/44'/60'/0'/0",
},
chainId: chainIds[chain],
Expand All @@ -95,14 +95,16 @@ function getChainConfig(chain: keyof typeof chainIds) {
if (chain === "base-sepolia") {
config = {
...config,
url: `https://base-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
url: `https://sepolia.base.org`,
gasPrice: 1000000000,
};
}

if (chain === "base-mainnet") {
config = {
...config,
url: `https://base-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
gasPrice: 1000000000,
};
}

Expand Down Expand Up @@ -209,6 +211,9 @@ const config: HardhatUserConfig = {
path: "m/44'/60'/0'/0",
},
chainId: chainIds.hardhat,
forking: {
url: `https://base-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
},
},
localhost: {
accounts: {
Expand Down
9 changes: 5 additions & 4 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-viem": "^2.0.2",
"@openzeppelin/contracts": "^4.9.3",
"@openzeppelin/hardhat-upgrades": "3.1.1",
"@openzeppelin/hardhat-upgrades": "3.2.1",
"@primitivefi/hardhat-dodoc": "^0.2.3",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-json": "^6.0.0",
Expand All @@ -63,19 +63,19 @@
"prettier-plugin-solidity": "^1.1.3",
"rimraf": "^5.0.5",
"rollup": "^4.0.2",
"rollup-plugin-swc3": "^0.11.2",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-swc3": "^0.11.2",
"shx": "^0.3.4",
"solhint": "^3.6.2",
"solhint-plugin-prettier": "^0.0.5",
"solmate": "^6.2.0",
"ts-node": "^10.9.1",
"typechain": "^8.3.2",
"typescript": "^5.5.3",
"viem": "^2.17.4",
"viem": "^2.19.7",
"xdeployer": "^2.1.13"
},
"keywords": [
Expand Down Expand Up @@ -110,6 +110,7 @@
"hardhat": "hardhat"
},
"dependencies": {
"hardhat": "^2.22.6"
"@tenderly/hardhat-tenderly": "^2.3.0",
"hardhat": "^2.22.8"
}
}
55 changes: 55 additions & 0 deletions contracts/src/deployments/deployment-marketplace-base-sepolia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"TransferManager": {
"address": "0xB3B776a8AAE5BC00c74BB9b3A45Ccc27C6F471F1",
"fullNamespace": "TransferManager",
"args": ["0xdc6d6f9ab5fcc398b92b017e8482749ae5afbf35"],
"encodedArgs": "0xdc6d6f9ab5fcc398b92b017e8482749ae5afbf35",
"tx": "0x61ffc042c14063f0c04297350fb9b314559a2d661bc1a38e663639a87b33a5aa"
},
"ProtocolFeeRecipient": {
"address": "0x5858053C0A20Ff1cBb00bbb58FAc7A575883F628",
"fullNamespace": "ProtocolFeeRecipient",
"args": ["0xe518aED97D9d45174a06bB8EF663B4fB51330725", "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9"],
"encodedArgs": "0xe518aed97d9d45174a06bb8ef663b4fb513307257b79995e5f793a07bc00c21412e50ecae098e7f9",
"tx": "0xdccdf1b9feefdd3cb884b285f02a56bd3df8396f73891c8e6cff8792bb628a6c"
},
"HypercertExchange": {
"address": "0x5DD43eff9FCC6F70564794e997A47722fE315847",
"fullNamespace": "LooksRareProtocol",
"args": [
"0xdc6d6f9ab5fcc398b92b017e8482749ae5afbf35",
"0x5858053C0A20Ff1cBb00bbb58FAc7A575883F628",
"0xB3B776a8AAE5BC00c74BB9b3A45Ccc27C6F471F1",
"0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9"
],
"encodedArgs": "0xdc6d6f9ab5fcc398b92b017e8482749ae5afbf355858053c0a20ff1cbb00bbb58fac7a575883f628b3b776a8aae5bc00c74bb9b3a45ccc27c6f471f17b79995e5f793a07bc00c21412e50ecae098e7f9",
"tx": "0xbf67d0d028ffbdd9afd63b5ddc457bcb22fd84470642b7120c46bb5cf4e6625f"
},
"RoyaltyFeeRegistry": {
"address": "0x3FAe80819f084DCf27Bf5F9d5002B9246e5Ca6E0",
"fullNamespace": "RoyaltyFeeRegistry",
"args": ["1000"],
"encodedArgs": "0x00000000000000000000000000000000000000000000000000000000000003e8",
"tx": "0xa6ecc69e62415a01ae2705176676ad7ccd943e6e92e07c91d7384d948e7241ba"
},
"OrderValidator": {
"address": "0x4F931F6954C694636b988f029b21b044aa420586",
"fullNamespace": "OrderValidatorV2A",
"args": ["0x5DD43eff9FCC6F70564794e997A47722fE315847"],
"encodedArgs": "0x5dd43eff9fcc6f70564794e997a47722fe315847"
},
"CreatorFeeManager": {
"address": "0xe3f64e5fc801a3404129b5afa1aef08f1476d9e5",
"fullNamespace": "CreatorFeeManagerWithRoyalties",
"args": ["0x3FAe80819f084DCf27Bf5F9d5002B9246e5Ca6E0"],
"encodedArgs": "0x3fae80819f084dcf27bf5f9d5002b9246e5ca6e0",
"tx": "0xa984b0e84602f928371c5b1eaf2374c6f0623932910b114359d118f96233a240"
},
"StrategyHypercertFractionOffer": {
"address": "0xf56ec8eebeed0b3cda7a41a57a3d8e87a17c4f43",
"fullNamespace": "StrategyHypercertFractionOffer",
"args": [],
"encodedArgs": "0x",
"tx": "0x433ead67b025cbfa98983b019ca633b56ee159cea7574411434131e6687c3e9f"
}
}
66 changes: 61 additions & 5 deletions contracts/tasks/deploy-marketplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ import {
} from "viem";
import { writeFile } from "node:fs/promises";

function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

type TokenAddressType = { sepolia: string; [key: string]: string };

const WETH: TokenAddressType = {
localhost: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", //dummy
hardhat: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", //dummy
sepolia: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
optimism: "0x4200000000000000000000000000000000000006",
"base-sepolia": "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
};

// LINK faucet for Sepolia: https://faucets.chain.link/
Expand All @@ -26,6 +31,7 @@ const DAI: TokenAddressType = {
hardhat: "0x779877A7B0D9E8603169DdbD7836e478b4624789",
sepolia: "0x779877A7B0D9E8603169DdbD7836e478b4624789",
optimism: "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1",
"base-sepolia": "0xE4aB69C077896252FAFBD49EFD26B5D171A32410",
};

// USDC https://faucet.circle.com/
Expand All @@ -34,6 +40,7 @@ const USDC: TokenAddressType = {
hardhat: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
sepolia: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
optimism: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
"base-sepolia": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
};

const getTokenAddresses = (network: string) => {
Expand All @@ -48,20 +55,34 @@ const ADMIN_ACCOUNT: { [key: string]: string } = {
localhost: "0x4f37308832c6eFE5A74737955cBa96257d76De17",
hardhat: "0x4f37308832c6eFE5A74737955cBa96257d76De17",
sepolia: "0x4f37308832c6eFE5A74737955cBa96257d76De17",
"base-sepolia": "0xA2Cb9D926b090577AD45fC0F40C753BF369B82Ff",
};

const getAdminAccount = (network: string) => {
return ADMIN_ACCOUNT[network];
const getAdminAccount = (network: string): string => {
const account = ADMIN_ACCOUNT[network];

if (!account || account === null || account.trim() === "") {
throw new Error(`Admin account for network "${network}" is not defined, null, or empty.`);
}

return account;
};

const FEE_RECIPIENT: { [key: string]: string } = {
localhost: "0x4f37308832c6eFE5A74737955cBa96257d76De17",
hardhat: "0x4f37308832c6eFE5A74737955cBa96257d76De17",
sepolia: "0x4f37308832c6eFE5A74737955cBa96257d76De17",
"base-sepolia": "0xe518aED97D9d45174a06bB8EF663B4fB51330725",
};

const getFeeRecipient = (network: string) => {
return FEE_RECIPIENT[network];
const getFeeRecipient = (network: string): string => {
const recipient = FEE_RECIPIENT[network];

if (!recipient || recipient === null || recipient.trim() === "") {
throw new Error(`Fee recipient for network "${network}" is not defined, null, or empty.`);
}

return recipient;
};

const getCreate2Address = async (
Expand Down Expand Up @@ -95,6 +116,14 @@ const runCreate2Deployment = async (
args: string[],
) => {
console.log(`deploying ${contractName} with args: ${args}`);
const { request } = await publicClient.simulateContract({
address: create2Instance.address,
abi: create2Instance.abi,
functionName: "safeCreate2",
args: [create2.salt, create2.deployData],
account: "0xdc6d6f9ab5fcc398b92b017e8482749ae5afbf35",
});

const hash = await create2Instance.write.safeCreate2([create2.salt, create2.deployData]);
const deployTx = await publicClient.waitForTransactionReceipt({
hash,
Expand Down Expand Up @@ -270,6 +299,10 @@ task("deploy-marketplace", "Deploy marketplace contracts and verify")
value: 1n,
});

console.log("deposited 1 wei in exchange");

await sleep(2000);

// Deploy ProtocolFeeRecipient
const protocolFeeRecipientTx = await runCreate2Deployment(
publicClient,
Expand All @@ -287,6 +320,8 @@ task("deploy-marketplace", "Deploy marketplace contracts and verify")
tx: protocolFeeRecipientTx,
};

await sleep(2000);

// Deploy HypercertsExchange
const hypercertsExchangeTx = await runCreate2Deployment(
publicClient,
Expand All @@ -304,6 +339,8 @@ task("deploy-marketplace", "Deploy marketplace contracts and verify")
tx: hypercertsExchangeTx,
};

await sleep(2000);

// Deploy RoyaltyFeeRegistry
const royaltyFeeRegistryTx = await runCreate2Deployment(
publicClient,
Expand All @@ -321,6 +358,8 @@ task("deploy-marketplace", "Deploy marketplace contracts and verify")
tx: royaltyFeeRegistryTx,
};

await sleep(2000);

// Allow Exchange as operator on transferManager
const transferManagerInstance = getContract({
address: transferManagerCreate2.address,
Expand All @@ -345,6 +384,8 @@ task("deploy-marketplace", "Deploy marketplace contracts and verify")
salt,
);

await sleep(2000);

const orderValidatorTx = await runCreate2Deployment(
publicClient,
create2Instance,
Expand All @@ -369,6 +410,8 @@ task("deploy-marketplace", "Deploy marketplace contracts and verify")

// Deploy CreatorFeeManager

await sleep(2000);

const creatorFeeManagerArgs = [royaltyFeeRegistryCreate2.address];

console.log("CreatorFeeManager args: ", creatorFeeManagerArgs);
Expand Down Expand Up @@ -405,17 +448,24 @@ task("deploy-marketplace", "Deploy marketplace contracts and verify")
client: { public: publicClient, wallet: deployer },
});

await sleep(2000);

// Update currency status for accepted tokens
await allowCurrency("0x0000000000000000000000000000000000000000", "native");
await allowCurrency(wethAddress, "WETH");
await allowCurrency(usdceAddress, "USDC");
await allowCurrency(daiAddress, "DAI");

// Update creatorFeeManager address
// Update creatorFeeManager address'

await sleep(2000);

const updateCreatorFeeManager = await hypercertsExchangeInstance.write.updateCreatorFeeManager([
creatorFeeManagerTx.contractAddress,
]);

await sleep(2000);

const updateCreatorFeeManagerTx = await publicClient.waitForTransactionReceipt({
hash: updateCreatorFeeManager,
});
Expand All @@ -428,6 +478,8 @@ task("deploy-marketplace", "Deploy marketplace contracts and verify")

// DEPLOYING STRATEGIES

await sleep(2000);

console.log("Deploying and adding strategies....");

await addStrategiesToExchange(strategies, marketplaceParameters);
Expand Down Expand Up @@ -549,6 +601,8 @@ task("deploy-marketplace", "Deploy marketplace contracts and verify")
? `Added strategy ${strat} to exchange successfully`
: `Failed to add ${strat}`,
);

await sleep(2000);
}

contracts[strategy.name] = {
Expand All @@ -572,5 +626,7 @@ task("deploy-marketplace", "Deploy marketplace contracts and verify")
? `Updated currency status for ${tokenAddress} (${name}) successfully`
: `Failed to update currency status for ${tokenAddress} (${name})`,
);

await sleep(2000);
}
});
Loading

0 comments on commit 055efcd

Please sign in to comment.