This repository was archived by the owner on Mar 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
create3 deployer #196
Open
OxMarco
wants to merge
1
commit into
master
Choose a base branch
from
deployer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
create3 deployer #196
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity >=0.8.12; | ||
|
|
||
| import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
| import { CREATE3 } from "solmate/src/utils/CREATE3.sol"; | ||
| import { Vault } from "./Vault.sol"; | ||
| import { Staker } from "./Staker.sol"; | ||
| import { Liquidator } from "./Liquidator.sol"; | ||
|
|
||
| /// @title Deployer contract | ||
| /// @author Ithil | ||
| /// @notice Used to deploy Ithil smart contracts to deterministic addresses | ||
| /// on multiple chains irrespective of contracts' bytecode | ||
| contract Deployer is Ownable { | ||
| bytes32 internal constant salt = keccak256(bytes("ithil")); | ||
Check warningCode scanning / Slither Conformance to Solidity naming conventions
Constant Deployer.salt (contracts/Deployer.sol#15) is not in UPPER_CASE_WITH_UNDERSCORES
|
||
|
|
||
| function getDeployed() public view returns (address) { | ||
| return CREATE3.getDeployed(salt); | ||
| } | ||
| } | ||
|
|
||
| contract VaultDeployer is Deployer { | ||
| address public vault; | ||
|
|
||
| function deploy(address weth) external onlyOwner { | ||
Check noticeCode scanning / Slither Missing zero address validation
VaultDeployer.deploy(address).weth (contracts/Deployer.sol#25) lacks a zero-check on :
- vault = CREATE3.deploy(salt,abi.encodePacked(type()(Vault).creationCode,abi.encode(weth)),0) (contracts/Deployer.sol#26)
|
||
| vault = CREATE3.deploy(salt, abi.encodePacked(type(Vault).creationCode, abi.encode(weth)), 0); | ||
| } | ||
|
Comment on lines
+25
to
+27
Check warningCode scanning / Slither Too many digits
VaultDeployer.deploy(address) (contracts/Deployer.sol#25-27) uses literals with too many digits:
- vault = CREATE3.deploy(salt,abi.encodePacked(type()(Vault).creationCode,abi.encode(weth)),0) (contracts/Deployer.sol#26)
|
||
| } | ||
|
|
||
| contract StakerDeployer is Deployer { | ||
| address public staker; | ||
|
|
||
| function deploy(address token) external onlyOwner { | ||
Check noticeCode scanning / Slither Missing zero address validation
StakerDeployer.deploy(address).token (contracts/Deployer.sol#33) lacks a zero-check on :
- staker = CREATE3.deploy(salt,abi.encodePacked(type()(Staker).creationCode,abi.encode(token)),0) (contracts/Deployer.sol#34)
|
||
| staker = CREATE3.deploy(salt, abi.encodePacked(type(Staker).creationCode, abi.encode(token)), 0); | ||
| } | ||
|
Comment on lines
+33
to
+35
Check warningCode scanning / Slither Too many digits
StakerDeployer.deploy(address) (contracts/Deployer.sol#33-35) uses literals with too many digits:
- staker = CREATE3.deploy(salt,abi.encodePacked(type()(Staker).creationCode,abi.encode(token)),0) (contracts/Deployer.sol#34)
|
||
| } | ||
|
|
||
| contract LiquidatorDeployer is Deployer { | ||
| address public liquidator; | ||
|
|
||
| function deploy(address staker) external onlyOwner { | ||
Check noticeCode scanning / Slither Missing zero address validation
LiquidatorDeployer.deploy(address).staker (contracts/Deployer.sol#41) lacks a zero-check on :
- liquidator = CREATE3.deploy(salt,abi.encodePacked(type()(Liquidator).creationCode,abi.encode(staker)),0) (contracts/Deployer.sol#42)
|
||
| liquidator = CREATE3.deploy(salt, abi.encodePacked(type(Liquidator).creationCode, abi.encode(staker)), 0); | ||
| } | ||
|
Comment on lines
+41
to
+43
Check warningCode scanning / Slither Too many digits
LiquidatorDeployer.deploy(address) (contracts/Deployer.sol#41-43) uses literals with too many digits:
- liquidator = CREATE3.deploy(salt,abi.encodePacked(type()(Liquidator).creationCode,abi.encode(staker)),0) (contracts/Deployer.sol#42)
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { expect } from "chai"; | ||
| import { artifacts, ethers, waffle } from "hardhat"; | ||
|
|
||
| import { tokens } from "../common/mainnet"; | ||
|
|
||
| describe("Create3 deployer tests", function () { | ||
| it("deploy", async function () { | ||
| const VaultDeployer = await ethers.getContractFactory("VaultDeployer"); | ||
| const vaultDeployer = await VaultDeployer.deploy(); | ||
| await vaultDeployer.deploy(tokens.WETH.address); | ||
| const vault = await vaultDeployer.vault(); | ||
| expect(vault).not.to.equal("0x0000000000000000000000000000000000000000"); | ||
| expect(vault).to.equal(await vaultDeployer.getDeployed()); | ||
|
|
||
| const StakerDeployer = await ethers.getContractFactory("StakerDeployer"); | ||
| const stakerDeployer = await StakerDeployer.deploy(); | ||
| await stakerDeployer.deploy(tokens.WETH.address); | ||
| const staker = await stakerDeployer.staker(); | ||
| expect(staker).not.to.equal("0x0000000000000000000000000000000000000000"); | ||
| expect(staker).to.equal(await stakerDeployer.getDeployed()); | ||
|
|
||
| const LiquidatorDeployer = await ethers.getContractFactory("LiquidatorDeployer"); | ||
| const liquidatorDeployer = await LiquidatorDeployer.deploy(); | ||
| await liquidatorDeployer.deploy(staker); | ||
| const liquidator = await liquidatorDeployer.liquidator(); | ||
| expect(liquidator).not.to.equal("0x0000000000000000000000000000000000000000"); | ||
| expect(liquidator).to.equal(await liquidatorDeployer.getDeployed()); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / Slither
Incorrect versions of Solidity