Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickGT committed Sep 12, 2024
0 parents commit 17df2c9
Show file tree
Hide file tree
Showing 610 changed files with 213,001 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Localhost RPC URL
export LOCALHOST_RPC_URL=http://127.0.0.1:8545

# Mainnet RPC URLs
export MAINNET_RPC_URL=
export BASE_RPC_URL=
export OPTIMISM_RPC_URL=

# Testnet RPC URLs
export SEPOLIA_RPC_URL=
export BASE_SEPOLIA_RPC_URL=
export OPTIMISM_SEPOLIA_RPC_URL=

# Used for verifying contracts on Etherscan
export ETHERSCAN_API_KEY=
export BASE_ETHERSCAN_API_KEY=
export OPTIMISM_ETHERSCAN_API_KEY=

# Used for deploying contracts on Mainnet
export PRIVATE_KEY=

# Used for deploying contracts on Testnet Dev environment
export DEV_PRIVATE_KEY=
54 changes: 54 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Forge Coverage

on:
push:
branches:
- main
pull_request:

permissions: write-all

jobs:
check:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Node
uses: actions/setup-node@v4

- name: Install NPM dependencies
run: npm install

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

- name: Run Forge build
run: |
forge --version
make sizes
id: build

- name: Install lcov
uses: hrishikesh-kadam/setup-lcov@v1

- name: Run coverage
env:
MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }}
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}
run: make coverage profile=ci
id: coverage

- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v3
with:
coverage-files: lcov.info
artifact-name: code-coverage-report
minimum-coverage: 0
github-token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
41 changes: 41 additions & 0 deletions .github/workflows/test-fork.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# name: Forge Fork Tests
#
# on:
# push:
# branches:
# - main
# pull_request:
#
# permissions: write-all
#
# jobs:
# check:
# name: Fork Tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
#
# - name: Setup Node
# uses: actions/setup-node@v4
#
# - name: Install NPM dependencies
# run: npm install
#
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
#
# - name: Run Forge build
# run: |
# forge --version
# make sizes
# id: build
#
# - name: Run Forge fork tests
# run: make fork profile=ci
# env:
# MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }}
# MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
# BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
# OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}
35 changes: 35 additions & 0 deletions .github/workflows/test-fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# name: Forge Fuzz Tests
#
# on:
# push:
# branches:
# - main
# pull_request:
#
# permissions: write-all
#
# jobs:
# check:
# name: Fuzz Tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
#
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
#
# - name: Run Forge build
# run: |
# forge --version
# make sizes
# id: build
#
# - name: Run Forge fuzz tests
# run: make fuzz profile=ci
# env:
# # make fuzzing semi-deterministic to avoid noisy gas cost estimation
# # due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
# FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}
# MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }}
56 changes: 56 additions & 0 deletions .github/workflows/test-gas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Forge Tests Gas Report

on:
push:
branches:
- main
pull_request:

permissions: write-all

jobs:
check:
name: Gas report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Node
uses: actions/setup-node@v4

- name: Install NPM dependencies
run: npm install

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

- name: Run Forge build
run: |
forge --version
make sizes
id: build

- name: Run Forge tests with gas report
run: make gas-report profile=ci
env:
# make fuzzing semi-deterministic to avoid noisy gas cost estimation
# due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}
MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }}
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}

- name: Compare gas reports
uses: Rubilmax/[email protected]
id: gas_diff

- name: Add gas diff to sticky comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: marocchino/sticky-pull-request-comment@v2
with:
# delete the comment in case changes no longer impact gas costs
delete: ${{ !steps.gas_diff.outputs.markdown }}
message: ${{ steps.gas_diff.outputs.markdown }}
30 changes: 30 additions & 0 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# name: Forge Integration Tests
#
# on:
# push:
# branches:
# - main
# pull_request:
#
# permissions: write-all
#
# jobs:
# check:
# name: Integration Tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
#
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
#
# - name: Run Forge build
# run: |
# forge --version
# make sizes
# id: build
#
# - name: Run Forge integration tests
# run: make integration profile=ci
35 changes: 35 additions & 0 deletions .github/workflows/test-invariant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# name: Forge Invariant Tests
#
# on:
# push:
# branches:
# - main
# pull_request:
#
# permissions: write-all
#
# jobs:
# check:
# name: Invariant Tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
#
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
#
# - name: Run Forge build
# run: |
# forge --version
# make sizes
# id: build
#
# - name: Run Forge invariant tests
# run: make invariant profile=ci
# env:
# # make fuzzing semi-deterministic to avoid noisy gas cost estimation
# # due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
# FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}
# MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }}
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
broadcast/**/*run*

# Coverage files
coverage/
lcov.info

# Docs
docs/

# Dotenv file
.env

# Mac OS files
.DS_Store

# NPM modules
node_modules
15 changes: 15 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = [email protected]:foundry-rs/forge-std.git
branch = v1
[submodule "lib/common"]
path = lib/common
url = [email protected]:m0-foundation/common.git
[submodule "lib/protocol"]
path = lib/protocol
url = [email protected]:m0-foundation/protocol.git
branch = spoke
[submodule "lib/ttg"]
path = lib/ttg
url = [email protected]:m0-foundation/ttg.git
branch = spoke
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint-staged && npm test
8 changes: 8 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"!(lib/**/*)*.{json,md,sol,yml}": [
"npm run prettier"
],
"!(lib/**/*)*.sol": [
"npm run solhint"
]
}
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"plugins": [
"prettier-plugin-solidity"
],
"overrides": [
{
"files": "*.sol",
"options": {
"bracketSpacing": true,
"compiler": "0.8.26",
"parser": "solidity-parse",
"printWidth": 120,
"tabWidth": 4,
}
}
]
}
34 changes: 34 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"extends": ["solhint:recommended"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"code-complexity": ["warn", 10],
"compiler-version": ["error", "0.8.26"],
"comprehensive-interface": "off",
"const-name-snakecase": "off",
"func-name-mixedcase": "off",
"func-visibility": [
"warn",
{
"ignoreConstructors": true
}
],
"function-max-lines": ["warn", 100],
"immutable-vars-naming": "off",
"imports-on-top": "error",
"imports-order": "warn",
"max-line-length": ["warn", 120],
"no-console": "warn",
"no-empty-blocks": "off",
"no-inline-assembly": "off",
"not-rely-on-time": "off",
"private-vars-leading-underscore": [
"warn",
{
"strict": true
}
],
"visibility-modifier-order": "error"
}
}
Loading

0 comments on commit 17df2c9

Please sign in to comment.