mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
Added events in InstaMaker
This commit is contained in:
parent
2c4d1d25d7
commit
e28ca6a6ee
|
@ -112,8 +112,17 @@ contract Helpers is DSMath {
|
||||||
|
|
||||||
contract CDPResolver is Helpers {
|
contract CDPResolver is Helpers {
|
||||||
|
|
||||||
|
event LogOpen(uint cdpNum, address owner);
|
||||||
|
event LogGive(uint cdpNum, address owner, address nextOwner);
|
||||||
|
event LogLock(uint cdpNum, uint amtETH, uint amtPETH, address owner);
|
||||||
|
event LogFree(uint cdpNum, uint amtETH, uint amtPETH, address owner);
|
||||||
|
event LogDraw(uint cdpNum, uint amtDAI, address owner);
|
||||||
|
event LogWipe(uint cdpNum, uint daiAmt, uint mkrFee, uint daiFee, address owner);
|
||||||
|
event LogShut(uint cdpNum);
|
||||||
|
|
||||||
function open() public returns (uint) {
|
function open() public returns (uint) {
|
||||||
bytes32 cup = TubInterface(getSaiTubAddress()).open();
|
bytes32 cup = TubInterface(getSaiTubAddress()).open();
|
||||||
|
emit LogOpen(uint(cup), address(this));
|
||||||
return uint(cup);
|
return uint(cup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +131,7 @@ contract CDPResolver is Helpers {
|
||||||
*/
|
*/
|
||||||
function give(uint cdpNum, address nextOwner) public {
|
function give(uint cdpNum, address nextOwner) public {
|
||||||
TubInterface(getSaiTubAddress()).give(bytes32(cdpNum), nextOwner);
|
TubInterface(getSaiTubAddress()).give(bytes32(cdpNum), nextOwner);
|
||||||
|
emit LogGive(cdpNum, address(this), nextOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
function lock(uint cdpNum) public payable {
|
function lock(uint cdpNum) public payable {
|
||||||
|
@ -146,6 +156,13 @@ contract CDPResolver is Helpers {
|
||||||
|
|
||||||
setAllowance(peth, tubAddr);
|
setAllowance(peth, tubAddr);
|
||||||
tub.lock(cup, ink);
|
tub.lock(cup, ink);
|
||||||
|
|
||||||
|
emit LogLock(
|
||||||
|
cdpNum,
|
||||||
|
msg.value,
|
||||||
|
ink,
|
||||||
|
address(this)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +186,13 @@ contract CDPResolver is Helpers {
|
||||||
weth.withdraw(freeJam);
|
weth.withdraw(freeJam);
|
||||||
|
|
||||||
address(msg.sender).transfer(freeJam);
|
address(msg.sender).transfer(freeJam);
|
||||||
|
|
||||||
|
emit LogFree(
|
||||||
|
cdpNum,
|
||||||
|
freeJam,
|
||||||
|
ink,
|
||||||
|
address(this)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +203,8 @@ contract CDPResolver is Helpers {
|
||||||
|
|
||||||
tub.draw(cup, _wad);
|
tub.draw(cup, _wad);
|
||||||
tub.sai().transfer(msg.sender, _wad);
|
tub.sai().transfer(msg.sender, _wad);
|
||||||
|
|
||||||
|
emit LogDraw(cdpNum, _wad, address(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,8 +230,8 @@ contract CDPResolver is Helpers {
|
||||||
// MKR required for wipe = Stability fees accrued in Dai / MKRUSD value
|
// MKR required for wipe = Stability fees accrued in Dai / MKRUSD value
|
||||||
uint mkrFee = wdiv(rmul(_wad, rdiv(tub.rap(cup), tub.tab(cup))), uint(val));
|
uint mkrFee = wdiv(rmul(_wad, rdiv(tub.rap(cup), tub.tab(cup))), uint(val));
|
||||||
|
|
||||||
uint daiAmt = daiEx.getTokenToEthOutputPrice(mkrEx.getEthToTokenOutputPrice(mkrFee));
|
uint daiFeeAmt = daiEx.getTokenToEthOutputPrice(mkrEx.getEthToTokenOutputPrice(mkrFee));
|
||||||
daiAmt = add(_wad, daiAmt);
|
uint daiAmt = add(_wad, daiFeeAmt);
|
||||||
require(dai.transferFrom(msg.sender, address(this), daiAmt), "not-approved-yet");
|
require(dai.transferFrom(msg.sender, address(this), daiAmt), "not-approved-yet");
|
||||||
|
|
||||||
if (ok && val != 0) {
|
if (ok && val != 0) {
|
||||||
|
@ -219,6 +245,15 @@ contract CDPResolver is Helpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
tub.wipe(cup, _wad);
|
tub.wipe(cup, _wad);
|
||||||
|
|
||||||
|
emit LogWipe(
|
||||||
|
cdpNum,
|
||||||
|
daiAmt,
|
||||||
|
mkrFee,
|
||||||
|
daiFeeAmt,
|
||||||
|
address(this)
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +281,7 @@ contract CDPCluster is CDPResolver {
|
||||||
TubInterface tub = TubInterface(getSaiTubAddress());
|
TubInterface tub = TubInterface(getSaiTubAddress());
|
||||||
wipeAndFree(cdpNum, rmul(tub.ink(cup), tub.per()), tub.tab(cup));
|
wipeAndFree(cdpNum, rmul(tub.ink(cup), tub.per()), tub.tab(cup));
|
||||||
tub.shut(cup);
|
tub.shut(cup);
|
||||||
|
emit LogShut(cdpNum); // fetch remaining data from WIPE & FREE events
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user