-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
163 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Show Forge version | ||
run: | | ||
forge --version | ||
- name: Run Forge fmt | ||
run: | | ||
forge fmt --check | ||
id: fmt | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge build --sizes | ||
id: build | ||
|
||
- name: Run Forge tests | ||
run: | | ||
forge test -vvv | ||
id: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,66 @@ | ||
# Multi-Token Rewards Contracts | ||
## Foundry | ||
|
||
This repository offers a suite of smart contracts designed to distribute rewards in multiple tokens across various DeFi scenarios. Developed with Foundry, these contracts are open-source and intended as a public good to benefit the broader blockchain community. | ||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** | ||
|
||
--- | ||
Foundry consists of: | ||
|
||
## Contracts Overview | ||
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). | ||
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. | ||
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. | ||
- **Chisel**: Fast, utilitarian, and verbose solidity REPL. | ||
|
||
1. **StandaloneRewarder**: Enables direct token staking and rewards without external dependencies. | ||
2. **MasterChefRewarder**: Integrates with MasterChef to provide multi-token rewards for liquidity providers. | ||
3. **ChefIncentivesRewarder**: Extends ChefIncentivesController, rewarding users holding aTokens or LP tokens. | ||
## Documentation | ||
|
||
--- | ||
https://book.getfoundry.sh/ | ||
|
||
## Getting Started | ||
## Usage | ||
|
||
Ensure Foundry is installed. If not, follow the instructions at [Foundry's official site](https://getfoundry.sh). | ||
### Build | ||
|
||
### Installation | ||
|
||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/your-repo-name.git | ||
cd your-repo-name | ||
``` | ||
|
||
2. Install dependencies: | ||
```bash | ||
forge install | ||
``` | ||
|
||
### Build the Project | ||
|
||
Compile the contracts: | ||
```bash | ||
forge build | ||
```shell | ||
$ forge build | ||
``` | ||
|
||
### Run Tests | ||
### Test | ||
|
||
Execute the test suite: | ||
```bash | ||
forge test | ||
```shell | ||
$ forge test | ||
``` | ||
|
||
--- | ||
|
||
## Deployment | ||
|
||
Deploy contracts as per your requirements: | ||
### Format | ||
|
||
- **StandaloneRewarder**: For independent staking and rewards. | ||
- **MasterChefRewarder**: To integrate with MasterChef. | ||
- **ChefIncentivesRewarder**: For use with ChefIncentivesController. | ||
|
||
Modify deployment scripts in the `script/` directory accordingly and run: | ||
```bash | ||
forge script script/Deploy.s.sol --broadcast | ||
```shell | ||
$ forge fmt | ||
``` | ||
|
||
--- | ||
### Gas Snapshots | ||
|
||
## Contribution | ||
```shell | ||
$ forge snapshot | ||
``` | ||
|
||
Contributions are welcome. To contribute: | ||
### Anvil | ||
|
||
1. Fork the repository. | ||
2. Create a new branch: | ||
```bash | ||
git checkout -b feature-name | ||
``` | ||
3. Commit your changes: | ||
```bash | ||
git commit -m "Description of changes" | ||
``` | ||
4. Push the branch: | ||
```bash | ||
git push origin feature-name | ||
``` | ||
5. Open a pull request. | ||
```shell | ||
$ anvil | ||
``` | ||
|
||
--- | ||
### Deploy | ||
|
||
## License | ||
```shell | ||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
``` | ||
|
||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. | ||
### Cast | ||
|
||
--- | ||
```shell | ||
$ cast <subcommand> | ||
``` | ||
|
||
## Acknowledgment | ||
### Help | ||
|
||
This project is released as a public good to support and enhance the DeFi ecosystem. For questions or support, please open an issue on GitHub. | ||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[profile.default] | ||
src = "src" | ||
out = "out" | ||
libs = ["lib"] | ||
|
||
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {Script, console} from "forge-std/Script.sol"; | ||
import {Counter} from "../src/Counter.sol"; | ||
|
||
contract CounterScript is Script { | ||
Counter public counter; | ||
|
||
function setUp() public {} | ||
|
||
function run() public { | ||
vm.startBroadcast(); | ||
|
||
counter = new Counter(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
contract Counter { | ||
uint256 public number; | ||
|
||
function setNumber(uint256 newNumber) public { | ||
number = newNumber; | ||
} | ||
|
||
function increment() public { | ||
number++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {Test, console} from "forge-std/Test.sol"; | ||
import {Counter} from "../src/Counter.sol"; | ||
|
||
contract CounterTest is Test { | ||
Counter public counter; | ||
|
||
function setUp() public { | ||
counter = new Counter(); | ||
counter.setNumber(0); | ||
} | ||
|
||
function test_Increment() public { | ||
counter.increment(); | ||
assertEq(counter.number(), 1); | ||
} | ||
|
||
function testFuzz_SetNumber(uint256 x) public { | ||
counter.setNumber(x); | ||
assertEq(counter.number(), x); | ||
} | ||
} |