Skip to content

Commit

Permalink
Merge branch 'v2.3' into prateek/pe-1346
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekdefi committed Oct 17, 2024
2 parents 4ccb4ef + f44c98a commit 8085045
Show file tree
Hide file tree
Showing 167 changed files with 2,592 additions and 1,134 deletions.
57 changes: 28 additions & 29 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ on:
pull_request:
branches:
- main
- v2.1
- v2.1.1
- v2.2
- v2.3
- v2.3-fix-review
workflow_dispatch:

env:
Expand Down Expand Up @@ -64,7 +62,7 @@ jobs:
MOCHA_REPORTER: dot
MOCHA_RETRY_COUNT: 2
run: |
yarn workspace @equilibria/perennial-v2 run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
yarn workspace @perennial/core run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -102,7 +100,7 @@ jobs:
MOCHA_RETRY_COUNT: 2
MAINNET_NODE_URL: ${{ secrets.MAINNET_NODE_URL }}
run: |
yarn workspace @equilibria/perennial-v2 run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
yarn workspace @perennial/core run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -172,7 +170,7 @@ jobs:
MOCHA_REPORTER: dot
MOCHA_RETRY_COUNT: 2
run: |
yarn workspace @equilibria/perennial-v2-account run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
yarn workspace @perennial/account run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -202,7 +200,7 @@ jobs:
MOCHA_RETRY_COUNT: 2
ARBITRUM_NODE_URL: ${{ secrets.ARBITRUM_NODE_URL }}
run: |
yarn workspace @equilibria/perennial-v2-account run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
yarn workspace @perennial/account run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -233,7 +231,7 @@ jobs:
MOCHA_REPORTER: dot
MOCHA_RETRY_COUNT: 2
run: |
yarn workspace @equilibria/perennial-v2-oracle run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
yarn workspace @perennial/oracle run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -263,7 +261,7 @@ jobs:
MOCHA_RETRY_COUNT: 2
MAINNET_NODE_URL: ${{ secrets.MAINNET_NODE_URL }}
run: |
yarn workspace @equilibria/perennial-v2-oracle run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
yarn workspace @perennial/oracle run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -293,7 +291,7 @@ jobs:
MOCHA_RETRY_COUNT: 2
ARBITRUM_SEPOLIA_NODE_URL: ${{ secrets.ARBITRUM_SEPOLIA_NODE_URL }}
run: |
yarn workspace @equilibria/perennial-v2-oracle run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integrationSepolia' || 'test:integrationSepolia' }}
yarn workspace @perennial/oracle run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integrationSepolia' || 'test:integrationSepolia' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -324,7 +322,7 @@ jobs:
MOCHA_REPORTER: dot
MOCHA_RETRY_COUNT: 2
run: |
yarn workspace @equilibria/perennial-v2-order run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
yarn workspace @perennial/order run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -354,7 +352,7 @@ jobs:
MOCHA_RETRY_COUNT: 2
ARBITRUM_NODE_URL: ${{ secrets.ARBITRUM_NODE_URL }}
run: |
yarn workspace @equilibria/perennial-v2-order run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
yarn workspace @perennial/order run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -385,7 +383,7 @@ jobs:
MOCHA_REPORTER: dot
MOCHA_RETRY_COUNT: 2
run: |
yarn workspace @equilibria/perennial-v2-vault run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
yarn workspace @perennial/vault run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -415,7 +413,7 @@ jobs:
MOCHA_RETRY_COUNT: 2
MAINNET_NODE_URL: ${{ secrets.MAINNET_NODE_URL }}
run: |
yarn workspace @equilibria/perennial-v2-vault run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
yarn workspace @perennial/vault run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -446,7 +444,7 @@ jobs:
MOCHA_REPORTER: dot
MOCHA_RETRY_COUNT: 2
run: |
yarn workspace @equilibria/perennial-v2-extensions run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
yarn workspace @perennial/extensions run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -476,7 +474,7 @@ jobs:
MOCHA_RETRY_COUNT: 2
MAINNET_NODE_URL: ${{ secrets.MAINNET_NODE_URL }}
run: |
yarn workspace @equilibria/perennial-v2-extensions run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
yarn workspace @perennial/extensions run ${{ env.PARSER_BROKEN != 'true' && 'coverage:integration' || 'test:integration' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -507,18 +505,19 @@ jobs:
MOCHA_REPORTER: dot
MOCHA_RETRY_COUNT: 2
run: |
yarn workspace @equilibria/perennial-v2-verifier run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
yarn workspace @perennial/verifier run ${{ env.PARSER_BROKEN != 'true' && 'coverage' || 'test' }}
- name: Upload lcov file
uses: actions/upload-artifact@v3
with:
name: verifier_unit_test_coverage
path: ./packages/perennial-verifier/coverage/lcov.info

# [PERIPHERY UNIT COVERAGE]
periphery-unit-test-coverage:
name: 'Periphery Unit Tests Coverage'
runs-on: ubuntu-latest
needs: [account-unit-test, oracle-unit-test, order-unit-test, vault-unit-test, extensions-unit-test, verifier-unit-test]
needs:
[account-unit-test, oracle-unit-test, order-unit-test, vault-unit-test, extensions-unit-test, verifier-unit-test]
steps:
- uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -558,10 +557,10 @@ jobs:
run: sudo apt-get update && sudo apt-get install lcov
- name: Combine unit test coverage
run: lcov -a account_unit_test_coverage/lcov.info
-a oracle_unit_test_coverage/lcov.info
-a order_unit_test_coverage/lcov.info
-a vault_unit_test_coverage/lcov.info
-a extensions_unit_test_coverage/lcov.info
-a oracle_unit_test_coverage/lcov.info
-a order_unit_test_coverage/lcov.info
-a vault_unit_test_coverage/lcov.info
-a extensions_unit_test_coverage/lcov.info
-a verifier_unit_test_coverage/lcov.info
--output-file periphery_unit_coverage.info
- name: Upload combined unit test lcov file
Expand Down Expand Up @@ -629,12 +628,12 @@ jobs:
- name: Install lcov
run: sudo apt-get update && sudo apt-get install lcov
- name: Combine integration test coverage
run: lcov -a account_integration_test_coverage/lcov.info
-a oracle_integration_test_coverage/lcov.info
-a oracle_sepolia_integration_test_coverage/lcov.info
-a order_integration_test_coverage/lcov.info
-a vault_integration_test_coverage/lcov.info
-a extensions_integration_test_coverage/lcov.info
run: lcov -a account_integration_test_coverage/lcov.info
-a oracle_integration_test_coverage/lcov.info
-a oracle_sepolia_integration_test_coverage/lcov.info
-a order_integration_test_coverage/lcov.info
-a vault_integration_test_coverage/lcov.info
-a extensions_integration_test_coverage/lcov.info
--output-file periphery_integration_coverage.info
- name: Upload combined integration test lcov file
uses: actions/upload-artifact@v3
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

## 📦 Packages

| Package | Description | Latest Version |
| -------------------------- | :-------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------: |
| `@perennial-v2` | Core perennial smart contracts. | [![npm version](https://badge.fury.io/js/@equilibria%2Fperennial-v2.svg)](https://badge.fury.io/js/@equilibria%2Fperennial-v2) |
| `@perennial-v2-deploy` | Deployment scripts and artifacts. | [![npm version](https://badge.fury.io/js/@equilibria%2Fperennial-v2-deploy.svg)](https://badge.fury.io/js/@equilibria%2Fperennial-v2-deploy) |
| `@perennial-v2-extensions` | Extension smart contracts. | [![npm version](https://badge.fury.io/js/@equilibria%2Fperennial-v2-extensions.svg)](https://badge.fury.io/js/@equilibria%2Fperennial-v2-extensions) |
| `@perennial-v2-oracle` | Oracle provider smart contracts. | [![npm version](https://badge.fury.io/js/@equilibria%2Fperennial-v2-oracle.svg)](https://badge.fury.io/js/@equilibria%2Fperennial-v2-oracle) |
| `@perennial-v2-vault` | Vault smart contracts. | [![npm version](https://badge.fury.io/js/@equilibria%2Fperennial-v2-vault.svg)](https://badge.fury.io/js/@equilibria%2Fperennial-v2-vault) |
| Package | Description | Latest Version |
| ----------------------- | :-------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------: |
| `@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/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) |

## 🔗 Resources

Expand Down Expand Up @@ -40,7 +40,7 @@ This also generates the Typechain types

### Test

Perennial has 4 logic packages: `perennial-v2`, `perennial-v2-extensions`, `perennial-v2-oracle`, and `perennial-v2-vault`
Perennial has 4 logic packages: `core`, `deploy`, `extensions`, `oracle`, and `vault`

Run the Mocha unit tests a specific package:

Expand All @@ -51,7 +51,7 @@ $ yarn workspace @equilibria/<package-name> run test
For example, to run the tests for the core package:

```sh
$ yarn workspace @equilibria/perennial-v2 run test
$ yarn workspace @perennial/core run test
```

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

```sh
$ yarn workspace @equilibria/perennial-v2 run test:integration
$ yarn workspace @perennial/core run test:integration
```

## 🔐 Security
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"@codechecks/client": "^0.1.10",
"@defi-wonderland/smock": "^2.0.7",
"@equilibria/root": "2.3.0-rc7",
"@equilibria/root": "2.3.0-rc8",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
"@nomicfoundation/hardhat-toolbox": "2.0.2",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/testutil/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface MarketParameter {
riskFee: BigNumberish
maxPendingGlobal: number
maxPendingLocal: number
maxPriceDeviation: BigNumberish
closed: boolean
settle: boolean
}
Expand Down Expand Up @@ -356,6 +357,7 @@ export const DEFAULT_MARKET_PARAMETER: MarketParameter = {
riskFee: 0,
maxPendingGlobal: 0,
maxPendingLocal: 0,
maxPriceDeviation: 0,
closed: false,
settle: false,
}
Expand Down
4 changes: 2 additions & 2 deletions packages/perennial-account/contracts/Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Token6 } from "@equilibria/root/token/types/Token6.sol";
import { Token18 } from "@equilibria/root/token/types/Token18.sol";

import { IAccount } from "./interfaces/IAccount.sol";
import { IMarket, Position } from "@equilibria/perennial-v2/contracts/interfaces/IMarket.sol";
import { IMarket, Position } from "@perennial/core/contracts/interfaces/IMarket.sol";

/// @title Account
/// @notice Collateral Accounts allow users to manage collateral across Perennial markets
Expand Down Expand Up @@ -108,4 +108,4 @@ contract Account is IAccount, Instance {
if (msg.sender != owner && msg.sender != address(factory())) revert AccountNotAuthorizedError();
_;
}
}
}
16 changes: 15 additions & 1 deletion packages/perennial-account/contracts/AccountVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.24;
import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import { VerifierBase } from "@equilibria/root/verifier/VerifierBase.sol";
import { IMarketFactory } from "@perennial/core/contracts/interfaces/IMarketFactory.sol";

import { IAccountVerifier } from "./interfaces/IAccountVerifier.sol";
import { IRelayVerifier } from "./interfaces/IRelayVerifier.sol"; // only needed for docstrings
Expand All @@ -21,8 +22,13 @@ import { RelayedAccessUpdateBatch, RelayedAccessUpdateBatchLib } from "./types/R
/// @title Verifier
/// @notice ERC712 signed message verifier for the Perennial V2 Collateral Accounts package.
contract AccountVerifier is VerifierBase, IAccountVerifier {
/// @dev market factory to check authorization
IMarketFactory internal immutable marketFactory;

/// @dev Initializes the domain separator and parameter caches
constructor() EIP712("Perennial V2 Collateral Accounts", "1.0.0") { }
constructor(IMarketFactory _marketFactory) EIP712("Perennial V2 Collateral Accounts", "1.0.0") {
marketFactory = _marketFactory;
}

/// @inheritdoc IAccountVerifier
function verifyAction(Action calldata action, bytes calldata signature)
Expand Down Expand Up @@ -148,4 +154,12 @@ contract AccountVerifier is VerifierBase, IAccountVerifier {
outerSignature
)) revert VerifierInvalidSignerError();
}

/// @notice Checks whether signer is allowed to sign a message for account
/// @param account user to check authorization for (not the collateral account)
/// @param signer address which signed a message for the account
/// @return true if signer is authorized, otherwise false
function _authorized(address account, address signer) internal view override returns (bool) {
return super._authorized(account, signer) || marketFactory.signers(account, signer);
}
}
Loading

0 comments on commit 8085045

Please sign in to comment.