Split Swap bug resolved

This commit is contained in:
Samyak Jain 2019-06-27 03:36:51 +05:30
parent 404aeee97d
commit c76cb12850
2 changed files with 4 additions and 9 deletions

View File

@ -170,7 +170,8 @@ contract Helpers is DSMath {
* @dev get admin address * @dev get admin address
*/ */
function getAddressSplitSwap() public pure returns (address payable splitSwap) { function getAddressSplitSwap() public pure returns (address payable splitSwap) {
splitSwap = 0x1E3A60112f600cb623087bd2C98c7842085a8c3F; splitSwap = // ADDRESS SPLIT SWAP;
// splitSwap = 0x1E3A60112f600cb623087bd2C98c7842085a8c3F;
} }
/** /**
@ -390,7 +391,6 @@ contract GetDetails is MakerHelpers {
if (ethToSwap < colToFree) { if (ethToSwap < colToFree) {
colToFree = ethToSwap; colToFree = ethToSwap;
} }
// (uint expectedRate,) = KyberInterface(getAddressKyber()).getExpectedRate(getAddressETH(), getAddressDAI(), colToFree);
(, uint expectedDAI) = SplitSwapInterface(getAddressSplitSwap()).getBest(getAddressETH(), getAddressDAI(), colToFree); (, uint expectedDAI) = SplitSwapInterface(getAddressSplitSwap()).getBest(getAddressETH(), getAddressDAI(), colToFree);
if (expectedDAI < daiDebt) { if (expectedDAI < daiDebt) {
finalEthCol = sub(ethCol, colToFree); finalEthCol = sub(ethCol, colToFree);
@ -484,16 +484,10 @@ contract Save is GetDetails {
if (colToSwap < colToFree) { if (colToSwap < colToFree) {
colToFree = colToSwap; colToFree = colToSwap;
} }
uint thisBalance = address(this).balance;
free(cdpID, colToFree); free(cdpID, colToFree);
uint destAmt = SplitSwapInterface(getAddressSplitSwap()).ethToDaiSwap.value(colToFree)(splitAmt, slippageAmt); uint destAmt = SplitSwapInterface(getAddressSplitSwap()).ethToDaiSwap.value(colToFree)(splitAmt, slippageAmt);
wipe(cdpID, destAmt); wipe(cdpID, destAmt);
if (thisBalance < address(this).balance) {
uint balToLock = sub(address(this).balance, thisBalance);
lock(cdpID, balToLock);
}
emit LogSaveCDP(cdpID, colToFree, destAmt); emit LogSaveCDP(cdpID, colToFree, destAmt);
} }

View File

@ -269,7 +269,8 @@ contract SplitResolver is SplitHelper {
} }
function swapKyber(address src, address dest, uint srcAmt) internal returns (uint destAmt) { function swapKyber(address src, address dest, uint srcAmt) internal returns (uint destAmt) {
destAmt = KyberInterface(kyberAddr).trade.value(srcAmt)( uint ethAmt = src == ethAddr ? srcAmt : 0;
destAmt = KyberInterface(kyberAddr).trade.value(ethAmt)(
src, src,
srcAmt, srcAmt,
dest, dest,