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

[official] Plugged Diamond Pattern on top ERC1967Proxy UUPS #438

Merged
merged 11 commits into from
Sep 20, 2024
Merged
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#default-profile
[profile.default]
solc-version = "0.8.19"
# solc-version = "0.8.19"
src = 'pkg/contracts/src'
script = 'pkg/contracts/script'
test = 'pkg/contracts/test'
Expand Down
2 changes: 1 addition & 1 deletion pkg/contracts/out/Allo.sol/Allo.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategyV0_0.sol/CVStrategyV0_0.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategyV0_0.sol/IPointStrategy.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pkg/contracts/out/CVStrategyV0_0.sol/StrategyStruct.json

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategyV0_1.sol/CVStrategyV0_1.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pkg/contracts/out/CVStrategyV0_1.sol/StrategyStruct2.json

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ERC20.sol/ERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ERC20/IERC20.sol/IERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/FAllo.sol/FAllo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/GV2ERC20.sol/GV2ERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IAllo.sol/IAllo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IArbitrator.sol/IArbitrator.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IERC20.sol/IERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IERC20Metadata.sol/IERC20Metadata.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IERC20Permit.sol/IERC20Permit.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IRegistry.sol/IRegistry.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ISafe.sol/Enum.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ISafe.sol/ISafe.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ISafe.sol/SafeProxyFactory.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/MockERC20.sol/MockERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/PassportScorer.sol/PassportScorer.json

Large diffs are not rendered by default.

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/contracts/out/Registry.sol/Registry.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/RegistrySetup.sol/RegistrySetup.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/RegistrySetup.sol/RegistrySetupFull.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/SafeArbitrator.sol/SafeArbitrator.json

Large diffs are not rendered by default.

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/contracts/out/SafeERC20.sol/SafeERC20.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions pkg/contracts/script/BaseMultiChain.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ abstract contract BaseMultiChain is Native, CVStrategyHelpers, Script, SafeSetup
// assertTrue(registryFactory.registryCommunityTemplate() != address(0x0), "Registry Community Template not set");
// assertTrue(registryFactory.collateralVaultTemplate() != address(0x0), "Collateral Vault Template not set");

// RegistryCommunityV0_1.InitializeParams memory params;
// RegistryCommunityInitializeParamsV0_0 memory params;

// metadata = Metadata({protocol: 1, pointer: "QmX5jPva6koRnn88s7ZcPnNXKg1UzmYaZu9h15d8kzH1CN"});
// params._metadata = metadata; // convenant ipfs
Expand All @@ -208,20 +208,20 @@ abstract contract BaseMultiChain is Native, CVStrategyHelpers, Script, SafeSetup

// RegistryCommunityV0_1 registryCommunity = RegistryCommunityV0_1(registryFactory.createRegistry(params));

// StrategyStruct.PointSystemConfig memory pointConfig;
// PointSystemConfig memory pointConfig;
// pointConfig.maxAmount = MINIMUM_STAKE * 2;

// proxy = new ERC1967Proxy(
// address(new SafeArbitrator()), abi.encodeWithSelector(SafeArbitrator.initialize.selector, 0.001 ether)
// );
// arbitrator = SafeArbitrator(payable(address(proxy)));

// StrategyStruct2.InitializeParams memory paramsCV = getParams(
// CVStrategyInitializeParamsV0_0 memory paramsCV = getParams(
// address(registryCommunity),
// StrategyStruct.ProposalType.Funding,
// StrategyStruct.PointSystem.Fixed,
// ProposalType.Funding,
// PointSystem.Fixed,
// pointConfig,
// StrategyStruct.ArbitrableConfig(
// ArbitrableConfig(
// IArbitrator(address(arbitrator)), payable(COUNCIL_SAFE), 0.002 ether, 0.001 ether, 1, 300
// )
// );
Expand Down Expand Up @@ -249,8 +249,8 @@ abstract contract BaseMultiChain is Native, CVStrategyHelpers, Script, SafeSetup
// // strategy1.setMaxRatio(_etherToFloat(0.3219782 ether)); // beta = maxRatio
// // strategy1.setWeight(_etherToFloat(0.010367 ether)); // RHO = p = weight

