mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	Fixes deposits tests
This commit is contained in:
		
							parent
							
								
									a7b6beef48
								
							
						
					
					
						commit
						03767e003f
					
				| 
						 | 
				
			
			@ -67,39 +67,6 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
 | 
			
		|||
    _setDecimals(underlyingAssetDecimals);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @notice ERC20 implementation internal function backing transfer() and transferFrom()
 | 
			
		||||
   **/
 | 
			
		||||
  function _transfer(
 | 
			
		||||
    address from,
 | 
			
		||||
    address to,
 | 
			
		||||
    uint256 amount,
 | 
			
		||||
    bool validate
 | 
			
		||||
  ) internal  {
 | 
			
		||||
    if(validate){
 | 
			
		||||
      require(isTransferAllowed(from, amount), Errors.TRANSFER_NOT_ALLOWED);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    uint256 index = _pool.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS);
 | 
			
		||||
 | 
			
		||||
    uint256 scaledAmount = amount.rayDiv(index);
 | 
			
		||||
 | 
			
		||||
    super._transfer(from, to, scaledAmount);
 | 
			
		||||
 | 
			
		||||
    //if the sender is redirecting his interest towards someone else,
 | 
			
		||||
    //adds to the redirected balance the accrued interest and removes the amount
 | 
			
		||||
    //being transferred
 | 
			
		||||
    _updateRedirectedBalanceOfRedirectionAddress(from, from, 0, scaledAmount, index);
 | 
			
		||||
 | 
			
		||||
    //if the receiver is redirecting his interest towards someone else,
 | 
			
		||||
    //adds to the redirected balance the accrued interest and the amount
 | 
			
		||||
    //being transferred
 | 
			
		||||
    _updateRedirectedBalanceOfRedirectionAddress(to, to, scaledAmount, 0, index);
 | 
			
		||||
 | 
			
		||||
    emit BalanceTransfer(from, to, amount, index);
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev redirects the interest generated to a target address.
 | 
			
		||||
   * when the interest is redirected, the user balance is added to
 | 
			
		||||
| 
						 | 
				
			
			@ -187,7 +154,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
 | 
			
		|||
    uint256 index = _pool.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS);
 | 
			
		||||
 | 
			
		||||
    uint256 scaledAmount = amount.rayDiv(index);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
    //mint an equivalent amount of tokens to cover the new deposit
 | 
			
		||||
    _mint(user,scaledAmount);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -232,8 +199,24 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
 | 
			
		|||
    if (currentScaledBalance == 0 && redirectedBalance == 0) {
 | 
			
		||||
      return 0;
 | 
			
		||||
    }
 | 
			
		||||
    uint256 scaledRedirectedBalance = redirectedBalance > 0 ?  redirectedBalance.rayDiv(_interestRedirectionIndexes[user]) : 0;
 | 
			
		||||
 | 
			
		||||
    return _calculateCumulatedBalance(user, currentScaledBalance, redirectedBalance);
 | 
			
		||||
    uint256 index = _pool.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS);
 | 
			
		||||
 | 
			
		||||
    if(_interestRedirectionAddresses[user] == address(0)){
 | 
			
		||||
      //if the user is not redirecting the interest, his balance is the result of
 | 
			
		||||
      //the interest accrued by his current scaled balance and the interest accrued by his
 | 
			
		||||
      //scaled redirected balance
 | 
			
		||||
      return currentScaledBalance.add(scaledRedirectedBalance).rayMul(index).sub(scaledRedirectedBalance);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //if the user is redirecting, his balance only increases by the balance he is being redirected to
 | 
			
		||||
    uint256 lastRedirectedBalance = currentScaledBalance.rayDiv(_interestRedirectionIndexes[user]);
 | 
			
		||||
 | 
			
		||||
    return
 | 
			
		||||
      lastRedirectedBalance.add(
 | 
			
		||||
        scaledRedirectedBalance.rayMul(index)
 | 
			
		||||
      ).sub(scaledRedirectedBalance);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			@ -246,6 +229,17 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
 | 
			
		|||
    return super.balanceOf(user);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev returns the scaled balance of the user. The scaled balance is the sum of all the
 | 
			
		||||
   * updated stored balance divided the reserve index at the moment of the update
 | 
			
		||||
   * @param user the address of the user
 | 
			
		||||
   * @return the scaled balance of the user
 | 
			
		||||
   **/
 | 
			
		||||
  function getUserInterestRedirectionIndex(address user) external override view returns (uint256) {
 | 
			
		||||
    return _interestRedirectionIndexes[user];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev calculates the total supply of the specific aToken
 | 
			
		||||
   * since the balance of every single user increases over time, the total supply
 | 
			
		||||
| 
						 | 
				
			
			@ -351,39 +345,6 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
 | 
			
		|||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev calculate the interest accrued by user on a specific balance
 | 
			
		||||
   * @param user the address of the user for which the interest is being accumulated
 | 
			
		||||
   * @param scaledBalance the balance on which the interest is calculated
 | 
			
		||||
   * @param redirectedBalance the balance redirected to the user
 | 
			
		||||
   * @return the interest rate accrued
 | 
			
		||||
   **/
 | 
			
		||||
  function _calculateCumulatedBalance(address user, uint256 scaledBalance, uint256 redirectedBalance)
 | 
			
		||||
    internal
 | 
			
		||||
    view
 | 
			
		||||
    returns (uint256)
 | 
			
		||||
  {
 | 
			
		||||
    uint256 scaledRedirectedBalance = redirectedBalance.wadToRay().rayDiv(_interestRedirectionIndexes[user]).rayToWad();
 | 
			
		||||
 | 
			
		||||
    uint256 index = _pool.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS);
 | 
			
		||||
 | 
			
		||||
    if(_interestRedirectionAddresses[user] == address(0)){
 | 
			
		||||
      //if the user is not redirecting the interest, his balance is the result of
 | 
			
		||||
      //the interest accrued by his current scaled balance and the interest accrued by his
 | 
			
		||||
      //scaled redirected balance
 | 
			
		||||
 | 
			
		||||
      return scaledBalance.add(scaledRedirectedBalance).rayMul(index).sub(scaledRedirectedBalance);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //if the user is redirecting, his balance only increases by the balance he is being redirected
 | 
			
		||||
    uint256 lastRedirectedBalance = scaledBalance.rayDiv(_interestRedirectionIndexes[user]);
 | 
			
		||||
 | 
			
		||||
    return
 | 
			
		||||
      lastRedirectedBalance.add(
 | 
			
		||||
        scaledRedirectedBalance.rayMul(index)
 | 
			
		||||
      ).sub(scaledRedirectedBalance);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev executes the redirection of the interest from one address to another.
 | 
			
		||||
   * immediately after redirection, the destination address will start to accrue interest.
 | 
			
		||||
| 
						 | 
				
			
			@ -444,13 +405,12 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev transfers the underlying asset to the target. Used by the lendingpool to transfer
 | 
			
		||||
   * assets in borrow(), redeem() and flashLoan()
 | 
			
		||||
   * @param target the target of the transfer
 | 
			
		||||
   * @param amount the amount to transfer
 | 
			
		||||
   * @return the amount transferred
 | 
			
		||||
   **/
 | 
			
		||||
 | 
			
		||||
  * @dev transfers the underlying asset to the target. Used by the lendingpool to transfer
 | 
			
		||||
  * assets in borrow(), redeem() and flashLoan()
 | 
			
		||||
  * @param target the target of the transfer
 | 
			
		||||
  * @param amount the amount to transfer
 | 
			
		||||
  * @return the amount transferred
 | 
			
		||||
  **/
 | 
			
		||||
  function transferUnderlyingTo(address target, uint256 amount)
 | 
			
		||||
    external
 | 
			
		||||
    override
 | 
			
		||||
| 
						 | 
				
			
			@ -461,6 +421,40 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
 | 
			
		|||
    return amount;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   /**
 | 
			
		||||
   * @notice ERC20 implementation internal function backing transfer() and transferFrom()
 | 
			
		||||
   **/
 | 
			
		||||
  function _transfer(
 | 
			
		||||
    address from,
 | 
			
		||||
    address to,
 | 
			
		||||
    uint256 amount,
 | 
			
		||||
    bool validate
 | 
			
		||||
  ) internal  {
 | 
			
		||||
    if(validate){
 | 
			
		||||
      require(isTransferAllowed(from, amount), Errors.TRANSFER_NOT_ALLOWED);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    uint256 index = _pool.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS);
 | 
			
		||||
 | 
			
		||||
    uint256 scaledAmount = amount.rayDiv(index);
 | 
			
		||||
 | 
			
		||||
    super._transfer(from, to, scaledAmount);
 | 
			
		||||
 | 
			
		||||
    //if the sender is redirecting his interest towards someone else,
 | 
			
		||||
    //adds to the redirected balance the accrued interest and removes the amount
 | 
			
		||||
    //being transferred
 | 
			
		||||
    _updateRedirectedBalanceOfRedirectionAddress(from, from, 0, scaledAmount, index);
 | 
			
		||||
 | 
			
		||||
    //if the receiver is redirecting his interest towards someone else,
 | 
			
		||||
    //adds to the redirected balance the accrued interest and the amount
 | 
			
		||||
    //being transferred
 | 
			
		||||
    _updateRedirectedBalanceOfRedirectionAddress(to, to, scaledAmount, 0, index);
 | 
			
		||||
 | 
			
		||||
    emit BalanceTransfer(from, to, amount, index);
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev aTokens should not receive ETH
 | 
			
		||||
   **/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -151,6 +151,13 @@ interface IAToken is IERC20 {
 | 
			
		|||
   **/
 | 
			
		||||
  function getInterestRedirectionAddress(address user) external view returns (address);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev returns the index of the user at the moment of redirection
 | 
			
		||||
   * @param user address of the user
 | 
			
		||||
   * @return interest redirection index
 | 
			
		||||
   **/
 | 
			
		||||
  function getUserInterestRedirectionIndex(address user) external view returns (uint256);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev returns the redirected balance of the user. The redirected balance is the balance
 | 
			
		||||
   * redirected by other accounts to the user, that is accrueing interest for him.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xf8c6eB390cDc5C08717bC2268aa0c1169A9B5deE",
 | 
			
		||||
      "address": "0x58F132FBB86E21545A4Bace3C19f1C05d86d7A22",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -15,7 +15,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x4a716924Dad0c0d0E558844F304548814e7089F1",
 | 
			
		||||
      "address": "0xa4bcDF64Cdd5451b6ac3743B414124A6299B65FF",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +25,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x798c5b4b62b1eA9D64955D6751B03075A003F123",
 | 
			
		||||
      "address": "0x5A0773Ff307Bf7C71a832dBB5312237fD3437f9F",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -188,7 +188,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x11df1AF606b85226Ab9a8B1FDa90395298e7494F",
 | 
			
		||||
      "address": "0x7c2C195CD6D34B8F845992d380aADB2730bB9C6F",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -198,7 +198,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x8f9A92c125FFEb83d8eC808Cd9f8cb80084c1E37",
 | 
			
		||||
      "address": "0x8858eeB3DfffA017D4BCE9801D340D36Cf895CCf",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -208,7 +208,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xc4007844AE6bBe168cE8D692C86a7A4414FBcD26",
 | 
			
		||||
      "address": "0x0078371BDeDE8aAc7DeBfFf451B74c5EDB385Af7",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -218,7 +218,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xAb768C858C33DfcB6651d1174AFb750433a87Be0",
 | 
			
		||||
      "address": "0xf4e77E5Da47AC3125140c470c71cBca77B5c638c",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -228,7 +228,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xA089557D64DAE4b4FcB65aB7C8A520AABb213e37",
 | 
			
		||||
      "address": "0x3619DbE27d7c1e7E91aA738697Ae7Bc5FC3eACA5",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -238,7 +238,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x20FAE2042b362E3FaB2806820b9A43CC116e2846",
 | 
			
		||||
      "address": "0x038B86d9d8FAFdd0a02ebd1A476432877b0107C8",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -248,7 +248,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x8880F314112f15C2AfF674c3B27f9a44Ca86e4d0",
 | 
			
		||||
      "address": "0x1A1FEe7EeD918BD762173e4dc5EfDB8a78C924A8",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -258,7 +258,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xDcb10C2e15110Db4B02C0a1df459768E680ce245",
 | 
			
		||||
      "address": "0x500D1d6A4c7D8Ae28240b47c8FCde034D827fD5e",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -268,7 +268,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xfD408ec64Da574b1859814F810564f73ea2Ff003",
 | 
			
		||||
      "address": "0xc4905364b78a742ccce7B890A89514061E47068D",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -278,7 +278,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x0006F7c3542BEE76Dd887f54eD22405Ac4ae905a",
 | 
			
		||||
      "address": "0xD6C850aeBFDC46D7F4c207e445cC0d6B0919BDBe",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -288,7 +288,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x6ca94a51c644eca3F9CA315bcC41CbA6940A66Eb",
 | 
			
		||||
      "address": "0x8B5B7a6055E54a36fF574bbE40cf2eA68d5554b3",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -298,7 +298,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x6765291Cab755B980F377445eFd0F9F945CDA6C4",
 | 
			
		||||
      "address": "0xEcc0a6dbC0bb4D51E4F84A315a9e5B0438cAD4f0",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -308,7 +308,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xa7dB4d25Fc525d19Fbda4E74AAF447B88420FbcB",
 | 
			
		||||
      "address": "0x20Ce94F404343aD2752A2D01b43fa407db9E0D00",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -318,7 +318,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x273D60904A8DBa3Ae6B20505c59902644124fF0E",
 | 
			
		||||
      "address": "0x1d80315fac6aBd3EfeEbE97dEc44461ba7556160",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -328,7 +328,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xfc37dE87C1Ee39cc856782BF96fEdcB6FA5c5A7f",
 | 
			
		||||
      "address": "0x2D8553F9ddA85A9B3259F6Bf26911364B85556F5",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -338,7 +338,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x049228dFFEdf91ff224e9F96247aEBA700e3590c",
 | 
			
		||||
      "address": "0x52d3b94181f8654db2530b0fEe1B19173f519C52",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -348,7 +348,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xA410D1f3fEAF300842142Cd7AA1709D84944DCb7",
 | 
			
		||||
      "address": "0xd15468525c35BDBC1eD8F2e09A00F8a173437f2f",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -358,7 +358,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x835973768750b3ED2D5c3EF5AdcD5eDb44d12aD4",
 | 
			
		||||
      "address": "0x7e35Eaf7e8FBd7887ad538D4A38Df5BbD073814a",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -368,7 +368,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x1181FC27dbF04B5105243E60BB1936c002e9d5C8",
 | 
			
		||||
      "address": "0x5bcb88A0d20426e451332eE6C4324b0e663c50E0",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -378,7 +378,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x6F96975e2a0e1380b6e2e406BB33Ae96e4b6DB65",
 | 
			
		||||
      "address": "0x3521eF8AaB0323004A6dD8b03CE890F4Ea3A13f5",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -388,7 +388,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xc032930653da193EDE295B4DcE3DD093a695c3b3",
 | 
			
		||||
      "address": "0x53369fd4680FfE3DfF39Fc6DDa9CfbfD43daeA2E",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -398,7 +398,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xb3363f4349b1160DbA55ec4D82fDe874A4123A2a",
 | 
			
		||||
      "address": "0xB00cC45B4a7d3e1FEE684cFc4417998A1c183e6d",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -408,7 +408,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xf8c6eB390cDc5C08717bC2268aa0c1169A9B5deE",
 | 
			
		||||
      "address": "0x58F132FBB86E21545A4Bace3C19f1C05d86d7A22",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -456,7 +456,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x1203D1b97BF6E546c00C45Cda035D3010ACe1180",
 | 
			
		||||
      "address": "0xF5E6E6B10E4F2f27DaC1fFdDE83367dE9525552a",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -466,7 +466,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x2cc20bE530F92865c2ed8CeD0b020a11bFe62Fe7",
 | 
			
		||||
      "address": "0xf784709d2317D872237C4bC22f867d1BAe2913AB",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -476,7 +476,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0x8733AfE8174BA7c04c6CD694bD673294079b7E10",
 | 
			
		||||
      "address": "0x7f23223A2FAf869962B38f5eC4aAB7f37454A45e",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			@ -486,7 +486,7 @@
 | 
			
		|||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    },
 | 
			
		||||
    "localhost": {
 | 
			
		||||
      "address": "0xA8083d78B6ABC328b4d3B714F76F384eCC7147e1",
 | 
			
		||||
      "address": "0x1203D1b97BF6E546c00C45Cda035D3010ACe1180",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,7 +41,7 @@ export const calcExpectedUserDataAfterDeposit = (
 | 
			
		|||
    txTimestamp
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  expectedUserData.principalATokenBalance = userDataBeforeAction.principalStableDebt;
 | 
			
		||||
  expectedUserData.principalStableDebt = userDataBeforeAction.principalStableDebt;
 | 
			
		||||
  expectedUserData.principalVariableDebt = userDataBeforeAction.principalVariableDebt;
 | 
			
		||||
  expectedUserData.variableBorrowIndex = userDataBeforeAction.variableBorrowIndex;
 | 
			
		||||
  expectedUserData.stableBorrowRate = userDataBeforeAction.stableBorrowRate;
 | 
			
		||||
| 
						 | 
				
			
			@ -49,9 +49,6 @@ export const calcExpectedUserDataAfterDeposit = (
 | 
			
		|||
 | 
			
		||||
  expectedUserData.liquidityRate = reserveDataAfterAction.liquidityRate;
 | 
			
		||||
 | 
			
		||||
  expectedUserData.currentATokenBalance = userDataBeforeAction.currentATokenBalance.plus(
 | 
			
		||||
    amountDeposited
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  if (userDataBeforeAction.currentATokenBalance.eq(0)) {
 | 
			
		||||
    expectedUserData.usageAsCollateralEnabled = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +64,10 @@ export const calcExpectedUserDataAfterDeposit = (
 | 
			
		|||
  expectedUserData.variableBorrowIndex = userDataBeforeAction.variableBorrowIndex;
 | 
			
		||||
  expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(amountDeposited);
 | 
			
		||||
 | 
			
		||||
  expectedUserData.principalATokenBalance = expectedUserData.currentATokenBalance = calcExpectedATokenBalance(
 | 
			
		||||
  expectedUserData.scaledATokenBalance = calcExpectedScaledATokenBalance(reserveDataAfterAction, userDataBeforeAction, new BigNumber(amountDeposited), new BigNumber(0));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  expectedUserData.currentATokenBalance = calcExpectedATokenBalance(
 | 
			
		||||
    reserveDataBeforeAction,
 | 
			
		||||
    userDataBeforeAction,
 | 
			
		||||
    txTimestamp
 | 
			
		||||
| 
						 | 
				
			
			@ -75,12 +75,8 @@ export const calcExpectedUserDataAfterDeposit = (
 | 
			
		|||
 | 
			
		||||
  expectedUserData.redirectedBalance = userDataBeforeAction.redirectedBalance;
 | 
			
		||||
  expectedUserData.interestRedirectionAddress = userDataBeforeAction.interestRedirectionAddress;
 | 
			
		||||
  expectedUserData.currentATokenUserIndex = calcExpectedATokenUserIndex(
 | 
			
		||||
    reserveDataBeforeAction,
 | 
			
		||||
    expectedUserData.currentATokenBalance,
 | 
			
		||||
    expectedUserData.redirectedBalance,
 | 
			
		||||
    txTimestamp
 | 
			
		||||
  );
 | 
			
		||||
  expectedUserData.interestRedirectionIndex = userDataBeforeAction.interestRedirectionAddress == ZERO_ADDRESS ? new BigNumber(0) : reserveDataAfterAction.liquidityIndex;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  expectedUserData.currentStableDebt = expectedUserData.principalStableDebt = calcExpectedStableDebtTokenBalance(
 | 
			
		||||
    userDataBeforeAction,
 | 
			
		||||
| 
						 | 
				
			
			@ -169,12 +165,6 @@ export const calcExpectedUserDataAfterWithdraw = (
 | 
			
		|||
  } else {
 | 
			
		||||
    expectedUserData.interestRedirectionAddress = userDataBeforeAction.interestRedirectionAddress;
 | 
			
		||||
  }
 | 
			
		||||
  expectedUserData.currentATokenUserIndex = calcExpectedATokenUserIndex(
 | 
			
		||||
    reserveDataBeforeAction,
 | 
			
		||||
    expectedUserData.currentATokenBalance,
 | 
			
		||||
    expectedUserData.redirectedBalance,
 | 
			
		||||
    txTimestamp
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  expectedUserData.redirectionAddressRedirectedBalance = calcExpectedRedirectedBalance(
 | 
			
		||||
    userDataBeforeAction,
 | 
			
		||||
| 
						 | 
				
			
			@ -814,12 +804,6 @@ export const calcExpectedUserDataAfterSwapRateMode = (
 | 
			
		|||
  expectedUserData.interestRedirectionAddress = userDataBeforeAction.interestRedirectionAddress;
 | 
			
		||||
  expectedUserData.redirectionAddressRedirectedBalance =
 | 
			
		||||
    userDataBeforeAction.redirectionAddressRedirectedBalance;
 | 
			
		||||
  expectedUserData.currentATokenUserIndex = calcExpectedATokenUserIndex(
 | 
			
		||||
    reserveDataBeforeAction,
 | 
			
		||||
    expectedUserData.currentATokenBalance,
 | 
			
		||||
    expectedUserData.redirectedBalance,
 | 
			
		||||
    txTimestamp
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  if (rateMode === RateMode.Stable) {
 | 
			
		||||
    // swap to variable
 | 
			
		||||
| 
						 | 
				
			
			@ -966,18 +950,12 @@ export const calcExpectedUserDataAfterStableRateRebalance = (
 | 
			
		|||
    userDataBeforeAction,
 | 
			
		||||
    txTimestamp
 | 
			
		||||
  );
 | 
			
		||||
  expectedUserData.principalATokenBalance = userDataBeforeAction.principalATokenBalance;
 | 
			
		||||
  expectedUserData.scaledATokenBalance = userDataBeforeAction.scaledATokenBalance;
 | 
			
		||||
  expectedUserData.redirectedBalance = userDataBeforeAction.redirectedBalance;
 | 
			
		||||
  expectedUserData.interestRedirectionAddress = userDataBeforeAction.interestRedirectionAddress;
 | 
			
		||||
  expectedUserData.redirectionAddressRedirectedBalance =
 | 
			
		||||
    userDataBeforeAction.redirectionAddressRedirectedBalance;
 | 
			
		||||
 | 
			
		||||
  expectedUserData.currentATokenUserIndex = calcExpectedATokenUserIndex(
 | 
			
		||||
    reserveDataBeforeAction,
 | 
			
		||||
    expectedUserData.currentATokenBalance,
 | 
			
		||||
    expectedUserData.redirectedBalance,
 | 
			
		||||
    txTimestamp
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  return expectedUserData;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -1012,7 +990,9 @@ export const calcExpectedUsersDataAfterRedirectInterest = (
 | 
			
		|||
  expectedFromData.stableBorrowRate = fromDataBeforeAction.stableBorrowRate;
 | 
			
		||||
  expectedToData.stableBorrowRate = toDataBeforeAction.stableBorrowRate;
 | 
			
		||||
 | 
			
		||||
  expectedFromData.principalATokenBalance = expectedFromData.currentATokenBalance = calcExpectedATokenBalance(
 | 
			
		||||
  expectedFromData.scaledATokenBalance =  
 | 
			
		||||
  
 | 
			
		||||
  expectedFromData.currentATokenBalance = calcExpectedATokenBalance(
 | 
			
		||||
    reserveDataBeforeAction,
 | 
			
		||||
    fromDataBeforeAction,
 | 
			
		||||
    txTimestamp
 | 
			
		||||
| 
						 | 
				
			
			@ -1047,70 +1027,52 @@ export const calcExpectedUsersDataAfterRedirectInterest = (
 | 
			
		|||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  expectedFromData.currentATokenUserIndex = calcExpectedATokenUserIndex(
 | 
			
		||||
    reserveDataBeforeAction,
 | 
			
		||||
    expectedFromData.currentATokenBalance,
 | 
			
		||||
    expectedFromData.redirectedBalance,
 | 
			
		||||
    txTimestamp
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  expectedToData.currentATokenUserIndex = calcExpectedATokenUserIndex(
 | 
			
		||||
    reserveDataBeforeAction,
 | 
			
		||||
    expectedToData.currentATokenBalance,
 | 
			
		||||
    expectedToData.redirectedBalance,
 | 
			
		||||
    txTimestamp
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  return [expectedFromData, expectedToData];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const calcExpectedATokenUserIndex = (
 | 
			
		||||
  reserveDataBeforeAction: ReserveData,
 | 
			
		||||
  expectedUserBalanceAfterAction: BigNumber,
 | 
			
		||||
  expectedUserRedirectedBalanceAterAction: BigNumber,
 | 
			
		||||
  currentTimestamp: BigNumber
 | 
			
		||||
 | 
			
		||||
const calcExpectedScaledATokenBalance = (
 | 
			
		||||
  reserveDataAfterAction: ReserveData,
 | 
			
		||||
  userDataBeforeAction: UserReserveData,
 | 
			
		||||
  amountAdded: BigNumber,
 | 
			
		||||
  amountTaken: BigNumber
 | 
			
		||||
  
 | 
			
		||||
) => {
 | 
			
		||||
  if (expectedUserBalanceAfterAction.eq(0) && expectedUserRedirectedBalanceAterAction.eq(0)) {
 | 
			
		||||
    return new BigNumber(0);
 | 
			
		||||
  }
 | 
			
		||||
  return calcExpectedReserveNormalizedIncome(reserveDataBeforeAction, currentTimestamp);
 | 
			
		||||
};
 | 
			
		||||
  return userDataBeforeAction.scaledATokenBalance.plus(amountAdded.rayDiv(reserveDataAfterAction.liquidityIndex));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const calcExpectedATokenBalance = (
 | 
			
		||||
  reserveDataBeforeAction: ReserveData,
 | 
			
		||||
  userDataBeforeAction: UserReserveData,
 | 
			
		||||
  currentTimestamp: BigNumber
 | 
			
		||||
) => {
 | 
			
		||||
  const income = calcExpectedReserveNormalizedIncome(reserveDataBeforeAction, currentTimestamp);
 | 
			
		||||
  const index = calcExpectedReserveNormalizedIncome(reserveDataBeforeAction, currentTimestamp);
 | 
			
		||||
 | 
			
		||||
  const {
 | 
			
		||||
    interestRedirectionAddress,
 | 
			
		||||
    currentATokenUserIndex: userIndexBeforeAction,
 | 
			
		||||
    interestRedirectionIndex: redirectionIndexBeforeAction,
 | 
			
		||||
    redirectedBalance,
 | 
			
		||||
    principalATokenBalance: principalBalanceBeforeAction,
 | 
			
		||||
    scaledATokenBalance: scaledBalanceBeforeAction,
 | 
			
		||||
  } = userDataBeforeAction;
 | 
			
		||||
 | 
			
		||||
  if (userIndexBeforeAction.eq(0)) {
 | 
			
		||||
    return principalBalanceBeforeAction;
 | 
			
		||||
  if (scaledBalanceBeforeAction.eq(0) && redirectedBalance.eq(0)) {
 | 
			
		||||
    return new BigNumber(0);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
  if (interestRedirectionAddress === ZERO_ADDRESS) {
 | 
			
		||||
    return principalBalanceBeforeAction
 | 
			
		||||
    return scaledBalanceBeforeAction
 | 
			
		||||
      .plus(redirectedBalance)
 | 
			
		||||
      .wadToRay()
 | 
			
		||||
      .rayMul(income)
 | 
			
		||||
      .rayDiv(userIndexBeforeAction)
 | 
			
		||||
      .rayToWad()
 | 
			
		||||
      .rayMul(index)
 | 
			
		||||
      .minus(redirectedBalance);
 | 
			
		||||
  } else {
 | 
			
		||||
    return principalBalanceBeforeAction.plus(
 | 
			
		||||
  } 
 | 
			
		||||
 | 
			
		||||
   const lastRedirectedBalance = scaledBalanceBeforeAction.rayDiv(redirectionIndexBeforeAction);
 | 
			
		||||
 
 | 
			
		||||
    return lastRedirectedBalance.plus(
 | 
			
		||||
      redirectedBalance
 | 
			
		||||
        .wadToRay()
 | 
			
		||||
        .rayMul(income)
 | 
			
		||||
        .rayDiv(userIndexBeforeAction)
 | 
			
		||||
        .rayToWad()
 | 
			
		||||
        .rayMul(index)
 | 
			
		||||
        .minus(redirectedBalance)
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const calcExpectedRedirectedBalance = (
 | 
			
		||||
| 
						 | 
				
			
			@ -1120,12 +1082,9 @@ const calcExpectedRedirectedBalance = (
 | 
			
		|||
  amountToAdd: BigNumber,
 | 
			
		||||
  amountToSubstract: BigNumber
 | 
			
		||||
): BigNumber => {
 | 
			
		||||
  const balanceIncrease = userDataBeforeAction.currentATokenBalance.minus(
 | 
			
		||||
    userDataBeforeAction.principalATokenBalance
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  return expectedUserDataAfterAction.interestRedirectionAddress !== ZERO_ADDRESS
 | 
			
		||||
    ? redirectedBalanceBefore.plus(balanceIncrease).plus(amountToAdd).minus(amountToSubstract)
 | 
			
		||||
    ? redirectedBalanceBefore.plus(amountToAdd).minus(amountToSubstract)
 | 
			
		||||
    : new BigNumber('0');
 | 
			
		||||
};
 | 
			
		||||
const calcExpectedAverageStableBorrowRate = (
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,22 +69,22 @@ export const getUserData = async (
 | 
			
		|||
  ]);
 | 
			
		||||
 | 
			
		||||
  const [
 | 
			
		||||
    userIndex,
 | 
			
		||||
    redirectedBalance,
 | 
			
		||||
    principalATokenBalance,
 | 
			
		||||
    scaledATokenBalance,
 | 
			
		||||
    redirectionAddressRedirectedBalance,
 | 
			
		||||
    interestRedirectionAddress,
 | 
			
		||||
    interestRedirectionIndex,
 | 
			
		||||
  ] = aTokenData;
 | 
			
		||||
 | 
			
		||||
  const token = await getMintableErc20(reserve);
 | 
			
		||||
  const walletBalance = new BigNumber((await token.balanceOf(user)).toString());
 | 
			
		||||
 | 
			
		||||
  return {
 | 
			
		||||
    principalATokenBalance: new BigNumber(principalATokenBalance),
 | 
			
		||||
    scaledATokenBalance: new BigNumber(scaledATokenBalance),
 | 
			
		||||
    interestRedirectionAddress,
 | 
			
		||||
    interestRedirectionIndex,
 | 
			
		||||
    redirectionAddressRedirectedBalance: new BigNumber(redirectionAddressRedirectedBalance),
 | 
			
		||||
    redirectedBalance: new BigNumber(redirectedBalance),
 | 
			
		||||
    currentATokenUserIndex: new BigNumber(userIndex),
 | 
			
		||||
    currentATokenBalance: new BigNumber(userData.currentATokenBalance.toString()),
 | 
			
		||||
    currentStableDebt: new BigNumber(userData.currentStableDebt.toString()),
 | 
			
		||||
    currentVariableDebt: new BigNumber(userData.currentVariableDebt.toString()),
 | 
			
		||||
| 
						 | 
				
			
			@ -115,15 +115,15 @@ const getATokenUserData = async (reserve: string, user: string, pool: LendingPoo
 | 
			
		|||
 | 
			
		||||
  const aToken = await getAToken(aTokenAddress);
 | 
			
		||||
  const [
 | 
			
		||||
    userIndex,
 | 
			
		||||
    interestRedirectionAddress,
 | 
			
		||||
    redirectedBalance,
 | 
			
		||||
    principalTokenBalance,
 | 
			
		||||
    scaledATokenBalance,
 | 
			
		||||
    interestRedirectionIndex
 | 
			
		||||
  ] = await Promise.all([
 | 
			
		||||
    aToken.getUserIndex(user),
 | 
			
		||||
    aToken.getInterestRedirectionAddress(user),
 | 
			
		||||
    aToken.getRedirectedBalance(user),
 | 
			
		||||
    aToken.principalBalanceOf(user),
 | 
			
		||||
    aToken.scaledBalanceOf(user),
 | 
			
		||||
    aToken.getUserInterestRedirectionIndex(user)
 | 
			
		||||
  ]);
 | 
			
		||||
 | 
			
		||||
  const redirectionAddressRedirectedBalance =
 | 
			
		||||
| 
						 | 
				
			
			@ -132,10 +132,10 @@ const getATokenUserData = async (reserve: string, user: string, pool: LendingPoo
 | 
			
		|||
      : new BigNumber('0');
 | 
			
		||||
 | 
			
		||||
  return [
 | 
			
		||||
    userIndex.toString(),
 | 
			
		||||
    redirectedBalance.toString(),
 | 
			
		||||
    principalTokenBalance.toString(),
 | 
			
		||||
    scaledATokenBalance.toString(),
 | 
			
		||||
    redirectionAddressRedirectedBalance.toString(),
 | 
			
		||||
    interestRedirectionAddress,
 | 
			
		||||
    interestRedirectionIndex
 | 
			
		||||
  ];
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
import BigNumber from 'bignumber.js';
 | 
			
		||||
 | 
			
		||||
export interface UserReserveData {
 | 
			
		||||
  principalATokenBalance: BigNumber;
 | 
			
		||||
  scaledATokenBalance: BigNumber;
 | 
			
		||||
  currentATokenBalance: BigNumber;
 | 
			
		||||
  currentATokenUserIndex: BigNumber;
 | 
			
		||||
  interestRedirectionAddress: string;
 | 
			
		||||
  interestRedirectionIndex: BigNumber;
 | 
			
		||||
  redirectionAddressRedirectedBalance: BigNumber;
 | 
			
		||||
  redirectedBalance: BigNumber;
 | 
			
		||||
  currentStableDebt: BigNumber;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN});
 | 
			
		|||
 | 
			
		||||
const scenarioFolder = './test/helpers/scenarios/';
 | 
			
		||||
 | 
			
		||||
const selectedScenarios: string[] = [];
 | 
			
		||||
const selectedScenarios: string[] = ['deposit.json'];
 | 
			
		||||
 | 
			
		||||
fs.readdirSync(scenarioFolder).forEach((file) => {
 | 
			
		||||
  if (selectedScenarios.length > 0 && !selectedScenarios.includes(file)) return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user