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

feat: add strategies deployment script #658

Closed
wants to merge 7 commits into from
Closed
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
5 changes: 5 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ ANVIL_PRIVATE_KEY=

# Gas report
COINMARKETCAP_API_KEY=

# Strategy deployment params
ALLO_ADDRESS=
DONATION_VOTING_MERKLE_DISTRIBUTION_IS_DIRECT_TRANSFER=
DONATION_VOTING_OFFCHAIN_IS_DIRECT_TRANSFER=
17 changes: 17 additions & 0 deletions script/DeployBase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {Script, console} from "forge-std/Script.sol";

abstract contract DeployBase is Script {
function run() public {
vm.startBroadcast();
(address _contract, string memory _contractName) = _deploy();
vm.stopBroadcast();

console.log("Contract name: %s", _contractName);
console.log("Deployed contract at address: %s", _contract);
}

function _deploy() internal virtual returns (address _contract, string memory _contractName) {}
}
14 changes: 14 additions & 0 deletions script/DeployDirectAllocation.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {DeployBase} from "script/DeployBase.sol";
import {DirectAllocationStrategy} from "contracts/strategies/examples/direct-allocation/DirectAllocation.sol";

contract DeployDirectAllocation is DeployBase {
function _deploy() internal override returns (address _contract, string memory _contractName) {
address _allo = vm.envAddress("ALLO_ADDRESS");

_contract = address(new DirectAllocationStrategy(_allo));
_contractName = "DirectAllocationStrategy";
}
}
16 changes: 16 additions & 0 deletions script/DeployDonationVotingMerkleDistribution.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {DeployBase} from "script/DeployBase.sol";
import {DonationVotingMerkleDistribution} from
"contracts/strategies/examples/donation-voting/DonationVotingMerkleDistribution.sol";

contract DeployDonationVotingMerkleDistribution is DeployBase {
function _deploy() internal override returns (address _contract, string memory _contractName) {
address _allo = vm.envAddress("ALLO_ADDRESS");
bool _directTransfer = vm.envBool("DONATION_VOTING_MERKLE_DISTRIBUTION_IS_DIRECT_TRANSFER");

_contract = address(new DonationVotingMerkleDistribution(_allo, _directTransfer));
_contractName = "DonationVotingMerkleDistributionStrategy";
}
}
15 changes: 15 additions & 0 deletions script/DeployDonationVotingOffchain.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {DeployBase} from "script/DeployBase.sol";
import {DonationVotingOffchain} from "contracts/strategies/examples/donation-voting/DonationVotingOffchain.sol";

contract DeployDonationVotingOffchain is DeployBase {
function _deploy() internal override returns (address _contract, string memory _contractName) {
address _allo = vm.envAddress("ALLO_ADDRESS");
bool _directTransfer = vm.envBool("DONATION_VOTING_OFFCHAIN_IS_DIRECT_TRANSFER");

_contract = address(new DonationVotingOffchain(_allo, _directTransfer));
_contractName = "DonationVotingOffchainStrategy";
}
}
14 changes: 14 additions & 0 deletions script/DeployDonationVotingOnchain.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {DeployBase} from "script/DeployBase.sol";
import {DonationVotingOnchain} from "contracts/strategies/examples/donation-voting/DonationVotingOnchain.sol";

contract DeployDonationVotingOnchain is DeployBase {
function _deploy() internal override returns (address _contract, string memory _contractName) {
address _allo = vm.envAddress("ALLO_ADDRESS");

_contract = address(new DonationVotingOnchain(_allo));
_contractName = "DonationVotingOnchainStrategy";
}
}
14 changes: 14 additions & 0 deletions script/DeployEasyRPGF.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {DeployBase} from "script/DeployBase.sol";
import {EasyRPGF} from "contracts/strategies/examples/easy-rpgf/EasyRPGF.sol";

contract DeployEasyRPGF is DeployBase {
function _deploy() internal override returns (address _contract, string memory _contractName) {
address _allo = vm.envAddress("ALLO_ADDRESS");

_contract = address(new EasyRPGF(_allo));
_contractName = "EasyRPGFStrategy";
}
}
14 changes: 14 additions & 0 deletions script/DeployQVImpactStream.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {DeployBase} from "script/DeployBase.sol";
import {QVImpactStream} from "contracts/strategies/examples/impact-stream/QVImpactStream.sol";

contract DeployQVImpactStream is DeployBase {
function _deploy() internal override returns (address _contract, string memory _contractName) {
address _allo = vm.envAddress("ALLO_ADDRESS");

_contract = address(new QVImpactStream(_allo));
_contractName = "QVImpactStreamStrategy";
}
}
14 changes: 14 additions & 0 deletions script/DeployQVSimple.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {DeployBase} from "script/DeployBase.sol";
import {QVSimple} from "contracts/strategies/examples/quadratic-voting/QVSimple.sol";

contract DeployQVSimple is DeployBase {
function _deploy() internal override returns (address _contract, string memory _contractName) {
address _allo = vm.envAddress("ALLO_ADDRESS");

_contract = address(new QVSimple(_allo));
_contractName = "QVSimpleStrategy";
}
}
14 changes: 14 additions & 0 deletions script/DeployRFPSimple.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {DeployBase} from "script/DeployBase.sol";
import {RFPSimple} from "contracts/strategies/examples/rfp/RFPSimple.sol";

contract DeployRFPSimple is DeployBase {
function _deploy() internal override returns (address _contract, string memory _contractName) {
address _allo = vm.envAddress("ALLO_ADDRESS");

_contract = address(new RFPSimple(_allo));
_contractName = "RFPSimpleStrategy";
}
}
17 changes: 17 additions & 0 deletions script/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Deployment scripts

This folder contains the scripts neccessary to deploy strategies and Allo contracts to the blockchain.

# Usage

1. Install dependencies by running `bun install`.
2. Compile contracts by running `bun smock && bun compile`.
3. Fill the necessary environment variables in `.env` file. You can use `.env.example` as a template.
4. Run the deployment script with:
```
forge script script/${SCRIPT_FILENAME}.sol:${SCRIPT_CONTRACT_NAME} --fork-url ${RPC_URL} --private-key ${PRIVATE_KEY} --broadcast
```
For example:
```
forge script script/DeployDirectAllocation.sol:DeployDirectAllocation --fork-url https://eth-sepolia.public.blastapi.io --private-key 0x0000 --broadcast
```
Loading