// paramsCV.proposalType = StrategyStruct.ProposalType.Signaling;
// paramsCV.pointSystem = StrategyStruct.PointSystem.Unlimited;
// paramsCV.proposalType = ProposalType.Signaling;
// paramsCV.pointSystem = PointSystem.Unlimited;
// paramsCV.sybilScorer = address(sybilScorer);

// (uint256 poolIdSignaling, address _strategy2) = registryCommunity.createPool(
Expand Down Expand Up @@ -302,7 +302,7 @@ abstract contract BaseMultiChain is Native, CVStrategyHelpers, Script, SafeSetup
// token.approve(address(allo), type(uint256).max);
// allo.fundPool(poolId, 10_000 ether);

// StrategyStruct.CreateProposal memory proposal = StrategyStruct.CreateProposal(
// CreateProposal memory proposal = CreateProposal(
// poolId,
// BENEFICIARY,
// 500 ether,
Expand All @@ -312,7 +312,7 @@ abstract contract BaseMultiChain is Native, CVStrategyHelpers, Script, SafeSetup
// bytes memory data = abi.encode(proposal);
// allo.registerRecipient{value: 0.002 ether}(poolId, data);

// proposal = StrategyStruct.CreateProposal(
// proposal = CreateProposal(
// poolId,
// BENEFICIARY,
// 1500 ether,
Expand All @@ -322,7 +322,7 @@ abstract contract BaseMultiChain is Native, CVStrategyHelpers, Script, SafeSetup
// data = abi.encode(proposal);
// allo.registerRecipient{value: 0.002 ether}(poolId, data);

// proposal = StrategyStruct.CreateProposal(
// proposal = CreateProposal(
// poolId,
// BENEFICIARY,
// 1500 ether,
Expand All @@ -333,7 +333,7 @@ abstract contract BaseMultiChain is Native, CVStrategyHelpers, Script, SafeSetup
// allo.registerRecipient{value: 0.002 ether}(poolId, data);

// // Strategy with Signaling
// StrategyStruct.CreateProposal memory proposal2 = StrategyStruct.CreateProposal(
// CreateProposal memory proposal2 = CreateProposal(
// poolIdSignaling,
// address(0),
// 0,
Expand All @@ -343,7 +343,7 @@ abstract contract BaseMultiChain is Native, CVStrategyHelpers, Script, SafeSetup
// bytes memory data2 = abi.encode(proposal2);
// allo.registerRecipient{value: 0.002 ether}(poolIdSignaling, data2);

// proposal2 = StrategyStruct.CreateProposal(
// proposal2 = CreateProposal(
// poolIdSignaling,
// address(0),
// 0,
Expand All @@ -354,7 +354,7 @@ abstract contract BaseMultiChain is Native, CVStrategyHelpers, Script, SafeSetup
// data2 = abi.encode(proposal2);
// allo.registerRecipient{value: 0.002 ether}(poolIdSignaling, data2);

