Skip to content

Commit

Permalink
Merge branch 'main' into sip-326-332-333-334
Browse files Browse the repository at this point in the history
  • Loading branch information
Rickk137 authored Aug 13, 2023
2 parents eb581ba + b0e1a51 commit e27cd83
Show file tree
Hide file tree
Showing 14 changed files with 378 additions and 106 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/check-packages.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: "Validate yarn.lock and cache"

on: [pull_request]
on:
pull_request: {}
push:
branches:
- "main"

jobs:
check:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Lint
on: [push]

on:
pull_request: {}
push:
branches:
- "main"

jobs:
lint:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/simulate-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
CANNON_IPFS_URL: "http://127.0.0.1:5001"
CANNON_PUBLISH_IPFS_URL: "http://127.0.0.1:5001"
strategy:
fail-fast: false
matrix:
network: [goerli, optimistic-goerli]
project: [protocol/oracle-manager, protocol/synthetix]
Expand Down
114 changes: 114 additions & 0 deletions .github/workflows/test-with-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Coverage

on:
push:
branches:
- "main"

jobs:
coverage:
runs-on: ubuntu-latest
env:
CANNON_IPFS_URL: "http://127.0.0.1:5001"
CANNON_PUBLISH_IPFS_URL: "http://127.0.0.1:5001"
strategy:
fail-fast: false
matrix:
workspace: [
"@synthetixio/main",
"@synthetixio/oracle-manager",
# "@synthetixio/governance", # no tests :/

"@synthetixio/core-contracts",
"@synthetixio/core-utils",
"@synthetixio/core-modules",
"@synthetixio/hardhat-storage",
"@synthetixio/sample-project",

# "@synthetixio/legacy-market", # tests fail
"@synthetixio/spot-market",
"@synthetixio/perps-market",

"@synthetixio/core-subgraph",
"@synthetixio/spot-market-subgraph",
"@synthetixio/perps-market-subgraph",
]

include:
- workspace: "@synthetixio/main"
codecov-file: protocol/synthetix/coverage.json
codecov-flags: main

- workspace: "@synthetixio/oracle-manager"
codecov-file: protocol/oracle-manager/coverage.json
codecov-flags: oracle-manager

- workspace: "@synthetixio/core-contracts"
codecov-file: utils/core-contracts/coverage.json
codecov-flags: core-contracts

- workspace: "@synthetixio/core-utils"
codecov-file: utils/core-utils/coverage/lcov.info
codecov-flags: core-utils

- workspace: "@synthetixio/core-modules"
codecov-file: utils/core-modules/coverage.json
codecov-flags: core-modules

- workspace: "@synthetixio/hardhat-storage"
codecov-file: utils/hardhat-storage/coverage/lcov.info
codecov-flags: hardhat-storage

- workspace: "@synthetixio/sample-project"
codecov-file: utils/sample-project/coverage.json
codecov-flags: sample-project

steps:
- name: Install Foundry (Cannon)
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- run: anvil -V
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16.20.1"
cache: "yarn"
- uses: ibnesayeed/setup-ipfs@92d412e0dad36c06ffab50733e9c624896a0964f
with:
run_daemon: true

- run: yarn install --immutable --immutable-cache
- run: yarn workspaces foreach --topological-dev --recursive --verbose --from "${{ matrix.workspace }}" run build:ts
- run: yarn workspaces foreach --topological-dev --recursive --verbose --from "${{ matrix.workspace }}" run build-testable

- name: Execute size-contracts command
run: |
if yarn workspace ${{ matrix.workspace }} run | grep size-contracts; then
yarn workspace ${{ matrix.workspace }} run size-contracts
else
echo 'SKIP. No "size-contracts" script'
fi
- name: Check storage.dump.sol is up-to-date
run: |
if yarn workspace ${{ matrix.workspace }} run | grep check:storage; then
yarn workspace ${{ matrix.workspace }} run check:storage
else
echo 'SKIP. No "check:storage" script'
fi
- name: Execute tests with coverage
run: |
if yarn workspace ${{ matrix.workspace }} run | grep coverage; then
REPORT_GAS=true yarn workspace ${{ matrix.workspace }} run coverage
else
echo 'SKIP. No "coverage" script'
fi
- if: ${{ matrix.codecov-file }}
name: Upload ${{ matrix.workspace }} coverage to Codecov
uses: codecov/codecov-action@v2
with:
files: ${{ matrix.codecov-file }}
flags: ${{ matrix.codecov-flags }}
82 changes: 25 additions & 57 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,36 @@ name: Test

on:
pull_request: {}
push:
branches:
- "main"

