-
Notifications
You must be signed in to change notification settings - Fork 10
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
0 parents
commit 7127b17
Showing
2,741 changed files
with
460,949 additions
and
0 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,41 @@ | ||
name: smartContractTest | ||
|
||
on: [push, workflow_dispatch] | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
submodules: recursive | ||
|
||
- name: Set up env variables | ||
run: | | ||
cp -n example.env .env | ||
- name: Install Foundry | ||
uses: foundry-rs/[email protected] | ||
with: | ||
version: nightly | ||
|
||
- name: Run Forge tests | ||
env: | ||
FOUNDRY_ETH_RPC_URL: ${{ secrets.RPC_URL_MAINNET }} | ||
run: | | ||
cp example.env .env | ||
forge test | ||
id: test | ||
|
||
- name: Run Forge coverage | ||
env: | ||
FOUNDRY_ETH_RPC_URL: ${{ secrets.RPC_URL_MAINNET }} | ||
run: | | ||
forge coverage |
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,25 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
**/.env | ||
|
||
# Mac files | ||
**/.DS_Store | ||
|
||
# VS Code files | ||
.vscode | ||
|
||
# Tests reports | ||
report | ||
tests | ||
crytic-export |
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 @@ | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
tag = v1.7.1 | ||
[submodule "lib/solmate"] | ||
path = lib/solmate | ||
url = https://github.com/transmissions11/solmate | ||
[submodule "lib/erc4626-tests"] | ||
path = lib/erc4626-tests | ||
url = https://github.com/a16z/erc4626-tests | ||
[submodule "lib/openzeppelin-contracts-v5.0.0"] | ||
path = lib/openzeppelin-contracts-v5.0.0 | ||
url = https://github.com/OpenZeppelin/openzeppelin-contracts | ||
tag = v5.0.0 | ||
[submodule "lib/openzeppelin-contracts-v4.9.3"] | ||
path = lib/openzeppelin-contracts-v4.9.3 | ||
url = https://github.com/OpenZeppelin/openzeppelin-contracts | ||
tag = v4.9.3 | ||
[submodule "lib/openzeppelin-contracts"] | ||
path = lib/openzeppelin-contracts | ||
url = https://github.com/OpenZeppelin/openzeppelin-contracts | ||
[submodule "lib/crytic"] | ||
path = lib/crytic | ||
url = https://github.com/crytic/properties |
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,125 @@ | ||
## Context | ||
`Amphor` protocol is a `L1 DeFi` protocol proposing `ERC-4626` based strategies. | ||
The first startegy to come out is a timelocked strategy that require the funds | ||
to exit the vault during the product duration (which varies from `2` to | ||
`6` weeks). | ||
|
||
## AmphorSyntheticVault | ||
This vault is the most basic strategy on the code side because the funds are | ||
deposited by the users, then the vault is locked during the product period. Once | ||
it has been locked, the funds go to a market maker wallet that is keeping the | ||
assets in garantee. | ||
At the end of the period (which varies from `2` to `6` weeks), `Amphor` | ||
get back the funds into the vault and users can `deposit` and/or `withdraw` | ||
again. | ||
|
||
## Underlying supported | ||
For the first iteration of the protocol, the only underlying supported will be | ||
`USDC` from `Circle`. | ||
In the future, we might support `WBTC` and `WETH` as underlying assets. | ||
Since `USDC` token supports `Permit` operations but not `WBTC` and `WETH`, we | ||
have separated this feature into another contract (`AmphorSyntheticVaultWithPermit`). | ||
|
||
## Process flow on the vault manager side | ||
`NOTE:` Management of the vault is handled by a multisig wallet. | ||
1. The vault contract is deployed (`constructor`) and some funds are directly | ||
deposited into it in order to bootstrap it and prevent as much as possible from | ||
inflation attacks (event if there are others protections from it). | ||
A performance fee of `20.00%` for `Amphor` protocol is set. | ||
2. The vault is open for `deposit` and `withdraw` during a little period (approx | ||
2 days). | ||
3. The vault is locked (`deposit`/`withdraw` shouldn't be possible) with the | ||
`start` function (callable only by `owner`/manager of the vault). During this | ||
transaction the funds are withdrawn from the contract. | ||
4. After the product period end, the vault is unlocked (`deposit`/`withdraw` | ||
are now be possible) using | ||
the `end` function (callable only by the `owner` of the vault). | ||
In case of a positive performance, some fees are taken fees by the protocol | ||
(that cannot exceed `30.00%` and can only be changed by `owner` of the vault). | ||
|
||
## Main contracts | ||
### Protocol contracts files | ||
- `AmphorSyntheticVault.sol`: Vanilla `AmphorSyntheticVault`. | ||
- `AmphorSyntheticVaultWithPermit.sol`: `AmphorSyntheticVault` with `Permit` feature. | ||
___ | ||
### Deployment contracts files | ||
- `L1_USDC_DeployAmphorSyntheticVault.sol`: Deployment script for `AmphorSyntheticVaultWithPermit` | ||
with `USDC` as underlying. Should bootstrap the vault with `100 USDC` (based on | ||
the `env` file). Should set the perf fees to `20.00%`. | ||
- `L1_WBTC_DeployAmphorSyntheticVault.sol`: Deployment script for `AmphorSyntheticVault` | ||
with `WBTC` as underlying. Should bootstrap the vault with `0.01 WBTC` (based on | ||
the `env` file). Should set the perf fees to `20.00%`. | ||
- `L1_WETH_DeployAmphorSyntheticVault.sol`: Deployment script for `AmphorSyntheticVault` | ||
with `WETH` as underlying. Should bootstrap the vault with `0.1 WETH` (based on | ||
the `env` file). Should set the perf fees to `20.00%`. | ||
___ | ||
### Test contracts files | ||
- `a16zCompliance.t.sol`: Implements the tests of `a16z`. Unfortunaly we didn't | ||
manage to make them work. | ||
- `cryticCompliance.t.sol`: Implements the tests of `crytic` (from | ||
[Trail of a bits](https://www.trailofbits.com/)). These one pass, you can launch | ||
them with the following command: | ||
``` | ||
$ echidna . --contract CryticERC4626PropertyTestsSynth --config test/echidna.config.yaml | ||
``` | ||
- `SyntheticBase.t.sol`: Should define a part of the main state variables. Should | ||
define some functions that will be directly used into the actual tests. | ||
- `SyntheticBasic.t.sol`: Should implement some basics tests that test the vault | ||
state variables and some basic properties of the vault. | ||
- `SyntheticDepositAndWithdraw.t.sol`: Should implement some tests on the deposit | ||
and the withdraw function. | ||
- `SyntheticEndAndStart.t.sol`: Should implement some tests on the start and the | ||
end function. | ||
- `SyntheticInflation.t.sol`: Should implement some tests demonstrating vault | ||
resilience in the face of inflationary attacks. | ||
- `SyntheticPausable.t.sol`: Should implement some tests demonstrating the good | ||
working of the `Pausable` feature. | ||
- `SyntheticPermit.t.sol`: Should implement some tests demonstrating the good | ||
working of the `Permit` feature. | ||
- `SigUtils.sol`: Should implement utils functions used by `SyntheticPermit` | ||
contract test (`SyntheticPermit.t.sol`). | ||
## Useful commands | ||
### Foundry | ||
The protocol is a [Foundry](https://book.getfoundry.sh) project. | ||
[Foundry](https://book.getfoundry.sh) a blazing fast, portable and modular | ||
toolkit for Ethereum application development written in Rust. | ||
#### Foundry commands | ||
##### Build | ||
```shell | ||
$ forge build | ||
``` | ||
##### Test | ||
```shell | ||
$ forge test | ||
``` | ||
##### Format | ||
```shell | ||
$ forge fmt | ||
``` | ||
##### Coverage | ||
```shell | ||
$ forge coverage | ||
``` | ||
##### Gas Snapshots | ||
```shell | ||
$ forge snapshot | ||
``` | ||
##### Anvil | ||
```shell | ||
$ anvil | ||
``` | ||
##### Deploy | ||
```shell | ||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
``` | ||
##### Cast | ||
```shell | ||
$ cast <subcommand> | ||
``` | ||
##### Help | ||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
``` | ||
___ |
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.