Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #19 from vesperfi/open-source
Browse files Browse the repository at this point in the history
Open source V2 work
  • Loading branch information
rokso authored Aug 27, 2021
2 parents 9f53e95 + 5f0bf82 commit df525ce
Show file tree
Hide file tree
Showing 142 changed files with 61,422 additions and 17,119 deletions.
19 changes: 13 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@
"web3": false,
"describe": false
},
"rules":{
"rules": {
"mocha/no-top-level-hooks": "off",
"mocha/no-hooks-for-single-case": "off"
"mocha/no-hooks-for-single-case": "off",
"mocha/no-exports": "off",
"mocha/no-setup-in-describe": "off"
}
},
{
"files": ["migrations/*.js"],
"files": ["hardhat*", "tasks/*"],
"globals": {
"artifacts": "readonly"
"ethers": false,
"hre": false,
"run": false,
"task": false,
"types": false
}
}
],
Expand All @@ -35,7 +41,8 @@
}
],
"jsdoc/require-jsdoc": "off",
"max-len": ["error", { "code": 120 }],
"semi": ["error", "never"]
"max-len": ["error", {"code": 120}],
"semi": ["error", "never"],
"quotes": ["error", "single"]
}
}
4 changes: 0 additions & 4 deletions .github/workflows/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,3 @@ jobs:
run: npm install
- name: Running Pool lifecycle tests
run: npm test "test/onlyController.js"
- name: Running Timelock tests
env:
NODE_URL: ${{env.NODE_URL}}
run: npm test "test/timelock.js"
28 changes: 28 additions & 0 deletions .github/workflows/governor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Governor
on: [pull_request]

jobs:
governor:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12]
steps:
- uses: actions/[email protected]
with:
submodules: true
- run: cat "${GITHUB_WORKSPACE}/.github/env.properties" >> $GITHUB_ENV
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Run npm install with node v${{ matrix.node }}
run: npm install
- name: Running Governor tests
env:
NODE_URL: ${{env.NODE_URL}}
run: npm test "test/governor-vsp.js"
- name: Running multi transfer tests
env:
NODE_URL: ${{env.NODE_URL}}
run: npm test "test/multitransfer.js"
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: vWBTC with AaveMakerStrategy
name: Payment Splitter
on: [pull_request]

jobs:
vwbtc-aave-test:
payment-splitter-test:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -18,7 +18,7 @@ jobs:
node-version: ${{ matrix.node }}
- name: Run npm install with node v${{ matrix.node }}
run: npm install
- name: Running vWBTC pool tests with AaveMakerStrategy
- name: Running Payment splitter tests
env:
NODE_URL: ${{env.NODE_URL}}
run: npm test "test/vwbtc-aave-maker.js"
run: npm test "test/payment-splitter.js"
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: vETH with AaveMakerStrategy
name: vDAI with VesperV3Strategy
on: [pull_request]

jobs:
veth-aave-maker-test:
vdai-vesper-v3-test:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -18,7 +18,7 @@ jobs:
node-version: ${{ matrix.node }}
- name: Run npm install with node v${{ matrix.node }}
run: npm install
- name: Running tests of vETH pool with AaveMakerStrategy
- name: Running tests of vDAI pool with VesperV3Strategy
env:
NODE_URL: ${{env.NODE_URL}}
run: npm test "test/veth-aave-maker.js"
run: npm test "test/vdai-vesper-v3.js"
6 changes: 5 additions & 1 deletion .github/workflows/vsp-and-vvsp-pool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ jobs:
- name: Running vVSP pool tests
env:
NODE_URL: ${{env.NODE_URL}}
run: npm test "test/vvsp-eth.js"
run: npm test "test/vvsp-eth.js"
- name: Running vVSP auctions tests
env:
NODE_URL: ${{env.NODE_URL}}
run: npm test "test/vvsp-auctions.js"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ coverage.json
.coverage*
.idea/
*.iml

