diff --git a/.env.sample b/.env.sample index a3e08ec67..3ecc608dd 100644 --- a/.env.sample +++ b/.env.sample @@ -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= \ No newline at end of file diff --git a/script/DeployBase.sol b/script/DeployBase.sol new file mode 100644 index 000000000..e2c575cb7 --- /dev/null +++ b/script/DeployBase.sol @@ -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) {} +} diff --git a/script/DeployDirectAllocation.sol b/script/DeployDirectAllocation.sol new file mode 100644 index 000000000..bce0c41a2 --- /dev/null +++ b/script/DeployDirectAllocation.sol @@ -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"; + } +} diff --git a/script/DeployDonationVotingMerkleDistribution.sol b/script/DeployDonationVotingMerkleDistribution.sol new file mode 100644 index 000000000..3bce28966 --- /dev/null +++ b/script/DeployDonationVotingMerkleDistribution.sol @@ -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"; + } +} diff --git a/script/DeployDonationVotingOffchain.sol b/script/DeployDonationVotingOffchain.sol new file mode 100644 index 000000000..80c269675 --- /dev/null +++ b/script/DeployDonationVotingOffchain.sol @@ -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"; + } +} diff --git a/script/DeployDonationVotingOnchain.sol b/script/DeployDonationVotingOnchain.sol new file mode 100644 index 000000000..602993ce6 --- /dev/null +++ b/script/DeployDonationVotingOnchain.sol @@ -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"; + } +} diff --git a/script/DeployEasyRPGF.sol b/script/DeployEasyRPGF.sol new file mode 100644 index 000000000..7c07909b9 --- /dev/null +++ b/script/DeployEasyRPGF.sol @@ -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"; + } +} diff --git a/script/DeployQVImpactStream.sol b/script/DeployQVImpactStream.sol new file mode 100644 index 000000000..6777db537 --- /dev/null +++ b/script/DeployQVImpactStream.sol @@ -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"; + } +} diff --git a/script/DeployQVSimple.sol b/script/DeployQVSimple.sol new file mode 100644 index 000000000..73611daa7 --- /dev/null +++ b/script/DeployQVSimple.sol @@ -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"; + } +} diff --git a/script/DeployRFPSimple.sol b/script/DeployRFPSimple.sol new file mode 100644 index 000000000..0a12d87bf --- /dev/null +++ b/script/DeployRFPSimple.sol @@ -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"; + } +} diff --git a/script/README.md b/script/README.md new file mode 100644 index 000000000..d48e55c35 --- /dev/null +++ b/script/README.md @@ -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 +``` \ No newline at end of file