mirror of
https://github.com/Instadapp/InstaContract.git
synced 2024-07-29 22:47:45 +00:00
Added UniQue CDP.
This commit is contained in:
parent
d33299787b
commit
750178c6da
56
contracts/protocols/MakerDAO/uniqueCDP.sol
Normal file
56
contracts/protocols/MakerDAO/uniqueCDP.sol
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
pragma solidity 0.4.24;
|
||||||
|
|
||||||
|
|
||||||
|
library SafeMath {
|
||||||
|
|
||||||
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
|
if (a == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
uint256 c = a * b;
|
||||||
|
require(c / a == b, "Assertion Failed");
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||||
|
require(b > 0, "Assertion Failed");
|
||||||
|
uint256 c = a / b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AddressRegistry {
|
||||||
|
function getAddr(string name) external view returns(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MakerCDP {
|
||||||
|
function open() external returns (bytes32 cup);
|
||||||
|
function give(bytes32 cup, address guy) external;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
contract UniqueCDP {
|
||||||
|
|
||||||
|
address public deployer;
|
||||||
|
address public cdpAddr;
|
||||||
|
|
||||||
|
constructor(address saiTub) public {
|
||||||
|
deployer = msg.sender;
|
||||||
|
cdpAddr = saiTub;
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerCDP(uint maxCup) public {
|
||||||
|
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
||||||
|
for (uint i = 0; i < maxCup; i++) {
|
||||||
|
loanMaster.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function transferCDP(address nextOwner, uint cdpNum) public {
|
||||||
|
require(msg.sender == deployer, "Invalid Address.");
|
||||||
|
MakerCDP loanMaster = MakerCDP(cdpAddr);
|
||||||
|
loanMaster.give(bytes32(cdpNum), nextOwner);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user