// proposal2 = StrategyStruct.CreateProposal(
// proposal2 = CreateProposal(
// poolIdSignaling,
// address(0),
// 0,
Expand Down
82 changes: 44 additions & 38 deletions pkg/contracts/script/DeployCV.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ import {CVStrategyHelpers, CVStrategyV0_1} from "../test/CVStrategyHelpers.sol";
import {TERC20} from "../test/shared/TERC20.sol";
import {CVStrategyV0_1} from "../src/CVStrategy/CVStrategyV0_1.sol";
import {RegistryFactoryV0_0} from "../src/RegistryFactory/RegistryFactoryV0_0.sol";
import {RegistryCommunityV0_1} from "../src/RegistryCommunity/RegistryCommunityV0_1.sol";
import {RegistryCommunityV0_1, RegistryCommunityInitializeParamsV0_0} from "../src/RegistryCommunity/RegistryCommunityV0_1.sol";
import {ISybilScorer} from "../src/ISybilScorer.sol";
import {PassportScorer} from "../src/PassportScorer.sol";
import {SafeSetup} from "../test/shared/SafeSetup.sol";
// import {Metadata} from "allo-v2-contracts/core/libraries/Metadata.sol";
import {IRegistry, Metadata} from "allo-v2-contracts/core/interfaces/IRegistry.sol";
import {Accounts} from "allo-v2-test/foundry/shared/Accounts.sol";
import {CVStrategyV0_0, StrategyStruct, StrategyStruct2, CVStrategyV0_1} from "../src/CVStrategy/CVStrategyV0_1.sol";
import {
CVStrategyV0_0,
CVStrategyV0_1,
PointSystemConfig,
PointSystem,
ArbitrableConfig,
ProposalType,
CreateProposal
} from "../src/CVStrategy/CVStrategyV0_1.sol";
import {CVStrategyInitializeParamsV0_0} from "../src/CVStrategy/CVStrategyV0_0.sol";
import {Upgrades} from "@openzeppelin/foundry/LegacyUpgrades.sol";
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

Expand Down Expand Up @@ -96,7 +105,7 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {

console2.log("Safe Arbitrator Addr: %s", address(safeArbitrator));

RegistryCommunityV0_1.InitializeParams memory params;
RegistryCommunityInitializeParamsV0_0 memory params;

params._allo = address(allo);
params._gardenToken = IERC20(address(token));
Expand All @@ -109,7 +118,7 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
RegistryCommunityV0_1 registryCommunity = RegistryCommunityV0_1(registryFactory.createRegistry(params));
token.mint(address(pool_admin()), 10_000 ether);

StrategyStruct2.InitializeParams memory paramsCV;
CVStrategyInitializeParamsV0_0 memory paramsCV;

// CVParams
paramsCV.cvParams.decay = _etherToFloat(0.9999799 ether); // alpha = decay
Expand All @@ -118,22 +127,22 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
paramsCV.cvParams.minThresholdPoints = 0.2 ether; // 20%

paramsCV.registryCommunity = address(registryCommunity);
paramsCV.proposalType = StrategyStruct.ProposalType.Funding;
paramsCV.pointSystem = StrategyStruct.PointSystem.Unlimited;
paramsCV.proposalType = ProposalType.Funding;
paramsCV.pointSystem = PointSystem.Unlimited;
paramsCV.sybilScorer = address(sybilScorer);

// Point config
StrategyStruct.PointSystemConfig memory pointConfig;
PointSystemConfig memory pointConfig;
pointConfig.maxAmount = MINIMUM_STAKE * 2;
if (pointConfig.maxAmount == 0) {
// StrategyStruct.PointSystemConfig memory pointConfig;
// PointSystemConfig memory pointConfig;
//Capped point system
pointConfig.maxAmount = 200 * DECIMALS;
}
paramsCV.pointConfig = pointConfig;

// ArbitrableConfig
StrategyStruct.ArbitrableConfig memory arbitrableConfig;
ArbitrableConfig memory arbitrableConfig;
arbitrableConfig.arbitrator = safeArbitrator;
arbitrableConfig.tribunalSafe = payable(address(_councilSafe()));
arbitrableConfig.submitterCollateralAmount = 0.1 ether;
Expand All @@ -154,8 +163,8 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
abi.encodeWithSelector(registryCommunity.addStrategy.selector, address(strategy1))
);

paramsCV.proposalType = StrategyStruct.ProposalType.Signaling;
paramsCV.pointSystem = StrategyStruct.PointSystem.Fixed;
paramsCV.proposalType = ProposalType.Signaling;
paramsCV.pointSystem = PointSystem.Fixed;

