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

v2.4 #489

Open
wants to merge 277 commits into
base: main
Choose a base branch
from
Open

v2.4 #489

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
277 commits
Select commit Hold shift + click to select a range
f8eafdc
uncommented without extra env
EdNoepel Oct 18, 2024
8e0c7b5
enable base tests in ci
EdNoepel Oct 18, 2024
7bd71de
reenable other ci jobs
EdNoepel Oct 19, 2024
6b3656d
tidy
EdNoepel Oct 21, 2024
637598a
moar linter fixes
EdNoepel Oct 21, 2024
7c97eb9
enable optimizer for compile
prateekdefi Oct 21, 2024
c26c839
adjust whitespace
EdNoepel Oct 22, 2024
8164258
folded verifier into core package
EdNoepel Oct 22, 2024
0cd9c38
renamed extensions package to periphery
EdNoepel Oct 22, 2024
6f4ef74
moved collateral accounts into periphery
EdNoepel Oct 23, 2024
f5c16d5
merged root files from trigger order package
EdNoepel Oct 23, 2024
39961c1
update workflow to print code size and gas report for base and PR branch
prateekdefi Oct 24, 2024
f692cf0
reorg contract folder structure
EdNoepel Oct 24, 2024
229843d
adjusted gas buffers for new arbitrum fork block
EdNoepel Oct 24, 2024
3acab77
Revert "update workflow to print code size and gas report for base an…
prateekdefi Oct 24, 2024
827c768
move contracts and tests from order package
EdNoepel Oct 24, 2024
ee5f6d0
fixed build and tests
EdNoepel Oct 24, 2024
5e0fe17
moved application-specific helpers alongside relevant tests
EdNoepel Oct 25, 2024
500fee9
upgrade 'hardhat-gas-reporter' package
prateekdefi Oct 25, 2024
84b945a
Merge branch 'v2.3' into prateek/pe-1866-code-size-gas-report
prateekdefi Oct 25, 2024
044f9a6
update yarn.lock
prateekdefi Oct 25, 2024
4ef4b99
deduped test setup implementations, resolved TODOs
EdNoepel Oct 25, 2024
e7c45ce
update scripts and workflow to get code size and gas report diff
prateekdefi Oct 28, 2024
e323d01
fix gas-report script to only output gas report
prateekdefi Oct 28, 2024
ee8cb46
fix gas report script to only output gas report
prateekdefi Oct 28, 2024
9c495da
update workflow to delete previous comment
prateekdefi Oct 28, 2024
48bc857
enable trackGasDeltas
prateekdefi Oct 28, 2024
1cd1292
Cache hardhat code size and gas report files
prateekdefi Oct 28, 2024
f2c8b00
enable trackGasDeltas
prateekdefi Oct 28, 2024
0ea33af
consolidated market deployment and creation
EdNoepel Oct 28, 2024
a58d282
upload cache folder in github artifacts
prateekdefi Oct 28, 2024
df217f3
run single integration test
prateekdefi Oct 28, 2024
db837bd
upload hidden files in artifacts
prateekdefi Oct 28, 2024
d0e61fc
run all tests
prateekdefi Oct 28, 2024
cbf91e1
run all tests
prateekdefi Oct 28, 2024
c98cce5
move fixture into chain-specific runner
EdNoepel Oct 28, 2024
2bca85c
moved reserve out of setupHelpers
EdNoepel Oct 28, 2024
cebfcec
refactored the fundWallet methods
EdNoepel Oct 29, 2024
b93c924
sorted account naming and funding
EdNoepel Oct 29, 2024
ddbbdbe
refactored chain-specific oracle stuff out of setupHelpers
EdNoepel Oct 29, 2024
b217b15
normalize advanceToPrice
EdNoepel Oct 29, 2024
ad7c853
removed unused arg, meaningless commit to create branch
EdNoepel Oct 30, 2024
24c9dd0
reduced quantities and got some Order tests working on Arbitrum
EdNoepel Oct 30, 2024
8321993
resolved settlement issue in test setup
EdNoepel Oct 31, 2024
f8bf3f2
Merge branch 'v2.4' into ed/folder-refactor2
EdNoepel Oct 31, 2024
2f6d314
enable 2.4 CI
EdNoepel Oct 31, 2024
4d1a05b
Merge branch 'v2.4' into ed/folder-refactor2
EdNoepel Oct 31, 2024
3dec5ae
first attempt updating CI
EdNoepel Nov 1, 2024
75fb05a
discovered some helpers were used by both unit and integration test, …
EdNoepel Nov 1, 2024
5f7764b
forgot to update these
EdNoepel Nov 1, 2024
e3c4f34
skip MI OrderCreated validation on Arbitrum due to timestamp mismatch
EdNoepel Nov 1, 2024
4389f6f
re-removed order module
EdNoepel Nov 2, 2024
e1b93ae
add oracles to IOracle
prateekdefi Nov 4, 2024
0e5b962
Merge pull request #479 from equilibria-xyz/prateek/pe-1866-code-size…
prateekdefi Nov 4, 2024
b3dbc17
Merge branch 'v2.4' into prateek/gas-and-code-size-diff
prateekdefi Nov 4, 2024
ce8f193
start refactoring MI Pyth test setup
EdNoepel Nov 4, 2024
d6b75a0
pass VAAs from the runner into the test
EdNoepel Nov 5, 2024
23ca020
remove unused comment
prateekdefi Nov 5, 2024
a7abbc8
missed this
EdNoepel Nov 5, 2024
fdc7e6d
switch to spec mocha reporter
EdNoepel Nov 5, 2024
0e4512a
debug logging
EdNoepel Nov 5, 2024
f867241
set retry count to 0
EdNoepel Nov 5, 2024
e40dde6
disable other CI jobs
EdNoepel Nov 5, 2024
8edd38a
trace all the things
EdNoepel Nov 5, 2024
0f38e62
print package versions
EdNoepel Nov 5, 2024
e543155
Merge branch 'v2.4' into ed/folder-refactor2
EdNoepel Nov 5, 2024
327e119
adjust gas config for new libs
EdNoepel Nov 5, 2024
9d6cbd9
reenable call traces
EdNoepel Nov 5, 2024
81361f4
adjust Base gas config
EdNoepel Nov 6, 2024
105035a
reverted debugging statements, enable all tests
EdNoepel Nov 6, 2024
ccd3986
Merge pull request #490 from equilibria-xyz/ed/folder-refactor2
EdNoepel Nov 6, 2024
c0b67ac
remove debugging step
EdNoepel Nov 6, 2024
441d2cd
renamed packages
EdNoepel Nov 6, 2024
69131e4
renamed folders
EdNoepel Nov 6, 2024
ece67ec
update CI
EdNoepel Nov 6, 2024
5fa882a
fixed workspace names
EdNoepel Nov 6, 2024
ce811bd
correct workspace name
EdNoepel Nov 7, 2024
bd7a990
Add temporary contract changes to show code size and gas diff in PR
prateekdefi Nov 8, 2024
1d8624e
Merge branch 'v2.4' into prateek/gas-and-code-size-diff
prateekdefi Nov 8, 2024
e5d34ab
Revert "Add temporary contract changes to show code size and gas diff…
prateekdefi Nov 8, 2024
6b321d4
Add temporary market contract changes to show code size and gas diff …
prateekdefi Nov 8, 2024
c9e4044
Merge pull request #494 from equilibria-xyz/ed/rename-packages
EdNoepel Nov 11, 2024
21b6642
refactor MarketFactory deployment to reduce setup code duplication
EdNoepel Nov 7, 2024
0bec276
hack around tooling issue causing local test failure
EdNoepel Nov 7, 2024
3843332
calculate syncFee rewarded to caller
EdNoepel Nov 8, 2024
50cac13
pass oracle version into test
EdNoepel Nov 11, 2024
ebfd24e
Add collapsible reports
prateekdefi Nov 11, 2024
1f98da2
Merge branch 'v2.4' into prateek/gas-and-code-size-diff
prateekdefi Nov 11, 2024
0548460
fix workflow
prateekdefi Nov 11, 2024
d89cc62
update script to capture first table instead of last
prateekdefi Nov 11, 2024
6767ab1
upload correct cache folder
prateekdefi Nov 11, 2024
9b74361
fix comment
prateekdefi Nov 11, 2024
7cd2acf
got Invoker MI tests running on Arbitrum
EdNoepel Nov 12, 2024
7edc59b
Update comment
prateekdefi Nov 12, 2024
5034dc6
update script to expand backslash escape sequences
prateekdefi Nov 12, 2024
9bce7f1
cleanup
EdNoepel Nov 12, 2024
022e818
removed chain from integration test directory structure
EdNoepel Nov 12, 2024
8912267
clean up gas config
EdNoepel Nov 12, 2024
d75834b
moved some helper functions
EdNoepel Nov 13, 2024
2905b40
Remove migration code
prateekdefi Nov 13, 2024
b416c8b
incorporate solidity-docgen
EdNoepel Nov 13, 2024
735be1c
updated README
EdNoepel Nov 13, 2024
6ecc92b
Merge pull request #495 from equilibria-xyz/ed/mi-tests-on-arbitrum
EdNoepel Nov 13, 2024
d070917
adjust wrapIfNecessary logic
EdNoepel Nov 14, 2024
e905827
fix position storage slot
prateekdefi Nov 14, 2024
337e40e
Merge branch 'v2.4' into prateek/pe-1917-oracles-getter
prateekdefi Nov 14, 2024
6688367
add unit test for oracles method
prateekdefi Nov 14, 2024
5976423
instrument versionLib for debugging
EdNoepel Nov 15, 2024
1a2ac96
start work on new test
EdNoepel Nov 15, 2024
9ba94fd
Merge pull request #497 from equilibria-xyz/ed/solidity-docgen
EdNoepel Nov 15, 2024
12cf510
add oracles method to return Epoch
prateekdefi Nov 15, 2024
1a6b7a3
Deprecate multiinvoker trigger orders
prateekdefi Nov 15, 2024
7c9b2e8
fix tests
prateekdefi Nov 15, 2024
10306ff
add natspec and remove unused imports
prateekdefi Nov 15, 2024
5d78c9e
remove migration code from oracles
prateekdefi Nov 15, 2024
f5f0041
tied out without referrals
EdNoepel Nov 15, 2024
782596c
debugging instrumentation
EdNoepel Nov 15, 2024
6065134
incorporated referral and subtractive fee into test
EdNoepel Nov 15, 2024
03e48e9
remove updateId tests
prateekdefi Nov 18, 2024
2f8ae31
deprecate unused states
prateekdefi Nov 18, 2024
9a6c5c1
tied out numbers without referrals, guarantees
EdNoepel Nov 18, 2024
f869879
with referrals
EdNoepel Nov 18, 2024
8f784f3
moar debugging instrumentation
EdNoepel Nov 18, 2024
47fe006
guarantees with takerFee test
EdNoepel Nov 18, 2024
acb86ab
remove debugging instrumentation
EdNoepel Nov 18, 2024
deb4db6
Revert "Add temporary market contract changes to show code size and g…
prateekdefi Nov 19, 2024
bde5bcb
add insurance fund contract
prateekdefi Nov 19, 2024
8728ff2
add tests
prateekdefi Nov 19, 2024
16634fd
fix lint
prateekdefi Nov 20, 2024
6bbff02
Merge pull request #499 from equilibria-xyz/ed/pe-1371
EdNoepel Nov 20, 2024
23f6967
Merge pull request #492 from equilibria-xyz/prateek/pe-1917-oracles-g…
prateekdefi Nov 20, 2024
c2a885c
Merge branch 'v2.4' into prateek/pe-745-insurance-fund
prateekdefi Nov 20, 2024
b2ba3c3
add inheritdoc and check market if created from same market factory
prateekdefi Nov 20, 2024
8765d47
update tests
prateekdefi Nov 20, 2024
89d1928
add risk coordinator for vault contract
prateekdefi Nov 21, 2024
036d2d2
fix vault integration tests
prateekdefi Nov 21, 2024
b4f2604
fix periphery integration tests
prateekdefi Nov 21, 2024
e98b01e
Merge branch 'v2.4' into prateek/pe-1871-remove-migration-code
prateekdefi Nov 22, 2024
b57d475
PR feedback
prateekdefi Nov 25, 2024
4faecc7
remove KeeperOracle_Migration dependency
prateekdefi Nov 25, 2024
f6a4d68
Merge pull request #488 from equilibria-xyz/prateek/gas-and-code-size…
prateekdefi Nov 25, 2024
602d313
Merge branch 'v2.4' into prateek/pe-1871-remove-migration-code
prateekdefi Nov 25, 2024
122e9c4
Merge branch 'v2.4' into prateek/pe-1292-deprecate-trigger-orders
prateekdefi Nov 25, 2024
b41baf1
Merge pull request #502 from equilibria-xyz/ed/pe-1831
EdNoepel Nov 26, 2024
91eb687
make maxStaleAfter uint16
prateekdefi Nov 26, 2024
d69098a
fix staleAfter max value in tests
prateekdefi Nov 26, 2024
087f52b
fix staleAfter storage
prateekdefi Nov 26, 2024
60717ea
PR feedback
prateekdefi Nov 26, 2024
5a7e82a
update test
prateekdefi Nov 26, 2024
865c939
Merge branch 'v2.4' into prateek/pe-745-insurance-fund
prateekdefi Nov 26, 2024
07380be
PR feedback
prateekdefi Nov 27, 2024
784aeab
fix compilation
prateekdefi Nov 27, 2024
47af207
update market claimExposure to be call by factory owner or operator o…
prateekdefi Nov 27, 2024
86b3918
add integration tests for insurance fund contract
prateekdefi Nov 27, 2024
bec05c5
fix integration test
prateekdefi Nov 27, 2024
e87ed90
add back comment
prateekdefi Nov 27, 2024
93b1f44
natspec and other cleaner
kbrizzle Nov 27, 2024
f6a79c4
fix claimExposure unit test
prateekdefi Nov 28, 2024
c960abc
PR feedback
prateekdefi Nov 28, 2024
2360b0b
remove MultiInvoker_Arbitrum and MultiInvoker_Optimism
prateekdefi Nov 28, 2024
b05a8b7
remove MultiInvoker_Arbitrum and MultiInvoker_Optimism tests and fix …
prateekdefi Nov 28, 2024
bbb571c
Merge pull request #496 from equilibria-xyz/prateek/pe-1871-remove-mi…
prateekdefi Nov 28, 2024
8976b7d
fix 'multi-delayed update w/ collateral (gas)' test
prateekdefi Nov 29, 2024
e8277c2
Merge pull request #504 from equilibria-xyz/prateek/pe-1978-staleAfte…
prateekdefi Dec 2, 2024
144b7d1
deprecate previous protocol parameter slot and add new protocol param…
prateekdefi Dec 2, 2024
80326f0
fix tests by setting minMinMaintenance to 0 in tests
prateekdefi Dec 2, 2024
4c42c24
fix market unit tests
prateekdefi Dec 2, 2024
cb15597
validate minMaintenance risk parameter
prateekdefi Dec 2, 2024
48d1b95
remove maxSettlementFee, add maxSyncFee and maxAsyncFee
prateekdefi Dec 2, 2024
f1a7de2
fix oracle unit tests
prateekdefi Dec 2, 2024
2fa9e6b
fix unit tests
prateekdefi Dec 2, 2024
8dc300e
fix parameter types unit tests
prateekdefi Dec 3, 2024
d54b4a0
remove maxSettlementFee from integration tests
prateekdefi Dec 3, 2024
c5c81bf
Merge pull request #498 from equilibria-xyz/prateek/pe-1292-deprecate…
prateekdefi Dec 3, 2024
d0b1367
update multiInvoker to get account operators from marketFactory
prateekdefi Dec 3, 2024
08ebcfc
update vault to get account operators from marketFactory
prateekdefi Dec 3, 2024
2095e52
fix vault integration test
prateekdefi Dec 3, 2024
a5aefa4
fix multiInvoker integration tests
prateekdefi Dec 3, 2024
740a148
Merge pull request #505 from equilibria-xyz/prateek/pe-1980-multi-del…
EdNoepel Dec 3, 2024
4ac8754
update insurance fund resolve to resolve specific account shortfall
prateekdefi Dec 4, 2024
087b8a4
update unit test
prateekdefi Dec 4, 2024
c358fd3
update integration tests
prateekdefi Dec 4, 2024
b1f6604
Revert 'update market claimExposure to be call by factory owner or op…
prateekdefi Dec 4, 2024
203e8fa
fix claimExposure unit and integration tests
prateekdefi Dec 4, 2024
36fa715
remove unused imports
prateekdefi Dec 4, 2024
26c5403
fix integration test
prateekdefi Dec 4, 2024
f361c4b
PR feedback
prateekdefi Dec 4, 2024
a154864
fix periphery integration test
prateekdefi Dec 4, 2024
4f295ad
Merge branch 'v2.4' into prateek/pe-1959-vault-risk-coordinator
prateekdefi Dec 4, 2024
69b926d
only allowed accounts can interact with vault
prateekdefi Dec 5, 2024
965b30a
only allowed accounts can interact with vault
prateekdefi Dec 5, 2024
eeae11f
fix vault integration tests
prateekdefi Dec 5, 2024
d11d4b1
fix multiinvoker integration tests
prateekdefi Dec 5, 2024
1ca61ae
update multiInvoker integration tests
prateekdefi Dec 5, 2024
b136518
PR feedback
prateekdefi Dec 5, 2024
56ba932
update tests
prateekdefi Dec 5, 2024
686b166
fix integration test
prateekdefi Dec 5, 2024
e654e26
remove magic values from core contracts
prateekdefi Dec 6, 2024
713a5e5
fix core tests
prateekdefi Dec 6, 2024
1f0d7b4
remove magic values from oracle and deploy package
prateekdefi Dec 6, 2024
83fa5b9
update account, multiinvoker and trigger orders to not use magic values
prateekdefi Dec 6, 2024
f3b09d4
fix tests
prateekdefi Dec 6, 2024
9506e44
remove magic value use from vault
prateekdefi Dec 6, 2024
0ffb344
add close method to close all position or liquidate
prateekdefi Dec 6, 2024
c61890f
add unit and integration tests for close()
prateekdefi Dec 6, 2024
d34b4e1
set async fee based on callbacks
prateekdefi Dec 6, 2024
27fea51
update unit tests
prateekdefi Dec 6, 2024
4eec980
fix liquidate test
prateekdefi Dec 9, 2024
ae4107f
PR feedback
prateekdefi Dec 9, 2024
1115278
fix test
prateekdefi Dec 9, 2024
38b498b
Merge pull request #500 from equilibria-xyz/prateek/pe-745-insurance-…
prateekdefi Dec 10, 2024
66313dd
Merge pull request #501 from equilibria-xyz/prateek/pe-1959-vault-ris…
prateekdefi Dec 10, 2024
ff8f408
reset chainlink params
prateekdefi Dec 10, 2024
503eec6
Merge branch 'main' into v2.4
prateekdefi Dec 10, 2024
4a33bef
Revert "set async fee based on callbacks"
prateekdefi Dec 12, 2024
9b12444
Revert "update unit tests"
prateekdefi Dec 12, 2024
3de1997
PR feedback
prateekdefi Dec 12, 2024
dbd6837
PR feedback
prateekdefi Dec 12, 2024
3017274
add minMinMaintenance unit test
prateekdefi Dec 12, 2024
51ecd3a
Merge branch 'v2.4' into prateek/pe-1877-permissioned-vaults
prateekdefi Dec 12, 2024
d13c720
update event
prateekdefi Dec 13, 2024
9552455
add comments
prateekdefi Dec 13, 2024
aac4ffe
remove applyFeeMaximum
prateekdefi Dec 13, 2024
0c00d29
update close method to fully close user position
prateekdefi Dec 16, 2024
2156dcb
update tests
prateekdefi Dec 16, 2024
b775d18
PR feedback
prateekdefi Dec 16, 2024
59070c2
add comment and test
prateekdefi Dec 16, 2024
15c545f
update transfer helper method in test
prateekdefi Dec 16, 2024
964dffd
add maker delta update
prateekdefi Dec 11, 2024
c3e7d59
update close method
prateekdefi Dec 16, 2024
b3f2f90
fix updateIntent
prateekdefi Dec 16, 2024
1a6f3b2
fix security note
kbrizzle Dec 17, 2024
9e9c1e1
Merge pull request #509 from equilibria-xyz/prateek/pe-1979-consolida…
prateekdefi Dec 17, 2024
d27baa9
add natspec in interface
prateekdefi Dec 17, 2024
340d533
Merge pull request #508 from equilibria-xyz/prateek/pe-1982-split-max…
prateekdefi Dec 17, 2024
d8dba22
Merge pull request #506 from equilibria-xyz/prateek/pe-1840-minMinMai…
prateekdefi Dec 17, 2024
58e80fb
fix makerReferral and update closable amount to UFixed6
prateekdefi Dec 17, 2024
e0623a0
Merge pull request #511 from equilibria-xyz/prateek/pe-1877-permissio…
prateekdefi Dec 18, 2024
28dfa2e
add order unit tests for 'from' method
prateekdefi Dec 23, 2024
ba2f18a
update order 'from' unit tests
prateekdefi Dec 23, 2024
a43b03e
Merge pull request #491 from equilibria-xyz/prateek/pe-1629-remove-ma…
prateekdefi Dec 24, 2024
57c657f
added leverage buffer parameter
prateekdefi Dec 27, 2024
2fc8884
updated tests
prateekdefi Dec 27, 2024
a95aaaf
add test for change in position with lower leverage buffer
prateekdefi Dec 27, 2024
e1985c7
fix multiInvoker setup
prateekdefi Jan 2, 2025
fcc93a6
fix 'updateParameter' calls
prateekdefi Jan 2, 2025
05ec8c1
add multiInvoker arbitrum tests
prateekdefi Jan 2, 2025
3ef3537
restore multiInvoker unit tests
prateekdefi Jan 2, 2025
6c8010a
Merge pull request #520 from equilibria-xyz/prateek/restore-multiInvo…
EdNoepel Jan 3, 2025
8ce3985
Merge pull request #519 from equilibria-xyz/prateek/pe-610-leverage-b…
kbrizzle Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
265 changes: 61 additions & 204 deletions .github/workflows/CI.yml

