From af0d4fc034bb520d5efffe94e32bbce472e264a0 Mon Sep 17 00:00:00 2001 From: Brian McMichael Date: Mon, 4 Oct 2021 18:34:08 -0400 Subject: [PATCH 1/3] don't commit hevm libs --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e2e7327..35b64b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /out +/hevm.libs.* \ No newline at end of file From 7076c9cd17d354de66eb95b7648f97a6e43fb42b Mon Sep 17 00:00:00 2001 From: Brian McMichael Date: Mon, 4 Oct 2021 18:35:24 -0400 Subject: [PATCH 2/3] Update dust setter to require ilk.hole >= ilk.dust --- src/DssExecLib.sol | 14 ++++++++++++-- src/test/DssAction.t.sol | 20 +++++++++++++++++++- src/test/DssExec.t.sol | 14 -------------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/DssExecLib.sol b/src/DssExecLib.sol index e6272d0..a2948d5 100644 --- a/src/DssExecLib.sol +++ b/src/DssExecLib.sol @@ -66,6 +66,10 @@ interface ClipLike { function ilk() external returns (bytes32); } +interface DogLike { + function ilks(bytes32) external returns (address clip, uint256 chop, uint256 hole, uint256 dirt); +} + interface JoinLike { function vat() external returns (address); function ilk() external returns (bytes32); @@ -662,6 +666,8 @@ library DssExecLib { */ function setIlkMinVaultAmount(bytes32 _ilk, uint256 _amount) public { require(_amount < WAD); // "LibDssExec/incorrect-ilk-dust-precision" + (,, uint256 _hole,) = DogLike(dog()).ilks(_ilk); + require(_amount <= _hole / RAD); // Ensure ilk.hole >= dust setValue(vat(), _ilk, "dust", _amount * RAD); (bool ok,) = clip(_ilk).call(abi.encodeWithSignature("upchost()")); ok; } @@ -990,12 +996,16 @@ library DssExecLib { } // Increase the global debt ceiling by the ilk ceiling increaseGlobalDebtCeiling(co.ilkDebtCeiling); + // Set the ilk debt ceiling setIlkDebtCeiling(co.ilk, co.ilkDebtCeiling); - // Set the ilk dust - setIlkMinVaultAmount(co.ilk, co.minVaultAmount); + // Set the hole size setIlkMaxLiquidationAmount(co.ilk, co.maxLiquidationAmount); + + // Set the ilk dust + setIlkMinVaultAmount(co.ilk, co.minVaultAmount); + // Set the ilk liquidation penalty setIlkLiquidationPenalty(co.ilk, co.liquidationPenalty); diff --git a/src/test/DssAction.t.sol b/src/test/DssAction.t.sol index 751edc4..3cb1d5c 100644 --- a/src/test/DssAction.t.sol +++ b/src/test/DssAction.t.sol @@ -659,10 +659,28 @@ contract ActionTest is DSTest { assertEq(autoLine.exec("gold"), 1000 * RAD); } - function test_setIlkMinVaultAmount() public { + function test_setIlkMinVaultAmountLt() public { + action.setIlkMaxLiquidationAmount_test("gold", 100); + action.setIlkMinVaultAmount_test("gold", 1); + (,,,, uint256 dust) = vat.ilks("gold"); + assertEq(dust, 1 * RAD); + } + + function test_setIlkMinVaultAmountEq() public { + action.setIlkMaxLiquidationAmount_test("gold", 100); action.setIlkMinVaultAmount_test("gold", 100); (,,,, uint256 dust) = vat.ilks("gold"); assertEq(dust, 100 * RAD); + + action.setIlkMaxLiquidationAmount_test("gold", 0); + action.setIlkMinVaultAmount_test("gold", 0); + (,,,, dust) = vat.ilks("gold"); + assertEq(dust, 0); + } + + function testFail_setIlkMinVaultAmountGt() public { + action.setIlkMaxLiquidationAmount_test("gold", 100); + action.setIlkMinVaultAmount_test("gold", 101); // Fail here } function test_setIlkLiquidationPenalty() public { diff --git a/src/test/DssExec.t.sol b/src/test/DssExec.t.sol index afabb8e..e01d7b5 100644 --- a/src/test/DssExec.t.sol +++ b/src/test/DssExec.t.sol @@ -240,8 +240,6 @@ contract DssLibExecTest is DSTest, DSMath { hevm = Hevm(address(CHEAT_CODE)); rates = new Rates(); - castPreviousSpell(); - spell = new DssExec( now + 30 days, // Expiration address(new DssLibSpellAction()) @@ -306,18 +304,6 @@ contract DssLibExecTest is DSTest, DSMath { }); } - // TODO remove after April 25, 2021 - function castPreviousSpell() internal { - SpellLike prevSpell = SpellLike(0xDb0D1af4531F59E4E7EfA4ec0AcADec7518D42B6); - // warp and cast previous spell so values are up-to-date to test against - if (prevSpell != SpellLike(0) && !prevSpell.done()) { - hevm.warp(1619372356); - // jump to nextCastTime to be a little more forgiving on the spell execution time - hevm.warp(prevSpell.nextCastTime()); - prevSpell.cast(); - } - } - function vote() private { if (chief.hat() != address(spell)) { hevm.store( From c3be2c4c2c0513fa40adefea4e4e8dc2859b204e Mon Sep 17 00:00:00 2001 From: Brian McMichael Date: Mon, 4 Oct 2021 18:37:06 -0400 Subject: [PATCH 3/3] line --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 35b64b0..b3a8834 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /out -/hevm.libs.* \ No newline at end of file +/hevm.libs.*