Merge pull request #2 from Sowmayjain/InstaKyber-changes

few changes for better code structure and one error
This commit is contained in:
Sowmay Jain 2019-03-28 01:56:55 +05:30 committed by GitHub
commit afba9e63f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,8 +104,8 @@ contract Helper {
uint slippageRate uint slippageRate
) )
{ {
(expectedRate, slippageRate) = KyberInterface(getAddressKyber()).getExpectedRate(src, dest, srcAmt); (expectedRate,) = KyberInterface(getAddressKyber()).getExpectedRate(src, dest, srcAmt);
slippageRate = (slippageRate / 97) * 99; // changing slippage rate upto 99% slippageRate = (expectedRate / 100) * 99; // changing slippage rate upto 99%
} }
/** /**
@ -181,7 +181,8 @@ contract Swap is Helper {
(uint ethBal, uint tknBal) = getBal(src); (uint ethBal, uint tknBal) = getBal(src);
destAmt = KyberInterface(getAddressKyber()).trade.value(ethQty)( KyberInterface swapCall = KyberInterface(getAddressKyber());
destAmt = swapCall.trade.value(ethQty)(
src, src,
srcAmt, srcAmt,
dest, dest,
@ -224,11 +225,11 @@ contract Swap is Helper {
function sell( function sell(
address src, address src,
address dest, address dest,
uint srcAmt uint srcAmt,
uint minDestAmt
) public payable returns (uint destAmt) ) public payable returns (uint destAmt)
{ {
uint ethQty = getToken(msg.sender, src, srcAmt); uint ethQty = getToken(msg.sender, src, srcAmt);
(, uint slippageRate) = getExpectedRate(src, dest, srcAmt);
KyberInterface swapCall = KyberInterface(getAddressKyber()); KyberInterface swapCall = KyberInterface(getAddressKyber());
destAmt = swapCall.trade.value(ethQty)( destAmt = swapCall.trade.value(ethQty)(
@ -237,7 +238,7 @@ contract Swap is Helper {
dest, dest,
msg.sender, msg.sender,
2**255, 2**255,
slippageRate, minDestAmt,
getAddressAdmin() getAddressAdmin()
); );
@ -248,7 +249,7 @@ contract Swap is Helper {
dest, dest,
destAmt, destAmt,
msg.sender, msg.sender,
slippageRate, minDestAmt,
getAddressAdmin() getAddressAdmin()
); );