-
-
Save lucasvo/0928dc8118e6f140fe656bb4409c8495 to your computer and use it in GitHub Desktop.
Tinlake Flip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract DROPJoin is GemJoin { | |
// the only line modified from GemJoin is the `auth` modifier in the function signature | |
function join(address usr, uint wad) external auth note { | |
require(live == 1, "GemJoin/not-live"); | |
require(int(wad) >= 0, "GemJoin/overflow"); | |
vat.slip(ilk, usr, int(wad)); | |
require(gem.transferFrom(msg.sender, address(this), wad), "GemJoin/failed-transfer"); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface RedeemLike { | |
function redeemOrder(uint, uint) public; | |
function disburse() public returns (uint, uint); | |
} | |
contract TinlakeFlipper { | |
RedeemLike public pool; | |
GemLike public dai; | |
GemLike public drop; | |
GemJoinLike public daiJoin; | |
DROPJoinLike public dropJoin; | |
uint public tab; | |
address public vow; | |
address public usr; // where to send excess DAI raised (back to pool) | |
function kick(address usr_, address gal, uint256 tab, uint256 lot, uint256 bid) | |
public auth returns (uint256 id) | |
{ | |
vow = gal; | |
usr = usr_; | |
vat.flux(ilk, msg.sender, address(this), lot); | |
dropJoin.exit(address(this), lot); | |
pool.redeemOrder(lot); | |
} | |
function take() public { | |
uint returned, _ = pool.disburse(); | |
if (tab < returned) { | |
dai.transferFrom(address(this), usr, sub(returned-tab)); | |
returned = tab; | |
} | |
if (tab != 0) { | |
dai.join(vow, returned); | |
tab = sub(tab, returned); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment