mirror of
https://github.com/Instadapp/dsa-resolvers-deprecated.git
synced 2024-07-29 22:38:16 +00:00
Fixed stack too deep error
This commit is contained in:
parent
2b295d1c5f
commit
92b6eb64a1
|
@ -33,11 +33,11 @@ interface OneProtoInterface {
|
||||||
);
|
);
|
||||||
|
|
||||||
function getExpectedReturnWithGasMulti(
|
function getExpectedReturnWithGasMulti(
|
||||||
TokenInterface[] memory tokens,
|
TokenInterface[] calldata tokens,
|
||||||
uint256 amount,
|
uint256 amount,
|
||||||
uint256[] memory parts,
|
uint256[] calldata parts,
|
||||||
uint256[] memory flags,
|
uint256[] calldata flags,
|
||||||
uint256[] memory destTokenEthPriceTimesGasPrices
|
uint256[] calldata destTokenEthPriceTimesGasPrices
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
|
@ -48,6 +48,11 @@ interface OneProtoInterface {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface OneProtoMappingInterface {
|
||||||
|
function oneProtoAddress() external view returns(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
interface TokenInterface {
|
interface TokenInterface {
|
||||||
function decimals() external view returns (uint);
|
function decimals() external view returns (uint);
|
||||||
function totalSupply() external view returns (uint256);
|
function totalSupply() external view returns (uint256);
|
||||||
|
@ -93,12 +98,19 @@ contract Helpers is DSMath {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract OneSplitHelpers is Helpers {
|
contract OneProtoHelpers is Helpers {
|
||||||
/**
|
/**
|
||||||
* @dev Return 1Split Address
|
* @dev Return 1proto mapping Address
|
||||||
*/
|
*/
|
||||||
function getOneProtoAddress() internal pure returns (address) {
|
function getOneProtoMappingAddress() internal pure returns (address payable) {
|
||||||
return 0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e;
|
return 0x8d0287AFa7755BB5f2eFe686AA8d4F0A7BC4AE7F;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Return 1proto Address
|
||||||
|
*/
|
||||||
|
function getOneProtoAddress() internal view returns (address payable) {
|
||||||
|
return payable(OneProtoMappingInterface(getOneProtoMappingAddress()).oneProtoAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTokenDecimals(TokenInterface buy, TokenInterface sell) internal view returns(uint _buyDec, uint _sellDec){
|
function getTokenDecimals(TokenInterface buy, TokenInterface sell) internal view returns(uint _buyDec, uint _sellDec){
|
||||||
|
@ -130,7 +142,7 @@ contract OneSplitHelpers is Helpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract Resolver is OneSplitHelpers {
|
contract Resolver is OneProtoHelpers {
|
||||||
|
|
||||||
function getBuyAmount(
|
function getBuyAmount(
|
||||||
address buyAddr,
|
address buyAddr,
|
||||||
|
@ -195,8 +207,6 @@ contract Resolver is OneSplitHelpers {
|
||||||
uint estimateGasAmount
|
uint estimateGasAmount
|
||||||
) {
|
) {
|
||||||
uint len = tokens.length;
|
uint len = tokens.length;
|
||||||
TokenInterface _buyAddr = TokenInterface(tokens[len - 1]);
|
|
||||||
TokenInterface _sellAddr = TokenInterface(tokens[0]);
|
|
||||||
(returnAmounts, estimateGasAmount, distributions) = OneProtoInterface(getOneProtoAddress())
|
(returnAmounts, estimateGasAmount, distributions) = OneProtoInterface(getOneProtoAddress())
|
||||||
.getExpectedReturnWithGasMulti(
|
.getExpectedReturnWithGasMulti(
|
||||||
tokens,
|
tokens,
|
||||||
|
@ -205,8 +215,8 @@ contract Resolver is OneSplitHelpers {
|
||||||
disableDexes,
|
disableDexes,
|
||||||
destTokenEthPriceTimesGasPrices
|
destTokenEthPriceTimesGasPrices
|
||||||
);
|
);
|
||||||
buyAmt = returnAmounts[len - 2];
|
buyAmt = returnAmounts[len - 1];
|
||||||
unitAmt = getBuyUnitAmt(_buyAddr, buyAmt, _sellAddr, sellAmt, slippage);
|
unitAmt = getBuyUnitAmt(TokenInterface(tokens[len - 1]), buyAmt, TokenInterface(tokens[0]), sellAmt, slippage);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MultiTokenPaths {
|
struct MultiTokenPaths {
|
||||||
|
@ -236,12 +246,19 @@ contract Resolver is OneSplitHelpers {
|
||||||
uint len = multiTokenPaths.length;
|
uint len = multiTokenPaths.length;
|
||||||
MultiTokenPathsBuyAmt[] memory data = new MultiTokenPathsBuyAmt[](len);
|
MultiTokenPathsBuyAmt[] memory data = new MultiTokenPathsBuyAmt[](len);
|
||||||
for (uint i = 0; i < len; i++) {
|
for (uint i = 0; i < len; i++) {
|
||||||
|
data[i] = MultiTokenPathsBuyAmt({
|
||||||
|
buyAmt: 0,
|
||||||
|
unitAmt: 0,
|
||||||
|
distributions: new uint[](0),
|
||||||
|
returnAmounts: new uint[](0),
|
||||||
|
estimateGasAmount: 0
|
||||||
|
});
|
||||||
(
|
(
|
||||||
uint buyAmt,
|
data[i].buyAmt,
|
||||||
uint unitAmt,
|
data[i].unitAmt,
|
||||||
uint[] memory distributions,
|
data[i].distributions,
|
||||||
uint[] memory returnAmounts,
|
data[i].returnAmounts,
|
||||||
uint estimateGasAmount
|
data[i].estimateGasAmount
|
||||||
) = getBuyAmountMultiWithGas(
|
) = getBuyAmountMultiWithGas(
|
||||||
multiTokenPaths[i].tokens,
|
multiTokenPaths[i].tokens,
|
||||||
sellAmt,
|
sellAmt,
|
||||||
|
@ -250,19 +267,12 @@ contract Resolver is OneSplitHelpers {
|
||||||
multiTokenPaths[i].disableDexes,
|
multiTokenPaths[i].disableDexes,
|
||||||
multiTokenPaths[i].destTokenEthPriceTimesGasPrices
|
multiTokenPaths[i].destTokenEthPriceTimesGasPrices
|
||||||
);
|
);
|
||||||
data[i] = MultiTokenPathsBuyAmt(
|
|
||||||
buyAmt,
|
|
||||||
unitAmt,
|
|
||||||
distributions,
|
|
||||||
returnAmounts,
|
|
||||||
estimateGasAmount
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract InstaOneSplitResolver is Resolver {
|
contract InstaOneProtoResolver is Resolver {
|
||||||
string public constant name = "1Proto-Resolver-v1";
|
string public constant name = "1Proto-Resolver-v1";
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user