Skip to content

Commit

Permalink
chore: update deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Oct 20, 2023
1 parent 4b36483 commit 51b806d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ This can be done permissionlessly if the most recent contract has not yet been d

1. Add your deployers Private key under PRIVATE_KEY in your .env file.
- NOTE: make sure to add `0x` to the beginning of the key.
2. Enter what contract you want to deploy on line 9
`ContractFile.sol:ContractName`
2. Run the deployment script
2. Run the deployment script for the contract you want to deploy.
```sh
forge script script/Deploy.s.sol:Deploy --broadcast --rpc-url YOUR_RPC
forge script script/DeployContractName.s.sol:DeployContractName --broadcast --rpc-url YOUR_RPC_URL
```
- You can do a dry run before officially deploying by removing the `--broadcast` flag.
- For chains that don't support 1559 tx's you may need to add a `--legacy` flag.
3. The address the contract was deployed at will print in the console and should match any other chain the same version has been deployed on.

## Swapper helper contracts

For strategies that need to swap reward tokens back into 'asset' a series of 'swapper' contracts have been pre-developed to make your preferred method as easy as possible to use.
Expand Down
43 changes: 43 additions & 0 deletions script/DeployAprOracle.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.18;

import "forge-std/Script.sol";

// Deploy a contract to a deterministic address with create2
contract DeployAprOracle is Script {

Deployer public deployer = Deployer(0x8D85e7c9A4e369E53Acc8d5426aE1568198b0112);

function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

// Get the bytecode
bytes memory bytecode = abi.encodePacked(vm.getCode("AprOracle.sol:AprOracle"));

// Pick an unique salt
uint256 salt = uint256(keccak256("APR Oracle"));

address contractAddress = deployer.deploy(bytecode, salt);

console.log("Address is ", contractAddress);

vm.stopBroadcast();
}
}

contract Deployer {
event Deployed(address addr, uint256 salt);

function deploy(bytes memory code, uint256 salt) external returns (address) {
address addr;
assembly {
addr := create2(0, add(code, 0x20), mload(code), salt)
if iszero(extcodesize(addr)) {
revert(0, 0)
}
}
emit Deployed(addr, salt);
return addr;
}
}
7 changes: 4 additions & 3 deletions script/Deploy.s.sol → script/DeployCommonTrigger.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.18;
import "forge-std/Script.sol";

// Deploy a contract to a deterministic address with create2
contract Deploy is Script {
contract DeployCommonTrigger is Script {

Deployer public deployer = Deployer(0x8D85e7c9A4e369E53Acc8d5426aE1568198b0112);

Expand All @@ -13,13 +13,14 @@ contract Deploy is Script {
vm.startBroadcast(deployerPrivateKey);

// Encode constructor arguments
bytes memory construct = abi.encode();
bytes memory construct = abi.encode(0x33333333D5eFb92f19a5F94a43456b3cec2797AE);

// Append constructor args to the bytecode
bytes memory bytecode = abi.encodePacked(vm.getCode("CommonReportTrigger.sol:CommonReportTrigger"), construct);


// Pick an unique salt
uint256 salt = uint256(keccak256("v3.0.0"));
uint256 salt = uint256(keccak256("Common Trigger"));

address contractAddress = deployer.deploy(bytecode, salt);

Expand Down

0 comments on commit 51b806d

Please sign in to comment.