From 17d0894bcc44e0de36b10c4bb15cf9492990d565 Mon Sep 17 00:00:00 2001 From: Samyak Jain Date: Wed, 19 Jun 2019 20:33:25 +0530 Subject: [PATCH] bridge almost done --- contracts/ProxyLogics/InstaBridge.sol | 28 +++++++++++++++++++++++++++ contracts/bridges/MakerCompound.sol | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/contracts/ProxyLogics/InstaBridge.sol b/contracts/ProxyLogics/InstaBridge.sol index 05b503e..1d5e0d9 100644 --- a/contracts/ProxyLogics/InstaBridge.sol +++ b/contracts/ProxyLogics/InstaBridge.sol @@ -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); + } + } \ No newline at end of file diff --git a/contracts/bridges/MakerCompound.sol b/contracts/bridges/MakerCompound.sol index c673681..7617887 100644 --- a/contracts/bridges/MakerCompound.sol +++ b/contracts/bridges/MakerCompound.sol @@ -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);