mirror of
				https://github.com/Instadapp/dsa-connectors.git
				synced 2024-07-29 22:37:00 +00:00 
			
		
		
		
	fixes + rest amount conversion
Signed-off-by: pradyuman-verma <pradyumnverma27@gmail.com>
This commit is contained in:
		
							parent
							
								
									3b280ee38e
								
							
						
					
					
						commit
						1a8c6aea4f
					
				|  | @ -70,8 +70,12 @@ abstract contract Helpers is DSMath, Basic { | |||
| 		uint256 _sellAmt = swapRouter.exactOutputSingle(params); | ||||
| 		require(_slippageAmt >= _sellAmt, "Too much slippage"); | ||||
| 
 | ||||
| 		isEth = address(buyData.buyAddr) == wethAddr; | ||||
| 		convertEthToWeth(isEth, _buyAddr, _slippageAmt); | ||||
| 		if (_slippageAmt > _sellAmt) { | ||||
| 			convertEthToWeth(isEth, _sellAddr, _slippageAmt - _sellAmt); | ||||
| 			approve(_sellAddr, address(swapRouter), 0); | ||||
| 		} | ||||
| 		isEth = address(buyData.buyAddr) == ethAddr; | ||||
| 		convertWethToEth(isEth, _buyAddr, _buyAmt); | ||||
| 
 | ||||
| 		setUint(setId, _sellAmt); | ||||
| 
 | ||||
|  | @ -131,8 +135,8 @@ abstract contract Helpers is DSMath, Basic { | |||
| 		uint256 _buyAmt = swapRouter.exactInputSingle(params); | ||||
| 		require(_slippageAmt <= _buyAmt, "Too much slippage"); | ||||
| 
 | ||||
| 		isEth = address(sellData.buyAddr) == wethAddr; | ||||
| 		convertEthToWeth(isEth, _buyAddr, _sellAmt); | ||||
| 		isEth = address(sellData.buyAddr) == ethAddr; | ||||
| 		convertWethToEth(isEth, _buyAddr, _buyAmt); | ||||
| 
 | ||||
| 		setUint(setId, _buyAmt); | ||||
| 
 | ||||
|  |  | |||
|  | @ -69,8 +69,12 @@ abstract contract Helpers is DSMath, Basic { | |||
| 		uint256 _sellAmt = swapRouter.exactOutputSingle(params); | ||||
| 		require(_slippageAmt >= _sellAmt, "Too much slippage"); | ||||
| 
 | ||||
| 		isEth = address(buyData.buyAddr) == wethAddr; | ||||
| 		convertEthToWeth(isEth, _buyAddr, _slippageAmt); | ||||
| 		if (_slippageAmt > _sellAmt) { | ||||
| 			convertEthToWeth(isEth, _sellAddr, _slippageAmt - _sellAmt); | ||||
| 			approve(_sellAddr, address(swapRouter), 0); | ||||
| 		} | ||||
| 		isEth = address(buyData.buyAddr) == ethAddr; | ||||
| 		convertWethToEth(isEth, _buyAddr, _buyAmt); | ||||
| 
 | ||||
| 		setUint(setId, _sellAmt); | ||||
| 
 | ||||
|  | @ -129,7 +133,7 @@ abstract contract Helpers is DSMath, Basic { | |||
| 		uint256 _buyAmt = swapRouter.exactInputSingle(params); | ||||
| 		require(_slippageAmt <= _buyAmt, "Too much slippage"); | ||||
| 
 | ||||
| 		isEth = address(sellData.buyAddr) == wethAddr; | ||||
| 		isEth = address(sellData.buyAddr) == ethAddr; | ||||
| 		convertWethToEth(isEth, _buyAddr, _buyAmt); | ||||
| 
 | ||||
| 		setUint(setId, _buyAmt); | ||||
|  |  | |||
|  | @ -70,8 +70,12 @@ abstract contract Helpers is DSMath, Basic { | |||
| 		uint256 _sellAmt = swapRouter.exactOutputSingle(params); | ||||
| 		require(_slippageAmt >= _sellAmt, "Too much slippage"); | ||||
| 
 | ||||
| 		if (_slippageAmt > _sellAmt) { | ||||
| 			convertEthToWeth(isEth, _sellAddr, _slippageAmt - _sellAmt); | ||||
| 			approve(_sellAddr, address(swapRouter), 0); | ||||
| 		} | ||||
| 		isEth = address(buyData.buyAddr) == ethAddr; | ||||
| 		convertEthToWeth(isEth, _buyAddr, _slippageAmt); | ||||
| 		convertWethToEth(isEth, _buyAddr, _buyAmt); | ||||
| 
 | ||||
| 		setUint(setId, _sellAmt); | ||||
| 
 | ||||
|  | @ -132,7 +136,7 @@ abstract contract Helpers is DSMath, Basic { | |||
| 		require(_slippageAmt <= _buyAmt, "Too much slippage"); | ||||
| 
 | ||||
| 		isEth = address(sellData.buyAddr) == ethAddr; | ||||
| 		convertEthToWeth(isEth, _buyAddr, _sellAmt); | ||||
| 		convertWethToEth(isEth, _buyAddr, _buyAmt); | ||||
| 
 | ||||
| 		setUint(setId, _buyAmt); | ||||
| 
 | ||||
|  |  | |||
|  | @ -69,8 +69,13 @@ abstract contract Helpers is DSMath, Basic { | |||
| 		uint256 _sellAmt = swapRouter.exactOutputSingle(params); | ||||
| 		require(_slippageAmt >= _sellAmt, "Too much slippage"); | ||||
| 
 | ||||
| 		if (_slippageAmt > _sellAmt) { | ||||
| 			convertMaticToWmatic(isMatic, _sellAddr, _slippageAmt - _sellAmt); | ||||
| 			approve(_sellAddr, address(swapRouter), 0); | ||||
| 		} | ||||
| 
 | ||||
| 		isMatic = address(buyData.buyAddr) == maticAddr; | ||||
| 		convertMaticToWmatic(isMatic, _buyAddr, _slippageAmt); | ||||
| 		convertWmaticToMatic(isMatic, _buyAddr, _buyAmt); | ||||
| 
 | ||||
| 		setUint(setId, _sellAmt); | ||||
| 
 | ||||
|  | @ -114,7 +119,7 @@ abstract contract Helpers is DSMath, Basic { | |||
| 			wmul(sellData.unitAmt, convertTo18(_sellAddr.decimals(), _sellAmt)) | ||||
| 		); | ||||
| 
 | ||||
| 		bool isMatic = address(buyData.sellAddr) == maticAddr; | ||||
| 		bool isMatic = address(sellData.sellAddr) == maticAddr; | ||||
| 		convertMaticToWmatic(isMatic, _sellAddr, _sellAmt); | ||||
| 		approve(_sellAddr, address(swapRouter), _sellAmt); | ||||
| 		ExactInputSingleParams memory params = ExactInputSingleParams({ | ||||
|  | @ -130,7 +135,7 @@ abstract contract Helpers is DSMath, Basic { | |||
| 		uint256 _buyAmt = swapRouter.exactInputSingle(params); | ||||
| 		require(_slippageAmt <= _buyAmt, "Too much slippage"); | ||||
| 
 | ||||
| 		isMatic = address(sellData.buyAddr) == wmaticAddr; | ||||
| 		isMatic = address(sellData.buyAddr) == maticAddr; | ||||
| 		convertWmaticToMatic(isMatic, _buyAddr, _buyAmt); | ||||
| 
 | ||||
| 		setUint(setId, _buyAmt); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 pradyuman-verma
						pradyuman-verma