generated from AngleProtocol/boilerplate
-
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
1 parent
d3f4d2a
commit c2cf40c
Showing
1 changed file
with
27 additions
and
152 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 |
---|---|---|
@@ -1,166 +1,41 @@ | ||
# <img src=".github/assets/logo.svg" alt="Angle" height="40px"> Angle Project Boilerplate | ||
# Angle Integration Strategies | ||
|
||
[![CI](https://github.com/AngleProtocol/boilerplate/actions/workflows/ci.yml/badge.svg)](https://github.com/AngleProtocol/boilerplate/actions) | ||
[![Coverage](https://codecov.io/gh/AngleProtocol/boilerplate/branch/main/graph/badge.svg)](https://codecov.io/gh/AngleProtocol/boilerplate) | ||
## Introduction | ||
|
||
This repository proposes a template that is based on foundry frameworks. It also provides templates for EVM compatible smart contracts (in `./contracts/example`), tests and deployment scripts. | ||
This repository contains strategies for integrators to use to let their users deposit into the Angle Protocol while taking a performance fee on the accrued yield. The strategies can be any DeFi product that has a yield, such as staking, lending, farming, etc. | ||
|
||
## Starting | ||
## BaseStrategy | ||
|
||
### Install packages | ||
It is an abstract contract that inherits the ERC4626 interface and that is meant to be a proxy of an underlying strategy contract. This means that instead of depositing in the underlying strategy, users will deposit in the proxy and gain the same yield as if they had deposited in the underlying strategy. The proxy will then deposit the funds in the underlying strategy. | ||
|
||
You can install all dependencies by running | ||
Extra features in this contract includes the ability to take a performance fee on the yield generated by the underlying strategy (split with developperFee which takes a portion of the performance fee), the ability to swap tokens and vest linearly external rewards for a period of time. | ||
|
||
```bash | ||
yarn | ||
forge i | ||
``` | ||
It has hooks that needs to be implemented to create a strategy: | ||
- `_beforeWithdraw` is called before the user withdraws their funds. It can be used to withdraw from the strategy if needed. | ||
- `_afterDeposit` is called after the user deposits their funds. It can be used to deposit in the strategy if needed. | ||
- `_assetsHeld` is called to get the amount of assets held by the strategy. | ||
|
||
### Create `.env` file | ||
And ERC4626 view functions that needs to be implemented: | ||
- `maxDeposit` is called to get the maximum amount of tokens that can be deposited in the strategy. | ||
- `maxWithdraw` is called to get the maximum amount of tokens that can be withdrawn from the strategy. | ||
- `maxMint` is called to get the maximum amount of tokens that can be minted by the strategy. | ||
- `maxRedeem` is called to get the maximum amount of tokens that can be redeemed by the strategy. | ||
|
||
In order to interact with non local networks, you must create an `.env` that has: | ||
A keeper needs to be created to accrue fees if there hasn't been any deposit or withdrawal for a certain period of time. The keeper needs to also harvest external rewards and swap tokens if needed. | ||
|
||
- `PRIVATE_KEY` | ||
- `MNEMONIC` | ||
- network key (eg. `ALCHEMY_NETWORK_KEY`) | ||
- `ETHERSCAN_API_KEY` | ||
## ERC4626Strategy | ||
|
||
For additional keys, you can check the `.env.example` file. | ||
It is an contract that inherits the BaseStrategy contract and implements the hooks needed to create a strategy for an underlying 4626 strategy. | ||
|
||
Warning: always keep your confidential information safe. | ||
One of the limitation of the contract is that the underlying strategy needs to have infinite minting such as stUSD or metamorpho. | ||
|
||
## Headers | ||
## Role Recaps | ||
|
||
To automatically create headers, follow: <https://github.com/Picodes/headers> | ||
There are three roles in the contract: | ||
- `KEEPER_ROLE`: The role that can swap tokens and vest rewards. | ||
- `DEVELOPER_ROLE`: The role that can set developer fees, developer fee recipient, vesting period and swap parameters (swap router and transfer token address). | ||
- `INTEGRATOR_ROLE`: The role that can set integrator fees, integrator fee recipient. | ||
|
||
## Hardhat Command line completion | ||
|
||
Follow these instructions to have hardhat command line arguments completion: <https://hardhat.org/hardhat-runner/docs/guides/command-line-completion> | ||
|
||
## Foundry Installation | ||
|
||
```bash | ||
curl -L https://foundry.paradigm.xyz | bash | ||
|
||
source /root/.zshrc | ||
# or, if you're under bash: source /root/.bashrc | ||
|
||
foundryup | ||
``` | ||
|
||
To install the standard library: | ||
|
||
```bash | ||
forge install foundry-rs/forge-std | ||
``` | ||
|
||
To update libraries: | ||
|
||
```bash | ||
forge update | ||
``` | ||
|
||
### Foundry on Docker 🐳 | ||
|
||
**If you don’t want to install Rust and Foundry on your computer, you can use Docker** | ||
Image is available here [ghcr.io/foundry-rs/foundry](http://ghcr.io/foundry-rs/foundry). | ||
|
||
```bash | ||
docker pull ghcr.io/foundry-rs/foundry | ||
docker tag ghcr.io/foundry-rs/foundry:latest foundry:latest | ||
``` | ||
|
||
To run the container: | ||
|
||
```bash | ||
docker run -it --rm -v $(pwd):/app -w /app foundry sh | ||
``` | ||
|
||
Then you are inside the container and can run Foundry’s commands. | ||
|
||
### Tests | ||
|
||
You can run tests as follows: | ||
|
||
```bash | ||
forge test -vvvv --watch | ||
forge test -vvvv --match-path contracts/forge-tests/KeeperMulticall.t.sol | ||
forge test -vvvv --match-test "testAbc*" | ||
forge test -vvvv --fork-url https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf | ||
``` | ||
|
||
You can also list tests: | ||
|
||
```bash | ||
forge test --list | ||
forge test --list --json --match-test "testXXX*" | ||
``` | ||
|
||
### Deploying | ||
|
||
There is an example script in the `scripts/foundry` folder. Then you can run: | ||
|
||
```bash | ||
yarn foundry:deploy <FILE_NAME> --rpc-url <NETWORK_NAME> | ||
``` | ||
|
||
Example: | ||
|
||
```bash | ||
yarn foundry:deploy scripts/foundry/DeployMockAgEUR.s.sol --rpc-url goerli | ||
``` | ||
|
||
### Coverage | ||
|
||
We recommend the use of this [vscode extension](ryanluker.vscode-coverage-gutters). | ||
|
||
```bash | ||
yarn hardhat:coverage | ||
yarn foundry:coverage | ||
``` | ||
|
||
### Simulate | ||
|
||
You can simulate your transaction live or in fork mode. For both option you need to | ||
complete the `scripts/foundry/Simulate.s.sol` with your values: address sending the tx, | ||
address caled and the data to give to this address call. | ||
|
||
For live simulation | ||
|
||
```bash | ||
yarn foundry:simulate | ||
``` | ||
|
||
For fork simulation | ||
|
||
```bash | ||
yarn foundry:fork | ||
yarn foundry:simulate:fork | ||
``` | ||
|
||
For fork simulation at a given block | ||
|
||
```bash | ||
yarn foundry:fork:block ${XXXX} | ||
yarn foundry:simulate:fork | ||
``` | ||
|
||
### Gas report | ||
|
||
```bash | ||
yarn foundry:gas | ||
``` | ||
|
||
## Slither | ||
|
||
```bash | ||
pip3 install slither-analyzer | ||
pip3 install solc-select | ||
solc-select install 0.8.11 | ||
solc-select use 0.8.11 | ||
slither . | ||
``` | ||
|
||
## Media | ||
|
||
Don't hesitate to reach out on [Twitter](https://twitter.com/AngleProtocol) 🐦 | ||
The Integrator role is its own admin meaning that the initial integrator can add a new integrator and remove themselves from the role. | ||
The Developer role is its own admin meaning that the initial developer can add a new developer and remove themselves from the role. | ||
The Keeper role has developer role as admin meaning that the initial developer can add a new keeper and remove initialKeeper from the role. (It is designed as such because the developer is the one that should be operating the keeper). |