Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update deployments #29

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading