Skip to content

Commit

Permalink
Fixes for the immunify bounty + instant exit (#1)
Browse files Browse the repository at this point in the history
* feat: remove deposit_for

* feat: emergency_withdrawal inside veANGLE

* feat: fixture to be able to deploy and use veANGLE

* feat: balanceOf now search for previous timestamp instead of reverting

* fix: compile errors for new version of veANGLE

* feat: remove the constructor from veANGLE

* feat: add back the deposit_for for  the veANGLE contract

* feat: chaneg the old veANGLE to the deployed version

* feat: withdraw fast now remove the lock and makes all non view functions unaccessible

* fix: veANGLE now compiles with some syntax fixes

* tests: emergency withdrawal

* feat: remove via_ir from compilation

* style: prettier contracts

* chore: less strict linting

* tests: unit tests for balanceOf

* tests: add invariants setup

* tests: add invariant working tests

* chore: update foundry.toml for invariants

* refacotr: update solidity version

* chore: remove --sizes check in ci

* chore: install vyper in ci

* chore: use correct python version to install vyper

* chore: try more verbose for unit tests

* feat: remove all unused files

* style: fix solhint warnings

* feat: add back some interfaces

* chore: switch to fsolidity version 0.8.22 and use via_ir

* feat: remove Simulate script

* feat: use private angle-sdk

* chore: update CI to install sdk

* tests: add more unit tests regarding withdraw_fast

* feat: add areason when reverting when no emergency

* chore: update solidity version in vscode settings

* chore: newline in .npmrc

* style: format IStableMaster

* chore: update utils dependency

* feat: DeployVeAngle script

* feat: vyper deployer with arguments use vyper

* refactor: remove BasicScript

* feat: add fuzz tests for emergencyWithdrawal

* tests: assertEq in invariants tests

* doc: update README.md

* doc: explain how to upgrade veANGLE

* tests: fix invariants tests for balanceOf

* fix: fuzz tests now doesn't infinite loop

* tests: try to withdraw twice

* fix: script to deploy inherit VyperDeployer

* fix: remove reetrancy lock in withdraw_fast

* chore: upgrade vyper version in CI

* chore: remove Upgrade doc
  • Loading branch information
0xtekgrinder authored Apr 25, 2024
1 parent 386791a commit e0d7134
Show file tree
Hide file tree
Showing 59 changed files with 3,105 additions and 640 deletions.
35 changes: 35 additions & 0 deletions .github/actions/setup-repo/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Setup repo
description: Runs all steps to setup the repo (install node_modules, build, etc...)
inputs:
registry-token:
description: 'PAT to access registries'
runs:
using: 'composite'
steps:
- name: Get yarn cache directory path
id: yarn-cache-dir-path
shell: bash
run: |
echo "::set-output name=dir::$(yarn cache dir)"
echo "::set-output name=version::$(yarn -v)"
- uses: actions/setup-node@v3
with:
node-version: '20'

- uses: actions/cache@v2
id: yarn-cache
with:
path: |
**/node_modules
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
shell: bash
run: echo "//npm.pkg.github.com/:_authToken=$GH_REGISTRY_ACCESS_TOKEN" >> .npmrc && yarn install --frozen-lockfile --verbose && rm -f .npmrc
env:
GH_REGISTRY_ACCESS_TOKEN: ${{ inputs.registry-token }}
38 changes: 35 additions & 3 deletions .github/workflows/ci-deep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ jobs:
node-version: 18
cache: "yarn"

- name: Install dependencies
run: yarn install
- name: Setup repo
uses: ./.github/actions/setup-repo
with:
registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }}

- name: Run solhint
run: yarn lint:check
Expand All @@ -56,7 +58,12 @@ jobs:
version: nightly

- name: Compile foundry
run: yarn compile --sizes
run: yarn compile

- name: Setup repo
uses: ./.github/actions/setup-repo
with:
registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }}

- name: "Cache the build so that it can be re-used by the other jobs"
uses: "actions/cache/save@v3"
Expand All @@ -65,6 +72,7 @@ jobs:
path: |
cache-forge
out
node_modules
- name: "Add build summary"
run: |
Expand All @@ -85,13 +93,21 @@ jobs:
path: |
cache-forge
out
node_modules
key: "build-${{ github.sha }}"

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Install vyper
run: pip install vyper==0.2.16

- name: Run Foundry tests
run: yarn test:unit
env:
Expand Down Expand Up @@ -119,13 +135,21 @@ jobs:
path: |
cache-forge
out
node_modules
key: "build-${{ github.sha }}"

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Install vyper
run: pip install vyper==0.2.16

- name: Run Foundry tests
run: yarn test:invariant
env:
Expand Down Expand Up @@ -155,13 +179,21 @@ jobs:
path: |
cache-forge
out
node_modules
key: "build-${{ github.sha }}"

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Install vyper
run: pip install vyper==0.2.16

- name: Run Foundry tests
run: yarn test:fuzz
env:
Expand Down
50 changes: 47 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ jobs:
node-version: 18
cache: "yarn"

- name: Install dependencies
run: yarn install
- name: Setup repo
uses: ./.github/actions/setup-repo
with:
registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }}

- name: Run solhint
run: yarn lint:check
Expand All @@ -44,8 +46,13 @@ jobs:
with:
version: nightly

- name: Setup repo
uses: ./.github/actions/setup-repo
with:
registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }}

- name: Compile foundry
run: yarn compile --sizes
run: yarn compile

- name: "Cache the build so that it can be re-used by the other jobs"
uses: "actions/cache/save@v3"
Expand All @@ -54,6 +61,7 @@ jobs:
path: |
cache-forge
out
node_modules
- name: "Add build summary"
run: |
Expand All @@ -74,13 +82,21 @@ jobs:
path: |
cache-forge
out
node_modules
key: "build-${{ github.sha }}"

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Install vyper
run: pip install vyper==0.2.16

- name: Run Foundry tests
run: yarn test:unit
env:
Expand Down Expand Up @@ -108,13 +124,21 @@ jobs:
path: |
cache-forge
out
node_modules
key: "build-${{ github.sha }}"

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Install vyper
run: pip install vyper==0.2.16

- name: Run Foundry tests
run: yarn test:invariant
env:
Expand Down Expand Up @@ -144,13 +168,21 @@ jobs:
path: |
cache-forge
out
node_modules
key: "build-${{ github.sha }}"

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Install vyper
run: pip install vyper==0.2.16

- name: Run Foundry tests
run: npm run test:fuzz
env:
Expand All @@ -176,6 +208,18 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: Setup repo
uses: ./.github/actions/setup-repo
with:
registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }}

- uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Install vyper
run: pip install vyper==0.2.16

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

Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@angleprotocol:registry=https://npm.pkg.github.com
5 changes: 3 additions & 2 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"max-line-length": ["error", 120],
"max-line-length": ["warn", 120],
"avoid-call-value": "warn",
"avoid-low-level-calls": "off",
"avoid-tx-origin": "warn",
Expand All @@ -23,6 +23,7 @@
"no-complex-fallback": "off",
"reason-string": "off",
"func-visibility": ["warn", { "ignoreConstructors": true }],
"explicit-types": ["error","explicit"]
"explicit-types": ["error","explicit"],
"custom-errors": "off"
}
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"solidity.compileUsingRemoteVersion": "0.8.20",
"solidity.compileUsingRemoteVersion": "0.8.22",
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity",
"editor.formatOnSave": true
Expand Down
31 changes: 3 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# <img src=".github/assets/logo.svg" alt="Angle" height="40px"> Angle DAO

[![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)

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.
## Overview

This repository contains all the contracts related to the Angle DAO including the angle, veANGLE ... etc.

## Starting

Expand Down Expand Up @@ -119,32 +120,6 @@ 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
Expand Down
Loading

0 comments on commit e0d7134

Please sign in to comment.