Skip to content

Commit

Permalink
chore: readme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Oct 15, 2024
1 parent c0aa6f7 commit a494cb0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 34 deletions.
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ NOTE: If you are on a windows machine it is recommended to use [WSL](https://lea

cd tokenized-strategy-periphery

pip install vyper==0.3.7

yarn


Expand All @@ -24,7 +26,7 @@ NOTE: you can use other services.

Use .env file
1. Make a copy of `.env.example`
2. Add the values for `ETH_RPC_URL`, `ETHERSCAN_API_KEY` and other example vars
2. Add the values for `ETH_RPC_URL`
NOTE: If you set up a global environment variable, that will take precedence.


Expand All @@ -43,21 +45,8 @@ make test

Deployment of periphery contracts such as the [Apr Oracle](https://github.com/yearn/tokenized-strategy-periphery/blob/master/src/AprOracle/AprOracle.sol) or [Common Report Trigger](https://github.com/yearn/tokenized-strategy-periphery/blob/master/src/ReportTrigger/CommonReportTrigger.sol) are done using a create2 factory in order to get a deterministic address that is the same on each EVM chain.

This can be done permissionlessly if the most recent contract has not yet been deployed on a chain you would like to use it on.

1. If you have not added a keystore private key to foundry before add your address to use

```shell
$ cast wallet import --interactive <wallet_name>
```
This can be done permissionlessly if the most recent contract has not yet been deployed on a chain you would like to use it on using this repo https://github.com/wavey0x/yearn-v3-deployer

2. Run the deployment script for the contract you want to deploy.
```sh
forge script script/DeployContractName.s.sol:DeployContractName --broadcast --rpc-url YOUR_RPC_URL --account ACCOUNT_NAME
```
- 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

Expand Down
30 changes: 11 additions & 19 deletions script/DeployCommonTrigger.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@ import "forge-std/Script.sol";
// Deploy a contract to a deterministic address with create2
contract DeployCommonTrigger is Script {

Deployer public deployer = Deployer(0x8D85e7c9A4e369E53Acc8d5426aE1568198b0112);
Deployer public deployer = Deployer(0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed);

function run() external {
vm.startBroadcast();

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

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

// Use 0 as salt.
bytes32 salt;

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

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

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

Expand All @@ -30,17 +29,10 @@ contract DeployCommonTrigger is Script {
}

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;
}
event ContractCreation(address indexed newContract, bytes32 indexed salt);

function deployCreate2(
bytes32 salt,
bytes memory initCode
) public payable returns (address newContract) {}
}

0 comments on commit a494cb0

Please sign in to comment.