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

Commit

Permalink
fix tob audit rounding patterns 1,3
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbreak committed Dec 8, 2017
1 parent f7b6b45 commit cb5d024
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
16 changes: 0 additions & 16 deletions src/sai.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1429,22 +1429,6 @@ contract TapTest is SaiTestBase {

tap.bust(51 ether);
}
function testTapBustHealsNetJoy() public {
sai.mint(tap, 20 ether);
sin.mint(tap, 10 ether);

tap.bust(0 ether);
assertEq(tap.joy(), 10 ether);
assertEq(tap.woe(), 0 ether);
}
function testTapBustHealsNetWoe() public {
sai.mint(tap, 10 ether);
sin.mint(tap, 20 ether);

tap.bust(0 ether);
assertEq(tap.joy(), 0 ether);
assertEq(tap.woe(), 10 ether);
}
function testTapBustFlipHealsNetJoy() public {
sai.mint(tap, 10 ether);
sin.mint(tap, 20 ether);
Expand Down
5 changes: 2 additions & 3 deletions src/tap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ contract SaiTap is DSThing {
return rmul(wad, wmul(s2s(), gap));
}
function flip(uint wad) internal {
require(ask(wad) > 0);
skr.push(msg.sender, wad);
sai.pull(msg.sender, ask(wad));
heal();
}
function flop(uint wad) internal {
skr.mint(sub(wad, fog()));
skr.push(msg.sender, wad);
sai.pull(msg.sender, ask(wad));
heal();
flip(wad);
require(joy() == 0); // can't flop into surplus
}
function flap(uint wad) internal {
Expand Down
4 changes: 4 additions & 0 deletions src/tub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ contract SaiTub is DSThing, SaiTubEvents {
}
function join(uint wad) public note {
require(!off);
require(ask(wad) > 0);
require(gem.transferFrom(msg.sender, this, ask(wad)));
skr.mint(msg.sender, wad);
}
Expand Down Expand Up @@ -262,9 +263,11 @@ contract SaiTub is DSThing, SaiTubEvents {
function draw(bytes32 cup, uint wad) public note {
require(!off);
require(msg.sender == cups[cup].lad);
require(rdiv(wad, chi()) > 0);

cups[cup].art = add(cups[cup].art, rdiv(wad, chi()));
rum = add(rum, rdiv(wad, chi()));

cups[cup].ire = add(cups[cup].ire, rdiv(wad, rhi()));
sai.mint(cups[cup].lad, wad);

Expand All @@ -278,6 +281,7 @@ contract SaiTub is DSThing, SaiTubEvents {

cups[cup].art = sub(cups[cup].art, rdiv(wad, chi()));
rum = sub(rum, rdiv(wad, chi()));

cups[cup].ire = sub(cups[cup].ire, rdiv(add(wad, owe), rhi()));
sai.burn(msg.sender, wad);

Expand Down

0 comments on commit cb5d024

Please sign in to comment.