Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modifyLiquidity script and call with ffi to check to test for accuracy #702

Merged
merged 17 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .env
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
FOUNDRY_FUZZ_SEED=0x4444

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
export FOUNDRY_SOLC="./bin/solc-static-linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
export FOUNDRY_SOLC="./bin/solc-mac"
fi
FOUNDRY_FUZZ_SEED=0x4444
53 changes: 25 additions & 28 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,28 @@ title: "[Bug]: "
labels: ["bug"]

body:
- type: markdown
attributes:
value: |
Please check that the bug is not already being tracked.
- type: textarea
attributes:
label: Describe the bug
description: Provide a clear and concise description of what the bug is and which contracts it affects.
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: Provide a clear and concise description of the desired fix.
validations:
required: true
- type: textarea
attributes:
label: To Reproduce
description: If you have written tests to showcase the bug, what can we run to reproduce the issue?
placeholder: "git checkout <branchname> / forge test --isolate --mt <testName>"
- type: textarea
attributes:
label: Additional context
description: If there is any additional context needed like a dependency or integrating contract that is affected please describe it below.



- type: markdown
attributes:
value: |
Please check that the bug is not already being tracked.
- type: textarea
attributes:
label: Describe the bug
description: Provide a clear and concise description of what the bug is and which contracts it affects.
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: Provide a clear and concise description of the desired fix.
validations:
required: true
- type: textarea
attributes:
label: To Reproduce
description: If you have written tests to showcase the bug, what can we run to reproduce the issue?
placeholder: "git checkout <branchname> / forge test --isolate --mt <testName>"
- type: textarea
attributes:
label: Additional context
description: If there is any additional context needed like a dependency or integrating contract that is affected please describe it below.
74 changes: 37 additions & 37 deletions .github/ISSUE_TEMPLATE/FEATURE_IMPROVEMENT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@ description: Suggest an improvement to v4-core.
labels: ["triage"]

body:
- type: markdown
attributes:
value: |
Please ensure that the feature has not already been requested.
- type: dropdown
attributes:
label: Component
description: Which area of code does your idea improve?
multiple: true
options:
- Hooks
- Singleton
- Lock and Call
- Delta accounting
- 1155 Balances
- Pool Actions (swap, modifyLiquidity, donate, take, settle, mint)
- Gas Optimization
- General design optimization (improving efficiency, cleanliness, or developer experience)
- Documentation
- type: textarea
attributes:
label: Describe the suggested feature and problem it solves.
description: Provide a clear and concise description of what feature you would like to see, and what problems it solves.
validations:
required: true
- type: textarea
attributes:
label: Describe the desired implementation.
description: If possible, provide a suggested architecture change or implementation.
- type: textarea
attributes:
label: Describe alternatives.
description: If possible, describe the alternatives you've considered, or describe the current functionality and how it may be sub-optimal.
- type: textarea
attributes:
label: Additional context.
description: Please list any additional dependencies or integrating contacts that are affected.
- type: markdown
attributes:
value: |
Please ensure that the feature has not already been requested.
- type: dropdown
attributes:
label: Component
description: Which area of code does your idea improve?
multiple: true
options:
- Hooks
- Singleton
- Lock and Call
- Delta accounting
- 1155 Balances
- Pool Actions (swap, modifyLiquidity, donate, take, settle, mint)
- Gas Optimization
- General design optimization (improving efficiency, cleanliness, or developer experience)
- Documentation
- type: textarea
attributes:
label: Describe the suggested feature and problem it solves.
description: Provide a clear and concise description of what feature you would like to see, and what problems it solves.
validations:
required: true
- type: textarea
attributes:
label: Describe the desired implementation.
description: If possible, provide a suggested architecture change or implementation.
- type: textarea
attributes:
label: Describe alternatives.
description: If possible, describe the alternatives you've considered, or describe the current functionality and how it may be sub-optimal.
- type: textarea
attributes:
label: Additional context.
description: Please list any additional dependencies or integrating contacts that are affected.
3 changes: 2 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Related Issue

Which issue does this pull request resolve?

