Skip to content

🥨 Contracts for Merkl, Angle Labs incentivization product for concentrated liquidity AMMs

License

Notifications You must be signed in to change notification settings

AngleProtocol/merkl-contracts

Repository files navigation

CI

This repository contains the core smart contracts for the Merkl solution.

The system consists of two primary contracts:

  • DistributionCreator: Allows DAOs and individuals to deposit rewards for incentivizing onchain actions
  • Distributor: Enables users to claim their earned rewards

Learn more about Merkl in the official documentation.

Setup

Install packages

Install all dependencies by running:

bun i

Create .env file

Copy the .env.example file to .env and populate it with your keys and RPC endpoints:

cp .env.example .env

Warning: Always keep your confidential information secure and never commit .env files to version control.

Foundry Installation

Install Foundry using the official installer:

curl -L https://foundry.paradigm.xyz | bash

source /root/.zshrc
# or, if you're using bash: source /root/.bashrc

foundryup

Tests

Run the complete test suite:

forge test

Deploying

Simulate deployment (dry run)

Run a script without broadcasting transactions to the network:

yarn foundry:script <path_to_script> --rpc-url <network>

Deploy to network

Execute and broadcast transactions:

yarn foundry:deploy <path_to_script> --rpc-url <network>

Scripts

Scripts can be executed with or without parameters:

  1. With parameters: Pass values directly as command-line arguments
  2. Without parameters: Modify default values within the script file before running

Running Scripts

Execute scripts using the following pattern:

# With parameters - pass values as arguments
forge script scripts/MockToken.s.sol:Deploy --rpc-url <network> --sender <address> --broadcast -i 1 \
  --sig "run(string,string,uint8)" "MyToken" "MTK" 18

# Without parameters - modify default values in the script first
forge script scripts/MockToken.s.sol:Deploy --rpc-url <network> --sender <address> --broadcast -i 1

# Common options:
#   --broadcast         Broadcasts transactions to the network
#   --sender <address>  Address that will execute the script
#   -i 1                Opens an interactive prompt to securely enter the sender's private key

Examples

Deploy a mock ERC20 token

forge script scripts/MockToken.s.sol:Deploy --rpc-url <network> --sender <address> --broadcast \
  --sig "run(string,string,uint8)" "MyToken" "MTK" 18

Mint tokens to an address

forge script scripts/MockToken.s.sol:Mint --rpc-url <network> --sender <address> --broadcast \
  --sig "run(address,address,uint256)" <token_address> <recipient> 1000000000000000000

Configure minimum reward token amount

forge script scripts/DistributionCreator.s.sol:SetRewardTokenMinAmounts --rpc-url <network> --sender <address> --broadcast \
  --sig "run(address,uint256)" <reward_token_address> <min_amount>

Set campaign fees

forge script scripts/DistributionCreator.s.sol:SetCampaignFees --rpc-url <network> --sender <address> --broadcast \
  --sig "run(uint32,uint256)" <campaign_type> <fees>

Modifying Default Script Parameters

For scripts without parameters, modify the default values directly in the script file before execution:

// In scripts/MockToken.s.sol:Deploy
function run() external broadcast {
  // MODIFY THESE VALUES TO SET YOUR DESIRED TOKEN PARAMETERS
  string memory name = 'My Token'; // <- Customize token name
  string memory symbol = 'MTK'; // <- Customize token symbol
  uint8 decimals = 18; // <- Customize decimal places
  _run(name, symbol, decimals);
}

Audits

The Merkl smart contracts have been audited by Code4rena. View the Code4rena audit report for details.

Access Control

Access Control Schema

Media

Reach out to us on Twitter 🐦

About

🥨 Contracts for Merkl, Angle Labs incentivization product for concentrated liquidity AMMs

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 13