Large diffs are not rendered by default.

104 changes: 104 additions & 0 deletions .github/workflows/gas_report_and_code_size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Gas Report and Code Size

on: [pull_request]

jobs:
gas-report-and-code-size:
permissions:
pull-requests: write
runs-on: ubuntu-latest

steps:
- uses: actions/setup-node@v3
with:
node-version: 18.19

- name: Checkout Base Branch
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}

- name: Install packages
run: yarn --frozen-lockfile

- name: Compile
run: yarn workspaces run compile

- name: Run gas report script for base branch
env:
MAINNET_NODE_URL: ${{ secrets.MAINNET_NODE_URL }}
run: yarn workspace @perennial/v2-core run gasReport

- name: Upload cache folder
uses: actions/upload-artifact@v4
with:
name: perennial-cache
path: packages/core/cache
if-no-files-found: error
retention-days: 1
include-hidden-files: true

- name: Checkout PR branch
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Download cache folder
uses: actions/download-artifact@v4
with:
name: perennial-cache
path: packages/core/cache

- name: Install packages
run: yarn --frozen-lockfile

- name: Compile and get code size diff
run: ./code-size.sh

- name: Run Gas Report Script for PR branch and get gas diff
env:
MAINNET_NODE_URL: ${{ secrets.MAINNET_NODE_URL }}
run: ./gas-report.sh

