mirror of
https://github.com/Instadapp/dsa-resolvers-deprecated.git
synced 2024-07-29 22:38:16 +00:00
Added multiple tokens path function
This commit is contained in:
parent
4d42846bca
commit
61e461bbf8
|
@ -208,6 +208,58 @@ contract Resolver is OneSplitHelpers {
|
||||||
buyAmt = returnAmounts[len - 2];
|
buyAmt = returnAmounts[len - 2];
|
||||||
unitAmt = getBuyUnitAmt(_buyAddr, buyAmt, _sellAddr, sellAmt, slippage);
|
unitAmt = getBuyUnitAmt(_buyAddr, buyAmt, _sellAddr, sellAmt, slippage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct MultiTokenPaths {
|
||||||
|
TokenInterface[] tokens;
|
||||||
|
uint[] distribution;
|
||||||
|
uint[] disableDexes;
|
||||||
|
uint[] destTokenEthPriceTimesGasPrices;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MultiTokenPathsBuyAmt {
|
||||||
|
uint buyAmt;
|
||||||
|
uint unitAmt;
|
||||||
|
uint[] distributions;
|
||||||
|
uint[] returnAmounts;
|
||||||
|
uint estimateGasAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBuyAmountsMulti(
|
||||||
|
MultiTokenPaths[] memory multiTokenPaths,
|
||||||
|
uint sellAmt,
|
||||||
|
uint slippage
|
||||||
|
)
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (MultiTokenPathsBuyAmt[] memory)
|
||||||
|
{
|
||||||
|
uint len = multiTokenPaths.length;
|
||||||
|
MultiTokenPathsBuyAmt[] memory data = new MultiTokenPathsBuyAmt[](len);
|
||||||
|
for (uint i = 0; i < len; i++) {
|
||||||
|
(
|
||||||
|
uint buyAmt,
|
||||||
|
uint unitAmt,
|
||||||
|
uint[] memory distributions,
|
||||||
|
uint[] memory returnAmounts,
|
||||||
|
uint estimateGasAmount
|
||||||
|
) = getBuyAmountMultiWithGas(
|
||||||
|
multiTokenPaths[i].tokens,
|
||||||
|
sellAmt,
|
||||||
|
slippage,
|
||||||
|
multiTokenPaths[i].distribution,
|
||||||
|
multiTokenPaths[i].disableDexes,
|
||||||
|
multiTokenPaths[i].destTokenEthPriceTimesGasPrices
|
||||||
|
);
|
||||||
|
data[i] = MultiTokenPathsBuyAmt(
|
||||||
|
buyAmt,
|
||||||
|
unitAmt,
|
||||||
|
distributions,
|
||||||
|
returnAmounts,
|
||||||
|
estimateGasAmount
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user