Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
39fd8be
Configure hardhat, add patch scripts, eth-optimism and hardhat-sizer …
cgewecke Apr 28, 2021
fec8aaf
Select initial contract set for ovm compilation / add ovm friendly OZ…
cgewecke Apr 28, 2021
728fe56
Minimize circleci (for now)
cgewecke Apr 29, 2021
e0a2d73
Use minimized circleci
cgewecke Apr 29, 2021
4738629
Restructure SetToken.sol to reduce size & make deployable to ovm
cgewecke Apr 29, 2021
05122ef
Add library linking in deployers / fixtures
cgewecke Apr 30, 2021
581bad4
Fix circleci rebase error
cgewecke Apr 30, 2021
7713be0
Add optimism client to CI and test set core deployment
cgewecke Apr 30, 2021
66bb954
Speed up build with pull?
cgewecke May 1, 2021
f50f31e
Remove extra build and compile steps
cgewecke May 1, 2021
9e5fbef
Refactor tests for HardhatEVM & OptimisticEVM / fix contracts
cgewecke May 3, 2021
77618a4
Use self-published builds for speedup
cgewecke May 3, 2021
f5d3c88
Add L1 -> L2 Eth deposits, L2 WETH helpers, add to setToken tests
cgewecke May 4, 2021
395a0b3
Substitute WETH transfer for `value` in OZ Address.sol#functionCallWi…
cgewecke May 12, 2021
4d6cff5
Fix tsc production build error caused by node_modules package
cgewecke May 12, 2021
37b37e2
Use gchr.io/setprotocol published optimism client images
cgewecke May 12, 2021
f2bb77d
Reduce SetToken size by commenting out events (temporarily)
cgewecke May 13, 2021
4cd7d6f
Add HardhatEVM CI job and mocha grepping logic
cgewecke May 13, 2021
80db055
Add OVM revert helpers / run setToken tests on OVM in CI
cgewecke May 13, 2021
6dc1c33
Add optimism client install & run scripts
cgewecke May 13, 2021
f834ec5
Fix const error
cgewecke May 13, 2021
48a2f88
Fix ci scripts
cgewecke May 13, 2021
28d0332
Run smaller subset of SetToken tests on Optimism client
cgewecke May 13, 2021
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
89 changes: 21 additions & 68 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ version: 2

jobs:
checkout_and_compile:
docker:
- image: circleci/node:10.16.0
environment:
NODE_OPTIONS: --max_old_space_size=8192
machine:
image: ubuntu-2004:202010-01
resource_class: large
working_directory: ~/set-protocol-v2
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: false
- restore_cache:
key: module-cache-{{ checksum "yarn.lock" }}
- run:
Expand All @@ -35,90 +31,50 @@ jobs:
docker:
- image: circleci/node:10.16.0
working_directory: ~/set-protocol-v2
parallelism: 3
steps:
- setup_remote_docker:
docker_layer_caching: false
- run:
name: Fetch solc version
command: docker pull ethereum/solc:0.6.10
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Set Up Environment Variables
command: cp .env.default .env
- run:
name: Re-compile for HardhatEVM
command: yarn compile --force
- run:
name: Test RPC
command: yarn chain
background: true
- run:
name: Hardhat Test
command: |
TEST_FILES="$(circleci tests glob "./test/**/*.spec.ts" | circleci tests split --split-by=timings)"
yarn test ${TEST_FILES}
command: yarn test:fast

coverage:
docker:
- image: circleci/node:10.11.0
test_ovm:
machine:
image: ubuntu-2004:202010-01
docker_layer_caching: true
working_directory: ~/set-protocol-v2
# When changing the parallelism value, you also
# need to update the `persist_to_workspace` paths
# in this job (below) as well as the list of files passed
# to istanbul-combine in the `report_coverage` job
parallelism: 5
steps:
- setup_remote_docker:
docker_layer_caching: false
- run:
name: Fetch solc version
command: docker pull ethereum/solc:0.6.10
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Set Up Environment Variables
command: cp .env.default .env
- run:
name: Create shared coverage outputs folder
command: mkdir -p /tmp/coverage
- run:
name: Coverage
name: Docker ghcr.io login
command: |
TEST_FILES="{$(circleci tests glob "./test/**/*.spec.ts" | \
circleci tests split --split-by=timings | xargs | sed -e 's/ /,/g')}"
yarn coverage -- --testfiles "$TEST_FILES"
docker login ghcr.io -u $DOCKER_USER -p $DOCKER_PASSWORD
- run:
name: Save coverage
command: |
cp coverage.json /tmp/coverage/cov_$CIRCLE_NODE_INDEX.json
chmod -R 777 /tmp/coverage/cov_$CIRCLE_NODE_INDEX.json
- persist_to_workspace:
root: /tmp/coverage
paths:
- cov_0.json
- cov_1.json
- cov_2.json
- cov_3.json
- cov_4.json