# Hard hat
artifacts
cache
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v12.13.0
9 changes: 8 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"printWidth": 100,
"overrides": [
{
"files": ["test/*.js", "test/**/*.js"],
"files": [
"test/*.js",
"test/**/*.js",
"migrations/*.js",
"*.js"
],
"options": {
"semi": false,
"singleQuote": true,
"printWidth": 120
}
}
Expand Down
50 changes: 32 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,61 @@ Please read and get familiar with [Vesper](https://docs.vesper.finance/). This r

## Setup

1. Install
1. Install

```sh
git clone --recursive https://github.com/vesperfi/vesper-pools.git
cd vesper-pools
npm install
npm run truffle compile
npm install
npm run compile
```

2. set NODE_URL in env
```sh
export NODE_URL=<eth mainnet url>
```

```sh
export NODE_URL=<eth mainnet url>
```

3. Test

Note: These tests will fork the mainnet as required in step 3. It is not recommended to run all tests at once, but rather to specify a single file.

- Run single file
```sh
npm test test/veth-aave.js
```
- Run single file

- Or run them all (but some will fail, because of state modifications to the forked chain)
```sh
npm test
```
```sh
npm test test/veth-aave.js
```

- Or run them all (but some will fail, because of state modifications to the forked chain)

```sh
npm test
```

## Mainnet fork deployment

Fork mainnet using ganache
```sh
npm run fork
```

```sh
npm run fork
```

## Run test with coverage

Coverage will launch its own in-process ganache server, so all you need to run is below command.

```sh
npm run coverage
```

Coverage for one file

```
npm run coverage -- --testfiles "<<filename>>"
```

If you get heap memory error in solidity coverage then try below command
```sh
node --max-old-space-size=4096 ./node_modules/.bin/truffle run coverage
node --max-old-space-size=4096 ./node_modules/.bin/hardhat coverage --testfiles "fileName"
```

6 changes: 5 additions & 1 deletion contracts/Controller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ contract Controller is Owned {
founderFee = _founderFee;
}

function updateInterestFee(address _pool, uint256 _interestFee) external onlyOwner {
function updateInterestFee(address _pool, uint256 _interestFee)
external
onlyOwner
validPool(_pool)
{
require(_interestFee <= 1e18, "Fee limit reached");
require(feeCollector[_pool] != address(0), "FeeCollector not set");
interestFee[_pool] = _interestFee;
Expand Down
35 changes: 20 additions & 15 deletions contracts/Owned.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,34 @@ contract Ownable is Context {

/**
* @dev Contract module extends Ownable and provide a way for safe transfer ownership.
* New owner has to call acceptOwnership in order to complete ownership trasnfer.
* Proposed owner has to call acceptOwnership in order to complete ownership trasnfer.
*/
contract Owned is Ownable {
address private _newOwner;
address private _proposedOwner;

/**
* @dev Initiate transfer ownership of the contract to a new account (`newOwner`).
* @dev Initiate transfer ownership of the contract to a new account (`proposedOwner`).
* Can only be called by the current owner. Current owner will still be owner until
* new owner accept ownership.
* @param newOwner new owner address
* proposed owner accept ownership.
* @param proposedOwner proposed owner address
*/
function transferOwnership(address newOwner) public override onlyOwner {
require(newOwner != address(0), "New owner is the zero address");
_newOwner = newOwner;
function transferOwnership(address proposedOwner) public override onlyOwner {
//solhint-disable-next-line reason-string
require(proposedOwner != address(0), "Proposed owner is the zero address");
_proposedOwner = proposedOwner;
}

/**
* @dev Allows new owner to accept ownership of the contract.
*/
/// @dev Allows proposed owner to accept ownership of the contract.
function acceptOwnership() public {
require(msg.sender == _newOwner, "Caller is not the new owner");
emit OwnershipTransferred(_owner, _newOwner);
_owner = _newOwner;
_newOwner = address(0);
require(msg.sender == _proposedOwner, "Caller is not the proposed owner");
emit OwnershipTransferred(_owner, _proposedOwner);
_owner = _proposedOwner;
_proposedOwner = address(0);
}

function renounceOwnership() public override onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
_proposedOwner = address(0);
}
}
Loading

0 comments on commit df525ce

Please sign in to comment.