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 6 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=
16 changes: 16 additions & 0 deletions script/DeployBase.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 {Script, console} from "forge-std/Script.sol";

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

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

function _deploy() internal virtual returns (address _contract) {}
}
12 changes: 12 additions & 0 deletions script/DeployDirectAllocation.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to also have a log of the name of the strategy we deploy

address _allo = vm.envAddress("ALLO_ADDRESS");
return address(new DirectAllocationStrategy(_allo));
}
}
14 changes: 14 additions & 0 deletions script/DeployDonationVotingMerkleDistribution.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 {DonationVotingMerkleDistribution} from
"contracts/strategies/examples/donation-voting/DonationVotingMerkleDistribution.sol";

contract DeployDonationVotingMerkleDistribution is DeployBase {
function _deploy() internal override returns (address _contract) {
address _allo = vm.envAddress("ALLO_ADDRESS");
bool _directTransfer = vm.envBool("DONATION_VOTING_MERKLE_DISTRIBUTION_IS_DIRECT_TRANSFER");
return address(new DonationVotingMerkleDistribution(_allo, _directTransfer));
}
}
13 changes: 13 additions & 0 deletions script/DeployDonationVotingOffchain.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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) {
address _allo = vm.envAddress("ALLO_ADDRESS");
bool _directTransfer = vm.envBool("DONATION_VOTING_OFFCHAIN_IS_DIRECT_TRANSFER");
return address(new DonationVotingOffchain(_allo, _directTransfer));
}
}
12 changes: 12 additions & 0 deletions script/DeployDonationVotingOnchain.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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) {
address _allo = vm.envAddress("ALLO_ADDRESS");
return address(new DonationVotingOnchain(_allo));
}
}
12 changes: 12 additions & 0 deletions script/DeployEasyRPGF.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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) {
address _allo = vm.envAddress("ALLO_ADDRESS");
return address(new EasyRPGF(_allo));
}
}
12 changes: 12 additions & 0 deletions script/DeployQVImpactStream.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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) {
address _allo = vm.envAddress("ALLO_ADDRESS");
return address(new QVImpactStream(_allo));
}
}
12 changes: 12 additions & 0 deletions script/DeployQVSimple.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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) {
address _allo = vm.envAddress("ALLO_ADDRESS");
return address(new QVSimple(_allo));
}
}
12 changes: 12 additions & 0 deletions script/DeployRFPSimple.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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) {
address _allo = vm.envAddress("ALLO_ADDRESS");
return address(new RFPSimple(_allo));
}
}
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