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

Deploy v2 #55

Merged
merged 33 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a755977
feat: merklV2 poc
sogipec Dec 1, 2023
916262d
merkl V2 contracts
sogipec Dec 3, 2023
9f41f8b
feat: distribution creator concatenated
sogipec Dec 5, 2023
ba7df73
feat: delete distribution creator
sogipec Dec 5, 2023
1d97045
feat: rework for wrapping new Merkl version in the contract
sogipec Dec 5, 2023
12c93d4
feat guardian governor
sogipec Dec 5, 2023
bcac8c6
feat: distribution update
sogipec Dec 12, 2023
79094e9
feat: add pagination in reward tokens
sogipec Dec 12, 2023
b9ac646
mock deployment merkl
sogipec Dec 19, 2023
be18616
feat: update creator
sogipec Dec 22, 2023
1ff8f66
feat: change creator
sogipec Dec 22, 2023
60ab65d
base deployment
sogipec Jan 10, 2024
9b3dc31
feat: wrapping campaigns
Picodes Jan 10, 2024
9557c32
fix: DistributionCreator v2
Picodes Jan 16, 2024
7f95d29
Iterations (#50)
sogipec Jan 31, 2024
fddf906
feat: getDistribution getter (#51)
Picodes Feb 1, 2024
4a9c48a
feat: chainId in campaignId (#52)
Picodes Feb 1, 2024
94645ab
Default fees (#53)
sogipec Feb 2, 2024
454198d
fix: signing
Picodes Feb 5, 2024
6c435bd
fix: signing (#54)
Picodes Feb 5, 2024
ff7fcfe
fix updates
sogipec Jan 31, 2024
0c8d92d
feat: deployment
sogipec Feb 5, 2024
43efbf3
feat: deploy-v2
sogipec Feb 5, 2024
76f0ef2
feat: deployments everywhere
sogipec Feb 5, 2024
d59a2a1
tests: update all tests for v2
0xtekgrinder Feb 9, 2024
d8fc719
chore: revert hardhat config back to pre v2
0xtekgrinder Feb 9, 2024
dc2852e
tests: add signAndCreateCampaign tests
0xtekgrinder Feb 9, 2024
b12e818
tests: add all missings unit tests for DistributionCreator
0xtekgrinder Feb 12, 2024
f365f2a
chore: coverage ci and README
0xtekgrinder Feb 12, 2024
e51cc67
tests: correct amount computation in distributioncreation test
0xtekgrinder Feb 12, 2024
3522c89
Scripts (#56)
sogipec Feb 14, 2024
63075d6
tests: revert to previous foundry tests
0xtekgrinder Feb 15, 2024
ab8d96c
fix: default value for private key in hardhat c onfig
0xtekgrinder Feb 15, 2024
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
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,45 @@ jobs:
run: |
echo "## Foundry Unit tests result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY

coverage:
needs: ["build", "lint"]
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install lcov"
run: "sudo apt-get install lcov"

- uses: actions/cache/restore@v3
with:
fail-on-cache-miss: true
path: |
cache-forge
out
cache-hh
artifacts
typechain
node_modules
key: "build-${{ github.sha }}"

- name: "Generate the coverage report using the unit and the integration tests"
run: "yarn ci:coverage"
env:
ETH_NODE_URI_OPTIMISM: ${{ secrets.ETH_NODE_URI_OPTIMISM }}

- name: "Upload coverage report to Codecov"
uses: "codecov/codecov-action@v3"
with:
files: "./lcov.info"
token: ${{ secrets.CODECOV_TOKEN }}

- name: "Add coverage summary"
run: |
echo "## Coverage result" >> $GITHUB_STEP_SUMMARY
echo "✅ Uploaded to Codecov" >> $GITHUB_STEP_SUMMARY
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"editor.defaultFormatter": "JuanBlanco.solidity"
},
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll": "explicit"
},
"solidity.compileUsingRemoteVersion": "v0.8.17+commit.8df45f5f"
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# <img src="logo.svg" alt="Merkl Contracts" height="40px"> Merkl Contracts

[![CI](https://github.com/AngleProtocol/merkl-contracts/actions/workflows/ci.yml/badge.svg)](https://github.com/AngleProtocol/merkl-contracts/actions)
[![Coverage](https://codecov.io/gh/AngleProtocol/merkl-contracts/branch/main/graph/badge.svg)](https://codecov.io/gh/AngleProtocol/merkl-contracts)

This repository contains the smart contracts of the Merkl product developed by Angle.

Expand Down
843 changes: 378 additions & 465 deletions contracts/DistributionCreator.sol

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions contracts/Distributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";

import "./utils/UUPSHelper.sol";

Check warning on line 42 in contracts/Distributor.sol

View workflow job for this annotation

GitHub Actions / lint

global import of path ./utils/UUPSHelper.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

struct MerkleTree {
// Root of a Merkle tree which leaves are `(address user, address token, uint amount)`
Expand All @@ -58,7 +58,7 @@
}

/// @title Distributor
/// @notice Allows LPs on AMMs with concentrated liquidity to claim the rewards that were distributed to them
/// @notice Allows to claim rewards distributed to them through Merkl
/// @author Angle Labs. Inc
contract Distributor is UUPSHelper {
using SafeERC20 for IERC20;
Expand Down Expand Up @@ -130,6 +130,12 @@
_;
}

/// @notice Checks whether the `msg.sender` has the governor role or the guardian role
modifier onlyGovernor() {
if (!core.isGovernor(msg.sender)) revert NotGovernor();
_;
}

/// @notice Checks whether the `msg.sender` is the `user` address or is a trusted address
modifier onlyTrustedOrUser(address user) {
if (user != msg.sender && canUpdateMerkleRoot[msg.sender] != 1 && !core.isGovernorOrGuardian(msg.sender))
Expand All @@ -147,7 +153,7 @@
}

/// @inheritdoc UUPSUpgradeable
function _authorizeUpgrade(address) internal view override onlyGuardianUpgrader(core) {}
function _authorizeUpgrade(address) internal view override onlyGovernorUpgrader(core) {}

// =============================== MAIN FUNCTION ===============================

Expand Down Expand Up @@ -205,7 +211,7 @@
// ============================ GOVERNANCE FUNCTIONS ===========================

/// @notice Adds or removes EOAs which are trusted to update the Merkle root
function toggleTrusted(address eoa) external onlyGovernorOrGuardian {
function toggleTrusted(address eoa) external onlyGovernor {
uint256 trustedStatus = 1 - canUpdateMerkleRoot[eoa];
canUpdateMerkleRoot[eoa] = trustedStatus;
emit TrustedToggled(eoa, trustedStatus == 1);
Expand All @@ -218,7 +224,7 @@
// A trusted address cannot update a tree right after a precedent tree update otherwise it can de facto
// validate a tree which has not passed the dispute period
((canUpdateMerkleRoot[msg.sender] != 1 || block.timestamp < endOfDisputePeriod) &&
!core.isGovernorOrGuardian(msg.sender))
!core.isGovernor(msg.sender))
) revert NotTrusted();
MerkleTree memory _lastTree = tree;
tree = _tree;
Expand Down Expand Up @@ -278,26 +284,26 @@
}

/// @notice Recovers any ERC20 token
function recoverERC20(address tokenAddress, address to, uint256 amountToRecover) external onlyGovernorOrGuardian {
function recoverERC20(address tokenAddress, address to, uint256 amountToRecover) external onlyGovernor {
IERC20(tokenAddress).safeTransfer(to, amountToRecover);
emit Recovered(tokenAddress, to, amountToRecover);
}

/// @notice Sets the dispute period after which a tree update becomes effective
function setDisputePeriod(uint48 _disputePeriod) external onlyGovernorOrGuardian {
function setDisputePeriod(uint48 _disputePeriod) external onlyGovernor {
disputePeriod = uint48(_disputePeriod);
emit DisputePeriodUpdated(_disputePeriod);
}

/// @notice Sets the token used as a caution during disputes
function setDisputeToken(IERC20 _disputeToken) external onlyGovernorOrGuardian {
function setDisputeToken(IERC20 _disputeToken) external onlyGovernor {
if (disputer != address(0)) revert UnresolvedDispute();
disputeToken = _disputeToken;
emit DisputeTokenUpdated(address(_disputeToken));
}

/// @notice Sets the amount of `disputeToken` used as a caution during disputes
function setDisputeAmount(uint256 _disputeAmount) external onlyGovernorOrGuardian {
function setDisputeAmount(uint256 _disputeAmount) external onlyGovernor {
if (disputer != address(0)) revert UnresolvedDispute();
disputeAmount = _disputeAmount;
emit DisputeAmountUpdated(_disputeAmount);
Expand Down
Loading
Loading