jobs:
test:
runs-on: ubuntu-latest
continue-on-error: true
env:
CANNON_IPFS_URL: "http://127.0.0.1:5001"
CANNON_PUBLISH_IPFS_URL: "http://127.0.0.1:5001"
strategy:
fail-fast: false
matrix:
package:
[
core-contracts,
core-utils,
core-modules,
sample-project,
main,
oracle-manager,
spot-market,
perps-market,
core-subgraph,
spot-market-subgraph,
perps-market-subgraph,
workspace: [
"@synthetixio/main",
"@synthetixio/oracle-manager",
# "@synthetixio/governance", # no tests :/

"@synthetixio/core-contracts",
"@synthetixio/core-utils",
"@synthetixio/core-modules",
"@synthetixio/hardhat-storage",
"@synthetixio/sample-project",

# "@synthetixio/legacy-market", # tests fail
"@synthetixio/spot-market",
"@synthetixio/perps-market",

"@synthetixio/core-subgraph",
"@synthetixio/spot-market-subgraph",
"@synthetixio/perps-market-subgraph",
]
include:
- package: core-contracts
workspace: "@synthetixio/core-contracts"
coverage-file: utils/core-contracts/coverage.json
- package: core-utils
workspace: "@synthetixio/core-utils"
coverage-file: utils/core-utils/coverage/lcov.info
- package: core-modules
workspace: "@synthetixio/core-modules"
coverage-file: utils/core-modules/coverage.json
- package: sample-project
workspace: "@synthetixio/sample-project"
- package: oracle-manager
workspace: "@synthetixio/oracle-manager"
- package: spot-market
workspace: "@synthetixio/spot-market"
- package: perps-market
workspace: "@synthetixio/perps-market"
- package: main
workspace: "@synthetixio/main"
- package: core-subgraph
workspace: "@synthetixio/core-subgraph"
- package: spot-market-subgraph
workspace: "@synthetixio/spot-market-subgraph"
- package: perps-market-subgraph
workspace: "@synthetixio/perps-market-subgraph"

steps:
- name: Install Foundry (Cannon)
uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -71,10 +48,8 @@ jobs:
run_daemon: true

- run: yarn install --immutable --immutable-cache

- run: yarn workspaces foreach --topological-dev --recursive --verbose --from ${{ matrix.workspace }} run build:ts

- run: yarn workspaces foreach --topological-dev --recursive --verbose --from ${{ matrix.workspace }} run build-testable
- run: yarn workspaces foreach --topological-dev --recursive --verbose --from "${{ matrix.workspace }}" run build:ts
- run: yarn workspaces foreach --topological-dev --recursive --verbose --from "${{ matrix.workspace }}" run build-testable

- name: Execute size-contracts command
run: |
Expand All @@ -94,15 +69,8 @@ jobs:
- name: Execute tests
run: |
if yarn workspace ${{ matrix.workspace }} run | grep coverage; then
REPORT_GAS=true yarn workspace ${{ matrix.workspace }} run coverage
if yarn workspace ${{ matrix.workspace }} run | grep test; then
REPORT_GAS=true yarn workspace ${{ matrix.workspace }} run test
else
echo 'SKIP. No "coverage" script'
echo 'SKIP. No "test" script'
fi
- if: ${{ matrix.coverage-file }}
name: Upload ${{ matrix.workspace }} coverage to Codecov
uses: codecov/codecov-action@v2
with:
files: ${{ matrix.coverage-file }}
flags: ${{ matrix.package }}
35 changes: 34 additions & 1 deletion markets/perps-market/contracts/interfaces/IAsyncOrderModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ interface IAsyncOrderModule {
address sender
);

/**
* @notice Gets fired when a new order is committed while a previous one was expired.
* @param marketId Id of the market used for the trade.
* @param accountId Id of the account used for the trade.
* @param sizeDelta requested change in size of the order sent by the user.
* @param acceptablePrice maximum or minimum, depending on the sizeDelta direction, accepted price to settle the order, set by the user.
* @param settlementTime Time at which the order can be settled.
* @param trackingCode Optional code for integrator tracking purposes.
*/
event PreviousOrderExpired(
uint128 indexed marketId,
uint128 indexed accountId,
int128 sizeDelta,
uint256 acceptablePrice,
uint256 settlementTime,
bytes32 indexed trackingCode
);

/**
* @notice Commit an async order via this function
* @param commitment Order commitment data (see AsyncOrder.OrderCommitmentRequest struct).
Expand All @@ -55,9 +73,24 @@ interface IAsyncOrderModule {
* @param marketId id of the market.
* @param sizeDelta size of position.
* @return orderFees incurred fees.
* @return fillPrice price at which the order would be filled.
*/
function computeOrderFees(
uint128 marketId,
int128 sizeDelta
) external view returns (uint256 orderFees);
) external view returns (uint256 orderFees, uint256 fillPrice);

/**
* @notice For a given market, account id, and a position size, returns the required total account margin for this order to succeed
* @dev Useful for integrators to determine if an order will succeed or fail
* @param marketId id of the market.
* @param accountId id of the trader account.
* @param sizeDelta size of position.
* @return requiredMargin margin required for the order to succeed.
*/
function requiredMarginForOrder(
uint128 marketId,
uint128 accountId,
int128 sizeDelta
) external view returns (uint256 requiredMargin);
}
Loading

0 comments on commit e27cd83

Please sign in to comment.