Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: oracles with firewalls on mint and burn #105

Merged
merged 54 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
66eb024
feat: oracles with firewalls on mint and burn
GuillaumeNervoXS Feb 27, 2024
55cb6d5
feat: oracles with target value as max
GuillaumeNervoXS Feb 27, 2024
e04c233
feat: fixed tests + test on mint and burn firewalls oracles
GuillaumeNervoXS Feb 28, 2024
9b7f422
test updateOracle
GuillaumeNervoXS Feb 29, 2024
120dd7d
feat: start testing deployment
GuillaumeNervoXS Mar 1, 2024
d29323a
feat: start scripts
GuillaumeNervoXS Mar 5, 2024
e2f708e
feat: mint and burn test done
GuillaumeNervoXS Mar 5, 2024
c383fb0
chore: try to fix linter issues
GuillaumeNervoXS Mar 5, 2024
feef55a
feat: testing done
GuillaumeNervoXS Mar 5, 2024
2f8fce5
format: prettier contracts
0xtekgrinder Mar 7, 2024
04ac2e1
chore : add scripts to ignored files in slither
0xtekgrinder Mar 7, 2024
dbe114a
chore: add uri env variables to ci tests
0xtekgrinder Mar 7, 2024
6afa900
fix: SwapTest and SavingsTest now compiles
0xtekgrinder Mar 10, 2024
bfa582e
fix part of the stack too deep when via-ir
GuillaumeNervoXS Mar 6, 2024
2742aa2
chore remap import from test
GuillaumeNervoXS Mar 6, 2024
ac8b2de
find which test files has compilation problem
GuillaumeNervoXS Mar 8, 2024
b83ff6b
fix all compilation tests except RedeemTest
GuillaumeNervoXS Mar 11, 2024
74b17b2
add back the RedeemTest
GuillaumeNervoXS Mar 11, 2024
4c6f8cf
fix redeem test compilation
GuillaumeNervoXS Mar 11, 2024
b0c9ee3
chore: setup repo inside ci
0xtekgrinder Mar 11, 2024
31b853d
chore: move setup repo action to actions subdirectory
0xtekgrinder Mar 11, 2024
54fb2dd
start burn protection for users
GuillaumeNervoXS Mar 13, 2024
41d56b5
fix firewall and user protection + tests
GuillaumeNervoXS Mar 13, 2024
218ef40
feat: add back burnRatio deviation user protection
GuillaumeNervoXS Mar 14, 2024
621d3c8
fix burnRatio protection
GuillaumeNervoXS Mar 14, 2024
93d4184
return ratio
GuillaumeNervoXS Mar 14, 2024
d509e5f
tests fixed
GuillaumeNervoXS Mar 20, 2024
cacd0fb
decimal issue
GuillaumeNervoXS Mar 20, 2024
159ed48
working tests
GuillaumeNervoXS Mar 21, 2024
f6be794
yarn prettier
GuillaumeNervoXS Mar 21, 2024
81c22ce
add bERNX + new target exposures
GuillaumeNervoXS Mar 21, 2024
df4f36e
testing after adding bERNX
GuillaumeNervoXS Mar 21, 2024
565cdaf
feat: change updateOracle to only trustedSeller only
GuillaumeNervoXS Mar 21, 2024
fb88360
add fork block number option
GuillaumeNervoXS Mar 22, 2024
d88e96d
change input to secret
GuillaumeNervoXS Mar 22, 2024
727afa6
revert prev change
GuillaumeNervoXS Mar 22, 2024
ba97362
add space
GuillaumeNervoXS Mar 22, 2024
3103458
fix: fix install
BaptistG Mar 22, 2024
0cdbe3c
update vscode settings
GuillaumeNervoXS Mar 22, 2024
6684097
reduce stack too deep
GuillaumeNervoXS Mar 22, 2024
5fa9919
fix burn test
GuillaumeNervoXS Mar 22, 2024
2c06fd8
revert deadline tests changes
GuillaumeNervoXS Mar 22, 2024
8623ccf
feat: USDA setup (#108)
sogipec Mar 25, 2024
7f4db42
Add a test on non arbitrage Mint->Burn
GuillaumeNervoXS Mar 27, 2024
60350fd
update post review
GuillaumeNervoXS Mar 27, 2024
cee97ae
removed checks on oracle update
GuillaumeNervoXS Mar 27, 2024
b75b0f0
compiling version
GuillaumeNervoXS Mar 27, 2024
e5052ff
fix tests
GuillaumeNervoXS Mar 27, 2024
b5489b0
fix all tests and deploy tests
GuillaumeNervoXS Mar 28, 2024
794b604
chore: review minor changes
GuillaumeNervoXS Mar 28, 2024
9235e72
update oracle hyperparameters
GuillaumeNervoXS Mar 28, 2024
e0f3824
remove test on no arbitrage --> impossible with the user protections
GuillaumeNervoXS Mar 28, 2024
ea38373
fix: invariant testing
GuillaumeNervoXS Mar 28, 2024
ea9f6f2
deployed update transmuter
GuillaumeNervoXS Mar 29, 2024
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
35 changes: 35 additions & 0 deletions .github/actions/setup-repo/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Setup repo
description: Runs all steps to setup the repo (install node_modules, build, etc...)
inputs:
registry-token:
description: 'PAT to access registries'
runs:
using: 'composite'
steps:
- name: Get yarn cache directory path
id: yarn-cache-dir-path
shell: bash
run: |
echo "::set-output name=dir::$(yarn cache dir)"
echo "::set-output name=version::$(yarn -v)"

- uses: actions/setup-node@v3
with:
node-version: '20'

- uses: actions/cache@v2
id: yarn-cache
with:
path: |
**/node_modules
${{ steps.yarn-cache-dir-path.outputs.dir }}

key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
shell: bash
run: echo "//npm.pkg.github.com/:_authToken=$GH_REGISTRY_ACCESS_TOKEN" >> .npmrc && yarn install --frozen-lockfile --verbose && rm -f .npmrc
env:
GH_REGISTRY_ACCESS_TOKEN: ${{ inputs.registry-token }}
29 changes: 26 additions & 3 deletions .github/workflows/ci-deep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ jobs:
node-version: 18
cache: "yarn"

- name: Setup repo
uses: ./.github/actions/setup-repo
with:
registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }}

