Skip to content

Commit

Permalink
Added tinlake-maker-lib as submodule pointing to code to be used in
Browse files Browse the repository at this point in the history
MIP22, updated code snippets in MIP22
  • Loading branch information
lucasvo committed Sep 18, 2020
1 parent c07e364 commit 06a9cb1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 59 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "MIP22/tinlake-maker-lib"]
path = MIP22/tinlake-maker-lib
url = https://github.com/centrifuge/tinlake-maker-lib/
10 changes: 0 additions & 10 deletions MIP22/drop_join.sol

This file was deleted.

22 changes: 12 additions & 10 deletions MIP22/mip22.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,30 +127,32 @@ The `Tinlake Flipper` takes all of the collateral from a Vault and requests rede
When a Vault is liquidated (`Cat.bite` is called), the Cat will call `Flipper.kick` which kicks off the liquidation. At first it withdraws the entire collateral (the DROP tokens) from the system and places a `redeemOrder` on the `pool` contract.

```
function kick(address usr_, address gal, uint256 tab, uint256 lot, uint256 bid)
function kick(address dest_, address gal, uint256 tab_, uint256 lot, uint256 bid)
public auth returns (uint256 id)
{
vow = gal;
usr = usr_;
dest = dest_;
tab = tab_;
vat.flux(ilk, msg.sender, address(this), lot);
dropJoin.exit(address(this), lot);
pool.redeemOrder(lot);
pool.redeemOrder(drop.balanceOf(address(this)));
emit Kick(id, lot, bid, tab_, dest, vow);
}
```

The redeem order will now be taken into account whenever loan repayments flow into the pool or other investors want to join the pool. As the pool redeems the DROP any user can call the function `take`. It moves the DAI available for withdrawal from the pool and either repays up outstanding debt (`tab`) to the `vow` or returns it to the pool. This method can be called multiple time to cause the pool to `disburse` more DAI and return it to the pool as funds available for borrowers.

```
function take() public {
uint returned, _ = pool.disburse();
if (tab < returned) {
dai.transferFrom(address(this), usr, sub(returned-tab));
returned = tab;
(uint returned, ) = pool.disburse();
uint tabWad = tab / RAY; // always rounds down, this could lead to < 1 RAY to be lost in dust
if (tabWad < returned) {
dai.transfer(dest, sub(returned, tabWad));
returned = tabWad;
}
if (tab != 0) {
dai.join(vow, returned);
tab = sub(tab, returned);
daiJoin.join(vow, returned);
tab = sub(tab, mul(returned, RAY));
}
}
```
Expand Down
1 change: 1 addition & 0 deletions MIP22/tinlake-maker-lib
Submodule tinlake-maker-lib added at 03daff
39 changes: 0 additions & 39 deletions MIP22/tinlake_flip.sol

This file was deleted.

0 comments on commit 06a9cb1

Please sign in to comment.