Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Hole gt dust (#83)
Browse files Browse the repository at this point in the history
* don't commit hevm libs

* Update dust setter to require ilk.hole >= ilk.dust

* line
  • Loading branch information
brianmcmichael authored Nov 22, 2021
1 parent 363b662 commit e4e483f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/out
/hevm.libs.*
14 changes: 12 additions & 2 deletions src/DssExecLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down
20 changes: 19 additions & 1 deletion src/test/DssAction.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 0 additions & 14 deletions src/test/DssExec.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit e4e483f

Please sign in to comment.