mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
Fixed stack too deep Error
This commit is contained in:
parent
466ce9b1e4
commit
72bbcfa8a3
|
@ -120,6 +120,29 @@ contract Resolver is OneHelpers {
|
||||||
|
|
||||||
require(_slippageAmt <= buyAmt, "Too much slippage");
|
require(_slippageAmt <= buyAmt, "Too much slippage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function oneInchSwap(
|
||||||
|
TokenInterface _buyAddr,
|
||||||
|
TokenInterface _sellAddr,
|
||||||
|
bytes memory callData,
|
||||||
|
uint sellAmt,
|
||||||
|
uint unitAmt,
|
||||||
|
uint ethAmt
|
||||||
|
) internal returns (uint buyAmt) {
|
||||||
|
(uint _buyDec, uint _sellDec) = getTokensDec(_buyAddr, _sellAddr);
|
||||||
|
uint _sellAmt18 = convertTo18(_sellDec, sellAmt);
|
||||||
|
uint _slippageAmt = convert18ToDec(_buyDec, wmul(unitAmt, _sellAmt18));
|
||||||
|
uint initalBal = getTokenBal(_buyAddr);
|
||||||
|
|
||||||
|
// solium-disable-next-line security/no-call-value
|
||||||
|
(bool success, ) = address(getOneInchAddress()).call.value(ethAmt)(callData);
|
||||||
|
if (!success) revert("1Inch-swap-failed");
|
||||||
|
|
||||||
|
uint finalBal = getTokenBal(_buyAddr);
|
||||||
|
buyAmt = sub(finalBal, initalBal);
|
||||||
|
|
||||||
|
require(_slippageAmt <= buyAmt, "Too much slippage");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract BasicResolver is Resolver {
|
contract BasicResolver is Resolver {
|
||||||
|
@ -219,10 +242,6 @@ contract BasicResolver is Resolver {
|
||||||
TokenInterface _buyAddr = TokenInterface(buyAddr);
|
TokenInterface _buyAddr = TokenInterface(buyAddr);
|
||||||
TokenInterface _sellAddr = TokenInterface(sellAddr);
|
TokenInterface _sellAddr = TokenInterface(sellAddr);
|
||||||
|
|
||||||
(uint _buyDec, uint _sellDec) = getTokensDec(_buyAddr, _sellAddr);
|
|
||||||
uint _sellAmt18 = convertTo18(_sellDec, sellAmt);
|
|
||||||
uint _slippageAmt = convert18ToDec(_buyDec, wmul(unitAmt, _sellAmt18));
|
|
||||||
|
|
||||||
uint ethAmt;
|
uint ethAmt;
|
||||||
if (address(_sellAddr) == getEthAddr()) {
|
if (address(_sellAddr) == getEthAddr()) {
|
||||||
ethAmt = sellAmt;
|
ethAmt = sellAmt;
|
||||||
|
@ -230,16 +249,7 @@ contract BasicResolver is Resolver {
|
||||||
TokenInterface(_sellAddr).approve(getOneInchAddress(), sellAmt);
|
TokenInterface(_sellAddr).approve(getOneInchAddress(), sellAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint initalBal = getTokenBal(_buyAddr);
|
uint buyAmt = oneInchSwap(_buyAddr, _sellAddr, callData, sellAmt, unitAmt, sellAmt);
|
||||||
|
|
||||||
// solium-disable-next-line security/no-call-value
|
|
||||||
(bool success, ) = address(getOneInchAddress()).call.value(ethAmt)(callData);
|
|
||||||
if (!success) revert("1Inch-swap-failed");
|
|
||||||
|
|
||||||
uint finalBal = getTokenBal(_buyAddr);
|
|
||||||
uint buyAmt = sub(finalBal, initalBal);
|
|
||||||
|
|
||||||
require(_slippageAmt <= buyAmt, "Too much slippage");
|
|
||||||
|
|
||||||
setUint(setId, buyAmt);
|
setUint(setId, buyAmt);
|
||||||
emit LogSell(address(_buyAddr), address(_sellAddr), buyAmt, sellAmt, 0, setId);
|
emit LogSell(address(_buyAddr), address(_sellAddr), buyAmt, sellAmt, 0, setId);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user