-
Notifications
You must be signed in to change notification settings - Fork 1
create3 deployer #196
base: master
Are you sure you want to change the base?
create3 deployer #196
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 warning Code 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 notice Code 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 warning Code 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 notice Code 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 warning Code 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 notice Code 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 warning Code 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)
|
||
} |
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()); | ||
}); | ||
}); |
Check warning
Code scanning / Slither
Incorrect versions of Solidity