From abf1adcd030e63e540c59699a59e55c244633224 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Thu, 14 May 2020 20:39:57 +0530 Subject: [PATCH] fixed 1split Resolver --- contracts/protocols/1split.sol | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/contracts/protocols/1split.sol b/contracts/protocols/1split.sol index 377f990..8d78586 100644 --- a/contracts/protocols/1split.sol +++ b/contracts/protocols/1split.sol @@ -70,9 +70,9 @@ contract OneSplitHelpers is Helpers { return 0xC586BeF4a0992C495Cf22e1aeEE4E446CECDee0E; } - function getTokenDecimals(address buy, address sell) internal view returns(uint _buyDec, uint _sellDec){ - _buyDec = buy == getAddressETH() ? 18 : TokenInterface(buy).decimals(); - _sellDec = sell == getAddressETH() ? 18 : TokenInterface(sell).decimals(); + function getTokenDecimals(TokenInterface buy, TokenInterface sell) internal view returns(uint _buyDec, uint _sellDec){ + _buyDec = address(buy) == getAddressETH() ? 18 : buy.decimals(); + _sellDec = address(sell) == getAddressETH() ? 18 : sell.decimals(); } function convertTo18(uint _dec, uint256 _amt) internal pure returns (uint256 amt) { @@ -90,8 +90,9 @@ contract OneSplitHelpers is Helpers { uint sellAmt, uint slippage ) internal view returns (uint unitAmt) { - uint _sellAmt = convertTo18(sellAddr.decimals(), sellAmt); - uint _buyAmt = convertTo18(buyAddr.decimals(), expectedAmt); + (uint buyDec, uint sellDec) = getTokenDecimals(buyAddr, sellAddr); + uint _sellAmt = convertTo18(sellDec, sellAmt); + uint _buyAmt = convertTo18(buyDec, expectedAmt); unitAmt = wdiv(_buyAmt, _sellAmt); unitAmt = wmul(unitAmt, sub(WAD, slippage)); }