Skip to content

Commit 521bc7b

Browse files
Era Factory (#567)
* wip: era * change structure * formatting and test case fix * fix * redeploy --------- Co-authored-by: 0xKurt <[email protected]>
1 parent 9d8003b commit 521bc7b

File tree

28 files changed

+3129
-1
lines changed

28 files changed

+3129
-1
lines changed

contracts/factories/DGLFactory.sol

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// SPDX-License-Identifier: AGPL-3.0-only
2+
pragma solidity 0.8.19;
3+
4+
// External Libraries
5+
import "solady/auth/Ownable.sol";
6+
// Internal Libraries
7+
import "../strategies/direct-grants-lite/DirectGrantsLite.sol";
8+
9+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
10+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
11+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⢿⣿⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
12+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⡟⠘⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
13+
// ⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⣾⣿⣿⣿⣿⣾⠻⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⡿⠀⠀⠸⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⢀⣠⣴⣴⣶⣶⣶⣦⣦⣀⡀⠀⠀⠀⠀⠀⠀
14+
// ⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⡿⠃⠀⠙⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⠁⠀⠀⠀⢻⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡀⠀⠀⠀⠀
15+
// ⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⡿⠁⠀⠀⠀⠘⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⠃⠀⠀⠀⠀⠈⢿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⣰⣿⣿⣿⡿⠋⠁⠀⠀⠈⠘⠹⣿⣿⣿⣿⣆⠀⠀⠀
16+
// ⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⠏⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⢰⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⡀⠀⠀
17+
// ⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⣿⣟⠀⡀⢀⠀⡀⢀⠀⡀⢈⢿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⡇⠀⠀
18+
// ⠀⠀⣠⣿⣿⣿⣿⣿⣿⡿⠋⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⡿⢿⠿⠿⠿⠿⠿⠿⠿⠿⠿⢿⣿⣿⣿⣷⡀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠸⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⠂⠀⠀
19+
// ⠀⠀⠙⠛⠿⠻⠻⠛⠉⠀⠀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣧⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⢻⣿⣿⣿⣷⣀⢀⠀⠀⠀⡀⣰⣾⣿⣿⣿⠏⠀⠀⠀
20+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣧⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠹⢿⣿⣿⣿⣿⣾⣾⣷⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀
21+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠙⠋⠛⠙⠋⠛⠙⠋⠛⠙⠋⠃⠀⠀⠀⠀⠀⠀⠀⠀⠠⠿⠻⠟⠿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠟⠿⠟⠿⠆⠀⠸⠿⠿⠟⠯⠀⠀⠀⠸⠿⠿⠿⠏⠀⠀⠀⠀⠀⠈⠉⠻⠻⡿⣿⢿⡿⡿⠿⠛⠁⠀⠀⠀⠀⠀⠀
22+
// allo.gitcoin.co
23+
24+
/// @title DirectGrantsLiteFactory
25+
/// @author @thelostone-mc <[email protected]>, @0xKurt <[email protected]>, @codenamejason <[email protected]>, @0xZakk <[email protected]>, @nfrgosselin <[email protected]>
26+
/// @notice This contract is used to create new DonationVotingMerkleDistributionDirectTransferStrategy contracts on Era.
27+
contract DGLFactory is Ownable {
28+
/// @notice Allo address
29+
address public allo;
30+
31+
/// @notice Strategy name
32+
string public name;
33+
34+
/// ===============================
35+
/// ========== Events =============
36+
/// ===============================
37+
38+
/// @notice Emitted when the allo address is updated
39+
/// @param allo The new allo address
40+
event AlloUpdated(address allo);
41+
42+
/// @notice Emitted when the name is updated
43+
/// @param name The new name
44+
event NameUpdated(string name);
45+
46+
/// @notice Emitted when a new strategy is created
47+
/// @param strategy The address of the new strategy
48+
event StrategyCreated(address strategy);
49+
50+
constructor(address _allo, string memory _name) {
51+
_initializeOwner(msg.sender);
52+
53+
allo = _allo;
54+
name = _name;
55+
56+
emit AlloUpdated(_allo);
57+
emit NameUpdated(_name);
58+
}
59+
60+
/// @notice Updates allo address
61+
/// @param _allo The address of the allo contract
62+
function updateAllo(address _allo) external onlyOwner {
63+
allo = _allo;
64+
emit AlloUpdated(_allo);
65+
}
66+
67+
/// @notice Updates name
68+
/// @param _name The name of the strategy
69+
function updateName(string memory _name) external onlyOwner {
70+
name = _name;
71+
emit NameUpdated(_name);
72+
}
73+
74+
/// @notice Creates a new DirectGrantsLiteStrategy
75+
function createStrategy() external returns (address strategy) {
76+
strategy = address(new DirectGrantsLiteStrategy(allo, name));
77+
emit StrategyCreated(strategy);
78+
}
79+
80+
/// @notice Creates a new DirectGrantsLiteStrategy with custom params
81+
/// @param _allo The 'Allo' contract
82+
/// @param _name The name of the strategy
83+
function createCustomStrategy(address _allo, string memory _name) external returns (address strategy) {
84+
strategy = address(new DirectGrantsLiteStrategy(_allo, _name));
85+
emit StrategyCreated(strategy);
86+
}
87+
}

contracts/factories/DVMDTFactory.sol

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// SPDX-License-Identifier: AGPL-3.0-only
2+
pragma solidity 0.8.19;
3+
4+
// External Libraries
5+
import "solady/auth/Ownable.sol";
6+
// Internal Libraries
7+
import
8+
"../strategies/donation-voting-merkle-distribution-direct-transfer/DonationVotingMerkleDistributionDirectTransferStrategy.sol";
9+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
10+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
11+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⢿⣿⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
12+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⡟⠘⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
13+
// ⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⣾⣿⣿⣿⣿⣾⠻⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⡿⠀⠀⠸⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠀⠀⢀⣠⣴⣴⣶⣶⣶⣦⣦⣀⡀⠀⠀⠀⠀⠀⠀
14+
// ⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⡿⠃⠀⠙⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⠁⠀⠀⠀⢻⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡀⠀⠀⠀⠀
15+
// ⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⡿⠁⠀⠀⠀⠘⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⠃⠀⠀⠀⠀⠈⢿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⣰⣿⣿⣿⡿⠋⠁⠀⠀⠈⠘⠹⣿⣿⣿⣿⣆⠀⠀⠀
16+
// ⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⠏⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⢰⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⡀⠀⠀
17+
// ⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⣿⣟⠀⡀⢀⠀⡀⢀⠀⡀⢈⢿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⡇⠀⠀
18+
// ⠀⠀⣠⣿⣿⣿⣿⣿⣿⡿⠋⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⡿⢿⠿⠿⠿⠿⠿⠿⠿⠿⠿⢿⣿⣿⣿⣷⡀⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠸⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⠂⠀⠀
19+
// ⠀⠀⠙⠛⠿⠻⠻⠛⠉⠀⠀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣧⠀⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⢻⣿⣿⣿⣷⣀⢀⠀⠀⠀⡀⣰⣾⣿⣿⣿⠏⠀⠀⠀
20+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣧⠀⠀⢸⣿⣿⣿⣗⠀⠀⠀⢸⣿⣿⣿⡯⠀⠀⠀⠀⠹⢿⣿⣿⣿⣿⣾⣾⣷⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀
21+
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠙⠋⠛⠙⠋⠛⠙⠋⠛⠙⠋⠃⠀⠀⠀⠀⠀⠀⠀⠀⠠⠿⠻⠟⠿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠟⠿⠟⠿⠆⠀⠸⠿⠿⠟⠯⠀⠀⠀⠸⠿⠿⠿⠏⠀⠀⠀⠀⠀⠈⠉⠻⠻⡿⣿⢿⡿⡿⠿⠛⠁⠀⠀⠀⠀⠀⠀
22+
// allo.gitcoin.co
23+
24+
/// @title DonationVotingMerkleDirectTransferFactory
25+
/// @author @thelostone-mc <[email protected]>, @0xKurt <[email protected]>, @codenamejason <[email protected]>, @0xZakk <[email protected]>, @nfrgosselin <[email protected]>
26+
/// @notice This contract is used to create new DonationVotingMerkleDistributionDirectTransferStrategy contracts on Era.
27+
contract DVMDTFactory is Ownable {
28+
/// @notice Allo address
29+
address public allo;
30+
31+
/// @notice Strategy name
32+
string public name;
33+
34+
/// @notice Permit2 contract
35+
ISignatureTransfer public permit2;
36+
37+
/// ===============================
38+
/// ========== Events =============
39+
/// ===============================
40+
41+
/// @notice Emitted when the allo address is updated
42+
/// @param allo The new allo address
43+
event AlloUpdated(address allo);
44+
45+
/// @notice Emitted when the name is updated
46+
/// @param name The new name
47+
event NameUpdated(string name);
48+
49+
/// @notice Emitted when the permit2 contract is updated
50+
/// @param permit2 The new permit2 contract
51+
event Permit2Updated(ISignatureTransfer permit2);
52+
53+
/// @notice Emitted when a new strategy is created
54+
/// @param strategy The address of the new strategy
55+
event StrategyCreated(address strategy);
56+
57+
constructor(address _allo, string memory _name, ISignatureTransfer _permit2) {
58+
_initializeOwner(msg.sender);
59+
60+
allo = _allo;
61+
name = _name;
62+
permit2 = _permit2;
63+
64+
emit AlloUpdated(_allo);
65+
emit NameUpdated(_name);
66+
emit Permit2Updated(_permit2);
67+
}
68+
69+
/// @notice Updates allo address
70+
/// @param _allo The address of the allo contract
71+
function updateAllo(address _allo) external onlyOwner {
72+
allo = _allo;
73+
emit AlloUpdated(_allo);
74+
}
75+
76+
/// @notice Updates name
77+
/// @param _name The name of the strategy
78+
function updateName(string memory _name) external onlyOwner {
79+
name = _name;
80+
emit NameUpdated(_name);
81+
}
82+
83+
/// @notice Updates permit2 contract
84+
/// @param _permit2 The permit2 contract
85+
function updatePermit2(ISignatureTransfer _permit2) external onlyOwner {
86+
permit2 = _permit2;
87+
emit Permit2Updated(_permit2);
88+
}
89+
90+
/// @notice Creates a new DonationVotingMerkleDistributionDirectTransferStrategy
91+
function createStrategy() external returns (address strategy) {
92+
strategy = address(new DonationVotingMerkleDistributionDirectTransferStrategy(allo, name, permit2));
93+
emit StrategyCreated(strategy);
94+
}
95+
96+
/// @notice Creates a new DonationVotingMerkleDistributionDirectTransferStrategy with custom params
97+
/// @param _allo The 'Allo' contract
98+
/// @param _name The name of the strategy
99+
/// @param _permit2 The permit2 contract
100+
function createStrategyCustom(address _allo, string memory _name, ISignatureTransfer _permit2)
101+
external
102+
returns (address strategy)
103+
{
104+
strategy = address(new DonationVotingMerkleDistributionDirectTransferStrategy(_allo, _name, _permit2));
105+
emit StrategyCreated(strategy);
106+
}
107+
}

contracts/factories/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Notes on Era
2+
3+
Since OZ contract uses create2 directly, and on Era VM the interface for create2 is very different. We would not be able to use `createPool` directly and would be forced to use `createPoolWithCustomStrategy`
4+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as hre from "hardhat";
2+
import { strategyConfig } from "../../../scripts/config/strategies.config";
3+
import { deployStrategyFactories } from "./utils";
4+
5+
export default async function () {
6+
const network = await hre.network.config;
7+
const chainId = Number(network.chainId);
8+
const strategyParams = strategyConfig[chainId]["direct-grants-lite"];
9+
10+
await deployStrategyFactories(
11+
"DGLFactory",
12+
strategyParams.name,
13+
strategyParams.version
14+
);
15+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as hre from "hardhat";
2+
import { strategyConfig } from "../../../scripts/config/strategies.config";
3+
import { commonConfig } from "../../../scripts/config/common.config";
4+
import { deployStrategyFactories } from "./utils";
5+
6+
export default async function () {
7+
const network = await hre.network.config;
8+
const chainId = Number(network.chainId);
9+
10+
const strategyParams = strategyConfig[chainId]["donation-voting-merkle-distribution-direct"];
11+
12+
await deployStrategyFactories(
13+
"DVMDTFactory",
14+
strategyParams.name,
15+
strategyParams.version,
16+
[commonConfig[chainId].permit2Address]
17+
);
18+
19+
};

deploy/zksync/factory/utils.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import hre from "hardhat";
2+
import { Deployments, verifyContract } from "../../../scripts/utils/scripts";
3+
import { Wallet } from "zksync-ethers";
4+
import { Addressable } from "ethers";
5+
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";
6+
7+
export async function deployStrategyFactories(
8+
contractName: string,
9+
strategyName: string,
10+
version: string,
11+
args: any = []
12+
): Promise<string|Addressable> {
13+
14+
const network = await hre.network.config;
15+
const networkName = await hre.network.name;
16+
const chainId = Number(network.chainId);
17+
18+
const deployerAddress = new Wallet(process.env.DEPLOYER_PRIVATE_KEY as string);
19+
20+
const deploymentIo = new Deployments(chainId, contractName);
21+
22+
const fileName = contractName.toLowerCase();
23+
const deployments = new Deployments(chainId, fileName);
24+
const alloAddress = deployments.getAllo();
25+
26+
console.log(`
27+
////////////////////////////////////////////////////
28+
Deploys ${contractName}.sol on ${networkName}
29+
////////////////////////////////////////////////////`
30+
);
31+
32+
console.table({
33+
contract: `Deploy ${contractName}.sol`,
34+
strategyName: strategyName,
35+
version: version,
36+
args: args,
37+
chainId: chainId,
38+
network: networkName,
39+
deployerAddress: deployerAddress.address,
40+
});
41+
42+
console.log(`Deploying ${contractName}.sol...`);
43+
44+
const deployer = new Deployer(hre, deployerAddress);
45+
const artifact = await deployer.loadArtifact(
46+
contractName
47+
);
48+
49+
const strategyNameWithVersion = strategyName + version;
50+
51+
const instance = await deployer.deploy(artifact, [alloAddress, strategyNameWithVersion, ...args]);
52+
const CONTRACT_ADDRESS = await instance.getAddress();
53+
54+
console.log(`${artifact.contractName} was deployed to ${CONTRACT_ADDRESS}`);
55+
56+
const objToWrite = {
57+
name: strategyName,
58+
version: version,
59+
address: instance.target,
60+
deployerAddress: deployerAddress.address,
61+
};
62+
63+
deploymentIo.write(objToWrite);
64+
65+
await verifyContract(CONTRACT_ADDRESS, [alloAddress, strategyNameWithVersion, ...args]);
66+
67+
return instance.target;
68+
}

0 commit comments

Comments
 (0)