mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	update universalTransferFromSenderToThis with returnExcess
This commit is contained in:
		
							parent
							
								
									43b5c2c832
								
							
						
					
					
						commit
						a281bdba97
					
				| 
						 | 
				
			
			@ -36,7 +36,7 @@ contract MockKyberProxy {
 | 
			
		|||
    ) external payable returns (uint256) {
 | 
			
		||||
        require(tokenToBurn.mint(1 ether), "TRADE_WITH_HINT. Reverted mint()");
 | 
			
		||||
        if (!_fromToken.isETH()) {
 | 
			
		||||
            _fromToken.universalTransferFromSenderToThis(_amount);
 | 
			
		||||
            _fromToken.universalTransferFromSenderToThis(_amount, true);
 | 
			
		||||
        }
 | 
			
		||||
        tokenToBurn.universalTransfer(msg.sender, 1 ether);
 | 
			
		||||
        return 1 ether;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ contract MockOneSplit is IOneSplit {
 | 
			
		|||
    ) public override payable {
 | 
			
		||||
        require(tokenToBurn.mint(10000 ether), "TRADE_WITH_HINT. Reverted mint()");
 | 
			
		||||
        if (!fromToken.isETH()) {
 | 
			
		||||
            fromToken.universalTransferFromSenderToThis(amount);
 | 
			
		||||
            fromToken.universalTransferFromSenderToThis(amount, true);
 | 
			
		||||
        }
 | 
			
		||||
        tokenToBurn.universalTransfer(msg.sender, 10000 ether);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -322,7 +322,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
 | 
			
		|||
                "User is sending ETH along with the ERC20 transfer."
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        IERC20(_reserve).universalTransferFromSenderToThis(_amount);
 | 
			
		||||
        IERC20(_reserve).universalTransferFromSenderToThis(_amount, true);
 | 
			
		||||
 | 
			
		||||
        //solium-disable-next-line
 | 
			
		||||
        emit Deposit(_reserve, msg.sender, _amount, _referralCode, block.timestamp);
 | 
			
		||||
| 
						 | 
				
			
			@ -646,13 +646,13 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable {
 | 
			
		|||
                "User is sending ETH along with the ERC20 transfer."
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        IERC20(_reserve).universalTransferFromSenderToThis(vars.paybackAmountMinusFees);
 | 
			
		||||
        IERC20(_reserve).universalTransferFromSenderToThis(vars.paybackAmountMinusFees, false);
 | 
			
		||||
 | 
			
		||||
        if (vars.isETH) {
 | 
			
		||||
            uint256 exceedAmount = msg.value
 | 
			
		||||
                .sub(vars.originationFee)
 | 
			
		||||
                .sub(vars.paybackAmountMinusFees);
 | 
			
		||||
            //send excess ETH back to the caller in needed
 | 
			
		||||
            //send excess ETH back to the caller if needed
 | 
			
		||||
            if (exceedAmount > 0) {
 | 
			
		||||
                IERC20(_reserve).universalTransfer(msg.sender, exceedAmount);
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -256,7 +256,7 @@ contract LendingPoolLiquidationManager is ReentrancyGuard, VersionedInitializabl
 | 
			
		|||
 | 
			
		||||
        //transfers the principal currency to the pool
 | 
			
		||||
        IERC20(_reserve).universalTransferFromSenderToThis(
 | 
			
		||||
            vars.actualAmountToLiquidate
 | 
			
		||||
            vars.actualAmountToLiquidate, true
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        if (vars.feeLiquidated > 0) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,7 +99,7 @@ library UniversalERC20 {
 | 
			
		|||
    * @param token underlying asset address
 | 
			
		||||
    * @param amount to move
 | 
			
		||||
    **/
 | 
			
		||||
    function universalTransferFromSenderToThis(IERC20 token, uint256 amount)
 | 
			
		||||
    function universalTransferFromSenderToThis(IERC20 token, uint256 amount, bool returnExcess)
 | 
			
		||||
        internal
 | 
			
		||||
    {
 | 
			
		||||
        if (amount == 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ library UniversalERC20 {
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        if (isETH(token)) {
 | 
			
		||||
            if (msg.value > amount) {
 | 
			
		||||
            if (msg.value > amount && returnExcess) {
 | 
			
		||||
                // Return remainder if exist
 | 
			
		||||
                (bool result, ) = msg.sender.call{
 | 
			
		||||
                    value: msg.value.sub(amount),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user