Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
tighter restriction on way, fee, tax
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbreak committed Dec 17, 2017
1 parent 7aa133d commit 4b0c94b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 39 deletions.
8 changes: 4 additions & 4 deletions src/mom.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ contract SaiMom is DSThing {
tub.mold("tax", ray);
var tax = tub.tax();
require(RAY <= tax);
require(tax < 10002 * 10 ** 23); // ~200% per hour
require(tax < 1000001100000000000000000000); // 10% / day
}
// Governance fee
function setFee(uint ray) public note auth {
tub.mold("fee", ray);
var fee = tub.fee();
require(RAY <= fee);
require(fee < 10002 * 10 ** 23); // ~200% per hour
require(fee < 1000001100000000000000000000); // 10% / day
}
// Liquidation fee
function setAxe(uint ray) public note auth {
Expand Down Expand Up @@ -91,8 +91,8 @@ contract SaiMom is DSThing {
}
// Rate of change of target price (per second)
function setWay(uint ray) public note auth {
require(ray < 10002 * 10 ** 23); // ~200% per hour
require(ray > 9998 * 10 ** 23);
require(ray < 1000001100000000000000000000); // 10% / day
require(ray > 999998800000000000000000000);
vox.mold("way", ray);
}
function setHow(uint ray) public note auth {
Expand Down
43 changes: 8 additions & 35 deletions src/sai.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1916,8 +1916,8 @@ contract WayTest is SaiTestBase {
warp(1 days);
assertEq(wad(vox.par()), 0.95 ether);

mom.setWay(1000008022568992670911001251); // 200% / day
warp(1 days);
mom.setWay(1000000021979553151239153027); // 200% / year
warp(1 years);
assertEq(wad(vox.par()), 1.90 ether);
}
function testWayDecreasingPrincipal() public {
Expand All @@ -1936,8 +1936,8 @@ contract WayTest is SaiTestBase {
function testWayCage() public {
waySetup();

mom.setWay(1000008022568992670911001251); // 200% / day
warp(1 days); // par now 2
mom.setWay(1000000021979553151239153027); // 200% / year
warp(1 years); // par now 2

// we have 100 sai
// gem is worth 10 ref
Expand All @@ -1951,8 +1951,8 @@ contract WayTest is SaiTestBase {
assertEq(sai.balanceOf(tap), 0 ether);
tap.cash(sai.balanceOf(this));
assertEq(gem.balanceOf(this), 1020 ether);
assertEq(sai.balanceOf(this), 0 ether);
assertEq(sai.balanceOf(tap), 0 ether);
assertEq(sai.balanceOf(this), 0 ether);
assertEq(sai.balanceOf(tap), 0 ether);
}

// `boom` and `bust` as par is now needed to determine
Expand All @@ -1973,8 +1973,8 @@ contract WayTest is SaiTestBase {
assertEq(tap.woe(), 75 ether);
assertEq(sai.balanceOf(this), 75 ether);

mom.setWay(999991977495368425989823173); // -50% / day
warp(1 days);
mom.setWay(999999978020447331861593082); // -50% / year
warp(1 years);
assertEq(wad(vox.par()), 0.5 ether);
// sai now worth half as much, so we cover twice as much debt
// for the same skr
Expand All @@ -1984,33 +1984,6 @@ contract WayTest is SaiTestBase {
assertEq(tap.woe(), 25 ether);
assertEq(sai.balanceOf(this), 25 ether);
}
function testWayBoom() public {
var cup = waySetup();
tub.join(100 ether); // give us some spare skr
sai.push(tap, 100 ether); // force some joy into the tap
assertEq(tap.joy(), 100 ether);

mark(2 ether);
mom.setWay(1000008022568992670911001251); // 200% / day
warp(1 days);
assertEq(wad(vox.par()), 2 ether);
tap.boom(100 ether);
assertEq(tap.joy(), 0 ether);
assertEq(tub.per(), ray(2 ether));

tub.join(100 ether);
tub.draw(cup, 100 ether);
sai.push(tap, 100 ether); // force some joy into the tap

// n.b. per is now 2
assertEq(tap.joy(), 100 ether);
mark(2 ether);
mom.setWay(999991977495368425989823173); // -50% / day
warp(2 days);
assertEq(wad(vox.par()), 0.5 ether);
tap.boom(12.5 ether);
assertEq(tap.joy(), 0 ether);
}
}

contract GapTest is SaiTestBase {
Expand Down

0 comments on commit 4b0c94b

Please sign in to comment.