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

Add Lite PSM and Splitter emergency spells #2

Merged
merged 18 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
22 changes: 12 additions & 10 deletions src/lite-psm-halt/SingleLitePsmHaltSpell.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import {DssEmergencySpell} from "../DssEmergencySpell.sol";

enum Flow {
SELL, // Halt only selling gems
BUY, // Halt only buying gems
BOTH // Halt both
BUY, // Halt only buying gems
BOTH // Halt both

}

interface LitePsmMomLike {
Expand All @@ -42,23 +43,24 @@ interface LitePsmLike {
contract SingleLitePsmHaltSpell is DssEmergencySpell {
LitePsmMomLike public immutable litePsmMom = LitePsmMomLike(_log.getAddress("LITE_PSM_MOM"));
Flow public immutable flow;
address public immutable psm = _log.getAddress("MCD_LITE_PSM_USDC_A");
address public immutable psm;

event Halt(Flow what);

constructor(Flow _flow) {
constructor(address _psm, Flow _flow) {
psm = _psm;
flow = _flow;
}

function flowToString(Flow _flow) internal pure returns (string memory) {
function _flowToString(Flow _flow) internal pure returns (string memory) {
if (_flow == Flow.SELL) return "SELL";
if (_flow == Flow.BUY) return "BUY";
if (_flow == Flow.BOTH) return "BOTH";
return "";
}

function description() external view returns (string memory) {
return string(abi.encodePacked("Emergency Spell | MCD_LITE_PSM_USDC_A halt: ", flowToString(flow)));
return string(abi.encodePacked("Emergency Spell | MCD_LITE_PSM_USDC_A halt: ", _flowToString(flow)));
}

/**
Expand Down Expand Up @@ -89,10 +91,10 @@ contract SingleLitePsmHaltSpell is DssEmergencySpell {
}

contract SingleLitePsmHaltSpellFactory {
event Deploy(Flow indexed flow, address spell);
event Deploy(address psm, Flow indexed flow, address spell);

function deploy(Flow flow) external returns (address spell) {
spell = address(new SingleLitePsmHaltSpell(flow));
emit Deploy(flow, spell);
function deploy(address psm, Flow flow) external returns (address spell) {
spell = address(new SingleLitePsmHaltSpell(psm, flow));
emit Deploy(psm, flow, spell);
}
}
13 changes: 6 additions & 7 deletions src/lite-psm-halt/SingleLitePsmHaltSpell.t.integration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ contract SingleLitePsmHaltSpellTest is DssTest {
LitePsmLike psm;
SingleLitePsmHaltSpellFactory factory;


function setUp() public {
vm.createSelectFork("mainnet");

Expand All @@ -29,19 +28,19 @@ contract SingleLitePsmHaltSpellTest is DssTest {
}

function testPsmHaltOnScheduleBuy() public {
testPsmHaltOnSchedule(Flow.BUY);
_checkPsmHaltOnSchedule(Flow.BUY);
}

function testPsmHaltOnScheduleSell() public {
testPsmHaltOnSchedule(Flow.SELL);
_checkPsmHaltOnSchedule(Flow.SELL);
}

function testPsmHaltOnScheduleBoth() public {
testPsmHaltOnSchedule(Flow.BOTH);
_checkPsmHaltOnSchedule(Flow.BOTH);
}

function testPsmHaltOnSchedule(Flow flow) internal {
DssEmergencySpellLike spell = DssEmergencySpellLike(factory.deploy(flow));
function _checkPsmHaltOnSchedule(Flow flow) internal {
DssEmergencySpellLike spell = DssEmergencySpellLike(factory.deploy(address(psm), flow));
stdstore.target(chief).sig("hat()").checked_write(address(spell));
vm.makePersistent(chief);

Expand Down Expand Up @@ -77,7 +76,7 @@ contract SingleLitePsmHaltSpellTest is DssTest {

function testRevertPsmHaltWhenItDoesNotHaveTheHat() public {
Flow flow = Flow.BOTH;
DssEmergencySpellLike spell = DssEmergencySpellLike(factory.deploy(flow));
DssEmergencySpellLike spell = DssEmergencySpellLike(factory.deploy(address(psm), flow));

uint256 preTin = psm.tin();
uint256 preTout = psm.tout();
Expand Down
4 changes: 2 additions & 2 deletions src/splitter-stop/SplitterStopSpell.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ contract SplitterStopSpell is DssEmergencySpell {
SplitterMomLike public immutable splitterMom = SplitterMomLike(_log.getAddress("SPLITTER_MOM"));
SplitterLike public immutable splitter = SplitterLike(_log.getAddress("MCD_SPLIT"));

event SplitterDisabled();
event Stop();

/**
* @notice Disables Splitter
*/
function _emergencyActions() internal override {
splitterMom.stop();
emit SplitterDisabled();
emit Stop();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/splitter-stop/SplitterStopSpell.t.integration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract SplitterStopSpellTest is DssTest {
assertFalse(spell.done(), "before: spell already done");

vm.expectEmit(true, false, false, false, address(spell));
emit SplitterDisabled();
emit Stop();

spell.schedule();

Expand All @@ -58,5 +58,5 @@ contract SplitterStopSpellTest is DssTest {
assertFalse(spell.done(), "after: spell done unexpectedly");
}

event SplitterDisabled();
event Stop();
}