mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
basic edits
This commit is contained in:
parent
697d6c2f9c
commit
a51238f1cf
|
@ -325,6 +325,7 @@ contract CompoundSave is CompoundResolver {
|
||||||
function save(
|
function save(
|
||||||
uint ethToFree,
|
uint ethToFree,
|
||||||
uint zrxEthAmt,
|
uint zrxEthAmt,
|
||||||
|
bool isKyber,
|
||||||
bytes memory calldataHexString,
|
bytes memory calldataHexString,
|
||||||
address[] memory ctokenAddr,
|
address[] memory ctokenAddr,
|
||||||
uint[] memory ctokenFactor
|
uint[] memory ctokenFactor
|
||||||
|
@ -339,7 +340,7 @@ contract CompoundSave is CompoundResolver {
|
||||||
wethContract.deposit.value(zrxEthAmt)();
|
wethContract.deposit.value(zrxEthAmt)();
|
||||||
wethContract.approve(getAddressZRXExchange(), zrxEthAmt);
|
wethContract.approve(getAddressZRXExchange(), zrxEthAmt);
|
||||||
getAddressZRXExchange().call(calldataHexString);
|
getAddressZRXExchange().call(calldataHexString);
|
||||||
if (address(this).balance > 0) {
|
if (address(this).balance > 0 && isKyber) {
|
||||||
KyberInterface(getAddressKyberProxy()).trade.value(address(this).balance)(
|
KyberInterface(getAddressKyberProxy()).trade.value(address(this).balance)(
|
||||||
getAddressETH(),
|
getAddressETH(),
|
||||||
address(this).balance,
|
address(this).balance,
|
||||||
|
@ -352,6 +353,9 @@ contract CompoundSave is CompoundResolver {
|
||||||
}
|
}
|
||||||
ERC20Interface usdcContract = ERC20Interface(getAddressUSDC());
|
ERC20Interface usdcContract = ERC20Interface(getAddressUSDC());
|
||||||
uint usdcBal = usdcContract.balanceOf(address(this));
|
uint usdcBal = usdcContract.balanceOf(address(this));
|
||||||
|
uint cut = wmul(2500000000000000, usdcBal);
|
||||||
|
usdcContract.transfer(getAddressAdmin(), cut);
|
||||||
|
usdcBal = sub(usdcBal, cut);
|
||||||
repayUsdc(usdcBal);
|
repayUsdc(usdcBal);
|
||||||
emit LogSaveCompoundUsdc(ethToSwap, usdcBal);
|
emit LogSaveCompoundUsdc(ethToSwap, usdcBal);
|
||||||
}
|
}
|
||||||
|
@ -360,6 +364,7 @@ contract CompoundSave is CompoundResolver {
|
||||||
uint usdcToBorrow,
|
uint usdcToBorrow,
|
||||||
uint zrxUsdcAmt,
|
uint zrxUsdcAmt,
|
||||||
bytes memory calldataHexString,
|
bytes memory calldataHexString,
|
||||||
|
bool isKyber,
|
||||||
address[] memory cTokenAddr,
|
address[] memory cTokenAddr,
|
||||||
uint[] memory ctokenFactor
|
uint[] memory ctokenFactor
|
||||||
) public
|
) public
|
||||||
|
@ -371,14 +376,18 @@ contract CompoundSave is CompoundResolver {
|
||||||
usdcToSwap = usdcToSwap < usdcToBorrow ? usdcToSwap : usdcToBorrow;
|
usdcToSwap = usdcToSwap < usdcToBorrow ? usdcToSwap : usdcToBorrow;
|
||||||
borrow(usdcToSwap);
|
borrow(usdcToSwap);
|
||||||
ERC20Interface usdcContract = ERC20Interface(getAddressUSDC());
|
ERC20Interface usdcContract = ERC20Interface(getAddressUSDC());
|
||||||
|
uint usdcBal = usdcContract.balanceOf(address(this));
|
||||||
|
uint cut = wmul(2500000000000000, usdcBal);
|
||||||
|
usdcContract.transfer(getAddressAdmin(), cut);
|
||||||
|
usdcBal = sub(usdcBal, cut);
|
||||||
usdcContract.approve(getAddressZRXExchange(), zrxUsdcAmt);
|
usdcContract.approve(getAddressZRXExchange(), zrxUsdcAmt);
|
||||||
getAddressZRXExchange().call(calldataHexString);
|
getAddressZRXExchange().call(calldataHexString);
|
||||||
uint usdcBal = usdcContract.balanceOf(address(this));
|
usdcBal = usdcContract.balanceOf(address(this));
|
||||||
if (usdcBal > 0) {
|
if (usdcBal > 0 && isKyber) {
|
||||||
usdcContract.approve(getAddressKyberProxy(), usdcBal);
|
usdcContract.approve(getAddressKyberProxy(), usdcBal);
|
||||||
KyberInterface(getAddressKyberProxy()).trade.value(address(this).balance)(
|
KyberInterface(getAddressKyberProxy()).trade.value(address(this).balance)(
|
||||||
getAddressUSDC(),
|
getAddressUSDC(),
|
||||||
address(this).balance,
|
usdcBal,
|
||||||
getAddressETH(),
|
getAddressETH(),
|
||||||
address(this),
|
address(this),
|
||||||
2**255,
|
2**255,
|
||||||
|
@ -390,8 +399,8 @@ contract CompoundSave is CompoundResolver {
|
||||||
uint wethBal = wethContract.balanceOf(address(this));
|
uint wethBal = wethContract.balanceOf(address(this));
|
||||||
wethContract.approve(getAddressWETH(), wethBal);
|
wethContract.approve(getAddressWETH(), wethBal);
|
||||||
wethContract.withdraw(wethBal);
|
wethContract.withdraw(wethBal);
|
||||||
mintCEth(address(this).balance);
|
mintCEth(wethBal);
|
||||||
emit LogLeverageCompoundUsdc(usdcToSwap, address(this).balance);
|
emit LogLeverageCompoundUsdc(usdcToSwap, wethBal);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user