-
Notifications
You must be signed in to change notification settings - Fork 40
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
MetaMorpho D3M #117
Merged
Merged
MetaMorpho D3M #117
Changes from 3 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
d8f53b4
test: change aave irm of DAI
MathisGD 439f8ae
feat: D3M 4626 pool
MathisGD a967466
add operator plan and tests
hexonaut 697f0c3
RAY unused
hexonaut 0b6de36
new lines at end of file
hexonaut 959cdc8
refactor: revert wards type change and remove urd claim
MathisGD 3d84643
test: minor improvements
MathisGD 66b01df
fix: exit proportionnal
MathisGD 5e39eca
chore: fmt
MathisGD ac32c5a
Merge remote-tracking branch 'origin/master' into feat/4626-vault-d3m
MathisGD ab9846e
style: renaming
MathisGD 062b526
style: match more style
MathisGD a888da1
return 0 target assets when disabled
hexonaut b1cb6a2
Merge pull request #116 from MathisGD/feat/4626-vault-d3m
hexonaut d09a093
fix: exit and constructor inputs
MathisGD 057b0cb
style: match more repo style
MathisGD de4730a
add deploy/init libraries and scripts
hexonaut 1e49d36
Merge branch 'multisig-plan' of github.com:makerdao/dss-direct-deposi…
hexonaut a0efe5d
fix compiler errors
hexonaut 3fef536
fix: hope hub at construction
MathisGD 3c5006f
fix: minor fixes
MathisGD 2643eb9
view on library; pause proxy is d3m admin
hexonaut 42c6a68
re-arrange 4626 pool to match Spark one to make diff easier for revie…
hexonaut bc257f5
switch auth and onlyHub
hexonaut c9348c6
add deposit/withdraw links
hexonaut cb604b1
set multisig
hexonaut 3052f83
hub to hub_
hexonaut ce81124
change to not-operator
hexonaut db98418
unused ilk
hexonaut d4e2110
remove useless hub
hexonaut 03af9eb
fix naming
hexonaut 2d79650
test: wip integration tests
MathisGD 9183aae
Merge remote-tracking branch 'refs/remotes/origin/multisig-plan' into…
MathisGD f65e1a0
test: various improvements
MathisGD 686e304
use new vault
hexonaut c6e9214
remove aave v3-specific stuff
hexonaut 5e655cc
test: minor improvements
MathisGD c160121
Merge remote-tracking branch 'origin/multisig-plan' into multisig-plan
MathisGD 3615bb4
test: fix invariant_vault_maxDeposit
MathisGD bbdea8b
fixing some test behaviour
hexonaut 698ec5c
fix morpho integration tests
hexonaut da5ae45
chore: update CI to CVL version 7
QGarchery d8a85f8
fix: separate multiple prover args
QGarchery efa9fd3
docs: small changes to the README
QGarchery 940cb93
test: first metamorpho specific integration test
MathisGD da33537
docs: typo
MathisGD 6cab878
Merge pull request #118 from QGarchery/certora/update-certora-ci
hexonaut 7f9752a
revert certora changes
hexonaut 574965d
remove increase in error threshold
hexonaut 6b827d0
enable the asserts again with the rounding taken into account
hexonaut bcd532c
use approx eq instead and remove comments
hexonaut 3a008e2
test: more integration test
MathisGD 5e659d1
Merge remote-tracking branch 'origin/multisig-plan' into multisig-plan
MathisGD f6fc31d
Merge branch 'master' into multisig-plan
hexonaut 22298e7
Merge branch 'multisig-plan' of github.com:makerdao/dss-direct-deposi…
hexonaut d0998b4
chore: revert prettier changes
MathisGD 1930068
test: deposit in 2 markets, reallocation
MathisGD d52372f
Merge remote-tracking branch 'origin/multisig-plan' into multisig-plan
MathisGD 0ddf50f
test: remove vm.assume
MathisGD 22c79f6
test: fmt and variables for addresses
MathisGD df2fd08
test: one test for each path
MathisGD e120253
update deploy params to match risk values
hexonaut 2929fab
add chainsecurity audit report
hexonaut 4eedf4f
test: concrete values deposit test
MathisGD 13916d8
Merge remote-tracking branch 'origin/multisig-plan' into multisig-plan
MathisGD aed0dc3
add date to audit
hexonaut 9dd885f
Merge branch 'master' into multisig-plan
hexonaut 576c75c
test: improve withdraw test
MathisGD 52856ab
Merge remote-tracking branch 'origin/multisig-plan' into multisig-plan
MathisGD c78d7e1
test: hardcode block before compound 227
MathisGD 8a18cb3
Merge pull request #121 from makerdao/test/fix-d3m-compound
hexonaut a9c6329
adding spearbit audit report
hexonaut fe9e4c7
update audit file name
hexonaut 45114d8
chore: remove metamorpho dependancy
MathisGD 2e1bdbd
chore: remove submodule
MathisGD 651ac7e
Merge pull request #122 from makerdao/chore/remove-metamorpho-dep
hexonaut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// SPDX-FileCopyrightText: © 2022 Dai Foundation <www.daifoundation.org> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
pragma solidity ^0.8.14; | ||
|
||
import "./ID3MPlan.sol"; | ||
|
||
/** | ||
* @title D3M Operator Plan | ||
* @notice An operator sets the desired target assets. | ||
*/ | ||
contract D3MOperatorPlan is ID3MPlan { | ||
|
||
mapping (address => uint256) public wards; | ||
uint256 public enabled; | ||
|
||
address public operator; | ||
uint256 public targetAssets; | ||
|
||
// --- Events --- | ||
event Rely(address indexed usr); | ||
event Deny(address indexed usr); | ||
event File(bytes32 indexed what, address data); | ||
event File(bytes32 indexed what, uint256 data); | ||
|
||
constructor() { | ||
enabled = 1; | ||
|
||
wards[msg.sender] = 1; | ||
emit Rely(msg.sender); | ||
} | ||
|
||
modifier auth { | ||
require(wards[msg.sender] == 1, "D3MOperatorPlan/not-authorized"); | ||
_; | ||
} | ||
|
||
// --- Admin --- | ||
function rely(address usr) external auth { | ||
wards[usr] = 1; | ||
emit Rely(usr); | ||
} | ||
function deny(address usr) external auth { | ||
wards[usr] = 0; | ||
emit Deny(usr); | ||
} | ||
|
||
function file(bytes32 what, address data) external auth { | ||
if (what == "operator") { | ||
operator = data; | ||
} else revert("D3MOperatorPlan/file-unrecognized-param"); | ||
emit File(what, data); | ||
} | ||
|
||
function file(bytes32 what, uint256 data) external auth { | ||
if (what == "enabled") { | ||
require(data <= 1, "D3MOperatorPlan/invalid-value"); | ||
enabled = data; | ||
} else revert("D3MOperatorPlan/file-unrecognized-param"); | ||
emit File(what, data); | ||
} | ||
MathisGD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
function setTargetAssets(uint256 value) external { | ||
MathisGD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
require(msg.sender == operator, "D3MOperatorPlan/not-authorized"); | ||
sunbreak1211 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
targetAssets = value; | ||
} | ||
|
||
function getTargetAssets(uint256) external override view returns (uint256) { | ||
return targetAssets; | ||
} | ||
hexonaut marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
function active() public view override returns (bool) { | ||
return enabled == 1; | ||
} | ||
|
||
function disable() external override auth { | ||
sunbreak1211 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
enabled = 0; | ||
emit Disable(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// SPDX-FileCopyrightText: © 2022 Dai Foundation <www.daifoundation.org> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
pragma solidity ^0.8.14; | ||
|
||
import { D3MPlanBaseTest } from "./D3MPlanBase.t.sol"; | ||
import { D3MOperatorPlan } from "../../plans/D3MOperatorPlan.sol"; | ||
|
||
contract D3MOperatorPlanTest is D3MPlanBaseTest { | ||
|
||
bytes32 ilk = "DIRECT-PROTOCOL-A"; | ||
sunbreak1211 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
D3MOperatorPlan plan; | ||
|
||
address operator = makeAddr("operator"); | ||
address randomAddress = makeAddr("randomAddress"); | ||
|
||
event Disable(); | ||
|
||
function setUp() public { | ||
vm.expectEmit(true, true, true, true); | ||
emit Rely(address(this)); | ||
plan = new D3MOperatorPlan(); | ||
|
||
baseInit(plan, "D3MOperatorPlan"); | ||
} | ||
|
||
function test_constructor() public { | ||
assertEq(plan.enabled(), 1); | ||
assertEq(plan.targetAssets(), 0); | ||
} | ||
|
||
function test_file() public { | ||
// File checks will increment the current value by 1 so | ||
// just set it to 0 to start with so there is no revert. | ||
plan.file("enabled", 0); | ||
checkFileUint(address(plan), contractName, ["enabled"]); | ||
checkFileAddress(address(plan), contractName, ["operator"]); | ||
} | ||
|
||
function test_file_bad_value() public { | ||
vm.expectRevert("D3MOperatorPlan/invalid-value"); | ||
plan.file("enabled", 2); | ||
} | ||
|
||
function _setupOperatorAndTargetAssets() internal { | ||
plan.file("operator", operator); | ||
vm.prank(operator); | ||
plan.setTargetAssets(100e18); | ||
} | ||
|
||
function test_setTargetAssets() public { | ||
_setupOperatorAndTargetAssets(); | ||
|
||
assertEq(plan.targetAssets(), 100e18); | ||
|
||
vm.prank(operator); | ||
plan.setTargetAssets(200e18); | ||
|
||
assertEq(plan.targetAssets(), 200e18); | ||
} | ||
|
||
function test_setTargetAssets_onlyOperator() public { | ||
_setupOperatorAndTargetAssets(); | ||
|
||
vm.prank(randomAddress); | ||
vm.expectRevert("D3MOperatorPlan/not-authorized"); | ||
plan.setTargetAssets(200e18); | ||
} | ||
|
||
function test_implements_getTargetAssets() public { | ||
_setupOperatorAndTargetAssets(); | ||
|
||
uint256 result = plan.getTargetAssets(123e18); | ||
|
||
assertEq(result, 100e18); | ||
} | ||
|
||
function test_disable() public { | ||
_setupOperatorAndTargetAssets(); | ||
|
||
assertEq(plan.enabled(), 1); | ||
assertTrue(plan.active()); | ||
vm.expectEmit(true, true, true, true); | ||
emit Disable(); | ||
plan.disable(); | ||
assertTrue(!plan.active()); | ||
assertEq(plan.enabled(), 0); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is public, this value can be read in place of
getTargetAssets
which would be interpreted incorrectly in caseenabled == 0
(because it seems it is expected to be interpreted as0
, pergetTargetAssets
's implementation)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think that it's better to enforce that the target assets is set back to zero before disabling the Plan. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this because it avoids side-effects which ultimately avoid unexpected/undesired behaviors
Is it compatible with the usual D3M life cycle though (awaiting confirmation from the Maker side ideally)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @hexonaut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to be able to disable without requiring target assets is 0 in the case the multisig goes rogue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but any account that's capable of disabling the plan is also capable of setting themselves as operator to set the target assets at zero right?
anyway the current version is also fine to me, but it has the little tradeoff that @Rubilmax is mentioning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or disabling the plan could also set back to zero target assets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the way we have this constructed. This contract can trigger without a delay: https://github.com/makerdao/dss-direct-deposit/blob/master/src/D3MMom.sol#L76
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just make
targetAssets
aprivate
variable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to leave this for now unless you guys feel strongly. Code is in audit, and this is somewhat of a superficial change on a backend contract which can be upgraded later if desired.