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

Hole gt dust #83

Merged
merged 3 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
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