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

[draft] make bad debt grace period configurable per-Ilk #147

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 4 additions & 2 deletions src/cat.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface VatLike {
}

interface VowLike {
function fess(uint256) external;
function fess(uint256,uint256) external;
}

contract Cat is LibNote {
Expand All @@ -60,6 +60,7 @@ contract Cat is LibNote {
address flip; // Liquidator
uint256 chop; // Liquidation Penalty [wad]
uint256 dunk; // Liquidation Quantity [rad]
uint256 wait; // Bad debt grace period [seconds]
}

mapping (bytes32 => Ilk) public ilks;
Expand Down Expand Up @@ -116,6 +117,7 @@ contract Cat is LibNote {
function file(bytes32 ilk, bytes32 what, uint256 data) external note auth {
if (what == "chop") ilks[ilk].chop = data;
else if (what == "dunk") ilks[ilk].dunk = data;
else if (what == "wait") ilks[ilk].wait = data;
else revert("Cat/file-unrecognized-param");
}
function file(bytes32 ilk, bytes32 what, address flip) external note auth {
Expand Down Expand Up @@ -155,7 +157,7 @@ contract Cat is LibNote {
vat.grab(
ilk, urn, address(this), address(vow), -int256(dink), -int256(dart)
);
vow.fess(mul(dart, rate));
vow.fess(add(now, milk.wait), mul(dart, rate));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure these changes make it into the dog.sol


{ // Avoid stack too deep
// This calcuation will overflow if dart*rate exceeds ~10^14,
Expand Down
9 changes: 4 additions & 5 deletions src/vow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ contract Vow is LibNote {
FlapLike public flapper; // Surplus Auction House
FlopLike public flopper; // Debt Auction House

mapping (uint256 => uint256) public sin; // debt queue
mapping (uint256 => uint256) public sin; // debt queue
uint256 public Sin; // Queued debt [rad]
uint256 public Ash; // On-auction debt [rad]

uint256 public wait; // Flop delay [seconds]
uint256 public dump; // Flop initial lot size [wad]
uint256 public sump; // Flop fixed bid size [rad]

Expand Down Expand Up @@ -109,13 +108,13 @@ contract Vow is LibNote {
}

// Push to debt-queue
function fess(uint tab) external note auth {
sin[now] = add(sin[now], tab);
function fess(uint era, uint tab) external note auth {
sin[era] = add(sin[era], tab);
Sin = add(Sin, tab);
}
// Pop from debt-queue
function flog(uint era) external note {
require(add(era, wait) <= now, "Vow/wait-not-finished");
require(era <= now, "Vow/wait-not-finished");
Sin = sub(Sin, sin[era]);
sin[era] = 0;
}
Expand Down