report_coverage:
docker:
- image: circleci/node:10.11.0
working_directory: ~/set-protocol-v2
steps:
- attach_workspace:
at: /tmp/coverage
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
name: Install Optimism client
command: yarn ovm:install
- run:
name: Combine coverage reports
command: |
mkdir -p reports
cp -R /tmp/coverage/* .
npx istanbul-combine-updated -r lcov cov_0.json cov_1.json cov_2.json cov_3.json cov_4.json
name: Launch Optimism client
command: yarn ovm:run:ci
- run:
name: Upload coverage
name: Test
command: |
cat coverage/lcov.info | node_modules/.bin/coveralls
yarn ovm:fundl2EthAccounts
yarn test:ovm:fast test/protocol/core.spec.ts
yarn test:ovm:fast test/protocol/setToken.spec.ts

workflows:
version: 2
Expand All @@ -128,9 +84,6 @@ workflows:
- test:
requires:
- checkout_and_compile
- coverage:
- test_ovm:
requires:
- checkout_and_compile
- report_coverage:
requires:
- coverage
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.DS_Store
/artifacts
/artifacts-ovm
/build
/cache
/cache-ovm
/optimism
/dist
/etherscan
/flatten
Expand Down
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,41 @@
## Contracts
[Set Protocol](https://setprotocol.com/) is a specification for tokenized asset management strategies on the ethereum blockchain written in the Solidity programming language. We use [Hardhat](https://hardhat.org/) as a development environment for compiling, testing, and deploying our contracts.

## Development
## Optimism

To use console.log during Solidity development, follow the [guides](https://hardhat.org/guides/hardhat-console.html).
**Install the Optimism client**

## Available Functionality
```
yarn ovm:install
```

**Run**

This command spins up several services and takes a couple minutes to get going. It's ready
when the log output shows `l2geth_1` blocks mining.
```
# In a separate terminal (use ctrl-c to stop)
yarn ovm:run
```

### Run Hardhat EVM
**Fund L2 accounts from L1 via bridge**
```
yarn ovm:fundl2EthAccounts
```

`yarn chain`
## Available Functionality

### Run Optimism OVM
```
cd optimism/ops
docker-compose up
```

### Build Contracts

`yarn compile`
`yarn compile:ovm`

To speed up compilation, install solc 0.6.10 natively with the following command.
To speed up compilation, install solc 0.6.12 natively with the following command.
```
brew install https://raw.githubusercontent.com/ethereum/homebrew-ethereum/06d13a8499801dc3ea4f19b2d24ed2eeb3072ebb/solidity.rb
```
Expand All @@ -35,9 +55,7 @@ brew install https://raw.githubusercontent.com/ethereum/homebrew-ethereum/06d13a

### Run Contract Tests

`yarn test` to run compiled contracts

OR `yarn test:clean` if contracts have been typings need to be updated
`yarn test:ovm` to run compiled contracts

### Run Coverage Report for Tests

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IBasicIssuanceModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IExchangeAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IIndexExchangeAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IIntegrationRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IManagerIssuanceHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IModuleIssuanceHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IOracleAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
17 changes: 5 additions & 12 deletions contracts/interfaces/ISetToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;
pragma experimental "ABIEncoderV2";
Expand Down Expand Up @@ -118,19 +116,14 @@ interface ISetToken is IERC20 {
function moduleStates(address _module) external view returns (ModuleState);
function getModules() external view returns (address[] memory);

function getDefaultPositionRealUnit(address _component) external view returns(int256);
function getExternalPositionRealUnit(address _component, address _positionModule) external view returns(int256);
function getComponents() external view returns(address[] memory);
function getComponents() external view returns (address[] memory);
function getExternalPositionVirtualUnit(address _component, address _module) external view returns (int256);
function getDefaultPositionVirtualUnit(address _component) external view returns (int256);
function getComponentExternalPosition(address _component, address _positionModule) external view returns (ExternalPosition memory);
function getExternalPositionModules(address _component) external view returns(address[] memory);
function getExternalPositionData(address _component, address _positionModule) external view returns(bytes memory);
function isExternalPositionModule(address _component, address _module) external view returns(bool);
function isComponent(address _component) external view returns(bool);

function positionMultiplier() external view returns (int256);
function getPositions() external view returns (Position[] memory);
function getTotalComponentRealUnits(address _component) external view returns(int256);

function isInitializedModule(address _module) external view returns(bool);
function isPendingModule(address _module) external view returns(bool);
function isLocked() external view returns (bool);
}
}
2 changes: 0 additions & 2 deletions contracts/interfaces/ISetValuer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;

Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IStreamingFeeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/
pragma solidity 0.6.12;
pragma experimental "ABIEncoderV2";
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/external/ICErc20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/

pragma solidity 0.6.12;
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/external/ISynth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/

pragma solidity 0.6.12;
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/external/ISynthetixExchanger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.

SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/

pragma solidity 0.6.12;
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/external/IUniswapV2Pair.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache License, Version 2.0

// @unsupported: ovm
*/

pragma solidity 0.6.12;
Expand Down
Loading