## Description of changes
## Description of changes
136 changes: 68 additions & 68 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: code coverage

on:
on:
pull_request:
branches:
- main
- main

jobs:
comment-forge-coverage:
Expand All @@ -13,77 +13,77 @@ jobs:
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
- name: Install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge build
run: |
- name: Run Forge build
run: |
forge --version
forge build --sizes
id: build
- name: Run forge coverage
id: coverage
run: |
{
echo 'COVERAGE<<EOF'
forge coverage | grep '^|' | grep -v 'test/'
echo EOF
} >> "$GITHUB_OUTPUT"
env:
FOUNDRY_RPC_URL: '${{ secrets.RPC_URL }}'

- name: Check coverage is updated
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const file = "coverage.txt"
if(!fs.existsSync(file)) {
console.log("Nothing to check");
return
}
const currentCoverage = fs.readFileSync(file, "utf8").trim();
const newCoverage = (`${{ steps.coverage.outputs.COVERAGE }}`).trim();
if (newCoverage != currentCoverage) {
core.setFailed(`Code coverage not updated. Run : forge coverage | grep '^|' | grep -v 'test/' > coverage.txt`);
}
id: build
- name: Run forge coverage
id: coverage
run: |
{
echo 'COVERAGE<<EOF'
forge coverage | grep '^|' | grep -v 'test/'
echo EOF
} >> "$GITHUB_OUTPUT"
env:
FOUNDRY_RPC_URL: "${{ secrets.RPC_URL }}"

- name: Comment on PR
id: comment
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
- name: Check coverage is updated
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const file = "coverage.txt"
if(!fs.existsSync(file)) {
console.log("Nothing to check");
return
}
const currentCoverage = fs.readFileSync(file, "utf8").trim();
const newCoverage = (`${{ steps.coverage.outputs.COVERAGE }}`).trim();
if (newCoverage != currentCoverage) {
core.setFailed(`Code coverage not updated. Run : forge coverage | grep '^|' | grep -v 'test/' > coverage.txt`);
}

const botComment = comments.find(comment => comment.user.id === 41898282)
- name: Comment on PR
id: comment
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})

const output = `${{ steps.coverage.outputs.COVERAGE }}`;
const commentBody = `Forge code coverage:\n${output}\n`;
const botComment = comments.find(comment => comment.user.id === 41898282)

if (botComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
})
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
}
const output = `${{ steps.coverage.outputs.COVERAGE }}`;
const commentBody = `Forge code coverage:\n${output}\n`;

if (botComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
})
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
}
12 changes: 12 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@ jobs:

- name: Lint
run: forge fmt --check

- uses: actions/cache@v2
name: Configure npm caching
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/workflows/prettier.yml') }}
restore-keys: |
${{ runner.os }}-npm-

- name: Check code formatting
run: |-
npx prettier --check .
2 changes: 1 addition & 1 deletion .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- main
schedule:
# random HH:MM to avoid a load spike on GitHub Actions at 00:00
- cron: '35 11 * * *'
- cron: "35 11 * * *"
jobs:
semgrep:
name: semgrep/ci
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/tests-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ jobs:
with:
submodules: recursive

- uses: actions/setup-node@v3
with:
node-version: 16
cache-dependency-path: './test/js-scripts'
cache: 'yarn'

- run: yarn
working-directory: ./test/js-scripts

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand All @@ -39,4 +30,3 @@ jobs:
env:
FOUNDRY_PROFILE: ci
FORGE_SNAPSHOT_CHECK: true

10 changes: 0 additions & 10 deletions .github/workflows/tests-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ jobs:
with:
submodules: recursive

- uses: actions/setup-node@v3
with:
node-version: 16
cache-dependency-path: './test/js-scripts'
cache: 'yarn'

- run: yarn
working-directory: ./test/js-scripts

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand All @@ -40,4 +31,3 @@ jobs:
env:
FOUNDRY_PROFILE: pr
FORGE_SNAPSHOT_CHECK: true

7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.prettierrc
foundry.toml
out
lib/
cache/
*.sol
dist/
Loading
Loading