- name: Install dependencies
run: yarn install

Expand All @@ -55,8 +60,13 @@ jobs:
with:
version: nightly

- name: Install node_modules
run: yarn install
- name: Setup repo
uses: ./.github/actions/setup-repo
with:
registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }}

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Compile foundry
run: yarn compile --sizes
Expand Down Expand Up @@ -99,6 +109,11 @@ jobs:

- name: Run Foundry tests
run: yarn test:unit
env:
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
ETH_NODE_URI_ARBITRUM: ${{ secrets.ETH_NODE_URI_ARBITRUM }}
ETH_NODE_URI_OPTIMISM: ${{ secrets.ETH_NODE_URI_OPTIMISM }}
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}

test-invariant:
needs: ["build", "lint"]
Expand Down Expand Up @@ -127,6 +142,10 @@ jobs:
env:
FOUNDRY_INVARIANT_RUNS: ${{ github.event.inputs.invariantRuns || '300' }}
FOUNDRY_INVARIANT_DEPTH: ${{ github.event.inputs.invariantDepth || '50' }}
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
ETH_NODE_URI_ARBITRUM: ${{ secrets.ETH_NODE_URI_ARBITRUM }}
ETH_NODE_URI_OPTIMISM: ${{ secrets.ETH_NODE_URI_OPTIMISM }}
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}

test-fuzz:
needs: ["build", "lint"]
Expand All @@ -153,4 +172,8 @@ jobs:
- name: Run Foundry tests
run: yarn test:fuzz
env:
FOUNDRY_FUZZ_RUNS: ${{ github.event.inputs.fuzzRuns || '10000' }}
FOUNDRY_FUZZ_RUNS: ${{ github.event.inputs.fuzzRuns || '10000' }}
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
ETH_NODE_URI_ARBITRUM: ${{ secrets.ETH_NODE_URI_ARBITRUM }}
ETH_NODE_URI_OPTIMISM: ${{ secrets.ETH_NODE_URI_OPTIMISM }}
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}
32 changes: 27 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ jobs:
node-version: 18
cache: "yarn"

- name: Install dependencies
run: yarn install
- name: Setup repo
uses: ./.github/actions/setup-repo
with:
registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }}

- name: Run solhint
run: yarn lint:check
Expand All @@ -44,8 +46,10 @@ jobs:
with:
version: nightly

- name: Install node_modules
run: yarn install
- name: Setup repo
uses: ./.github/actions/setup-repo
with:
registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }}

- name: Compile foundry
run: yarn compile --sizes
Expand Down Expand Up @@ -88,6 +92,11 @@ jobs:

- name: Run Foundry tests
run: yarn test:unit
env:
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
ETH_NODE_URI_ARBITRUM: ${{ secrets.ETH_NODE_URI_ARBITRUM }}
ETH_NODE_URI_OPTIMISM: ${{ secrets.ETH_NODE_URI_OPTIMISM }}
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}

test-invariant:
needs: ["build", "lint"]
Expand Down Expand Up @@ -116,6 +125,10 @@ jobs:
env:
FOUNDRY_INVARIANT_RUNS: "8"
FOUNDRY_INVARIANT_DEPTH: "256"
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
ETH_NODE_URI_ARBITRUM: ${{ secrets.ETH_NODE_URI_ARBITRUM }}
ETH_NODE_URI_OPTIMISM: ${{ secrets.ETH_NODE_URI_OPTIMISM }}
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}

test-fuzz:
needs: ["build", "lint"]
Expand Down Expand Up @@ -143,6 +156,10 @@ jobs:
run: yarn test:fuzz
env:
FOUNDRY_FUZZ_RUNS: "5000"
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
ETH_NODE_URI_ARBITRUM: ${{ secrets.ETH_NODE_URI_ARBITRUM }}
ETH_NODE_URI_OPTIMISM: ${{ secrets.ETH_NODE_URI_OPTIMISM }}
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}

