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: rebase immutability #92

Merged
merged 14 commits into from
Dec 11, 2024
8 changes: 4 additions & 4 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
contact@angle.money.
<contact@merkl.xyz>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -116,13 +116,13 @@ the community.

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at
<https://www.contributor-covenant.org/translations>.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ The Merkl smart contracts have been audited by Code4rena, find the audit report

## Media

Don't hesitate to reach out on [Twitter](https://x.com/merkl_xyz)
Don't hesitate to reach out on [Twitter](https://x.com/merkl_xyz) 🐦
202 changes: 122 additions & 80 deletions contracts/DistributionCreator.sol

Large diffs are not rendered by default.

307 changes: 218 additions & 89 deletions contracts/Distributor.sol

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/interfaces/IAccessControlManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.17;

/// @title IAccessControlManager
/// @author Angle Labs, Inc.
/// @notice Interface for the `IAccessControlManager` contracts used in Merkl contracts
/// @notice Interface for the `AccessControlManager` contracts of Merkl contracts
interface IAccessControlManager {
/// @notice Checks whether an address is governor
/// @param admin Address to check
Expand Down
1 change: 1 addition & 0 deletions contracts/partners/tokenWrappers/BaseTokenWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Errors } from "../../utils/Errors.sol";

interface IDistributionCreator {
function distributor() external view returns (address);

function feeRecipient() external view returns (address);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/struct/CampaignParameters.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.17;
pragma solidity >=0.8.0;

struct CampaignParameters {
// POPULATED ONCE CREATED
Expand Down
2 changes: 1 addition & 1 deletion contracts/struct/DistributionParameters.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.17;
pragma solidity >=0.8.0;

struct DistributionParameters {
// ID of the reward (populated once created). This can be left as a null bytes32 when creating distributions
Expand Down
23 changes: 0 additions & 23 deletions contracts/struct/ExtensiveDistributionParameters.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/struct/RewardTokenAmounts.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.17;
pragma solidity >=0.8.0;

struct RewardTokenAmounts {
address token;
Expand Down
5 changes: 5 additions & 0 deletions contracts/utils/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,28 @@ library Errors {
error CampaignShouldStartInFuture();
error InvalidDispute();
error InvalidLengths();
error InvalidOverride();
error InvalidParam();
error InvalidParams();
error InvalidProof();
error InvalidUninitializedRoot();
error InvalidReturnMessage();
error InvalidReward();
error InvalidSignature();
error NoDispute();
error NoOverrideForCampaign();
error NotAllowed();
error NotGovernor();
error NotGovernorOrGuardian();
error NotSigned();
error NotTrusted();
error NotUpgradeable();
error NotWhitelisted();
error UnresolvedDispute();
error ZeroAddress();
error DisputeFundsTransferFailed();
error EthNotAccepted();
error ReentrantCall();
error WithdrawalFailed();
error InvalidClaim();
}
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ libs = ['node_modules']
script = 'scripts'
cache_path = 'cache-forge'
gas_reports = ["*"]
optimizer_runs=100
optimizer_runs = 100
fs_permissions = [{ access = "read", path = "./node_modules/@angleprotocol/sdk/dist/src/registry/registry.json" }]
solc = "0.8.24"

Expand Down
56 changes: 56 additions & 0 deletions scripts/DistributionCreator.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { JsonReader } from "./utils/JsonReader.sol";
import { DistributionCreator } from "../contracts/DistributionCreator.sol";
import { IAccessControlManager } from "../contracts/interfaces/IAccessControlManager.sol";
import { CampaignParameters } from "../contracts/struct/CampaignParameters.sol";
import { MockToken } from "../contracts/mock/MockToken.sol";

// Base contract with shared utilities
contract DistributionCreatorScript is BaseScript, JsonReader {
Expand Down Expand Up @@ -419,6 +420,61 @@ contract CreateCampaigns is DistributionCreatorScript {
}
}

// CreateCampaign script
contract CreateCampaignTest is DistributionCreatorScript {
function run() external {
vm.createSelectFork(vm.envString("BASE_NODE_URI"));
uint256 chainId = block.chainid;

/// TODO: COMPLETE
IERC20 rewardToken = IERC20(0xC011882d0f7672D8942e7fE2248C174eeD640c8f);
uint256 amount = 100 ether;
/// END

address creatorAddress = readAddress(chainId, "Merkl.DistributionCreator");
DistributionCreator distributionCreator = DistributionCreator(creatorAddress);

vm.startBroadcast(broadcaster);

MockToken(address(rewardToken)).mint(broadcaster, amount);
rewardToken.approve(address(distributionCreator), amount);

uint32 startTimestamp = uint32(block.timestamp + 600);

bytes32 campaignId = distributionCreator.createCampaign(
CampaignParameters({
campaignId: bytes32(0),
creator: broadcaster,
rewardToken: address(rewardToken),
amount: amount,
campaignType: 1,
startTimestamp: startTimestamp,
duration: 3600 * 24,
campaignData: abi.encode(
0xbEEfa1aBfEbE621DF50ceaEF9f54FdB73648c92C,
new address[](0),
new address[](0),
"",
new bytes[](0),
new bytes[](0),
hex""
)
})
);
vm.stopBroadcast();

CampaignParameters memory campaign = distributionCreator.campaign(campaignId);
require(campaign.creator == broadcaster, "Invalid creator");
require(campaign.rewardToken == address(rewardToken), "Invalid reward token");
require(campaign.amount == (amount * (1e9 - distributionCreator.defaultFees())) / 1e9, "Invalid amount");
require(campaign.campaignType == 1, "Invalid campaign type");
require(campaign.startTimestamp == startTimestamp, "Invalid start timestamp");
require(campaign.duration == 3600 * 24, "Invalid duration");

console.log("Campaign created with ID:", vm.toString(campaignId));
}
}

// SignAndCreateCampaign script
contract SignAndCreateCampaign is DistributionCreatorScript {
function run() external broadcast {
Expand Down
22 changes: 0 additions & 22 deletions scripts/Distributor.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -295,25 +295,3 @@ contract Claim is DistributorScript {
console.log("Claimed rewards for", users.length, "users");
}
}

// ToggleOnlyOperatorCanClaim script
contract ToggleOnlyOperatorCanClaim is DistributorScript {
function run() external broadcast {
// MODIFY THIS VALUE TO SET YOUR DESIRED USER
address user = address(0);
_run(user);
}

function run(address user) external broadcast {
_run(user);
}

function _run(address user) internal {
uint256 chainId = block.chainid;
address distributorAddress = readAddress(chainId, "Merkl.Distributor");

Distributor(distributorAddress).toggleOnlyOperatorCanClaim(user);

console.log("Toggled operator-only claiming for user:", user);
}
}
Loading
Loading