bridge almost done

This commit is contained in:
Samyak Jain 2019-06-19 20:33:25 +05:30
parent 6886c863df
commit 17d0894bcc
2 changed files with 29 additions and 1 deletions

View File

@ -45,11 +45,17 @@ interface ComptrollerInterface {
interface CTokenInterface {
function borrow(uint borrowAmount) external returns (uint);
function exchangeRateCurrent() external returns (uint);
function transfer(address, uint) external returns (bool);
function transferFrom(address, address, uint) external returns (bool);
}
interface BridgeInterface {
function makerToCompound(uint, uint, uint) external returns (uint);
function compoundToMaker(uint, uint, uint) external;
}
contract DSMath {
@ -175,4 +181,26 @@ contract CompoundHelper is MakerHelper {
cDaiContract.transfer(getBridgeAddress());
}
}
contract InstaBridge is CompoundHelper {
function makerToCompound(uint cdpId, uint ethCol, uint daiDebt) public {
give(cdpId, getBridgeAddress());
BridgeInterface bridge = BridgeInterface(getBridgeAddress());
uint daiAmt = bridge.makerToCompound(cdpId, ethCol, daiDebt);
// setApproval(getDaiAddress(), daiAmt, getBridgeAddress());
bridge.takeDebtBack(daiAmt);
}
function compoundToMaker(uint cdpId, uint ethCol, uint daiDebt) public {
if (cdpId != 0) {
give(cdpId, getBridgeAddress());
}
BridgeInterface bridge = BridgeInterface(getBridgeAddress());
// setApproval(getCEthAddress(), daiAmt, getBridgeAddress());
uint daiAmt = bridge.compoundToMaker(cdpId, ethCol, daiDebt);
}
}

View File

@ -388,7 +388,7 @@ contract Bridge is CompoundResolver {
give(cdpId, msg.sender);
}
function compoundToMaker(uint cdpId, uint ethCol, uint daiDebt) public payable isUserWallet returns (uint daiAmt) {
function compoundToMaker(uint cdpId, uint ethCol, uint daiDebt) public payable isUserWallet {
payUsersDebt(daiDebt);
takeCETH(ethCol);
redeemUnderlying(cEth, ethCol);