Skip to content

Commit

Permalink
Upgrade 3CRV Convex Meta Vault (#84)
Browse files Browse the repository at this point in the history
* feat: Added afterRemoveVault hook and updateAssestsPerShare after vault is removed

* feat: test for update assetsPerShare after removal of underlyingVault

* Hardhat tasks to snap vault data (#72)

* chore: small update to vault deposit and mint HH tasks
* chore: removed links to missing FraxBP diagrams

* feat: added convex-3crv-snap HH task
chore: added assets in underlying vaults to convex-3crv-mv-snap HH task

* chore: test to get data for a worked sandwich attack on a Convex 3Crv vault

* chore: added collected fees to vault snaps

* chore: added worked Curve Metapools example for article

* Docs and fork tests (#73)

* chore: added process diagram for chargePerformanceFee

* chore: README updated

* chore: fork test donation of USDT and DAI

* chore: Added maxFee protection to liq-init-swap HH task
chore: better reporting of rewards in liq-collect-rewards HH task

* chore: add gas price to liq-init-swap HH task

* chore: HH task liq-donate-tokens further parameterized

* Fix to charge performance fee (#75)

* chore: Updated HH task convex-3crv-snap

* chore: added stored assets/share to convex-3crv-mv-snap HH task
fix: logs in mv-charge-perf-fee HH task

* fix: charge of performance fee needs to store assets per share with fee shares included

* chore: updated PerfFeeAbstractVault version

* chore: added docgen script using solidity-docgen

* chore: Added HH task vault-max-withdraw

* feat: Added HH task vault-slippage to measure deposit and redeem slippage

* chore: README updated with docgen

* chore: creates npm publish action (#78)

* chore: creates npm publish action

* chore: adds comments to npmrc

* chore: updates github actions to do not run when draft

* chore: updates github actions to do not run when draft

* chore: updates publish config on web-config.ts

* test: increase test coverage on Liquidator (#79)

* test: increse test coverage on Liquidator

* chore: simplified Curve library tests (#81)

* fix: to Curve3CrvAbstractMetaVault reset allowance

* test: increase test coverage on libraries

* chore: added updateAssetPerShare and chargePerformanceFee to fork tests

* chore: removed modules not used by metavaults

* chore: increased coverage of Curve3CrvMetapoolCalculatorLibrary

* chore: bumper version to 0.0.6

* hardhat deploy tasks have optional proxy flag (#85)

* feat: added optional proxy flag to contract deployments so only the implementation can be deployed

* chore: removed unused import in liquidator Hardhat tasks file

Co-authored-by: Nick Addison <nick@addisonbrown.com.au>
Co-authored-by: tushargargght <tushargargght@gmail.com>
Co-authored-by: doncesarts <doncesarts@gmail.com>
  • Loading branch information
3 people committed Nov 21, 2022
1 parent 8ac027a commit 02754fc
Show file tree
Hide file tree
Showing 65 changed files with 2,238 additions and 1,052 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install
- run: yarn compile
- run: yarn lint-ts

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GH_NPM_TOKEN}}
2 changes: 1 addition & 1 deletion .github/workflows/slither.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- master
- release-v*

- main
jobs:
analyze:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-fork.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
on: ["push"]
name: Test-Forks

jobs:
build:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-vaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on: ["push"]
name: Test-Vaults
jobs:
build:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ artifacts
# Typechain
/types/generated

docs/natspec

# VS Code Solidity Extension
bin/contracts

Expand Down
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@mstable:registry=https://npm.pkg.github.com
# Github Package Registry
# @mstable:registry=https://npm.pkg.github.com
1 change: 1 addition & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
skipFiles: [
"integrations",
"upgradability",
"contracts/interfaces",
"./vault/liquidity/convex/Convex3CrvBasicVault.sol",
"./shared/SafeCastExtended.sol",
"z_mocks",
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Key folders:

## Testing

Tests are written with [Hardhat](https://hardhat.org/), [Ethers.js](https://docs.ethers.io), [Waffle](https://ethereum-waffle.readthedocs.io/) & [Typescript](https://www.typescriptlang.org/), using [Typechain](https://github.com/dethcrypto/TypeChain) to generate typings for all contracts. Tests are executed using `hardhat` in hardhats evm.
Tests are written with [Hardhat](https://hardhat.org/), [Ethers.js](https://docs.ethers.io), [Mocha](https://mochajs.org/) & [Typescript](https://www.typescriptlang.org/), using [Typechain](https://github.com/dethcrypto/TypeChain) to generate typings for all contracts. Tests are executed using `hardhat` in hardhats evm.

```
$ yarn test
Expand All @@ -84,7 +84,7 @@ $ yarn test

[Solidity-coverage](https://github.com/sc-forks/solidity-coverage) is used to run coverage analysis on test suite.

This produces reports that are visible in the `/coverage` folder, and navigatable/uploadable. Ultimately they are used as a reference that there is some sort of adequate cover, although they will not be a source of truth for a robust test framework. Reports publically available on [coveralls](https://coveralls.io/github/mstable/metavaults).
This produces reports that are visible in the `/coverage` folder, and navigatable/uploadable. Ultimately they are used as a reference that there is some sort of adequate cover, although they will not be a source of truth for a robust test framework. Reports are publicly available on [coveralls](https://coveralls.io/github/mstable/metavaults).

_NB: solidity-coverage runs with solc `optimizer=false` (see [discussion](https://github.com/sc-forks/solidity-coverage/issues/417))_

Expand Down Expand Up @@ -177,6 +177,18 @@ export NODE_URL=https://mainnet.infura.io/v3/yourApiKey
yarn task token-transfer --network mainnet --asset MTA --recipient mStableDAO -- amount 1000
```

## Document generation from Natspec

The contract Natspec can be generated into a markdown file in the `docs/natspec` folder using the following command.

```
yarn docgen
```

The markdown for the relevant contracts can then be copied into GitBook.

Unfortunately the generated markdown will not include inherited classes. These need to be manually include for now.

## Other mStable Meta Vault repositories

- https://github.com/mstable/mStable-defender
Expand Down
82 changes: 0 additions & 82 deletions SecondMetaVaultAudit.md

This file was deleted.

51 changes: 51 additions & 0 deletions contracts/interfaces/ILiquidatorV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.17;

/**
* @title Collects reward tokens from vaults, swaps them and donated the purchased token back to the vaults.
* Supports asynchronous and synchronous swaps.
* @author mStable
* @dev VERSION: 1.0
* DATE: 2022-05-11
*/
interface ILiquidatorV2 {
function collectRewards(address[] memory vaults)
external
returns (
address[][] memory rewardTokens,
uint256[][] memory rewards,
address[][] memory purchaseTokens
);

function initiateSwap(
address rewardToken,
address assetToken,
bytes memory data
) external returns (uint256 batch, uint256 rewards);

function swap(
address rewardToken,
address assetToken,
uint256 minAssets,
bytes memory data
)
external
returns (
uint256 batch,
uint256 rewards,
uint256 assets
);

function initiateSwaps(
address[] memory rewardTokens,
address[] memory assetTokens,
bytes[] memory datas
) external returns (uint256[] memory batchs, uint256[] memory rewards);

function settleSwaps(
address[] memory rewardTokens,
address[] memory assetTokens,
uint256[] memory assets,
bytes[] memory datas
) external returns (uint256[] memory batchs, uint256[] memory rewards);
}
Loading

0 comments on commit 02754fc

Please sign in to comment.