This repository was archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Instant actions #96
Open
brianmcmichael
wants to merge
10
commits into
master
Choose a base branch
from
instant_actions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Instant actions #96
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ec66e35
Update end address
brianmcmichael cd431d4
Add instantActions() hook
brianmcmichael cb7a378
Delegatecall to instant action after schedule
brianmcmichael 1affa27
Add disable to DssExecLib
brianmcmichael ab20590
Import aave mock
brianmcmichael b1fff3c
move aave to mock folder
brianmcmichael 0637bcd
Test disable as action and instantAction
brianmcmichael 067e858
Update README
brianmcmichael 08f4b66
Use changelog for rpc tests
brianmcmichael d36f090
Ensure bar will have a value if 0 on mainnet
brianmcmichael 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
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
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
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 |
---|---|---|
|
@@ -32,6 +32,10 @@ interface Authorizable { | |
function setAuthority(address) external; | ||
} | ||
|
||
interface Disableable { | ||
function disable(address) external; | ||
} | ||
|
||
interface Fileable { | ||
function file(bytes32, address) external; | ||
function file(bytes32, uint256) external; | ||
|
@@ -282,6 +286,14 @@ library DssExecLib { | |
function setAuthority(address _base, address _authority) public { | ||
Authorizable(_base).setAuthority(_authority); | ||
} | ||
/** | ||
@dev Deactivates a module with a disable function | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding other mom-related breaker pattern instant actions (e.g. |
||
@param _base The address of the contract with the `disable(address)` pattern | ||
@param _target The contract that will be disabled | ||
*/ | ||
function disable(address _base, address _target) public { | ||
Disableable(_base).disable(_target); | ||
} | ||
/** | ||
@dev Delegate vat authority to the specified address. | ||
@param _usr Address to be authorized | ||
|
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 |
---|---|---|
|
@@ -40,6 +40,8 @@ import {DssAutoLine} from "dss-auto-line/DssAutoLine.sol"; | |
import {LerpFactory} from "dss-lerp/LerpFactory.sol"; | ||
import {DssDirectDepositAaveDai} | ||
from "dss-direct-deposit/DssDirectDepositAaveDai.sol"; | ||
import {AaveMock} from "./fixtures/AaveMock.sol"; | ||
import {DirectDepositMom} from "dss-direct-deposit/DirectDepositMom.sol"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. D3M repo won't be able to be imported here anymore as it is using solc 0.8.x. We will need to find another way to test D3M stuff. |
||
import {RwaLiquidationOracle} | ||
from "MIP21-RWA-Example/RwaLiquidationOracle.sol"; | ||
import {AuthGemJoin} from "dss-gem-joins/join-auth.sol"; | ||
|
@@ -85,20 +87,6 @@ contract UniPairMock { | |
} | ||
} | ||
|
||
contract AaveMock { | ||
// https://docs.aave.com/developers/the-core-protocol/lendingpool | ||
function getReserveData(address dai) public view returns ( | ||
uint256, uint128, uint128, uint128, uint128, uint128, uint40, address, address, address, address, uint8 | ||
) { | ||
address _dai = dai; // avoid stack too deep | ||
return (0,0,0,0,0,0,0, _dai, _dai, _dai, address(this), 0); | ||
} | ||
|
||
function getMaxVariableBorrowRate() public pure returns (uint256) { | ||
return type(uint256).max; | ||
} | ||
} | ||
|
||
contract ActionTest is DSTest { | ||
Hevm hevm; | ||
|
||
|
@@ -506,6 +494,22 @@ contract ActionTest is DSTest { | |
assertEq(clipperMom.authority(), address(1)); | ||
} | ||
|
||
function test_disable() public { | ||
AaveMock aave = new AaveMock(); | ||
DssDirectDepositAaveDai d3m = new DssDirectDepositAaveDai(address(clog), "tungsten", address(aave), address(0)); | ||
d3m.rely(address(action)); | ||
action.setD3MTargetInterestRate_test(address(d3m), 500); // set to 5% | ||
assertEq(d3m.bar(), 5 * RAY / 100); | ||
DirectDepositMom directDepositMom = new DirectDepositMom(); | ||
directDepositMom.setAuthority(address(govGuard)); | ||
assertEq(directDepositMom.authority(), address(govGuard)); | ||
d3m.rely(address(directDepositMom)); | ||
assertEq(d3m.wards(address(directDepositMom)), 1); | ||
|
||
action.disable_test(address(directDepositMom), address(d3m)); | ||
assertEq(d3m.bar(), 0); | ||
} | ||
|
||
function test_delegateVat() public { | ||
assertEq(vat.can(address(action), address(1)), 0); | ||
action.delegateVat_test(address(1)); | ||
|
@@ -1037,6 +1041,7 @@ contract ActionTest is DSTest { | |
assertEq(d3m.bar(), 99 * RAY / 100); | ||
} | ||
|
||
|
||
/*****************************/ | ||
/*** Collateral Onboarding ***/ | ||
/*****************************/ | ||
|
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
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
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,16 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity ^0.6.12; | ||
|
||
contract AaveMock { | ||
// https://docs.aave.com/developers/the-core-protocol/lendingpool | ||
function getReserveData(address dai) public view returns ( | ||
uint256, uint128, uint128, uint128, uint128, uint128, uint40, address, address, address, address, uint8 | ||
) { | ||
address _dai = dai; // avoid stack too deep | ||
return (0,0,0,0,0,0,0, _dai, _dai, _dai, address(this), 0); | ||
} | ||
|
||
function getMaxVariableBorrowRate() public pure returns (uint256) { | ||
return type(uint256).max; | ||
} | ||
} |
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.
Wondering if would be better to define it without empty implementation so we we make sure to always overwrite it by an empty one in the spell action being deployed.
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 do them so rarely that I didn't want to force it into every spellaction.