(uint256 poolIdFixed, address _strategy2) = registryCommunity.createPool(address(token), paramsCV, metadata);

Expand All @@ -173,14 +182,14 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
// address(registryCommunity),
// registry,
// address(0),
// StrategyStruct.ProposalType.Signaling,
// StrategyStruct.PointSystem.Unlimited
// ProposalType.Signaling,
// PointSystem.Unlimited
// );

// strategy1.setDecay(_etherToFloat(0.9965402 ether)); // alpha = decay
// strategy1.setMaxRatio(_etherToFloat(0.1 ether)); // beta = maxRatio
// strategy1.setWeight(_etherToFloat(0.0005 ether)); // RHO = p = weight
// StrategyStruct.CVParams memory poolParams1;
// CVParams memory poolParams1;
// poolParams1.decay = _etherToFloat(0.9999799 ether); // alpha = decay
// poolParams1.maxRatio = _etherToFloat(0.1 ether); // beta = maxRatio
// poolParams1.weight = _etherToFloat(0.0005 ether); // RHO = p = weight
Expand Down Expand Up @@ -226,23 +235,22 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
allo.fundPool(poolId, 3_000 ether); // ether
allo.fundPool(poolIdFixed, 1_000 ether); // ether

// StrategyStruct.CreateProposal memory proposal =
// StrategyStruct.CreateProposal(poolId, membersStaked[0], 50 ether, address(token), metadata);
// CreateProposal memory proposal =
// CreateProposal(poolId, membersStaked[0], 50 ether, address(token), metadata);
// bytes memory data = abi.encode(proposal);
// allo.registerRecipient{value:2 ether}(poolId, data);

// proposal = StrategyStruct.CreateProposal(poolId, membersStaked[1], 25 ether, address(token), metadata);
// proposal = CreateProposal(poolId, membersStaked[1], 25 ether, address(token), metadata);
// data = abi.encode(proposal);
// allo.registerRecipient{value:2 ether}(poolId, data);

// proposal = StrategyStruct.CreateProposal(poolId, membersStaked[2], 10 ether, address(token), metadata);
// proposal = CreateProposal(poolId, membersStaked[2], 10 ether, address(token), metadata);
// data = abi.encode(proposal);
// allo.registerRecipient{value:2 ether}(poolId, data);

// allo.fundPool{value: 0.1 ether}(poolIdNative, 0.1 ether);

StrategyStruct.CreateProposal memory proposal2 =
StrategyStruct.CreateProposal(poolIdFixed, membersStaked[0], 0, address(token), metadata);
CreateProposal memory proposal2 = CreateProposal(poolIdFixed, membersStaked[0], 0, address(token), metadata);
bytes memory data2 = abi.encode(proposal2);
allo.registerRecipient{value: 3 ether}(poolIdFixed, data2);
vm.stopBroadcast();
Expand All @@ -268,8 +276,8 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
console2.log("Council Safe Addr: %s", address(_councilSafe()));
}

