Skip to content

Commit 6e6ce35

Browse files
snreynoldsdianakocsisgretzke
authored
Add modifyLiquidity script and call with ffi to check to test for accuracy (#702)
* import v3-sdk to ffi * run with isolate * checkpoint ffi addLiq * modifyLiquidity delta check * add weird pool setups * failing fuzz * add fuzz ffi for addLiquidity * remove console * Use MIT license for test scripts * bundle typescript into javascript files (#713) * bundle typescript into javascript files * remove unused imports * adjust just file * fix ci * remove console logs * add prettier config and format code * add prettier to linter --------- Co-authored-by: Diana Kocsis <[email protected]> Co-authored-by: gretzke <[email protected]>
1 parent c0adc1c commit 6e6ce35

29 files changed

+118459
-1222
lines changed

.env

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
FOUNDRY_FUZZ_SEED=0x4444
2-
3-
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
4-
export FOUNDRY_SOLC="./bin/solc-static-linux"
5-
elif [[ "$OSTYPE" == "darwin"* ]]; then
6-
export FOUNDRY_SOLC="./bin/solc-mac"
7-
fi
1+
FOUNDRY_FUZZ_SEED=0x4444

.github/ISSUE_TEMPLATE/BUG_REPORT.yml

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,28 @@ title: "[Bug]: "
44
labels: ["bug"]
55

66
body:
7-
- type: markdown
8-
attributes:
9-
value: |
10-
Please check that the bug is not already being tracked.
11-
- type: textarea
12-
attributes:
13-
label: Describe the bug
14-
description: Provide a clear and concise description of what the bug is and which contracts it affects.
15-
validations:
16-
required: true
17-
- type: textarea
18-
attributes:
19-
label: Expected Behavior
20-
description: Provide a clear and concise description of the desired fix.
21-
validations:
22-
required: true
23-
- type: textarea
24-
attributes:
25-
label: To Reproduce
26-
description: If you have written tests to showcase the bug, what can we run to reproduce the issue?
27-
placeholder: "git checkout <branchname> / forge test --isolate --mt <testName>"
28-
- type: textarea
29-
attributes:
30-
label: Additional context
31-
description: If there is any additional context needed like a dependency or integrating contract that is affected please describe it below.
32-
33-
34-
7+
- type: markdown
8+
attributes:
9+
value: |
10+
Please check that the bug is not already being tracked.
11+
- type: textarea
12+
attributes:
13+
label: Describe the bug
14+
description: Provide a clear and concise description of what the bug is and which contracts it affects.
15+
validations:
16+
required: true
17+
- type: textarea
18+
attributes:
19+
label: Expected Behavior
20+
description: Provide a clear and concise description of the desired fix.
21+
validations:
22+
required: true
23+
- type: textarea
24+
attributes:
25+
label: To Reproduce
26+
description: If you have written tests to showcase the bug, what can we run to reproduce the issue?
27+
placeholder: "git checkout <branchname> / forge test --isolate --mt <testName>"
28+
- type: textarea
29+
attributes:
30+
label: Additional context
31+
description: If there is any additional context needed like a dependency or integrating contract that is affected please describe it below.

.github/ISSUE_TEMPLATE/FEATURE_IMPROVEMENT.yml

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,40 @@ description: Suggest an improvement to v4-core.
33
labels: ["triage"]
44

55
body:
6-
- type: markdown
7-
attributes:
8-
value: |
9-
Please ensure that the feature has not already been requested.
10-
- type: dropdown
11-
attributes:
12-
label: Component
13-
description: Which area of code does your idea improve?
14-
multiple: true
15-
options:
16-
- Hooks
17-
- Singleton
18-
- Lock and Call
19-
- Delta accounting
20-
- 1155 Balances
21-
- Pool Actions (swap, modifyLiquidity, donate, take, settle, mint)
22-
- Gas Optimization
23-
- General design optimization (improving efficiency, cleanliness, or developer experience)
24-
- Documentation
25-
- type: textarea
26-
attributes:
27-
label: Describe the suggested feature and problem it solves.
28-
description: Provide a clear and concise description of what feature you would like to see, and what problems it solves.
29-
validations:
30-
required: true
31-
- type: textarea
32-
attributes:
33-
label: Describe the desired implementation.
34-
description: If possible, provide a suggested architecture change or implementation.
35-
- type: textarea
36-
attributes:
37-
label: Describe alternatives.
38-
description: If possible, describe the alternatives you've considered, or describe the current functionality and how it may be sub-optimal.
39-
- type: textarea
40-
attributes:
41-
label: Additional context.
42-
description: Please list any additional dependencies or integrating contacts that are affected.
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Please ensure that the feature has not already been requested.
10+
- type: dropdown
11+
attributes:
12+
label: Component
13+
description: Which area of code does your idea improve?
14+
multiple: true
15+
options:
16+
- Hooks
17+
- Singleton
18+
- Lock and Call
19+
- Delta accounting
20+
- 1155 Balances
21+
- Pool Actions (swap, modifyLiquidity, donate, take, settle, mint)
22+
- Gas Optimization
23+
- General design optimization (improving efficiency, cleanliness, or developer experience)
24+
- Documentation
25+
- type: textarea
26+
attributes:
27+
label: Describe the suggested feature and problem it solves.
28+
description: Provide a clear and concise description of what feature you would like to see, and what problems it solves.
29+
validations:
30+
required: true
31+
- type: textarea
32+
attributes:
33+
label: Describe the desired implementation.
34+
description: If possible, provide a suggested architecture change or implementation.
35+
- type: textarea
36+
attributes:
37+
label: Describe alternatives.
38+
description: If possible, describe the alternatives you've considered, or describe the current functionality and how it may be sub-optimal.
39+
- type: textarea
40+
attributes:
41+
label: Additional context.
42+
description: Please list any additional dependencies or integrating contacts that are affected.

.github/pull_request_template.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## Related Issue
2+
23
Which issue does this pull request resolve?
34

4-
## Description of changes
5+
## Description of changes

.github/workflows/coverage.yml

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: code coverage
22

3-
on:
3+
on:
44
pull_request:
55
branches:
6-
- main
6+
- main
77

88
jobs:
99
comment-forge-coverage:
@@ -13,77 +13,77 @@ jobs:
1313
pull-requests: write
1414

1515
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v3
18-
with:
19-
token: ${{ secrets.GITHUB_TOKEN }}
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
with:
19+
token: ${{ secrets.GITHUB_TOKEN }}
2020

21-
- name: Install foundry
22-
uses: foundry-rs/foundry-toolchain@v1
23-
with:
21+
- name: Install foundry
22+
uses: foundry-rs/foundry-toolchain@v1
23+
with:
2424
version: nightly
25-
- name: Run Forge build
26-
run: |
25+
- name: Run Forge build
26+
run: |
2727
forge --version
2828
forge build --sizes
29-
id: build
30-
- name: Run forge coverage
31-
id: coverage
32-
run: |
33-
{
34-
echo 'COVERAGE<<EOF'
35-
forge coverage | grep '^|' | grep -v 'test/'
36-
echo EOF
37-
} >> "$GITHUB_OUTPUT"
38-
env:
39-
FOUNDRY_RPC_URL: '${{ secrets.RPC_URL }}'
40-
41-
- name: Check coverage is updated
42-
uses: actions/github-script@v5
43-
with:
44-
github-token: ${{ secrets.GITHUB_TOKEN }}
45-
script: |
46-
const fs = require('fs');
47-
const file = "coverage.txt"
48-
if(!fs.existsSync(file)) {
49-
console.log("Nothing to check");
50-
return
51-
}
52-
const currentCoverage = fs.readFileSync(file, "utf8").trim();
53-
const newCoverage = (`${{ steps.coverage.outputs.COVERAGE }}`).trim();
54-
if (newCoverage != currentCoverage) {
55-
core.setFailed(`Code coverage not updated. Run : forge coverage | grep '^|' | grep -v 'test/' > coverage.txt`);
56-
}
29+
id: build
30+
- name: Run forge coverage
31+
id: coverage
32+
run: |
33+
{
34+
echo 'COVERAGE<<EOF'
35+
forge coverage | grep '^|' | grep -v 'test/'
36+
echo EOF
37+
} >> "$GITHUB_OUTPUT"
38+
env:
39+
FOUNDRY_RPC_URL: "${{ secrets.RPC_URL }}"
5740

58-
- name: Comment on PR
59-
id: comment
60-
uses: actions/github-script@v5
61-
with:
62-
github-token: ${{ secrets.GITHUB_TOKEN }}
63-
script: |
64-
const {data: comments} = await github.rest.issues.listComments({
65-
owner: context.repo.owner,
66-
repo: context.repo.repo,
67-
issue_number: context.issue.number,
68-
})
41+
- name: Check coverage is updated
42+
uses: actions/github-script@v5
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
script: |
46+
const fs = require('fs');
47+
const file = "coverage.txt"
48+
if(!fs.existsSync(file)) {
49+
console.log("Nothing to check");
50+
return
51+
}
52+
const currentCoverage = fs.readFileSync(file, "utf8").trim();
53+
const newCoverage = (`${{ steps.coverage.outputs.COVERAGE }}`).trim();
54+
if (newCoverage != currentCoverage) {
55+
core.setFailed(`Code coverage not updated. Run : forge coverage | grep '^|' | grep -v 'test/' > coverage.txt`);
56+
}
6957
70-
const botComment = comments.find(comment => comment.user.id === 41898282)
58+
- name: Comment on PR
59+
id: comment
60+
uses: actions/github-script@v5
61+
with:
62+
github-token: ${{ secrets.GITHUB_TOKEN }}
63+
script: |
64+
const {data: comments} = await github.rest.issues.listComments({
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
issue_number: context.issue.number,
68+
})
7169
72-
const output = `${{ steps.coverage.outputs.COVERAGE }}`;
73-
const commentBody = `Forge code coverage:\n${output}\n`;
70+
const botComment = comments.find(comment => comment.user.id === 41898282)
7471
75-
if (botComment) {
76-
github.rest.issues.updateComment({
77-
owner: context.repo.owner,
78-
repo: context.repo.repo,
79-
comment_id: botComment.id,
80-
body: commentBody
81-
})
82-
} else {
83-
github.rest.issues.createComment({
84-
issue_number: context.issue.number,
85-
owner: context.repo.owner,
86-
repo: context.repo.repo,
87-
body: commentBody
88-
});
89-
}
72+
const output = `${{ steps.coverage.outputs.COVERAGE }}`;
73+
const commentBody = `Forge code coverage:\n${output}\n`;
74+
75+
if (botComment) {
76+
github.rest.issues.updateComment({
77+
owner: context.repo.owner,
78+
repo: context.repo.repo,
79+
comment_id: botComment.id,
80+
body: commentBody
81+
})
82+
} else {
83+
github.rest.issues.createComment({
84+
issue_number: context.issue.number,
85+
owner: context.repo.owner,
86+
repo: context.repo.repo,
87+
body: commentBody
88+
});
89+
}

.github/workflows/lint.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,15 @@ jobs:
2222

2323
- name: Lint
2424
run: forge fmt --check
25+
26+
- uses: actions/cache@v2
27+
name: Configure npm caching
28+
with:
29+
path: ~/.npm
30+
key: ${{ runner.os }}-npm-${{ hashFiles('**/workflows/prettier.yml') }}
31+
restore-keys: |
32+
${{ runner.os }}-npm-
33+
34+
- name: Check code formatting
35+
run: |-
36+
npx prettier --check .

.github/workflows/semgrep.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- main
88
schedule:
99
# random HH:MM to avoid a load spike on GitHub Actions at 00:00
10-
- cron: '35 11 * * *'
10+
- cron: "35 11 * * *"
1111
jobs:
1212
semgrep:
1313
name: semgrep/ci

.github/workflows/tests-merge.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ jobs:
1515
with:
1616
submodules: recursive
1717

18-
- uses: actions/setup-node@v3
19-
with:
20-
node-version: 16
21-
cache-dependency-path: './test/js-scripts'
22-
cache: 'yarn'
23-
24-
- run: yarn
25-
working-directory: ./test/js-scripts
26-
2718
- name: Install Foundry
2819
uses: foundry-rs/foundry-toolchain@v1
2920
with:
@@ -39,4 +30,3 @@ jobs:
3930
env:
4031
FOUNDRY_PROFILE: ci
4132
FORGE_SNAPSHOT_CHECK: true
42-

.github/workflows/tests-pr.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ jobs:
1616
with:
1717
submodules: recursive
1818

19-
- uses: actions/setup-node@v3
20-
with:
21-
node-version: 16
22-
cache-dependency-path: './test/js-scripts'
23-
cache: 'yarn'
24-
25-
- run: yarn
26-
working-directory: ./test/js-scripts
27-
2819
- name: Install Foundry
2920
uses: foundry-rs/foundry-toolchain@v1
3021
with:
@@ -40,4 +31,3 @@ jobs:
4031
env:
4132
FOUNDRY_PROFILE: pr
4233
FORGE_SNAPSHOT_CHECK: true
43-

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.prettierrc
2+
foundry.toml
3+
out
4+
lib/
5+
cache/
6+
*.sol
7+
dist/

0 commit comments

Comments
 (0)