coverage:
needs: ["build", "lint"]
Expand All @@ -169,6 +186,11 @@ jobs:

- name: "Generate the coverage report using the unit and the integration tests"
run: "yarn ci:coverage"
env:
ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }}
ETH_NODE_URI_ARBITRUM: ${{ secrets.ETH_NODE_URI_ARBITRUM }}
ETH_NODE_URI_OPTIMISM: ${{ secrets.ETH_NODE_URI_OPTIMISM }}
ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }}

- name: "Upload coverage report to Codecov"
uses: "codecov/codecov-action@v3"
Expand Down Expand Up @@ -217,4 +239,4 @@ jobs:
- name: "Add Slither summary"
run: |
echo "## Slither result" >> $GITHUB_STEP_SUMMARY
echo "✅ Uploaded to GitHub code scanning" >> $GITHUB_STEP_SUMMARY
echo "✅ Uploaded to GitHub code scanning" >> $GITHUB_STEP_SUMMARY
2 changes: 2 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
version = v4.7.3
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
version = v4.7.3
[submodule "lib/utils"]
path = lib/utils
url = https://github.com/AngleProtocol/utils
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@angleprotocol:registry=https://npm.pkg.github.com
23 changes: 18 additions & 5 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"plugins": [
"prettier"
],
"rules": {
"max-line-length": ["error", 120],
"max-line-length": [
"error",
120
],
"avoid-call-value": "warn",
"avoid-low-level-calls": "off",
"avoid-tx-origin": "warn",
Expand All @@ -22,7 +27,15 @@
"no-inline-assembly": "off",
"no-complex-fallback": "off",
"reason-string": "off",
"func-visibility": ["warn", { "ignoreConstructors": true }],
"explicit-types": ["error","explicit"]
"func-visibility": [
"warn",
{
"ignoreConstructors": true
}
],
"explicit-types": [
"error",
"explicit"
]
}
}
}
24 changes: 19 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
{
"solidity.formatter": "prettier",
"[typescript]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
},
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"editor.formatOnSave": true,
"workbench.colorCustomizations": {
"diffEditor.insertedTextBackground": "#00bb0044",
"diffEditor.removedTextBackground": "#ff000044"
},
"slither.solcPath": "",
"slither.hiddenDetectors": [],
"solidity.compileUsingRemoteVersion": "v0.8.19+commit.7dd6d404"
"solidity.compileUsingRemoteVersion": "v0.8.22",
"files.insertFinalNewline": true,
"solidity.remappings": [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"stringutils/=lib/solidity-stringutils",
"contracts/=contracts/",
"test/=test/",
"interfaces/=contracts/interfaces/",
"oz/=lib/openzeppelin-contracts/contracts/",
"oz-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"mock/=test/mock/",
"prb/math/=lib/prb-math/src/",
"borrow/=lib/borrow-contracts/contracts",
"utils/=lib/utils"
]
}
1 change: 0 additions & 1 deletion contracts/helpers/Rebalancer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
pragma solidity ^0.8.19;

import { IERC20 } from "oz/interfaces/IERC20.sol";
import { IERC20Metadata } from "oz/interfaces/IERC20Metadata.sol";
import { SafeERC20 } from "oz/token/ERC20/utils/SafeERC20.sol";
import { SafeCast } from "oz/utils/math/SafeCast.sol";

Expand Down
3 changes: 2 additions & 1 deletion contracts/interfaces/IGetters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ interface IGetters {
OracleReadType oracleType,
OracleReadType targetType,
bytes memory oracleData,
bytes memory targetData
bytes memory targetData,
bytes memory hyperparameters
);

/// @notice Returns if the associated functionality is paused or not
Expand Down
3 changes: 3 additions & 0 deletions contracts/interfaces/ISetters.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.5.0;

Check warning on line 3 in contracts/interfaces/ISetters.sol

View workflow job for this annotation

GitHub Actions / lint

Found more than One contract per file. 2 contracts found!

import { IERC20 } from "oz/interfaces/IERC20.sol";

Expand Down Expand Up @@ -40,6 +40,9 @@
/// @notice Sets the `oracleConfig` used to read the value of `collateral` for the mint, burn and redemption
/// operations
function setOracle(address collateral, bytes memory oracleConfig) external;

/// @notice Update oracle data for a given `collateral`
function updateOracle(address collateral) external;
}

/// @title ISettersGovernor
Expand Down
3 changes: 3 additions & 0 deletions contracts/interfaces/ITransmuterOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ interface ITransmuterOracle {
/// @notice Reads the oracle value for asset to use in a burn transaction as well as the ratio
/// between the current price and the target price for the asset
function readBurn() external view returns (uint256 oracleValue, uint256 ratio);

/// @notice Reads the oracle value for asset
function read() external view returns (uint256);
}
9 changes: 9 additions & 0 deletions contracts/interfaces/external/morpho/IMorphoOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.5.0;

/// @title IMorphoOracle
/// @notice Interface for the oracle contracts used within Morpho
interface IMorphoOracle {
function price() external view returns (uint256);
}
Loading
Loading