- name: Comment PR with code size and gas report
uses: actions/github-script@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const prNumber = context.payload.pull_request.number;

const isWorkflowComment = (comment) => {
return (comment.body.includes('### Code Size Diff:') || comment.body.includes('### Gas Report Diff:'));
};

const { data: comments } = await github.rest.issues.listComments({
...context.repo,
issue_number: prNumber,
});

for (const comment of comments) {
if (isWorkflowComment(comment)) {
await github.rest.issues.deleteComment({
...context.repo,
comment_id: comment.id,
});
}
}

const code_size = fs.readFileSync('code_size.txt', 'utf8');
const gas_report = fs.readFileSync('gas_report.txt', 'utf8');

// Post the Code Size comment
await github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: `### Code Size Diff:\n\n${code_size}\n`
});

// Post the Gas Report comment
await github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: `### Gas Report Diff:\n\n${gas_report}\n`
});
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
.vscode

**/.env
**/docs
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| ----------------------- | :-------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------: |
| `@perennial/core` | Core perennial smart contracts. | [![npm version](https://badge.fury.io/js/@perennial%2Fcore.svg)](https://badge.fury.io/js/@perennial%2Fcore) |
| `@perennial/deploy` | Deployment scripts and artifacts. | [![npm version](https://badge.fury.io/js/@perennial%2Fperennial/deploy.svg)](https://badge.fury.io/js/@perennial%2Fperennial/deploy) |
| `@perennial/extensions` | Extension smart contracts. | [![npm version](https://badge.fury.io/js/@perennial%2Fperennial/extensions.svg)](https://badge.fury.io/js/@perennial%2Fperennial/extensions) |
| `@perennial/periphery` | MultiInvoker and extension contracts. | [![npm version](https://badge.fury.io/js/@perennial%2Fperennial/periphery.svg)](https://badge.fury.io/js/@perennial%2Fperennial/periphery) |
| `@perennial/oracle` | Oracle provider smart contracts. | [![npm version](https://badge.fury.io/js/@perennial%2Fperennial/oracle.svg)](https://badge.fury.io/js/@perennial%2Fperennial/oracle) |
| `@perennial/vault` | Vault smart contracts. | [![npm version](https://badge.fury.io/js/@perennial%2Fperennial/vault.svg)](https://badge.fury.io/js/@perennial%2Fperennial/vault) |

Expand All @@ -36,16 +36,23 @@ Compile the smart contracts for each package with Hardhat:
$ yarn workspaces run compile
```

This also generates the Typechain types
This also generates the Typechain types.

### Test
### Docs

Perennial has 4 logic packages: `core`, `deploy`, `periphery`, `oracle`, and `vault`

To compile code documentation for a specific package:
```sh
$ yarn workspace @perennial/<package-name> run doc
```

Perennial has 4 logic packages: `core`, `deploy`, `extensions`, `oracle`, and `vault`
### Test

Run the Mocha unit tests a specific package:

```sh
$ yarn workspace @equilibria/<package-name> run test
$ yarn workspace @perennial/<package-name> run test
```

For example, to run the tests for the core package:
Expand All @@ -57,7 +64,7 @@ $ yarn workspace @perennial/core run test
To run tests against a Mainnet fork, set your `MAINNET_NODE_URL` in the root `.env` and run

```sh
$ yarn workspace run @equilibria/<package-name> test:integration
$ yarn workspace run @perennial/<package-name> test:integration
```

For example, to run the integration tests for the core package:
Expand All @@ -78,4 +85,4 @@ The vast majority of the Perennial V2 codebase is licensed under the Apache 2.0
| License | License |
| ------------ | :------------------------------------------------------------------------------------ |
| `Apache-2.0` | All, unless stated otherwise. |
| `BUSL-1.1` | Smart contracts: `Market.sol` and `MarketFactory.sol` in the `@perennial-v2` package. |
| `BUSL-1.1` | Smart contracts: `Market.sol` and `MarketFactory.sol` in the `@perennial/core` package. |
28 changes: 28 additions & 0 deletions code-size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Output file path
output_file="code_size.txt"

# Run the command and filter lines that start with '|' or '·', removing color codes
filtered_output=$(yarn workspaces run build | grep -E '^\s*(\||·)' | sed -r 's/\x1B\[[0-9;]*[mK]//g')

# Extract only the core contracts table
core_code_size_table=$(echo "$filtered_output" | awk '
/·--/ {
# Capture first table starting and ending with ·--
if (capturing) {
print
exit
}
capturing = 1
}
capturing {
print
}
')

# Format the captured table for GitHub comment with collapsible section
formatted_core_code_size_table="<details>\n<summary>View Report</summary>\n\n\`\`\`\n$core_code_size_table\n\`\`\`\n</details>"

# Write the formatted table to the output file
printf "%b" "$formatted_core_code_size_table" > "$output_file"
27 changes: 27 additions & 0 deletions gas-report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Run the gas report command and filter lines that start with optional spaces followed by '|' or '·'
filtered_output=$(yarn workspace @perennial/v2-core run gasReport | grep -E '^\s*(\||·)' | sed -r 's/\x1B\[[0-9;]*[mK]//g')

# Function to extract the gas report
extract_gas_report() {
echo "$filtered_output" | awk '
/·--/ {
table_count++ # Increment table count at each boundary
if (table_count == 4) { # Start capturing when reaching the third table
capturing = 1
}
next
}
capturing { print } # Print only lines within the third table
'
}

# Capture the gas report table output
gas_report_output=$(extract_gas_report)

# Format the gas report table output for a GitHub comment collapse section
formatted_gas_report_output="<details>\n<summary>View Report</summary>\n\n\`\`\`\n$gas_report_output\n\`\`\`\n</details>"

# Write the formatted gas report table output to a file
printf "%b" "$formatted_gas_report_output" > gas_report.txt
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"hardhat-contract-sizer": "^2.10.0",
"hardhat-dependency-compiler": "1.1.3",
"hardhat-deploy": "0.11.31",
"hardhat-gas-reporter": "1.0.9",
"hardhat-gas-reporter": "2.2.1",
"hardhat-tracer": "2.5.1",
"husky": ">=6",
"lerna": "^4.0.0",
Expand All @@ -51,6 +51,7 @@
"solhint": "^3.4.1",
"solhint-plugin-prettier": "0.0.5",
"solidity-coverage": "0.8.3",
"solidity-docgen": "^0.6.0-beta.36",
"ts-generator": "^0.1.1",
"ts-node": "^9.0.0",
"typechain": "^8.1.0",
Expand Down
7 changes: 6 additions & 1 deletion packages/common/hardhat.default.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'hardhat-deploy'
import 'hardhat-dependency-compiler'
import 'hardhat-tracer'
import 'solidity-coverage'
import 'solidity-docgen'

import { getChainId, isArbitrum, isBase, isOptimism, SupportedChain } from './testutil/network'

Expand Down Expand Up @@ -130,7 +131,7 @@ export default function defaultConfig({
: undefined,
chainId: getChainId('hardhat'),
allowUnlimitedContractSize: true,
blockGasLimit: 32000000,
blockGasLimit: 32_000_000,
mining: NODE_INTERVAL_MINING
? {
interval: NODE_INTERVAL_MINING,
Expand Down Expand Up @@ -210,6 +211,7 @@ export default function defaultConfig({
currency: 'USD',
gasPrice: 100,
enabled: process.env.REPORT_GAS ? true : false,
trackGasDeltas: true,
},
typechain: {
outDir: 'types/generated',
Expand All @@ -222,6 +224,9 @@ export default function defaultConfig({
timeout: 4800000,
retries: Number(MOCHA_RETRY_COUNT),
},
docgen: {
pages: 'files',
},
contractSizer: {
alphaSort: true,
disambiguatePaths: false,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
52 changes: 52 additions & 0 deletions packages/core/contracts/InsuranceFund.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.24;

import { Ownable } from "@equilibria/root/attribute/Ownable.sol";
import { Token18 } from "@equilibria/root/token/types/Token18.sol";
import { Fixed6, Fixed6Lib } from "@equilibria/root/number/types/Fixed6.sol";
import { IFactory } from "@equilibria/root/attribute/interfaces/IFactory.sol";
import { IInstance } from "@equilibria/root/attribute/interfaces/IInstance.sol";

import { IInsuranceFund } from "./interfaces/IInsuranceFund.sol";
import { IMarket } from "./interfaces/IMarket.sol";

/// @title InsuranceFund
/// @notice This contract manages the protocol fee and shortfalls for markets.
contract InsuranceFund is IInsuranceFund, Ownable {

/// @dev The address of the market factory
IFactory public immutable marketFactory;

/// @dev The address of token
Token18 public immutable token;

constructor(IFactory _marketFactory, Token18 _token) {
marketFactory = _marketFactory;
token = _token;
}

/// @inheritdoc IInsuranceFund
function initialize() external initializer(1) {
__Ownable__initialize();
}

/// @inheritdoc IInsuranceFund
function claim(IMarket market) external isMarketInstance(market) {
market.claimFee(marketFactory.owner());
}

/// @inheritdoc IInsuranceFund
function resolve(IMarket market, address account) external onlyOwner isMarketInstance(market) {
token.approve(address(market));
market.settle(account);
Fixed6 resolutionAmount = market.locals(account).collateral.mul(Fixed6Lib.NEG_ONE);
market.update(account, Fixed6Lib.ZERO, resolutionAmount, address(0));
}

/// @notice Validates that a market was created by the market factory
/// @param market Market to validate
modifier isMarketInstance(IMarket market) {
if (!marketFactory.instances(IInstance(market))) revert InsuranceFundInvalidInstanceError();
_;
}
}
Loading
Loading