function _getPointConfig() internal pure returns (StrategyStruct.PointSystemConfig memory) {
StrategyStruct.PointSystemConfig memory pointConfig;
function _getPointConfig() internal pure returns (PointSystemConfig memory) {
PointSystemConfig memory pointConfig;
pointConfig.maxAmount = MINIMUM_STAKE * 2;
return pointConfig;
}
Expand All @@ -283,7 +291,7 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {

// console2.log("Registry Factory Addr: %s", address(registryFactory));

RegistryCommunityV0_1.InitializeParams memory params;
RegistryCommunityInitializeParamsV0_0 memory params;

params._allo = address(allo);

Expand Down Expand Up @@ -330,7 +338,7 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
);

// ArbitrableConfig
StrategyStruct.ArbitrableConfig memory arbitrableConfig;
ArbitrableConfig memory arbitrableConfig;
arbitrableConfig.arbitrator = safeArbitrator;
arbitrableConfig.tribunalSafe = payable(address(_councilSafe()));
arbitrableConfig.submitterCollateralAmount = 0.1 ether;
Expand All @@ -345,8 +353,8 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
address(registryCommunity),
registry,
address(token),
StrategyStruct.ProposalType.Funding,
StrategyStruct.PointSystem.Unlimited,
ProposalType.Funding,
PointSystem.Unlimited,
_getPointConfig(),
arbitrableConfig
);
Expand All @@ -357,8 +365,8 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
address(registryCommunity),
registry,
address(token),
StrategyStruct.ProposalType.Funding,
StrategyStruct.PointSystem.Fixed,
ProposalType.Funding,
PointSystem.Fixed,
_getPointConfig(),
arbitrableConfig
);
Expand All @@ -369,12 +377,12 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
// address(registryCommunity),
// registry,
// address(0),
// StrategyStruct.ProposalType.Signaling,
// StrategyStruct.PointSystem.Unlimited
// ProposalType.Signaling,
// PointSystem.Unlimited
// );

// Goss: Commented because already set in getParams
// StrategyStruct.CVParams memory poolParams1;
// CVParams memory poolParams1;
// poolParams1.decay = _etherToFloat(0.9999799 ether); // alpha = decay
// poolParams1.maxRatio = _etherToFloat(0.1 ether); // beta = maxRatio
// poolParams1.weight = _etherToFloat(0.0005 ether); // RHO = p = weight
Expand All @@ -387,7 +395,7 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {

// Goss: Commented because already set in getParams
// FAST 1 MIN GROWTH
// StrategyStruct.CVParams memory poolParams2;
// CVParams memory poolParams2;
// poolParams2.decay = _etherToFloat(0.9965402 ether); // alpha = decay
// poolParams2.maxRatio = _etherToFloat(0.1 ether); // beta = maxRatio
// poolParams2.weight = _etherToFloat(0.0005 ether); // RHO = p = weight
Expand Down Expand Up @@ -420,25 +428,23 @@ contract DeployCV is Native, CVStrategyHelpers, Script, SafeSetup {
allo.fundPool(poolId, 3_000 ether); // ether
allo.fundPool(poolIdFixed, 1_000 ether); // ether

StrategyStruct.CreateProposal memory proposal =
StrategyStruct.CreateProposal(poolId, membersStaked[0], 50 ether, address(token), metadata);
CreateProposal memory proposal = CreateProposal(poolId, membersStaked[0], 50 ether, address(token), metadata);
bytes memory data = abi.encode(proposal);
allo.registerRecipient{value: 3 ether}(poolId, data);

proposal = StrategyStruct.CreateProposal(poolId, membersStaked[1], 25 ether, address(token), metadata);
proposal = CreateProposal(poolId, membersStaked[1], 25 ether, address(token), metadata);
data = abi.encode(proposal);

allo.registerRecipient{value: 3 ether}(poolId, data);

proposal = StrategyStruct.CreateProposal(poolId, membersStaked[2], 10 ether, address(token), metadata);
proposal = CreateProposal(poolId, membersStaked[2], 10 ether, address(token), metadata);

data = abi.encode(proposal);
allo.registerRecipient{value: 3 ether}(poolId, data);

// allo.fundPool{value: 0.1 ether}(poolIdNative, 0.1 ether);

StrategyStruct.CreateProposal memory proposal2 =
StrategyStruct.CreateProposal(poolIdFixed, membersStaked[0], 0, address(token), metadata);
CreateProposal memory proposal2 = CreateProposal(poolIdFixed, membersStaked[0], 0, address(token), metadata);

bytes memory data2 = abi.encode(proposal2);
allo.registerRecipient{value: 3 ether}(poolIdFixed, data2);
Expand Down
Loading
Loading