diff --git a/.gitignore b/.gitignore index e2e7327..b3a8834 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /out +/hevm.libs.* 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(